babylon.max.js 6.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149
  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. if (keys.length === 1) {
  3535. return this._getKeyValue(keys[0].value);
  3536. }
  3537. // Try to get a hash to find the right key
  3538. 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));
  3539. if (keys[startKeyIndex].frame >= currentFrame) {
  3540. while (startKeyIndex - 1 >= 0 && keys[startKeyIndex].frame >= currentFrame) {
  3541. startKeyIndex--;
  3542. }
  3543. }
  3544. for (var key = startKeyIndex; key < keys.length; key++) {
  3545. var endKey = keys[key + 1];
  3546. if (endKey.frame >= currentFrame) {
  3547. var startKey = keys[key];
  3548. var startValue = this._getKeyValue(startKey.value);
  3549. if (startKey.interpolation === _animationKey__WEBPACK_IMPORTED_MODULE_4__["AnimationKeyInterpolation"].STEP) {
  3550. return startValue;
  3551. }
  3552. var endValue = this._getKeyValue(endKey.value);
  3553. var useTangent = startKey.outTangent !== undefined && endKey.inTangent !== undefined;
  3554. var frameDelta = endKey.frame - startKey.frame;
  3555. // gradient : percent of currentFrame between the frame inf and the frame sup
  3556. var gradient = (currentFrame - startKey.frame) / frameDelta;
  3557. // check for easingFunction and correction of gradient
  3558. var easingFunction = this.getEasingFunction();
  3559. if (easingFunction != null) {
  3560. gradient = easingFunction.ease(gradient);
  3561. }
  3562. switch (this.dataType) {
  3563. // Float
  3564. case Animation.ANIMATIONTYPE_FLOAT:
  3565. var floatValue = useTangent ? this.floatInterpolateFunctionWithTangents(startValue, startKey.outTangent * frameDelta, endValue, endKey.inTangent * frameDelta, gradient) : this.floatInterpolateFunction(startValue, endValue, gradient);
  3566. switch (loopMode) {
  3567. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3568. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3569. return floatValue;
  3570. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3571. return offsetValue * repeatCount + floatValue;
  3572. }
  3573. break;
  3574. // Quaternion
  3575. case Animation.ANIMATIONTYPE_QUATERNION:
  3576. var quatValue = useTangent ? this.quaternionInterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.quaternionInterpolateFunction(startValue, endValue, gradient);
  3577. switch (loopMode) {
  3578. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3579. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3580. return quatValue;
  3581. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3582. return quatValue.addInPlace(offsetValue.scale(repeatCount));
  3583. }
  3584. return quatValue;
  3585. // Vector3
  3586. case Animation.ANIMATIONTYPE_VECTOR3:
  3587. var vec3Value = useTangent ? this.vector3InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector3InterpolateFunction(startValue, endValue, gradient);
  3588. switch (loopMode) {
  3589. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3590. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3591. return vec3Value;
  3592. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3593. return vec3Value.add(offsetValue.scale(repeatCount));
  3594. }
  3595. // Vector2
  3596. case Animation.ANIMATIONTYPE_VECTOR2:
  3597. var vec2Value = useTangent ? this.vector2InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector2InterpolateFunction(startValue, endValue, gradient);
  3598. switch (loopMode) {
  3599. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3600. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3601. return vec2Value;
  3602. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3603. return vec2Value.add(offsetValue.scale(repeatCount));
  3604. }
  3605. // Size
  3606. case Animation.ANIMATIONTYPE_SIZE:
  3607. switch (loopMode) {
  3608. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3609. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3610. return this.sizeInterpolateFunction(startValue, endValue, gradient);
  3611. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3612. return this.sizeInterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3613. }
  3614. // Color3
  3615. case Animation.ANIMATIONTYPE_COLOR3:
  3616. switch (loopMode) {
  3617. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3618. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3619. return this.color3InterpolateFunction(startValue, endValue, gradient);
  3620. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3621. return this.color3InterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3622. }
  3623. // Matrix
  3624. case Animation.ANIMATIONTYPE_MATRIX:
  3625. switch (loopMode) {
  3626. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3627. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3628. if (Animation.AllowMatricesInterpolation) {
  3629. return this.matrixInterpolateFunction(startValue, endValue, gradient, workValue);
  3630. }
  3631. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3632. return startValue;
  3633. }
  3634. default:
  3635. break;
  3636. }
  3637. break;
  3638. }
  3639. }
  3640. return this._getKeyValue(keys[keys.length - 1].value);
  3641. };
  3642. /**
  3643. * Defines the function to use to interpolate matrices
  3644. * @param startValue defines the start matrix
  3645. * @param endValue defines the end matrix
  3646. * @param gradient defines the gradient between both matrices
  3647. * @param result defines an optional target matrix where to store the interpolation
  3648. * @returns the interpolated matrix
  3649. */
  3650. Animation.prototype.matrixInterpolateFunction = function (startValue, endValue, gradient, result) {
  3651. if (Animation.AllowMatrixDecomposeForInterpolation) {
  3652. if (result) {
  3653. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(startValue, endValue, gradient, result);
  3654. return result;
  3655. }
  3656. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(startValue, endValue, gradient);
  3657. }
  3658. if (result) {
  3659. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(startValue, endValue, gradient, result);
  3660. return result;
  3661. }
  3662. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(startValue, endValue, gradient);
  3663. };
  3664. /**
  3665. * Makes a copy of the animation
  3666. * @returns Cloned animation
  3667. */
  3668. Animation.prototype.clone = function () {
  3669. var clone = new Animation(this.name, this.targetPropertyPath.join("."), this.framePerSecond, this.dataType, this.loopMode);
  3670. clone.enableBlending = this.enableBlending;
  3671. clone.blendingSpeed = this.blendingSpeed;
  3672. if (this._keys) {
  3673. clone.setKeys(this._keys);
  3674. }
  3675. if (this._ranges) {
  3676. clone._ranges = {};
  3677. for (var name in this._ranges) {
  3678. var range = this._ranges[name];
  3679. if (!range) {
  3680. continue;
  3681. }
  3682. clone._ranges[name] = range.clone();
  3683. }
  3684. }
  3685. return clone;
  3686. };
  3687. /**
  3688. * Sets the key frames of the animation
  3689. * @param values The animation key frames to set
  3690. */
  3691. Animation.prototype.setKeys = function (values) {
  3692. this._keys = values.slice(0);
  3693. };
  3694. /**
  3695. * Serializes the animation to an object
  3696. * @returns Serialized object
  3697. */
  3698. Animation.prototype.serialize = function () {
  3699. var serializationObject = {};
  3700. serializationObject.name = this.name;
  3701. serializationObject.property = this.targetProperty;
  3702. serializationObject.framePerSecond = this.framePerSecond;
  3703. serializationObject.dataType = this.dataType;
  3704. serializationObject.loopBehavior = this.loopMode;
  3705. serializationObject.enableBlending = this.enableBlending;
  3706. serializationObject.blendingSpeed = this.blendingSpeed;
  3707. var dataType = this.dataType;
  3708. serializationObject.keys = [];
  3709. var keys = this.getKeys();
  3710. for (var index = 0; index < keys.length; index++) {
  3711. var animationKey = keys[index];
  3712. var key = {};
  3713. key.frame = animationKey.frame;
  3714. switch (dataType) {
  3715. case Animation.ANIMATIONTYPE_FLOAT:
  3716. key.values = [animationKey.value];
  3717. break;
  3718. case Animation.ANIMATIONTYPE_QUATERNION:
  3719. case Animation.ANIMATIONTYPE_MATRIX:
  3720. case Animation.ANIMATIONTYPE_VECTOR3:
  3721. case Animation.ANIMATIONTYPE_COLOR3:
  3722. key.values = animationKey.value.asArray();
  3723. break;
  3724. }
  3725. serializationObject.keys.push(key);
  3726. }
  3727. serializationObject.ranges = [];
  3728. for (var name in this._ranges) {
  3729. var source = this._ranges[name];
  3730. if (!source) {
  3731. continue;
  3732. }
  3733. var range = {};
  3734. range.name = name;
  3735. range.from = source.from;
  3736. range.to = source.to;
  3737. serializationObject.ranges.push(range);
  3738. }
  3739. return serializationObject;
  3740. };
  3741. Object.defineProperty(Animation, "ANIMATIONTYPE_FLOAT", {
  3742. /**
  3743. * Get the float animation type
  3744. */
  3745. get: function () {
  3746. return Animation._ANIMATIONTYPE_FLOAT;
  3747. },
  3748. enumerable: true,
  3749. configurable: true
  3750. });
  3751. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR3", {
  3752. /**
  3753. * Get the Vector3 animation type
  3754. */
  3755. get: function () {
  3756. return Animation._ANIMATIONTYPE_VECTOR3;
  3757. },
  3758. enumerable: true,
  3759. configurable: true
  3760. });
  3761. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR2", {
  3762. /**
  3763. * Get the Vector2 animation type
  3764. */
  3765. get: function () {
  3766. return Animation._ANIMATIONTYPE_VECTOR2;
  3767. },
  3768. enumerable: true,
  3769. configurable: true
  3770. });
  3771. Object.defineProperty(Animation, "ANIMATIONTYPE_SIZE", {
  3772. /**
  3773. * Get the Size animation type
  3774. */
  3775. get: function () {
  3776. return Animation._ANIMATIONTYPE_SIZE;
  3777. },
  3778. enumerable: true,
  3779. configurable: true
  3780. });
  3781. Object.defineProperty(Animation, "ANIMATIONTYPE_QUATERNION", {
  3782. /**
  3783. * Get the Quaternion animation type
  3784. */
  3785. get: function () {
  3786. return Animation._ANIMATIONTYPE_QUATERNION;
  3787. },
  3788. enumerable: true,
  3789. configurable: true
  3790. });
  3791. Object.defineProperty(Animation, "ANIMATIONTYPE_MATRIX", {
  3792. /**
  3793. * Get the Matrix animation type
  3794. */
  3795. get: function () {
  3796. return Animation._ANIMATIONTYPE_MATRIX;
  3797. },
  3798. enumerable: true,
  3799. configurable: true
  3800. });
  3801. Object.defineProperty(Animation, "ANIMATIONTYPE_COLOR3", {
  3802. /**
  3803. * Get the Color3 animation type
  3804. */
  3805. get: function () {
  3806. return Animation._ANIMATIONTYPE_COLOR3;
  3807. },
  3808. enumerable: true,
  3809. configurable: true
  3810. });
  3811. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_RELATIVE", {
  3812. /**
  3813. * Get the Relative Loop Mode
  3814. */
  3815. get: function () {
  3816. return Animation._ANIMATIONLOOPMODE_RELATIVE;
  3817. },
  3818. enumerable: true,
  3819. configurable: true
  3820. });
  3821. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CYCLE", {
  3822. /**
  3823. * Get the Cycle Loop Mode
  3824. */
  3825. get: function () {
  3826. return Animation._ANIMATIONLOOPMODE_CYCLE;
  3827. },
  3828. enumerable: true,
  3829. configurable: true
  3830. });
  3831. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CONSTANT", {
  3832. /**
  3833. * Get the Constant Loop Mode
  3834. */
  3835. get: function () {
  3836. return Animation._ANIMATIONLOOPMODE_CONSTANT;
  3837. },
  3838. enumerable: true,
  3839. configurable: true
  3840. });
  3841. /** @hidden */
  3842. Animation._UniversalLerp = function (left, right, amount) {
  3843. var constructor = left.constructor;
  3844. if (constructor.Lerp) { // Lerp supported
  3845. return constructor.Lerp(left, right, amount);
  3846. }
  3847. else if (constructor.Slerp) { // Slerp supported
  3848. return constructor.Slerp(left, right, amount);
  3849. }
  3850. else if (left.toFixed) { // Number
  3851. return left * (1.0 - amount) + amount * right;
  3852. }
  3853. else { // Blending not supported
  3854. return right;
  3855. }
  3856. };
  3857. /**
  3858. * Parses an animation object and creates an animation
  3859. * @param parsedAnimation Parsed animation object
  3860. * @returns Animation object
  3861. */
  3862. Animation.Parse = function (parsedAnimation) {
  3863. var animation = new Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
  3864. var dataType = parsedAnimation.dataType;
  3865. var keys = [];
  3866. var data;
  3867. var index;
  3868. if (parsedAnimation.enableBlending) {
  3869. animation.enableBlending = parsedAnimation.enableBlending;
  3870. }
  3871. if (parsedAnimation.blendingSpeed) {
  3872. animation.blendingSpeed = parsedAnimation.blendingSpeed;
  3873. }
  3874. for (index = 0; index < parsedAnimation.keys.length; index++) {
  3875. var key = parsedAnimation.keys[index];
  3876. var inTangent;
  3877. var outTangent;
  3878. switch (dataType) {
  3879. case Animation.ANIMATIONTYPE_FLOAT:
  3880. data = key.values[0];
  3881. if (key.values.length >= 1) {
  3882. inTangent = key.values[1];
  3883. }
  3884. if (key.values.length >= 2) {
  3885. outTangent = key.values[2];
  3886. }
  3887. break;
  3888. case Animation.ANIMATIONTYPE_QUATERNION:
  3889. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values);
  3890. if (key.values.length >= 8) {
  3891. var _inTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(4, 8));
  3892. if (!_inTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3893. inTangent = _inTangent;
  3894. }
  3895. }
  3896. if (key.values.length >= 12) {
  3897. var _outTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(8, 12));
  3898. if (!_outTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3899. outTangent = _outTangent;
  3900. }
  3901. }
  3902. break;
  3903. case Animation.ANIMATIONTYPE_MATRIX:
  3904. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromArray(key.values);
  3905. break;
  3906. case Animation.ANIMATIONTYPE_COLOR3:
  3907. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(key.values);
  3908. break;
  3909. case Animation.ANIMATIONTYPE_VECTOR3:
  3910. default:
  3911. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(key.values);
  3912. break;
  3913. }
  3914. var keyData = {};
  3915. keyData.frame = key.frame;
  3916. keyData.value = data;
  3917. if (inTangent != undefined) {
  3918. keyData.inTangent = inTangent;
  3919. }
  3920. if (outTangent != undefined) {
  3921. keyData.outTangent = outTangent;
  3922. }
  3923. keys.push(keyData);
  3924. }
  3925. animation.setKeys(keys);
  3926. if (parsedAnimation.ranges) {
  3927. for (index = 0; index < parsedAnimation.ranges.length; index++) {
  3928. data = parsedAnimation.ranges[index];
  3929. animation.createRange(data.name, data.from, data.to);
  3930. }
  3931. }
  3932. return animation;
  3933. };
  3934. /**
  3935. * Appends the serialized animations from the source animations
  3936. * @param source Source containing the animations
  3937. * @param destination Target to store the animations
  3938. */
  3939. Animation.AppendSerializedAnimations = function (source, destination) {
  3940. _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].AppendSerializedAnimations(source, destination);
  3941. };
  3942. /**
  3943. * Use matrix interpolation instead of using direct key value when animating matrices
  3944. */
  3945. Animation.AllowMatricesInterpolation = false;
  3946. /**
  3947. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3948. */
  3949. Animation.AllowMatrixDecomposeForInterpolation = true;
  3950. // Statics
  3951. /**
  3952. * Float animation type
  3953. */
  3954. Animation._ANIMATIONTYPE_FLOAT = 0;
  3955. /**
  3956. * Vector3 animation type
  3957. */
  3958. Animation._ANIMATIONTYPE_VECTOR3 = 1;
  3959. /**
  3960. * Quaternion animation type
  3961. */
  3962. Animation._ANIMATIONTYPE_QUATERNION = 2;
  3963. /**
  3964. * Matrix animation type
  3965. */
  3966. Animation._ANIMATIONTYPE_MATRIX = 3;
  3967. /**
  3968. * Color3 animation type
  3969. */
  3970. Animation._ANIMATIONTYPE_COLOR3 = 4;
  3971. /**
  3972. * Vector2 animation type
  3973. */
  3974. Animation._ANIMATIONTYPE_VECTOR2 = 5;
  3975. /**
  3976. * Size animation type
  3977. */
  3978. Animation._ANIMATIONTYPE_SIZE = 6;
  3979. /**
  3980. * Relative Loop Mode
  3981. */
  3982. Animation._ANIMATIONLOOPMODE_RELATIVE = 0;
  3983. /**
  3984. * Cycle Loop Mode
  3985. */
  3986. Animation._ANIMATIONLOOPMODE_CYCLE = 1;
  3987. /**
  3988. * Constant Loop Mode
  3989. */
  3990. Animation._ANIMATIONLOOPMODE_CONSTANT = 2;
  3991. return Animation;
  3992. }());
  3993. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.Animation"] = Animation;
  3994. _node__WEBPACK_IMPORTED_MODULE_6__["Node"]._AnimationRangeFactory = function (name, from, to) { return new _animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to); };
  3995. /***/ }),
  3996. /***/ "./Animations/animationEvent.ts":
  3997. /*!**************************************!*\
  3998. !*** ./Animations/animationEvent.ts ***!
  3999. \**************************************/
  4000. /*! exports provided: AnimationEvent */
  4001. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4002. "use strict";
  4003. __webpack_require__.r(__webpack_exports__);
  4004. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return AnimationEvent; });
  4005. /**
  4006. * Composed of a frame, and an action function
  4007. */
  4008. var AnimationEvent = /** @class */ (function () {
  4009. /**
  4010. * Initializes the animation event
  4011. * @param frame The frame for which the event is triggered
  4012. * @param action The event to perform when triggered
  4013. * @param onlyOnce Specifies if the event should be triggered only once
  4014. */
  4015. function AnimationEvent(
  4016. /** The frame for which the event is triggered **/
  4017. frame,
  4018. /** The event to perform when triggered **/
  4019. action,
  4020. /** Specifies if the event should be triggered only once**/
  4021. onlyOnce) {
  4022. this.frame = frame;
  4023. this.action = action;
  4024. this.onlyOnce = onlyOnce;
  4025. /**
  4026. * Specifies if the animation event is done
  4027. */
  4028. this.isDone = false;
  4029. }
  4030. /** @hidden */
  4031. AnimationEvent.prototype._clone = function () {
  4032. return new AnimationEvent(this.frame, this.action, this.onlyOnce);
  4033. };
  4034. return AnimationEvent;
  4035. }());
  4036. /***/ }),
  4037. /***/ "./Animations/animationGroup.ts":
  4038. /*!**************************************!*\
  4039. !*** ./Animations/animationGroup.ts ***!
  4040. \**************************************/
  4041. /*! exports provided: TargetedAnimation, AnimationGroup */
  4042. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4043. "use strict";
  4044. __webpack_require__.r(__webpack_exports__);
  4045. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return TargetedAnimation; });
  4046. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return AnimationGroup; });
  4047. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  4048. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  4049. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  4050. /**
  4051. * This class defines the direct association between an animation and a target
  4052. */
  4053. var TargetedAnimation = /** @class */ (function () {
  4054. function TargetedAnimation() {
  4055. }
  4056. return TargetedAnimation;
  4057. }());
  4058. /**
  4059. * Use this class to create coordinated animations on multiple targets
  4060. */
  4061. var AnimationGroup = /** @class */ (function () {
  4062. /**
  4063. * Instantiates a new Animation Group.
  4064. * This helps managing several animations at once.
  4065. * @see http://doc.babylonjs.com/how_to/group
  4066. * @param name Defines the name of the group
  4067. * @param scene Defines the scene the group belongs to
  4068. */
  4069. function AnimationGroup(
  4070. /** The name of the animation group */
  4071. name, scene) {
  4072. if (scene === void 0) { scene = null; }
  4073. this.name = name;
  4074. this._targetedAnimations = new Array();
  4075. this._animatables = new Array();
  4076. this._from = Number.MAX_VALUE;
  4077. this._to = -Number.MAX_VALUE;
  4078. this._speedRatio = 1;
  4079. /**
  4080. * This observable will notify when one animation have ended
  4081. */
  4082. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4083. /**
  4084. * Observer raised when one animation loops
  4085. */
  4086. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4087. /**
  4088. * This observable will notify when all animations have ended.
  4089. */
  4090. this.onAnimationGroupEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4091. /**
  4092. * This observable will notify when all animations have paused.
  4093. */
  4094. this.onAnimationGroupPauseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4095. /**
  4096. * This observable will notify when all animations are playing.
  4097. */
  4098. this.onAnimationGroupPlayObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4099. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  4100. this.uniqueId = this._scene.getUniqueId();
  4101. this._scene.animationGroups.push(this);
  4102. }
  4103. Object.defineProperty(AnimationGroup.prototype, "from", {
  4104. /**
  4105. * Gets the first frame
  4106. */
  4107. get: function () {
  4108. return this._from;
  4109. },
  4110. enumerable: true,
  4111. configurable: true
  4112. });
  4113. Object.defineProperty(AnimationGroup.prototype, "to", {
  4114. /**
  4115. * Gets the last frame
  4116. */
  4117. get: function () {
  4118. return this._to;
  4119. },
  4120. enumerable: true,
  4121. configurable: true
  4122. });
  4123. Object.defineProperty(AnimationGroup.prototype, "isStarted", {
  4124. /**
  4125. * Define if the animations are started
  4126. */
  4127. get: function () {
  4128. return this._isStarted;
  4129. },
  4130. enumerable: true,
  4131. configurable: true
  4132. });
  4133. Object.defineProperty(AnimationGroup.prototype, "isPlaying", {
  4134. /**
  4135. * Gets a value indicating that the current group is playing
  4136. */
  4137. get: function () {
  4138. return this._isStarted && !this._isPaused;
  4139. },
  4140. enumerable: true,
  4141. configurable: true
  4142. });
  4143. Object.defineProperty(AnimationGroup.prototype, "speedRatio", {
  4144. /**
  4145. * Gets or sets the speed ratio to use for all animations
  4146. */
  4147. get: function () {
  4148. return this._speedRatio;
  4149. },
  4150. /**
  4151. * Gets or sets the speed ratio to use for all animations
  4152. */
  4153. set: function (value) {
  4154. if (this._speedRatio === value) {
  4155. return;
  4156. }
  4157. this._speedRatio = value;
  4158. for (var index = 0; index < this._animatables.length; index++) {
  4159. var animatable = this._animatables[index];
  4160. animatable.speedRatio = this._speedRatio;
  4161. }
  4162. },
  4163. enumerable: true,
  4164. configurable: true
  4165. });
  4166. Object.defineProperty(AnimationGroup.prototype, "targetedAnimations", {
  4167. /**
  4168. * Gets the targeted animations for this animation group
  4169. */
  4170. get: function () {
  4171. return this._targetedAnimations;
  4172. },
  4173. enumerable: true,
  4174. configurable: true
  4175. });
  4176. Object.defineProperty(AnimationGroup.prototype, "animatables", {
  4177. /**
  4178. * returning the list of animatables controlled by this animation group.
  4179. */
  4180. get: function () {
  4181. return this._animatables;
  4182. },
  4183. enumerable: true,
  4184. configurable: true
  4185. });
  4186. /**
  4187. * Add an animation (with its target) in the group
  4188. * @param animation defines the animation we want to add
  4189. * @param target defines the target of the animation
  4190. * @returns the TargetedAnimation object
  4191. */
  4192. AnimationGroup.prototype.addTargetedAnimation = function (animation, target) {
  4193. var targetedAnimation = {
  4194. animation: animation,
  4195. target: target
  4196. };
  4197. var keys = animation.getKeys();
  4198. if (this._from > keys[0].frame) {
  4199. this._from = keys[0].frame;
  4200. }
  4201. if (this._to < keys[keys.length - 1].frame) {
  4202. this._to = keys[keys.length - 1].frame;
  4203. }
  4204. this._targetedAnimations.push(targetedAnimation);
  4205. return targetedAnimation;
  4206. };
  4207. /**
  4208. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4209. * It can add constant keys at begin or end
  4210. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4211. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4212. * @returns the animation group
  4213. */
  4214. AnimationGroup.prototype.normalize = function (beginFrame, endFrame) {
  4215. if (beginFrame === void 0) { beginFrame = null; }
  4216. if (endFrame === void 0) { endFrame = null; }
  4217. if (beginFrame == null) {
  4218. beginFrame = this._from;
  4219. }
  4220. if (endFrame == null) {
  4221. endFrame = this._to;
  4222. }
  4223. for (var index = 0; index < this._targetedAnimations.length; index++) {
  4224. var targetedAnimation = this._targetedAnimations[index];
  4225. var keys = targetedAnimation.animation.getKeys();
  4226. var startKey = keys[0];
  4227. var endKey = keys[keys.length - 1];
  4228. if (startKey.frame > beginFrame) {
  4229. var newKey = {
  4230. frame: beginFrame,
  4231. value: startKey.value,
  4232. inTangent: startKey.inTangent,
  4233. outTangent: startKey.outTangent,
  4234. interpolation: startKey.interpolation
  4235. };
  4236. keys.splice(0, 0, newKey);
  4237. }
  4238. if (endKey.frame < endFrame) {
  4239. var newKey = {
  4240. frame: endFrame,
  4241. value: endKey.value,
  4242. inTangent: endKey.outTangent,
  4243. outTangent: endKey.outTangent,
  4244. interpolation: endKey.interpolation
  4245. };
  4246. keys.push(newKey);
  4247. }
  4248. }
  4249. this._from = beginFrame;
  4250. this._to = endFrame;
  4251. return this;
  4252. };
  4253. /**
  4254. * Start all animations on given targets
  4255. * @param loop defines if animations must loop
  4256. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4257. * @param from defines the from key (optional)
  4258. * @param to defines the to key (optional)
  4259. * @returns the current animation group
  4260. */
  4261. AnimationGroup.prototype.start = function (loop, speedRatio, from, to) {
  4262. var _this = this;
  4263. if (loop === void 0) { loop = false; }
  4264. if (speedRatio === void 0) { speedRatio = 1; }
  4265. if (this._isStarted || this._targetedAnimations.length === 0) {
  4266. return this;
  4267. }
  4268. var _loop_1 = function (targetedAnimation) {
  4269. var animatable = this_1._scene.beginDirectAnimation(targetedAnimation.target, [targetedAnimation.animation], from !== undefined ? from : this_1._from, to !== undefined ? to : this_1._to, loop, speedRatio);
  4270. animatable.onAnimationEnd = function () {
  4271. _this.onAnimationEndObservable.notifyObservers(targetedAnimation);
  4272. _this._checkAnimationGroupEnded(animatable);
  4273. };
  4274. animatable.onAnimationLoop = function () {
  4275. _this.onAnimationLoopObservable.notifyObservers(targetedAnimation);
  4276. };
  4277. this_1._animatables.push(animatable);
  4278. };
  4279. var this_1 = this;
  4280. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4281. var targetedAnimation = _a[_i];
  4282. _loop_1(targetedAnimation);
  4283. }
  4284. this._speedRatio = speedRatio;
  4285. if (from !== undefined && to !== undefined && from > to && this._speedRatio > 0) {
  4286. this._speedRatio = -speedRatio;
  4287. }
  4288. this._isStarted = true;
  4289. this._isPaused = false;
  4290. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4291. return this;
  4292. };
  4293. /**
  4294. * Pause all animations
  4295. * @returns the animation group
  4296. */
  4297. AnimationGroup.prototype.pause = function () {
  4298. if (!this._isStarted) {
  4299. return this;
  4300. }
  4301. this._isPaused = true;
  4302. for (var index = 0; index < this._animatables.length; index++) {
  4303. var animatable = this._animatables[index];
  4304. animatable.pause();
  4305. }
  4306. this.onAnimationGroupPauseObservable.notifyObservers(this);
  4307. return this;
  4308. };
  4309. /**
  4310. * Play all animations to initial state
  4311. * This function will start() the animations if they were not started or will restart() them if they were paused
  4312. * @param loop defines if animations must loop
  4313. * @returns the animation group
  4314. */
  4315. AnimationGroup.prototype.play = function (loop) {
  4316. // only if all animatables are ready and exist
  4317. if (this.isStarted && this._animatables.length === this._targetedAnimations.length) {
  4318. if (loop !== undefined) {
  4319. for (var index = 0; index < this._animatables.length; index++) {
  4320. var animatable = this._animatables[index];
  4321. animatable.loopAnimation = loop;
  4322. }
  4323. }
  4324. this.restart();
  4325. }
  4326. else {
  4327. this.stop();
  4328. this.start(loop, this._speedRatio);
  4329. }
  4330. this._isPaused = false;
  4331. return this;
  4332. };
  4333. /**
  4334. * Reset all animations to initial state
  4335. * @returns the animation group
  4336. */
  4337. AnimationGroup.prototype.reset = function () {
  4338. if (!this._isStarted) {
  4339. return this;
  4340. }
  4341. for (var index = 0; index < this._animatables.length; index++) {
  4342. var animatable = this._animatables[index];
  4343. animatable.reset();
  4344. }
  4345. return this;
  4346. };
  4347. /**
  4348. * Restart animations from key 0
  4349. * @returns the animation group
  4350. */
  4351. AnimationGroup.prototype.restart = function () {
  4352. if (!this._isStarted) {
  4353. return this;
  4354. }
  4355. for (var index = 0; index < this._animatables.length; index++) {
  4356. var animatable = this._animatables[index];
  4357. animatable.restart();
  4358. }
  4359. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4360. return this;
  4361. };
  4362. /**
  4363. * Stop all animations
  4364. * @returns the animation group
  4365. */
  4366. AnimationGroup.prototype.stop = function () {
  4367. if (!this._isStarted) {
  4368. return this;
  4369. }
  4370. var list = this._animatables.slice();
  4371. for (var index = 0; index < list.length; index++) {
  4372. list[index].stop();
  4373. }
  4374. this._isStarted = false;
  4375. return this;
  4376. };
  4377. /**
  4378. * Set animation weight for all animatables
  4379. * @param weight defines the weight to use
  4380. * @return the animationGroup
  4381. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4382. */
  4383. AnimationGroup.prototype.setWeightForAllAnimatables = function (weight) {
  4384. for (var index = 0; index < this._animatables.length; index++) {
  4385. var animatable = this._animatables[index];
  4386. animatable.weight = weight;
  4387. }
  4388. return this;
  4389. };
  4390. /**
  4391. * Synchronize and normalize all animatables with a source animatable
  4392. * @param root defines the root animatable to synchronize with
  4393. * @return the animationGroup
  4394. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4395. */
  4396. AnimationGroup.prototype.syncAllAnimationsWith = function (root) {
  4397. for (var index = 0; index < this._animatables.length; index++) {
  4398. var animatable = this._animatables[index];
  4399. animatable.syncWith(root);
  4400. }
  4401. return this;
  4402. };
  4403. /**
  4404. * Goes to a specific frame in this animation group
  4405. * @param frame the frame number to go to
  4406. * @return the animationGroup
  4407. */
  4408. AnimationGroup.prototype.goToFrame = function (frame) {
  4409. if (!this._isStarted) {
  4410. return this;
  4411. }
  4412. for (var index = 0; index < this._animatables.length; index++) {
  4413. var animatable = this._animatables[index];
  4414. animatable.goToFrame(frame);
  4415. }
  4416. return this;
  4417. };
  4418. /**
  4419. * Dispose all associated resources
  4420. */
  4421. AnimationGroup.prototype.dispose = function () {
  4422. this._targetedAnimations = [];
  4423. this._animatables = [];
  4424. var index = this._scene.animationGroups.indexOf(this);
  4425. if (index > -1) {
  4426. this._scene.animationGroups.splice(index, 1);
  4427. }
  4428. this.onAnimationEndObservable.clear();
  4429. this.onAnimationGroupEndObservable.clear();
  4430. this.onAnimationGroupPauseObservable.clear();
  4431. this.onAnimationGroupPlayObservable.clear();
  4432. this.onAnimationLoopObservable.clear();
  4433. };
  4434. AnimationGroup.prototype._checkAnimationGroupEnded = function (animatable) {
  4435. // animatable should be taken out of the array
  4436. var idx = this._animatables.indexOf(animatable);
  4437. if (idx > -1) {
  4438. this._animatables.splice(idx, 1);
  4439. }
  4440. // all animatables were removed? animation group ended!
  4441. if (this._animatables.length === 0) {
  4442. this._isStarted = false;
  4443. this.onAnimationGroupEndObservable.notifyObservers(this);
  4444. }
  4445. };
  4446. /**
  4447. * Clone the current animation group and returns a copy
  4448. * @param newName defines the name of the new group
  4449. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  4450. * @returns the new aniamtion group
  4451. */
  4452. AnimationGroup.prototype.clone = function (newName, targetConverter) {
  4453. var newGroup = new AnimationGroup(newName || this.name, this._scene);
  4454. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4455. var targetAnimation = _a[_i];
  4456. newGroup.addTargetedAnimation(targetAnimation.animation.clone(), targetConverter ? targetConverter(targetAnimation.target) : targetAnimation.target);
  4457. }
  4458. return newGroup;
  4459. };
  4460. // Statics
  4461. /**
  4462. * Returns a new AnimationGroup object parsed from the source provided.
  4463. * @param parsedAnimationGroup defines the source
  4464. * @param scene defines the scene that will receive the animationGroup
  4465. * @returns a new AnimationGroup
  4466. */
  4467. AnimationGroup.Parse = function (parsedAnimationGroup, scene) {
  4468. var animationGroup = new AnimationGroup(parsedAnimationGroup.name, scene);
  4469. for (var i = 0; i < parsedAnimationGroup.targetedAnimations.length; i++) {
  4470. var targetedAnimation = parsedAnimationGroup.targetedAnimations[i];
  4471. var animation = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].Parse(targetedAnimation.animation);
  4472. var id = targetedAnimation.targetId;
  4473. if (targetedAnimation.animation.property === "influence") { // morph target animation
  4474. var morphTarget = scene.getMorphTargetById(id);
  4475. if (morphTarget) {
  4476. animationGroup.addTargetedAnimation(animation, morphTarget);
  4477. }
  4478. }
  4479. else {
  4480. var targetNode = scene.getNodeByID(id);
  4481. if (targetNode != null) {
  4482. animationGroup.addTargetedAnimation(animation, targetNode);
  4483. }
  4484. }
  4485. }
  4486. if (parsedAnimationGroup.from !== null && parsedAnimationGroup.from !== null) {
  4487. animationGroup.normalize(parsedAnimationGroup.from, parsedAnimationGroup.to);
  4488. }
  4489. return animationGroup;
  4490. };
  4491. /**
  4492. * Returns the string "AnimationGroup"
  4493. * @returns "AnimationGroup"
  4494. */
  4495. AnimationGroup.prototype.getClassName = function () {
  4496. return "AnimationGroup";
  4497. };
  4498. /**
  4499. * Creates a detailled string about the object
  4500. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4501. * @returns a string representing the object
  4502. */
  4503. AnimationGroup.prototype.toString = function (fullDetails) {
  4504. var ret = "Name: " + this.name;
  4505. ret += ", type: " + this.getClassName();
  4506. if (fullDetails) {
  4507. ret += ", from: " + this._from;
  4508. ret += ", to: " + this._to;
  4509. ret += ", isStarted: " + this._isStarted;
  4510. ret += ", speedRatio: " + this._speedRatio;
  4511. ret += ", targetedAnimations length: " + this._targetedAnimations.length;
  4512. ret += ", animatables length: " + this._animatables;
  4513. }
  4514. return ret;
  4515. };
  4516. return AnimationGroup;
  4517. }());
  4518. /***/ }),
  4519. /***/ "./Animations/animationKey.ts":
  4520. /*!************************************!*\
  4521. !*** ./Animations/animationKey.ts ***!
  4522. \************************************/
  4523. /*! exports provided: AnimationKeyInterpolation */
  4524. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4525. "use strict";
  4526. __webpack_require__.r(__webpack_exports__);
  4527. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return AnimationKeyInterpolation; });
  4528. /**
  4529. * Enum for the animation key frame interpolation type
  4530. */
  4531. var AnimationKeyInterpolation;
  4532. (function (AnimationKeyInterpolation) {
  4533. /**
  4534. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4535. */
  4536. AnimationKeyInterpolation[AnimationKeyInterpolation["STEP"] = 1] = "STEP";
  4537. })(AnimationKeyInterpolation || (AnimationKeyInterpolation = {}));
  4538. /***/ }),
  4539. /***/ "./Animations/animationPropertiesOverride.ts":
  4540. /*!***************************************************!*\
  4541. !*** ./Animations/animationPropertiesOverride.ts ***!
  4542. \***************************************************/
  4543. /*! exports provided: AnimationPropertiesOverride */
  4544. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4545. "use strict";
  4546. __webpack_require__.r(__webpack_exports__);
  4547. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return AnimationPropertiesOverride; });
  4548. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  4549. /**
  4550. * Class used to override all child animations of a given target
  4551. */
  4552. var AnimationPropertiesOverride = /** @class */ (function () {
  4553. function AnimationPropertiesOverride() {
  4554. /**
  4555. * Gets or sets a value indicating if animation blending must be used
  4556. */
  4557. this.enableBlending = false;
  4558. /**
  4559. * Gets or sets the blending speed to use when enableBlending is true
  4560. */
  4561. this.blendingSpeed = 0.01;
  4562. /**
  4563. * Gets or sets the default loop mode to use
  4564. */
  4565. this.loopMode = _Animations_animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONLOOPMODE_CYCLE;
  4566. }
  4567. return AnimationPropertiesOverride;
  4568. }());
  4569. /***/ }),
  4570. /***/ "./Animations/animationRange.ts":
  4571. /*!**************************************!*\
  4572. !*** ./Animations/animationRange.ts ***!
  4573. \**************************************/
  4574. /*! exports provided: AnimationRange */
  4575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4576. "use strict";
  4577. __webpack_require__.r(__webpack_exports__);
  4578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return AnimationRange; });
  4579. /**
  4580. * Represents the range of an animation
  4581. */
  4582. var AnimationRange = /** @class */ (function () {
  4583. /**
  4584. * Initializes the range of an animation
  4585. * @param name The name of the animation range
  4586. * @param from The starting frame of the animation
  4587. * @param to The ending frame of the animation
  4588. */
  4589. function AnimationRange(
  4590. /**The name of the animation range**/
  4591. name,
  4592. /**The starting frame of the animation */
  4593. from,
  4594. /**The ending frame of the animation*/
  4595. to) {
  4596. this.name = name;
  4597. this.from = from;
  4598. this.to = to;
  4599. }
  4600. /**
  4601. * Makes a copy of the animation range
  4602. * @returns A copy of the animation range
  4603. */
  4604. AnimationRange.prototype.clone = function () {
  4605. return new AnimationRange(this.name, this.from, this.to);
  4606. };
  4607. return AnimationRange;
  4608. }());
  4609. /***/ }),
  4610. /***/ "./Animations/easing.ts":
  4611. /*!******************************!*\
  4612. !*** ./Animations/easing.ts ***!
  4613. \******************************/
  4614. /*! exports provided: EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase */
  4615. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4616. "use strict";
  4617. __webpack_require__.r(__webpack_exports__);
  4618. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return EasingFunction; });
  4619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return CircleEase; });
  4620. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return BackEase; });
  4621. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return BounceEase; });
  4622. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return CubicEase; });
  4623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return ElasticEase; });
  4624. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return ExponentialEase; });
  4625. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return PowerEase; });
  4626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return QuadraticEase; });
  4627. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return QuarticEase; });
  4628. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return QuinticEase; });
  4629. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return SineEase; });
  4630. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return BezierCurveEase; });
  4631. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  4632. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  4633. /**
  4634. * Base class used for every default easing function.
  4635. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4636. */
  4637. var EasingFunction = /** @class */ (function () {
  4638. function EasingFunction() {
  4639. this._easingMode = EasingFunction.EASINGMODE_EASEIN;
  4640. }
  4641. /**
  4642. * Sets the easing mode of the current function.
  4643. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4644. */
  4645. EasingFunction.prototype.setEasingMode = function (easingMode) {
  4646. var n = Math.min(Math.max(easingMode, 0), 2);
  4647. this._easingMode = n;
  4648. };
  4649. /**
  4650. * Gets the current easing mode.
  4651. * @returns the easing mode
  4652. */
  4653. EasingFunction.prototype.getEasingMode = function () {
  4654. return this._easingMode;
  4655. };
  4656. /**
  4657. * @hidden
  4658. */
  4659. EasingFunction.prototype.easeInCore = function (gradient) {
  4660. throw new Error('You must implement this method');
  4661. };
  4662. /**
  4663. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4664. * of the easing function.
  4665. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4666. * @returns the corresponding value on the curve defined by the easing function
  4667. */
  4668. EasingFunction.prototype.ease = function (gradient) {
  4669. switch (this._easingMode) {
  4670. case EasingFunction.EASINGMODE_EASEIN:
  4671. return this.easeInCore(gradient);
  4672. case EasingFunction.EASINGMODE_EASEOUT:
  4673. return (1 - this.easeInCore(1 - gradient));
  4674. }
  4675. if (gradient >= 0.5) {
  4676. return (((1 - this.easeInCore((1 - gradient) * 2)) * 0.5) + 0.5);
  4677. }
  4678. return (this.easeInCore(gradient * 2) * 0.5);
  4679. };
  4680. /**
  4681. * Interpolation follows the mathematical formula associated with the easing function.
  4682. */
  4683. EasingFunction.EASINGMODE_EASEIN = 0;
  4684. /**
  4685. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4686. */
  4687. EasingFunction.EASINGMODE_EASEOUT = 1;
  4688. /**
  4689. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4690. */
  4691. EasingFunction.EASINGMODE_EASEINOUT = 2;
  4692. return EasingFunction;
  4693. }());
  4694. /**
  4695. * Easing function with a circle shape (see link below).
  4696. * @see https://easings.net/#easeInCirc
  4697. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4698. */
  4699. var CircleEase = /** @class */ (function (_super) {
  4700. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleEase, _super);
  4701. function CircleEase() {
  4702. return _super !== null && _super.apply(this, arguments) || this;
  4703. }
  4704. /** @hidden */
  4705. CircleEase.prototype.easeInCore = function (gradient) {
  4706. gradient = Math.max(0, Math.min(1, gradient));
  4707. return (1.0 - Math.sqrt(1.0 - (gradient * gradient)));
  4708. };
  4709. return CircleEase;
  4710. }(EasingFunction));
  4711. /**
  4712. * Easing function with a ease back shape (see link below).
  4713. * @see https://easings.net/#easeInBack
  4714. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4715. */
  4716. var BackEase = /** @class */ (function (_super) {
  4717. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackEase, _super);
  4718. /**
  4719. * Instantiates a back ease easing
  4720. * @see https://easings.net/#easeInBack
  4721. * @param amplitude Defines the amplitude of the function
  4722. */
  4723. function BackEase(
  4724. /** Defines the amplitude of the function */
  4725. amplitude) {
  4726. if (amplitude === void 0) { amplitude = 1; }
  4727. var _this = _super.call(this) || this;
  4728. _this.amplitude = amplitude;
  4729. return _this;
  4730. }
  4731. /** @hidden */
  4732. BackEase.prototype.easeInCore = function (gradient) {
  4733. var num = Math.max(0, this.amplitude);
  4734. return (Math.pow(gradient, 3.0) - ((gradient * num) * Math.sin(3.1415926535897931 * gradient)));
  4735. };
  4736. return BackEase;
  4737. }(EasingFunction));
  4738. /**
  4739. * Easing function with a bouncing shape (see link below).
  4740. * @see https://easings.net/#easeInBounce
  4741. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4742. */
  4743. var BounceEase = /** @class */ (function (_super) {
  4744. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BounceEase, _super);
  4745. /**
  4746. * Instantiates a bounce easing
  4747. * @see https://easings.net/#easeInBounce
  4748. * @param bounces Defines the number of bounces
  4749. * @param bounciness Defines the amplitude of the bounce
  4750. */
  4751. function BounceEase(
  4752. /** Defines the number of bounces */
  4753. bounces,
  4754. /** Defines the amplitude of the bounce */
  4755. bounciness) {
  4756. if (bounces === void 0) { bounces = 3; }
  4757. if (bounciness === void 0) { bounciness = 2; }
  4758. var _this = _super.call(this) || this;
  4759. _this.bounces = bounces;
  4760. _this.bounciness = bounciness;
  4761. return _this;
  4762. }
  4763. /** @hidden */
  4764. BounceEase.prototype.easeInCore = function (gradient) {
  4765. var y = Math.max(0.0, this.bounces);
  4766. var bounciness = this.bounciness;
  4767. if (bounciness <= 1.0) {
  4768. bounciness = 1.001;
  4769. }
  4770. var num9 = Math.pow(bounciness, y);
  4771. var num5 = 1.0 - bounciness;
  4772. var num4 = ((1.0 - num9) / num5) + (num9 * 0.5);
  4773. var num15 = gradient * num4;
  4774. var num65 = Math.log((-num15 * (1.0 - bounciness)) + 1.0) / Math.log(bounciness);
  4775. var num3 = Math.floor(num65);
  4776. var num13 = num3 + 1.0;
  4777. var num8 = (1.0 - Math.pow(bounciness, num3)) / (num5 * num4);
  4778. var num12 = (1.0 - Math.pow(bounciness, num13)) / (num5 * num4);
  4779. var num7 = (num8 + num12) * 0.5;
  4780. var num6 = gradient - num7;
  4781. var num2 = num7 - num8;
  4782. return (((-Math.pow(1.0 / bounciness, y - num3) / (num2 * num2)) * (num6 - num2)) * (num6 + num2));
  4783. };
  4784. return BounceEase;
  4785. }(EasingFunction));
  4786. /**
  4787. * Easing function with a power of 3 shape (see link below).
  4788. * @see https://easings.net/#easeInCubic
  4789. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4790. */
  4791. var CubicEase = /** @class */ (function (_super) {
  4792. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubicEase, _super);
  4793. function CubicEase() {
  4794. return _super !== null && _super.apply(this, arguments) || this;
  4795. }
  4796. /** @hidden */
  4797. CubicEase.prototype.easeInCore = function (gradient) {
  4798. return (gradient * gradient * gradient);
  4799. };
  4800. return CubicEase;
  4801. }(EasingFunction));
  4802. /**
  4803. * Easing function with an elastic shape (see link below).
  4804. * @see https://easings.net/#easeInElastic
  4805. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4806. */
  4807. var ElasticEase = /** @class */ (function (_super) {
  4808. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ElasticEase, _super);
  4809. /**
  4810. * Instantiates an elastic easing function
  4811. * @see https://easings.net/#easeInElastic
  4812. * @param oscillations Defines the number of oscillations
  4813. * @param springiness Defines the amplitude of the oscillations
  4814. */
  4815. function ElasticEase(
  4816. /** Defines the number of oscillations*/
  4817. oscillations,
  4818. /** Defines the amplitude of the oscillations*/
  4819. springiness) {
  4820. if (oscillations === void 0) { oscillations = 3; }
  4821. if (springiness === void 0) { springiness = 3; }
  4822. var _this = _super.call(this) || this;
  4823. _this.oscillations = oscillations;
  4824. _this.springiness = springiness;
  4825. return _this;
  4826. }
  4827. /** @hidden */
  4828. ElasticEase.prototype.easeInCore = function (gradient) {
  4829. var num2;
  4830. var num3 = Math.max(0.0, this.oscillations);
  4831. var num = Math.max(0.0, this.springiness);
  4832. if (num == 0) {
  4833. num2 = gradient;
  4834. }
  4835. else {
  4836. num2 = (Math.exp(num * gradient) - 1.0) / (Math.exp(num) - 1.0);
  4837. }
  4838. return (num2 * Math.sin(((6.2831853071795862 * num3) + 1.5707963267948966) * gradient));
  4839. };
  4840. return ElasticEase;
  4841. }(EasingFunction));
  4842. /**
  4843. * Easing function with an exponential shape (see link below).
  4844. * @see https://easings.net/#easeInExpo
  4845. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4846. */
  4847. var ExponentialEase = /** @class */ (function (_super) {
  4848. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExponentialEase, _super);
  4849. /**
  4850. * Instantiates an exponential easing function
  4851. * @see https://easings.net/#easeInExpo
  4852. * @param exponent Defines the exponent of the function
  4853. */
  4854. function ExponentialEase(
  4855. /** Defines the exponent of the function */
  4856. exponent) {
  4857. if (exponent === void 0) { exponent = 2; }
  4858. var _this = _super.call(this) || this;
  4859. _this.exponent = exponent;
  4860. return _this;
  4861. }
  4862. /** @hidden */
  4863. ExponentialEase.prototype.easeInCore = function (gradient) {
  4864. if (this.exponent <= 0) {
  4865. return gradient;
  4866. }
  4867. return ((Math.exp(this.exponent * gradient) - 1.0) / (Math.exp(this.exponent) - 1.0));
  4868. };
  4869. return ExponentialEase;
  4870. }(EasingFunction));
  4871. /**
  4872. * Easing function with a power shape (see link below).
  4873. * @see https://easings.net/#easeInQuad
  4874. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4875. */
  4876. var PowerEase = /** @class */ (function (_super) {
  4877. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PowerEase, _super);
  4878. /**
  4879. * Instantiates an power base easing function
  4880. * @see https://easings.net/#easeInQuad
  4881. * @param power Defines the power of the function
  4882. */
  4883. function PowerEase(
  4884. /** Defines the power of the function */
  4885. power) {
  4886. if (power === void 0) { power = 2; }
  4887. var _this = _super.call(this) || this;
  4888. _this.power = power;
  4889. return _this;
  4890. }
  4891. /** @hidden */
  4892. PowerEase.prototype.easeInCore = function (gradient) {
  4893. var y = Math.max(0.0, this.power);
  4894. return Math.pow(gradient, y);
  4895. };
  4896. return PowerEase;
  4897. }(EasingFunction));
  4898. /**
  4899. * Easing function with a power of 2 shape (see link below).
  4900. * @see https://easings.net/#easeInQuad
  4901. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4902. */
  4903. var QuadraticEase = /** @class */ (function (_super) {
  4904. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuadraticEase, _super);
  4905. function QuadraticEase() {
  4906. return _super !== null && _super.apply(this, arguments) || this;
  4907. }
  4908. /** @hidden */
  4909. QuadraticEase.prototype.easeInCore = function (gradient) {
  4910. return (gradient * gradient);
  4911. };
  4912. return QuadraticEase;
  4913. }(EasingFunction));
  4914. /**
  4915. * Easing function with a power of 4 shape (see link below).
  4916. * @see https://easings.net/#easeInQuart
  4917. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4918. */
  4919. var QuarticEase = /** @class */ (function (_super) {
  4920. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuarticEase, _super);
  4921. function QuarticEase() {
  4922. return _super !== null && _super.apply(this, arguments) || this;
  4923. }
  4924. /** @hidden */
  4925. QuarticEase.prototype.easeInCore = function (gradient) {
  4926. return (gradient * gradient * gradient * gradient);
  4927. };
  4928. return QuarticEase;
  4929. }(EasingFunction));
  4930. /**
  4931. * Easing function with a power of 5 shape (see link below).
  4932. * @see https://easings.net/#easeInQuint
  4933. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4934. */
  4935. var QuinticEase = /** @class */ (function (_super) {
  4936. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuinticEase, _super);
  4937. function QuinticEase() {
  4938. return _super !== null && _super.apply(this, arguments) || this;
  4939. }
  4940. /** @hidden */
  4941. QuinticEase.prototype.easeInCore = function (gradient) {
  4942. return (gradient * gradient * gradient * gradient * gradient);
  4943. };
  4944. return QuinticEase;
  4945. }(EasingFunction));
  4946. /**
  4947. * Easing function with a sin shape (see link below).
  4948. * @see https://easings.net/#easeInSine
  4949. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4950. */
  4951. var SineEase = /** @class */ (function (_super) {
  4952. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SineEase, _super);
  4953. function SineEase() {
  4954. return _super !== null && _super.apply(this, arguments) || this;
  4955. }
  4956. /** @hidden */
  4957. SineEase.prototype.easeInCore = function (gradient) {
  4958. return (1.0 - Math.sin(1.5707963267948966 * (1.0 - gradient)));
  4959. };
  4960. return SineEase;
  4961. }(EasingFunction));
  4962. /**
  4963. * Easing function with a bezier shape (see link below).
  4964. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4965. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4966. */
  4967. var BezierCurveEase = /** @class */ (function (_super) {
  4968. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BezierCurveEase, _super);
  4969. /**
  4970. * Instantiates a bezier function
  4971. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4972. * @param x1 Defines the x component of the start tangent in the bezier curve
  4973. * @param y1 Defines the y component of the start tangent in the bezier curve
  4974. * @param x2 Defines the x component of the end tangent in the bezier curve
  4975. * @param y2 Defines the y component of the end tangent in the bezier curve
  4976. */
  4977. function BezierCurveEase(
  4978. /** Defines the x component of the start tangent in the bezier curve */
  4979. x1,
  4980. /** Defines the y component of the start tangent in the bezier curve */
  4981. y1,
  4982. /** Defines the x component of the end tangent in the bezier curve */
  4983. x2,
  4984. /** Defines the y component of the end tangent in the bezier curve */
  4985. y2) {
  4986. if (x1 === void 0) { x1 = 0; }
  4987. if (y1 === void 0) { y1 = 0; }
  4988. if (x2 === void 0) { x2 = 1; }
  4989. if (y2 === void 0) { y2 = 1; }
  4990. var _this = _super.call(this) || this;
  4991. _this.x1 = x1;
  4992. _this.y1 = y1;
  4993. _this.x2 = x2;
  4994. _this.y2 = y2;
  4995. return _this;
  4996. }
  4997. /** @hidden */
  4998. BezierCurveEase.prototype.easeInCore = function (gradient) {
  4999. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"].Interpolate(gradient, this.x1, this.y1, this.x2, this.y2);
  5000. };
  5001. return BezierCurveEase;
  5002. }(EasingFunction));
  5003. /***/ }),
  5004. /***/ "./Animations/index.ts":
  5005. /*!*****************************!*\
  5006. !*** ./Animations/index.ts ***!
  5007. \*****************************/
  5008. /*! exports provided: Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange */
  5009. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5010. "use strict";
  5011. __webpack_require__.r(__webpack_exports__);
  5012. /* harmony import */ var _animatable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animatable */ "./Animations/animatable.ts");
  5013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _animatable__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  5014. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]; });
  5016. /* harmony import */ var _animationGroup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./animationGroup */ "./Animations/animationGroup.ts");
  5017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  5018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  5019. /* harmony import */ var _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./animationPropertiesOverride */ "./Animations/animationPropertiesOverride.ts");
  5020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__["AnimationPropertiesOverride"]; });
  5021. /* harmony import */ var _easing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./easing */ "./Animations/easing.ts");
  5022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["EasingFunction"]; });
  5023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CircleEase"]; });
  5024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BackEase"]; });
  5025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BounceEase"]; });
  5026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CubicEase"]; });
  5027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ElasticEase"]; });
  5028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ExponentialEase"]; });
  5029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["PowerEase"]; });
  5030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuadraticEase"]; });
  5031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuarticEase"]; });
  5032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuinticEase"]; });
  5033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["SineEase"]; });
  5034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BezierCurveEase"]; });
  5035. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  5036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__["RuntimeAnimation"]; });
  5037. /* harmony import */ var _animationEvent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./animationEvent */ "./Animations/animationEvent.ts");
  5038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _animationEvent__WEBPACK_IMPORTED_MODULE_6__["AnimationEvent"]; });
  5039. /* empty/unused harmony star reexport *//* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  5040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _animationKey__WEBPACK_IMPORTED_MODULE_7__["AnimationKeyInterpolation"]; });
  5041. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  5042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _animationRange__WEBPACK_IMPORTED_MODULE_8__["AnimationRange"]; });
  5043. /***/ }),
  5044. /***/ "./Animations/runtimeAnimation.ts":
  5045. /*!****************************************!*\
  5046. !*** ./Animations/runtimeAnimation.ts ***!
  5047. \****************************************/
  5048. /*! exports provided: RuntimeAnimation */
  5049. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5050. "use strict";
  5051. __webpack_require__.r(__webpack_exports__);
  5052. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return RuntimeAnimation; });
  5053. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  5054. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5055. // Static values to help the garbage collector
  5056. // Quaternion
  5057. var _staticOffsetValueQuaternion = Object.freeze(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"](0, 0, 0, 0));
  5058. // Vector3
  5059. var _staticOffsetValueVector3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero());
  5060. // Vector2
  5061. var _staticOffsetValueVector2 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero());
  5062. // Size
  5063. var _staticOffsetValueSize = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Zero());
  5064. // Color3
  5065. var _staticOffsetValueColor3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Black());
  5066. /**
  5067. * Defines a runtime animation
  5068. */
  5069. var RuntimeAnimation = /** @class */ (function () {
  5070. /**
  5071. * Create a new RuntimeAnimation object
  5072. * @param target defines the target of the animation
  5073. * @param animation defines the source animation object
  5074. * @param scene defines the hosting scene
  5075. * @param host defines the initiating Animatable
  5076. */
  5077. function RuntimeAnimation(target, animation, scene, host) {
  5078. var _this = this;
  5079. this._events = new Array();
  5080. /**
  5081. * The current frame of the runtime animation
  5082. */
  5083. this._currentFrame = 0;
  5084. /**
  5085. * The original value of the runtime animation
  5086. */
  5087. this._originalValue = new Array();
  5088. /**
  5089. * The offsets cache of the runtime animation
  5090. */
  5091. this._offsetsCache = {};
  5092. /**
  5093. * The high limits cache of the runtime animation
  5094. */
  5095. this._highLimitsCache = {};
  5096. /**
  5097. * Specifies if the runtime animation has been stopped
  5098. */
  5099. this._stopped = false;
  5100. /**
  5101. * The blending factor of the runtime animation
  5102. */
  5103. this._blendingFactor = 0;
  5104. /**
  5105. * The target path of the runtime animation
  5106. */
  5107. this._targetPath = "";
  5108. /**
  5109. * The weight of the runtime animation
  5110. */
  5111. this._weight = 1.0;
  5112. /**
  5113. * The ratio offset of the runtime animation
  5114. */
  5115. this._ratioOffset = 0;
  5116. /**
  5117. * The previous delay of the runtime animation
  5118. */
  5119. this._previousDelay = 0;
  5120. /**
  5121. * The previous ratio of the runtime animation
  5122. */
  5123. this._previousRatio = 0;
  5124. this._animation = animation;
  5125. this._target = target;
  5126. this._scene = scene;
  5127. this._host = host;
  5128. animation._runtimeAnimations.push(this);
  5129. // Cloning events locally
  5130. var events = animation.getEvents();
  5131. if (events && events.length > 0) {
  5132. events.forEach(function (e) {
  5133. _this._events.push(e._clone());
  5134. });
  5135. }
  5136. }
  5137. Object.defineProperty(RuntimeAnimation.prototype, "currentFrame", {
  5138. /**
  5139. * Gets the current frame of the runtime animation
  5140. */
  5141. get: function () {
  5142. return this._currentFrame;
  5143. },
  5144. enumerable: true,
  5145. configurable: true
  5146. });
  5147. Object.defineProperty(RuntimeAnimation.prototype, "weight", {
  5148. /**
  5149. * Gets the weight of the runtime animation
  5150. */
  5151. get: function () {
  5152. return this._weight;
  5153. },
  5154. enumerable: true,
  5155. configurable: true
  5156. });
  5157. Object.defineProperty(RuntimeAnimation.prototype, "currentValue", {
  5158. /**
  5159. * Gets the current value of the runtime animation
  5160. */
  5161. get: function () {
  5162. return this._currentValue;
  5163. },
  5164. enumerable: true,
  5165. configurable: true
  5166. });
  5167. Object.defineProperty(RuntimeAnimation.prototype, "targetPath", {
  5168. /**
  5169. * Gets the target path of the runtime animation
  5170. */
  5171. get: function () {
  5172. return this._targetPath;
  5173. },
  5174. enumerable: true,
  5175. configurable: true
  5176. });
  5177. Object.defineProperty(RuntimeAnimation.prototype, "target", {
  5178. /**
  5179. * Gets the actual target of the runtime animation
  5180. */
  5181. get: function () {
  5182. return this._activeTarget;
  5183. },
  5184. enumerable: true,
  5185. configurable: true
  5186. });
  5187. Object.defineProperty(RuntimeAnimation.prototype, "animation", {
  5188. /**
  5189. * Gets the animation from the runtime animation
  5190. */
  5191. get: function () {
  5192. return this._animation;
  5193. },
  5194. enumerable: true,
  5195. configurable: true
  5196. });
  5197. /**
  5198. * Resets the runtime animation to the beginning
  5199. * @param restoreOriginal defines whether to restore the target property to the original value
  5200. */
  5201. RuntimeAnimation.prototype.reset = function (restoreOriginal) {
  5202. if (restoreOriginal === void 0) { restoreOriginal = false; }
  5203. if (restoreOriginal) {
  5204. if (this._target instanceof Array) {
  5205. var index = 0;
  5206. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5207. var target = _a[_i];
  5208. if (this._originalValue[index] !== undefined) {
  5209. this._setValue(target, this._originalValue[index], -1);
  5210. }
  5211. index++;
  5212. }
  5213. }
  5214. else {
  5215. if (this._originalValue[0] !== undefined) {
  5216. this._setValue(this._target, this._originalValue[0], -1);
  5217. }
  5218. }
  5219. }
  5220. this._offsetsCache = {};
  5221. this._highLimitsCache = {};
  5222. this._currentFrame = 0;
  5223. this._blendingFactor = 0;
  5224. this._originalValue = new Array();
  5225. // Events
  5226. for (var index = 0; index < this._events.length; index++) {
  5227. this._events[index].isDone = false;
  5228. }
  5229. };
  5230. /**
  5231. * Specifies if the runtime animation is stopped
  5232. * @returns Boolean specifying if the runtime animation is stopped
  5233. */
  5234. RuntimeAnimation.prototype.isStopped = function () {
  5235. return this._stopped;
  5236. };
  5237. /**
  5238. * Disposes of the runtime animation
  5239. */
  5240. RuntimeAnimation.prototype.dispose = function () {
  5241. var index = this._animation.runtimeAnimations.indexOf(this);
  5242. if (index > -1) {
  5243. this._animation.runtimeAnimations.splice(index, 1);
  5244. }
  5245. };
  5246. /**
  5247. * Interpolates the animation from the current frame
  5248. * @param currentFrame The frame to interpolate the animation to
  5249. * @param repeatCount The number of times that the animation should loop
  5250. * @param loopMode The type of looping mode to use
  5251. * @param offsetValue Animation offset value
  5252. * @param highLimitValue The high limit value
  5253. * @returns The interpolated value
  5254. */
  5255. RuntimeAnimation.prototype._interpolate = function (currentFrame, repeatCount, loopMode, offsetValue, highLimitValue) {
  5256. this._currentFrame = currentFrame;
  5257. if (this._animation.dataType === _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_MATRIX && !this._workValue) {
  5258. this._workValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Zero();
  5259. }
  5260. return this._animation._interpolate(currentFrame, repeatCount, this._workValue, loopMode, offsetValue, highLimitValue);
  5261. };
  5262. /**
  5263. * Apply the interpolated value to the target
  5264. * @param currentValue defines the value computed by the animation
  5265. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5266. */
  5267. RuntimeAnimation.prototype.setValue = function (currentValue, weight) {
  5268. if (weight === void 0) { weight = 1.0; }
  5269. if (this._target instanceof Array) {
  5270. var index = 0;
  5271. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5272. var target = _a[_i];
  5273. this._setValue(target, currentValue, weight, index);
  5274. index++;
  5275. }
  5276. }
  5277. else {
  5278. this._setValue(this._target, currentValue, weight);
  5279. }
  5280. };
  5281. RuntimeAnimation.prototype._setValue = function (target, currentValue, weight, targetIndex) {
  5282. if (targetIndex === void 0) { targetIndex = 0; }
  5283. // Set value
  5284. var path;
  5285. var destination;
  5286. var targetPropertyPath = this._animation.targetPropertyPath;
  5287. if (targetPropertyPath.length > 1) {
  5288. var property = target[targetPropertyPath[0]];
  5289. for (var index = 1; index < targetPropertyPath.length - 1; index++) {
  5290. property = property[targetPropertyPath[index]];
  5291. }
  5292. path = targetPropertyPath[targetPropertyPath.length - 1];
  5293. destination = property;
  5294. }
  5295. else {
  5296. path = targetPropertyPath[0];
  5297. destination = target;
  5298. }
  5299. this._targetPath = path;
  5300. this._activeTarget = destination;
  5301. this._weight = weight;
  5302. if (this._originalValue[targetIndex] === undefined) {
  5303. var originalValue = void 0;
  5304. if (destination.getRestPose && path === "_matrix") { // For bones
  5305. originalValue = destination.getRestPose();
  5306. }
  5307. else {
  5308. originalValue = destination[path];
  5309. }
  5310. if (originalValue && originalValue.clone) {
  5311. this._originalValue[targetIndex] = originalValue.clone();
  5312. }
  5313. else {
  5314. this._originalValue[targetIndex] = originalValue;
  5315. }
  5316. }
  5317. // Blending
  5318. var enableBlending = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.enableBlending : this._animation.enableBlending;
  5319. if (enableBlending && this._blendingFactor <= 1.0) {
  5320. if (!this._originalBlendValue) {
  5321. var originalValue = destination[path];
  5322. if (originalValue.clone) {
  5323. this._originalBlendValue = originalValue.clone();
  5324. }
  5325. else {
  5326. this._originalBlendValue = originalValue;
  5327. }
  5328. }
  5329. if (this._originalBlendValue.m) { // Matrix
  5330. if (_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].AllowMatrixDecomposeForInterpolation) {
  5331. if (this._currentValue) {
  5332. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5333. }
  5334. else {
  5335. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5336. }
  5337. }
  5338. else {
  5339. if (this._currentValue) {
  5340. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5341. }
  5342. else {
  5343. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5344. }
  5345. }
  5346. }
  5347. else {
  5348. this._currentValue = _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]._UniversalLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5349. }
  5350. var blendingSpeed = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
  5351. this._blendingFactor += blendingSpeed;
  5352. }
  5353. else {
  5354. this._currentValue = currentValue;
  5355. }
  5356. if (weight !== -1.0) {
  5357. this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[targetIndex]);
  5358. }
  5359. else {
  5360. destination[path] = this._currentValue;
  5361. }
  5362. if (target.markAsDirty) {
  5363. target.markAsDirty(this._animation.targetProperty);
  5364. }
  5365. };
  5366. /**
  5367. * Gets the loop pmode of the runtime animation
  5368. * @returns Loop Mode
  5369. */
  5370. RuntimeAnimation.prototype._getCorrectLoopMode = function () {
  5371. if (this._target && this._target.animationPropertiesOverride) {
  5372. return this._target.animationPropertiesOverride.loopMode;
  5373. }
  5374. return this._animation.loopMode;
  5375. };
  5376. /**
  5377. * Move the current animation to a given frame
  5378. * @param frame defines the frame to move to
  5379. */
  5380. RuntimeAnimation.prototype.goToFrame = function (frame) {
  5381. var keys = this._animation.getKeys();
  5382. if (frame < keys[0].frame) {
  5383. frame = keys[0].frame;
  5384. }
  5385. else if (frame > keys[keys.length - 1].frame) {
  5386. frame = keys[keys.length - 1].frame;
  5387. }
  5388. var currentValue = this._interpolate(frame, 0, this._getCorrectLoopMode());
  5389. this.setValue(currentValue, -1);
  5390. };
  5391. /**
  5392. * @hidden Internal use only
  5393. */
  5394. RuntimeAnimation.prototype._prepareForSpeedRatioChange = function (newSpeedRatio) {
  5395. var newRatio = this._previousDelay * (this._animation.framePerSecond * newSpeedRatio) / 1000.0;
  5396. this._ratioOffset = this._previousRatio - newRatio;
  5397. };
  5398. /**
  5399. * Execute the current animation
  5400. * @param delay defines the delay to add to the current frame
  5401. * @param from defines the lower bound of the animation range
  5402. * @param to defines the upper bound of the animation range
  5403. * @param loop defines if the current animation must loop
  5404. * @param speedRatio defines the current speed ratio
  5405. * @param weight defines the weight of the animation (default is -1 so no weight)
  5406. * @param onLoop optional callback called when animation loops
  5407. * @returns a boolean indicating if the animation is running
  5408. */
  5409. RuntimeAnimation.prototype.animate = function (delay, from, to, loop, speedRatio, weight, onLoop) {
  5410. if (weight === void 0) { weight = -1.0; }
  5411. var targetPropertyPath = this._animation.targetPropertyPath;
  5412. if (!targetPropertyPath || targetPropertyPath.length < 1) {
  5413. this._stopped = true;
  5414. return false;
  5415. }
  5416. var returnValue = true;
  5417. var keys = this._animation.getKeys();
  5418. var min = keys[0].frame;
  5419. var max = keys[keys.length - 1].frame;
  5420. // Add a start key at frame 0 if missing
  5421. if (min !== 0) {
  5422. var newKey = { frame: 0, value: keys[0].value };
  5423. keys.splice(0, 0, newKey);
  5424. }
  5425. // Check limits
  5426. if (from < min || from > max) {
  5427. from = min;
  5428. }
  5429. if (to < min || to > max) {
  5430. to = max;
  5431. }
  5432. var range = to - from;
  5433. var offsetValue;
  5434. // Compute ratio which represents the frame delta between from and to
  5435. var ratio = (delay * (this._animation.framePerSecond * speedRatio) / 1000.0) + this._ratioOffset;
  5436. var highLimitValue = 0;
  5437. this._previousDelay = delay;
  5438. this._previousRatio = ratio;
  5439. if (((to > from && ratio >= range) || (from > to && ratio <= range)) && !loop) { // If we are out of range and not looping get back to caller
  5440. returnValue = false;
  5441. highLimitValue = this._animation._getKeyValue(keys[keys.length - 1].value);
  5442. }
  5443. else {
  5444. // Get max value if required
  5445. if (this._getCorrectLoopMode() !== _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE) {
  5446. var keyOffset = to.toString() + from.toString();
  5447. if (!this._offsetsCache[keyOffset]) {
  5448. var fromValue = this._interpolate(from, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5449. var toValue = this._interpolate(to, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5450. switch (this._animation.dataType) {
  5451. // Float
  5452. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5453. this._offsetsCache[keyOffset] = toValue - fromValue;
  5454. break;
  5455. // Quaternion
  5456. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5457. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5458. break;
  5459. // Vector3
  5460. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5461. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5462. // Vector2
  5463. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5464. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5465. // Size
  5466. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5467. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5468. // Color3
  5469. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5470. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5471. default:
  5472. break;
  5473. }
  5474. this._highLimitsCache[keyOffset] = toValue;
  5475. }
  5476. highLimitValue = this._highLimitsCache[keyOffset];
  5477. offsetValue = this._offsetsCache[keyOffset];
  5478. }
  5479. }
  5480. if (offsetValue === undefined) {
  5481. switch (this._animation.dataType) {
  5482. // Float
  5483. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5484. offsetValue = 0;
  5485. break;
  5486. // Quaternion
  5487. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5488. offsetValue = _staticOffsetValueQuaternion;
  5489. break;
  5490. // Vector3
  5491. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5492. offsetValue = _staticOffsetValueVector3;
  5493. break;
  5494. // Vector2
  5495. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5496. offsetValue = _staticOffsetValueVector2;
  5497. break;
  5498. // Size
  5499. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5500. offsetValue = _staticOffsetValueSize;
  5501. break;
  5502. // Color3
  5503. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5504. offsetValue = _staticOffsetValueColor3;
  5505. }
  5506. }
  5507. // Compute value
  5508. var currentFrame = (returnValue && range !== 0) ? from + ratio % range : to;
  5509. // Need to normalize?
  5510. if (this._host && this._host.syncRoot) {
  5511. var syncRoot = this._host.syncRoot;
  5512. var hostNormalizedFrame = (syncRoot.masterFrame - syncRoot.fromFrame) / (syncRoot.toFrame - syncRoot.fromFrame);
  5513. currentFrame = from + (to - from) * hostNormalizedFrame;
  5514. }
  5515. // Reset events if looping
  5516. var events = this._events;
  5517. if (range > 0 && this.currentFrame > currentFrame ||
  5518. range < 0 && this.currentFrame < currentFrame) {
  5519. if (onLoop) {
  5520. onLoop();
  5521. }
  5522. // Need to reset animation events
  5523. for (var index = 0; index < events.length; index++) {
  5524. if (!events[index].onlyOnce) {
  5525. // reset event, the animation is looping
  5526. events[index].isDone = false;
  5527. }
  5528. }
  5529. }
  5530. var repeatCount = range === 0 ? 0 : (ratio / range) >> 0;
  5531. var currentValue = this._interpolate(currentFrame, repeatCount, this._getCorrectLoopMode(), offsetValue, highLimitValue);
  5532. // Set value
  5533. this.setValue(currentValue, weight);
  5534. // Check events
  5535. for (var index = 0; index < events.length; index++) {
  5536. // Make sure current frame has passed event frame and that event frame is within the current range
  5537. // Also, handle both forward and reverse animations
  5538. if ((range > 0 && currentFrame >= events[index].frame && events[index].frame >= from) ||
  5539. (range < 0 && currentFrame <= events[index].frame && events[index].frame <= from)) {
  5540. var event = events[index];
  5541. if (!event.isDone) {
  5542. // If event should be done only once, remove it.
  5543. if (event.onlyOnce) {
  5544. events.splice(index, 1);
  5545. index--;
  5546. }
  5547. event.isDone = true;
  5548. event.action(currentFrame);
  5549. } // Don't do anything if the event has already be done.
  5550. }
  5551. }
  5552. if (!returnValue) {
  5553. this._stopped = true;
  5554. }
  5555. return returnValue;
  5556. };
  5557. return RuntimeAnimation;
  5558. }());
  5559. /***/ }),
  5560. /***/ "./Audio/analyser.ts":
  5561. /*!***************************!*\
  5562. !*** ./Audio/analyser.ts ***!
  5563. \***************************/
  5564. /*! exports provided: Analyser */
  5565. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5566. "use strict";
  5567. __webpack_require__.r(__webpack_exports__);
  5568. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return Analyser; });
  5569. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5570. /**
  5571. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5572. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5573. */
  5574. var Analyser = /** @class */ (function () {
  5575. /**
  5576. * Creates a new analyser
  5577. * @param scene defines hosting scene
  5578. */
  5579. function Analyser(scene) {
  5580. /**
  5581. * Gets or sets the smoothing
  5582. * @ignorenaming
  5583. */
  5584. this.SMOOTHING = 0.75;
  5585. /**
  5586. * Gets or sets the FFT table size
  5587. * @ignorenaming
  5588. */
  5589. this.FFT_SIZE = 512;
  5590. /**
  5591. * Gets or sets the bar graph amplitude
  5592. * @ignorenaming
  5593. */
  5594. this.BARGRAPHAMPLITUDE = 256;
  5595. /**
  5596. * Gets or sets the position of the debug canvas
  5597. * @ignorenaming
  5598. */
  5599. this.DEBUGCANVASPOS = { x: 20, y: 20 };
  5600. /**
  5601. * Gets or sets the debug canvas size
  5602. * @ignorenaming
  5603. */
  5604. this.DEBUGCANVASSIZE = { width: 320, height: 200 };
  5605. this._scene = scene;
  5606. this._audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine;
  5607. if (this._audioEngine.canUseWebAudio && this._audioEngine.audioContext) {
  5608. this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser();
  5609. this._webAudioAnalyser.minDecibels = -140;
  5610. this._webAudioAnalyser.maxDecibels = 0;
  5611. this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5612. this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5613. this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount);
  5614. }
  5615. }
  5616. /**
  5617. * Get the number of data values you will have to play with for the visualization
  5618. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5619. * @returns a number
  5620. */
  5621. Analyser.prototype.getFrequencyBinCount = function () {
  5622. if (this._audioEngine.canUseWebAudio) {
  5623. return this._webAudioAnalyser.frequencyBinCount;
  5624. }
  5625. else {
  5626. return 0;
  5627. }
  5628. };
  5629. /**
  5630. * Gets the current frequency data as a byte array
  5631. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5632. * @returns a Uint8Array
  5633. */
  5634. Analyser.prototype.getByteFrequencyData = function () {
  5635. if (this._audioEngine.canUseWebAudio) {
  5636. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5637. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5638. this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs);
  5639. }
  5640. return this._byteFreqs;
  5641. };
  5642. /**
  5643. * Gets the current waveform as a byte array
  5644. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5645. * @returns a Uint8Array
  5646. */
  5647. Analyser.prototype.getByteTimeDomainData = function () {
  5648. if (this._audioEngine.canUseWebAudio) {
  5649. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5650. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5651. this._webAudioAnalyser.getByteTimeDomainData(this._byteTime);
  5652. }
  5653. return this._byteTime;
  5654. };
  5655. /**
  5656. * Gets the current frequency data as a float array
  5657. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5658. * @returns a Float32Array
  5659. */
  5660. Analyser.prototype.getFloatFrequencyData = function () {
  5661. if (this._audioEngine.canUseWebAudio) {
  5662. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5663. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5664. this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs);
  5665. }
  5666. return this._floatFreqs;
  5667. };
  5668. /**
  5669. * Renders the debug canvas
  5670. */
  5671. Analyser.prototype.drawDebugCanvas = function () {
  5672. var _this = this;
  5673. if (this._audioEngine.canUseWebAudio) {
  5674. if (!this._debugCanvas) {
  5675. this._debugCanvas = document.createElement("canvas");
  5676. this._debugCanvas.width = this.DEBUGCANVASSIZE.width;
  5677. this._debugCanvas.height = this.DEBUGCANVASSIZE.height;
  5678. this._debugCanvas.style.position = "absolute";
  5679. this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + "px";
  5680. this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + "px";
  5681. this._debugCanvasContext = this._debugCanvas.getContext("2d");
  5682. document.body.appendChild(this._debugCanvas);
  5683. this._registerFunc = function () {
  5684. _this.drawDebugCanvas();
  5685. };
  5686. this._scene.registerBeforeRender(this._registerFunc);
  5687. }
  5688. if (this._registerFunc && this._debugCanvasContext) {
  5689. var workingArray = this.getByteFrequencyData();
  5690. this._debugCanvasContext.fillStyle = 'rgb(0, 0, 0)';
  5691. this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);
  5692. // Draw the frequency domain chart.
  5693. for (var i = 0; i < this.getFrequencyBinCount(); i++) {
  5694. var value = workingArray[i];
  5695. var percent = value / this.BARGRAPHAMPLITUDE;
  5696. var height = this.DEBUGCANVASSIZE.height * percent;
  5697. var offset = this.DEBUGCANVASSIZE.height - height - 1;
  5698. var barWidth = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount();
  5699. var hue = i / this.getFrequencyBinCount() * 360;
  5700. this._debugCanvasContext.fillStyle = 'hsl(' + hue + ', 100%, 50%)';
  5701. this._debugCanvasContext.fillRect(i * barWidth, offset, barWidth, height);
  5702. }
  5703. }
  5704. }
  5705. };
  5706. /**
  5707. * Stops rendering the debug canvas and removes it
  5708. */
  5709. Analyser.prototype.stopDebugCanvas = function () {
  5710. if (this._debugCanvas) {
  5711. if (this._registerFunc) {
  5712. this._scene.unregisterBeforeRender(this._registerFunc);
  5713. this._registerFunc = null;
  5714. }
  5715. document.body.removeChild(this._debugCanvas);
  5716. this._debugCanvas = null;
  5717. this._debugCanvasContext = null;
  5718. }
  5719. };
  5720. /**
  5721. * Connects two audio nodes
  5722. * @param inputAudioNode defines first node to connect
  5723. * @param outputAudioNode defines second node to connect
  5724. */
  5725. Analyser.prototype.connectAudioNodes = function (inputAudioNode, outputAudioNode) {
  5726. if (this._audioEngine.canUseWebAudio) {
  5727. inputAudioNode.connect(this._webAudioAnalyser);
  5728. this._webAudioAnalyser.connect(outputAudioNode);
  5729. }
  5730. };
  5731. /**
  5732. * Releases all associated resources
  5733. */
  5734. Analyser.prototype.dispose = function () {
  5735. if (this._audioEngine.canUseWebAudio) {
  5736. this._webAudioAnalyser.disconnect();
  5737. }
  5738. };
  5739. return Analyser;
  5740. }());
  5741. /***/ }),
  5742. /***/ "./Audio/audioEngine.ts":
  5743. /*!******************************!*\
  5744. !*** ./Audio/audioEngine.ts ***!
  5745. \******************************/
  5746. /*! exports provided: AudioEngine */
  5747. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5748. "use strict";
  5749. __webpack_require__.r(__webpack_exports__);
  5750. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return AudioEngine; });
  5751. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  5752. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  5753. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5754. // Sets the default audio engine to Babylon.js
  5755. _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].AudioEngineFactory = function (hostElement) { return new AudioEngine(hostElement); };
  5756. /**
  5757. * This represents the default audio engine used in babylon.
  5758. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5759. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5760. */
  5761. var AudioEngine = /** @class */ (function () {
  5762. /**
  5763. * Instantiates a new audio engine.
  5764. *
  5765. * There should be only one per page as some browsers restrict the number
  5766. * of audio contexts you can create.
  5767. * @param hostElement defines the host element where to display the mute icon if necessary
  5768. */
  5769. function AudioEngine(hostElement) {
  5770. if (hostElement === void 0) { hostElement = null; }
  5771. var _this = this;
  5772. this._audioContext = null;
  5773. this._audioContextInitialized = false;
  5774. this._muteButton = null;
  5775. /**
  5776. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5777. */
  5778. this.canUseWebAudio = false;
  5779. /**
  5780. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5781. * @ignoreNaming
  5782. */
  5783. this.WarnedWebAudioUnsupported = false;
  5784. /**
  5785. * Gets whether or not mp3 are supported by your browser.
  5786. */
  5787. this.isMP3supported = false;
  5788. /**
  5789. * Gets whether or not ogg are supported by your browser.
  5790. */
  5791. this.isOGGsupported = false;
  5792. /**
  5793. * Gets whether audio has been unlocked on the device.
  5794. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5795. * a user interaction has happened.
  5796. */
  5797. this.unlocked = true;
  5798. /**
  5799. * Defines if the audio engine relies on a custom unlocked button.
  5800. * In this case, the embedded button will not be displayed.
  5801. */
  5802. this.useCustomUnlockedButton = false;
  5803. /**
  5804. * Event raised when audio has been unlocked on the browser.
  5805. */
  5806. this.onAudioUnlockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5807. /**
  5808. * Event raised when audio has been locked on the browser.
  5809. */
  5810. this.onAudioLockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5811. this._tryToRun = false;
  5812. this._onResize = function () {
  5813. _this._moveButtonToTopLeft();
  5814. };
  5815. if (typeof window.AudioContext !== 'undefined' || typeof window.webkitAudioContext !== 'undefined') {
  5816. window.AudioContext = window.AudioContext || window.webkitAudioContext;
  5817. this.canUseWebAudio = true;
  5818. }
  5819. var audioElem = document.createElement('audio');
  5820. this._hostElement = hostElement;
  5821. try {
  5822. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, '')) {
  5823. this.isMP3supported = true;
  5824. }
  5825. }
  5826. catch (e) {
  5827. // protect error during capability check.
  5828. }
  5829. try {
  5830. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) {
  5831. this.isOGGsupported = true;
  5832. }
  5833. }
  5834. catch (e) {
  5835. // protect error during capability check.
  5836. }
  5837. }
  5838. Object.defineProperty(AudioEngine.prototype, "audioContext", {
  5839. /**
  5840. * Gets the current AudioContext if available.
  5841. */
  5842. get: function () {
  5843. if (!this._audioContextInitialized) {
  5844. this._initializeAudioContext();
  5845. }
  5846. else {
  5847. if (!this.unlocked && !this._muteButton) {
  5848. this._displayMuteButton();
  5849. }
  5850. }
  5851. return this._audioContext;
  5852. },
  5853. enumerable: true,
  5854. configurable: true
  5855. });
  5856. /**
  5857. * Flags the audio engine in Locked state.
  5858. * This happens due to new browser policies preventing audio to autoplay.
  5859. */
  5860. AudioEngine.prototype.lock = function () {
  5861. this._triggerSuspendedState();
  5862. };
  5863. /**
  5864. * Unlocks the audio engine once a user action has been done on the dom.
  5865. * This is helpful to resume play once browser policies have been satisfied.
  5866. */
  5867. AudioEngine.prototype.unlock = function () {
  5868. this._triggerRunningState();
  5869. };
  5870. AudioEngine.prototype._resumeAudioContext = function () {
  5871. var result;
  5872. if (this._audioContext.resume) {
  5873. result = this._audioContext.resume();
  5874. }
  5875. return result || Promise.resolve();
  5876. };
  5877. AudioEngine.prototype._initializeAudioContext = function () {
  5878. try {
  5879. if (this.canUseWebAudio) {
  5880. this._audioContext = new AudioContext();
  5881. // create a global volume gain node
  5882. this.masterGain = this._audioContext.createGain();
  5883. this.masterGain.gain.value = 1;
  5884. this.masterGain.connect(this._audioContext.destination);
  5885. this._audioContextInitialized = true;
  5886. if (this._audioContext.state === "running") {
  5887. // Do not wait for the promise to unlock.
  5888. this._triggerRunningState();
  5889. }
  5890. }
  5891. }
  5892. catch (e) {
  5893. this.canUseWebAudio = false;
  5894. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Web Audio: " + e.message);
  5895. }
  5896. };
  5897. AudioEngine.prototype._triggerRunningState = function () {
  5898. var _this = this;
  5899. if (this._tryToRun) {
  5900. return;
  5901. }
  5902. this._tryToRun = true;
  5903. this._resumeAudioContext()
  5904. .then(function () {
  5905. _this._tryToRun = false;
  5906. if (_this._muteButton) {
  5907. _this._hideMuteButton();
  5908. }
  5909. }).catch(function () {
  5910. _this._tryToRun = false;
  5911. _this.unlocked = false;
  5912. });
  5913. // Notify users that the audio stack is unlocked/unmuted
  5914. this.unlocked = true;
  5915. this.onAudioUnlockedObservable.notifyObservers(this);
  5916. };
  5917. AudioEngine.prototype._triggerSuspendedState = function () {
  5918. this.unlocked = false;
  5919. this.onAudioLockedObservable.notifyObservers(this);
  5920. this._displayMuteButton();
  5921. };
  5922. AudioEngine.prototype._displayMuteButton = function () {
  5923. var _this = this;
  5924. if (this.useCustomUnlockedButton || this._muteButton) {
  5925. return;
  5926. }
  5927. this._muteButton = document.createElement("BUTTON");
  5928. this._muteButton.className = "babylonUnmuteIcon";
  5929. this._muteButton.id = "babylonUnmuteIconBtn";
  5930. this._muteButton.title = "Unmute";
  5931. 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) }";
  5932. var style = document.createElement('style');
  5933. style.appendChild(document.createTextNode(css));
  5934. document.getElementsByTagName('head')[0].appendChild(style);
  5935. document.body.appendChild(this._muteButton);
  5936. this._moveButtonToTopLeft();
  5937. this._muteButton.addEventListener('touchend', function () {
  5938. _this._triggerRunningState();
  5939. }, true);
  5940. this._muteButton.addEventListener('click', function () {
  5941. _this._triggerRunningState();
  5942. }, true);
  5943. window.addEventListener("resize", this._onResize);
  5944. };
  5945. AudioEngine.prototype._moveButtonToTopLeft = function () {
  5946. if (this._hostElement && this._muteButton) {
  5947. this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px";
  5948. this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px";
  5949. }
  5950. };
  5951. AudioEngine.prototype._hideMuteButton = function () {
  5952. if (this._muteButton) {
  5953. document.body.removeChild(this._muteButton);
  5954. this._muteButton = null;
  5955. }
  5956. };
  5957. /**
  5958. * Destroy and release the resources associated with the audio ccontext.
  5959. */
  5960. AudioEngine.prototype.dispose = function () {
  5961. if (this.canUseWebAudio && this._audioContextInitialized) {
  5962. if (this._connectedAnalyser && this._audioContext) {
  5963. this._connectedAnalyser.stopDebugCanvas();
  5964. this._connectedAnalyser.dispose();
  5965. this.masterGain.disconnect();
  5966. this.masterGain.connect(this._audioContext.destination);
  5967. this._connectedAnalyser = null;
  5968. }
  5969. this.masterGain.gain.value = 1;
  5970. }
  5971. this.WarnedWebAudioUnsupported = false;
  5972. this._hideMuteButton();
  5973. window.removeEventListener("resize", this._onResize);
  5974. this.onAudioUnlockedObservable.clear();
  5975. this.onAudioLockedObservable.clear();
  5976. };
  5977. /**
  5978. * Gets the global volume sets on the master gain.
  5979. * @returns the global volume if set or -1 otherwise
  5980. */
  5981. AudioEngine.prototype.getGlobalVolume = function () {
  5982. if (this.canUseWebAudio && this._audioContextInitialized) {
  5983. return this.masterGain.gain.value;
  5984. }
  5985. else {
  5986. return -1;
  5987. }
  5988. };
  5989. /**
  5990. * Sets the global volume of your experience (sets on the master gain).
  5991. * @param newVolume Defines the new global volume of the application
  5992. */
  5993. AudioEngine.prototype.setGlobalVolume = function (newVolume) {
  5994. if (this.canUseWebAudio && this._audioContextInitialized) {
  5995. this.masterGain.gain.value = newVolume;
  5996. }
  5997. };
  5998. /**
  5999. * Connect the audio engine to an audio analyser allowing some amazing
  6000. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  6001. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  6002. * @param analyser The analyser to connect to the engine
  6003. */
  6004. AudioEngine.prototype.connectToAnalyser = function (analyser) {
  6005. if (this._connectedAnalyser) {
  6006. this._connectedAnalyser.stopDebugCanvas();
  6007. }
  6008. if (this.canUseWebAudio && this._audioContextInitialized && this._audioContext) {
  6009. this._connectedAnalyser = analyser;
  6010. this.masterGain.disconnect();
  6011. this._connectedAnalyser.connectAudioNodes(this.masterGain, this._audioContext.destination);
  6012. }
  6013. };
  6014. return AudioEngine;
  6015. }());
  6016. /***/ }),
  6017. /***/ "./Audio/audioSceneComponent.ts":
  6018. /*!**************************************!*\
  6019. !*** ./Audio/audioSceneComponent.ts ***!
  6020. \**************************************/
  6021. /*! exports provided: AudioSceneComponent */
  6022. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6023. "use strict";
  6024. __webpack_require__.r(__webpack_exports__);
  6025. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return AudioSceneComponent; });
  6026. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6027. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6028. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6029. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6030. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  6031. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  6032. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  6033. // Adds the parser to the scene parsers.
  6034. _abstractScene__WEBPACK_IMPORTED_MODULE_6__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO, function (parsedData, scene, container, rootUrl) {
  6035. // TODO: add sound
  6036. var loadedSounds = [];
  6037. var loadedSound;
  6038. container.sounds = container.sounds || [];
  6039. if (parsedData.sounds !== undefined && parsedData.sounds !== null) {
  6040. for (var index = 0, cache = parsedData.sounds.length; index < cache; index++) {
  6041. var parsedSound = parsedData.sounds[index];
  6042. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine.canUseWebAudio) {
  6043. if (!parsedSound.url) {
  6044. parsedSound.url = parsedSound.name;
  6045. }
  6046. if (!loadedSounds[parsedSound.url]) {
  6047. loadedSound = _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl);
  6048. loadedSounds[parsedSound.url] = loadedSound;
  6049. container.sounds.push(loadedSound);
  6050. }
  6051. else {
  6052. container.sounds.push(_sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl, loadedSounds[parsedSound.url]));
  6053. }
  6054. }
  6055. else {
  6056. container.sounds.push(new _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"](parsedSound.name, null, scene));
  6057. }
  6058. }
  6059. }
  6060. loadedSounds = [];
  6061. });
  6062. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "mainSoundTrack", {
  6063. get: function () {
  6064. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6065. if (!compo) {
  6066. compo = new AudioSceneComponent(this);
  6067. this._addComponent(compo);
  6068. }
  6069. if (!this._mainSoundTrack) {
  6070. this._mainSoundTrack = new _soundTrack__WEBPACK_IMPORTED_MODULE_1__["SoundTrack"](this, { mainTrack: true });
  6071. }
  6072. return this._mainSoundTrack;
  6073. },
  6074. enumerable: true,
  6075. configurable: true
  6076. });
  6077. _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype.getSoundByName = function (name) {
  6078. var index;
  6079. for (index = 0; index < this.mainSoundTrack.soundCollection.length; index++) {
  6080. if (this.mainSoundTrack.soundCollection[index].name === name) {
  6081. return this.mainSoundTrack.soundCollection[index];
  6082. }
  6083. }
  6084. if (this.soundTracks) {
  6085. for (var sdIndex = 0; sdIndex < this.soundTracks.length; sdIndex++) {
  6086. for (index = 0; index < this.soundTracks[sdIndex].soundCollection.length; index++) {
  6087. if (this.soundTracks[sdIndex].soundCollection[index].name === name) {
  6088. return this.soundTracks[sdIndex].soundCollection[index];
  6089. }
  6090. }
  6091. }
  6092. }
  6093. return null;
  6094. };
  6095. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "audioEnabled", {
  6096. get: function () {
  6097. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6098. if (!compo) {
  6099. compo = new AudioSceneComponent(this);
  6100. this._addComponent(compo);
  6101. }
  6102. return compo.audioEnabled;
  6103. },
  6104. set: function (value) {
  6105. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6106. if (!compo) {
  6107. compo = new AudioSceneComponent(this);
  6108. this._addComponent(compo);
  6109. }
  6110. if (value) {
  6111. compo.enableAudio();
  6112. }
  6113. else {
  6114. compo.disableAudio();
  6115. }
  6116. },
  6117. enumerable: true,
  6118. configurable: true
  6119. });
  6120. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "headphone", {
  6121. get: function () {
  6122. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6123. if (!compo) {
  6124. compo = new AudioSceneComponent(this);
  6125. this._addComponent(compo);
  6126. }
  6127. return compo.headphone;
  6128. },
  6129. set: function (value) {
  6130. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6131. if (!compo) {
  6132. compo = new AudioSceneComponent(this);
  6133. this._addComponent(compo);
  6134. }
  6135. if (value) {
  6136. compo.switchAudioModeForHeadphones();
  6137. }
  6138. else {
  6139. compo.switchAudioModeForNormalSpeakers();
  6140. }
  6141. },
  6142. enumerable: true,
  6143. configurable: true
  6144. });
  6145. /**
  6146. * Defines the sound scene component responsible to manage any sounds
  6147. * in a given scene.
  6148. */
  6149. var AudioSceneComponent = /** @class */ (function () {
  6150. /**
  6151. * Creates a new instance of the component for the given scene
  6152. * @param scene Defines the scene to register the component in
  6153. */
  6154. function AudioSceneComponent(scene) {
  6155. /**
  6156. * The component name helpfull to identify the component in the list of scene components.
  6157. */
  6158. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO;
  6159. this._audioEnabled = true;
  6160. this._headphone = false;
  6161. this.scene = scene;
  6162. scene.soundTracks = new Array();
  6163. scene.sounds = new Array();
  6164. }
  6165. Object.defineProperty(AudioSceneComponent.prototype, "audioEnabled", {
  6166. /**
  6167. * Gets whether audio is enabled or not.
  6168. * Please use related enable/disable method to switch state.
  6169. */
  6170. get: function () {
  6171. return this._audioEnabled;
  6172. },
  6173. enumerable: true,
  6174. configurable: true
  6175. });
  6176. Object.defineProperty(AudioSceneComponent.prototype, "headphone", {
  6177. /**
  6178. * Gets whether audio is outputing to headphone or not.
  6179. * Please use the according Switch methods to change output.
  6180. */
  6181. get: function () {
  6182. return this._headphone;
  6183. },
  6184. enumerable: true,
  6185. configurable: true
  6186. });
  6187. /**
  6188. * Registers the component in a given scene
  6189. */
  6190. AudioSceneComponent.prototype.register = function () {
  6191. this.scene._afterRenderStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDER_AUDIO, this, this._afterRender);
  6192. };
  6193. /**
  6194. * Rebuilds the elements related to this component in case of
  6195. * context lost for instance.
  6196. */
  6197. AudioSceneComponent.prototype.rebuild = function () {
  6198. // Nothing to do here. (Not rendering related)
  6199. };
  6200. /**
  6201. * Serializes the component data to the specified json object
  6202. * @param serializationObject The object to serialize to
  6203. */
  6204. AudioSceneComponent.prototype.serialize = function (serializationObject) {
  6205. serializationObject.sounds = [];
  6206. if (this.scene.soundTracks) {
  6207. for (var index = 0; index < this.scene.soundTracks.length; index++) {
  6208. var soundtrack = this.scene.soundTracks[index];
  6209. for (var soundId = 0; soundId < soundtrack.soundCollection.length; soundId++) {
  6210. serializationObject.sounds.push(soundtrack.soundCollection[soundId].serialize());
  6211. }
  6212. }
  6213. }
  6214. };
  6215. /**
  6216. * Adds all the element from the container to the scene
  6217. * @param container the container holding the elements
  6218. */
  6219. AudioSceneComponent.prototype.addFromContainer = function (container) {
  6220. var _this = this;
  6221. if (!container.sounds) {
  6222. return;
  6223. }
  6224. container.sounds.forEach(function (sound) {
  6225. sound.play();
  6226. sound.autoplay = true;
  6227. _this.scene.mainSoundTrack.AddSound(sound);
  6228. });
  6229. };
  6230. /**
  6231. * Removes all the elements in the container from the scene
  6232. * @param container contains the elements to remove
  6233. */
  6234. AudioSceneComponent.prototype.removeFromContainer = function (container) {
  6235. var _this = this;
  6236. if (!container.sounds) {
  6237. return;
  6238. }
  6239. container.sounds.forEach(function (sound) {
  6240. sound.stop();
  6241. sound.autoplay = false;
  6242. _this.scene.mainSoundTrack.RemoveSound(sound);
  6243. });
  6244. };
  6245. /**
  6246. * Disposes the component and the associated ressources.
  6247. */
  6248. AudioSceneComponent.prototype.dispose = function () {
  6249. var scene = this.scene;
  6250. if (scene._mainSoundTrack) {
  6251. scene.mainSoundTrack.dispose();
  6252. }
  6253. if (scene.soundTracks) {
  6254. for (var scIndex = 0; scIndex < scene.soundTracks.length; scIndex++) {
  6255. scene.soundTracks[scIndex].dispose();
  6256. }
  6257. }
  6258. };
  6259. /**
  6260. * Disables audio in the associated scene.
  6261. */
  6262. AudioSceneComponent.prototype.disableAudio = function () {
  6263. var scene = this.scene;
  6264. this._audioEnabled = false;
  6265. var i;
  6266. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6267. scene.mainSoundTrack.soundCollection[i].pause();
  6268. }
  6269. if (scene.soundTracks) {
  6270. for (i = 0; i < scene.soundTracks.length; i++) {
  6271. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6272. scene.soundTracks[i].soundCollection[j].pause();
  6273. }
  6274. }
  6275. }
  6276. };
  6277. /**
  6278. * Enables audio in the associated scene.
  6279. */
  6280. AudioSceneComponent.prototype.enableAudio = function () {
  6281. var scene = this.scene;
  6282. this._audioEnabled = true;
  6283. var i;
  6284. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6285. if (scene.mainSoundTrack.soundCollection[i].isPaused) {
  6286. scene.mainSoundTrack.soundCollection[i].play();
  6287. }
  6288. }
  6289. if (scene.soundTracks) {
  6290. for (i = 0; i < scene.soundTracks.length; i++) {
  6291. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6292. if (scene.soundTracks[i].soundCollection[j].isPaused) {
  6293. scene.soundTracks[i].soundCollection[j].play();
  6294. }
  6295. }
  6296. }
  6297. }
  6298. };
  6299. /**
  6300. * Switch audio to headphone output.
  6301. */
  6302. AudioSceneComponent.prototype.switchAudioModeForHeadphones = function () {
  6303. var scene = this.scene;
  6304. this._headphone = true;
  6305. scene.mainSoundTrack.switchPanningModelToHRTF();
  6306. if (scene.soundTracks) {
  6307. for (var i = 0; i < scene.soundTracks.length; i++) {
  6308. scene.soundTracks[i].switchPanningModelToHRTF();
  6309. }
  6310. }
  6311. };
  6312. /**
  6313. * Switch audio to normal speakers.
  6314. */
  6315. AudioSceneComponent.prototype.switchAudioModeForNormalSpeakers = function () {
  6316. var scene = this.scene;
  6317. this._headphone = false;
  6318. scene.mainSoundTrack.switchPanningModelToEqualPower();
  6319. if (scene.soundTracks) {
  6320. for (var i = 0; i < scene.soundTracks.length; i++) {
  6321. scene.soundTracks[i].switchPanningModelToEqualPower();
  6322. }
  6323. }
  6324. };
  6325. AudioSceneComponent.prototype._afterRender = function () {
  6326. var scene = this.scene;
  6327. if (!this._audioEnabled || !scene._mainSoundTrack || !scene.soundTracks || (scene._mainSoundTrack.soundCollection.length === 0 && scene.soundTracks.length === 1)) {
  6328. return;
  6329. }
  6330. var listeningCamera;
  6331. var audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine;
  6332. if (scene.activeCameras.length > 0) {
  6333. listeningCamera = scene.activeCameras[0];
  6334. }
  6335. else {
  6336. listeningCamera = scene.activeCamera;
  6337. }
  6338. if (listeningCamera && audioEngine.audioContext) {
  6339. audioEngine.audioContext.listener.setPosition(listeningCamera.position.x, listeningCamera.position.y, listeningCamera.position.z);
  6340. // for VR cameras
  6341. if (listeningCamera.rigCameras && listeningCamera.rigCameras.length > 0) {
  6342. listeningCamera = listeningCamera.rigCameras[0];
  6343. }
  6344. var mat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(listeningCamera.getViewMatrix());
  6345. var cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1), mat);
  6346. cameraDirection.normalize();
  6347. // To avoid some errors on GearVR
  6348. if (!isNaN(cameraDirection.x) && !isNaN(cameraDirection.y) && !isNaN(cameraDirection.z)) {
  6349. audioEngine.audioContext.listener.setOrientation(cameraDirection.x, cameraDirection.y, cameraDirection.z, 0, 1, 0);
  6350. }
  6351. var i;
  6352. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6353. var sound = scene.mainSoundTrack.soundCollection[i];
  6354. if (sound.useCustomAttenuation) {
  6355. sound.updateDistanceFromListener();
  6356. }
  6357. }
  6358. if (scene.soundTracks) {
  6359. for (i = 0; i < scene.soundTracks.length; i++) {
  6360. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6361. sound = scene.soundTracks[i].soundCollection[j];
  6362. if (sound.useCustomAttenuation) {
  6363. sound.updateDistanceFromListener();
  6364. }
  6365. }
  6366. }
  6367. }
  6368. }
  6369. };
  6370. return AudioSceneComponent;
  6371. }());
  6372. _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"]._SceneComponentInitialization = function (scene) {
  6373. var compo = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6374. if (!compo) {
  6375. compo = new AudioSceneComponent(scene);
  6376. scene._addComponent(compo);
  6377. }
  6378. };
  6379. /***/ }),
  6380. /***/ "./Audio/index.ts":
  6381. /*!************************!*\
  6382. !*** ./Audio/index.ts ***!
  6383. \************************/
  6384. /*! exports provided: Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound */
  6385. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6386. "use strict";
  6387. __webpack_require__.r(__webpack_exports__);
  6388. /* harmony import */ var _analyser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./analyser */ "./Audio/analyser.ts");
  6389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _analyser__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  6390. /* harmony import */ var _audioEngine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./audioEngine */ "./Audio/audioEngine.ts");
  6391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _audioEngine__WEBPACK_IMPORTED_MODULE_1__["AudioEngine"]; });
  6392. /* harmony import */ var _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./audioSceneComponent */ "./Audio/audioSceneComponent.ts");
  6393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__["AudioSceneComponent"]; });
  6394. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _sound__WEBPACK_IMPORTED_MODULE_3__["Sound"]; });
  6396. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _soundTrack__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  6398. /* harmony import */ var _weightedsound__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./weightedsound */ "./Audio/weightedsound.ts");
  6399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _weightedsound__WEBPACK_IMPORTED_MODULE_5__["WeightedSound"]; });
  6400. /***/ }),
  6401. /***/ "./Audio/sound.ts":
  6402. /*!************************!*\
  6403. !*** ./Audio/sound.ts ***!
  6404. \************************/
  6405. /*! exports provided: Sound */
  6406. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6407. "use strict";
  6408. __webpack_require__.r(__webpack_exports__);
  6409. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return Sound; });
  6410. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  6411. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  6412. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6413. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6414. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  6415. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  6416. /**
  6417. * Defines a sound that can be played in the application.
  6418. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  6419. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6420. */
  6421. var Sound = /** @class */ (function () {
  6422. /**
  6423. * Create a sound and attach it to a scene
  6424. * @param name Name of your sound
  6425. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  6426. * @param scene defines the scene the sound belongs to
  6427. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  6428. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  6429. */
  6430. function Sound(name, urlOrArrayBuffer, scene, readyToPlayCallback, options) {
  6431. if (readyToPlayCallback === void 0) { readyToPlayCallback = null; }
  6432. var _this = this;
  6433. /**
  6434. * Does the sound autoplay once loaded.
  6435. */
  6436. this.autoplay = false;
  6437. /**
  6438. * Does the sound loop after it finishes playing once.
  6439. */
  6440. this.loop = false;
  6441. /**
  6442. * Does the sound use a custom attenuation curve to simulate the falloff
  6443. * happening when the source gets further away from the camera.
  6444. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6445. */
  6446. this.useCustomAttenuation = false;
  6447. /**
  6448. * Is this sound currently played.
  6449. */
  6450. this.isPlaying = false;
  6451. /**
  6452. * Is this sound currently paused.
  6453. */
  6454. this.isPaused = false;
  6455. /**
  6456. * Does this sound enables spatial sound.
  6457. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6458. */
  6459. this.spatialSound = false;
  6460. /**
  6461. * Define the reference distance the sound should be heard perfectly.
  6462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6463. */
  6464. this.refDistance = 1;
  6465. /**
  6466. * Define the roll off factor of spatial sounds.
  6467. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6468. */
  6469. this.rolloffFactor = 1;
  6470. /**
  6471. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  6472. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6473. */
  6474. this.maxDistance = 100;
  6475. /**
  6476. * Define the distance attenuation model the sound will follow.
  6477. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6478. */
  6479. this.distanceModel = "linear";
  6480. /**
  6481. * Observable event when the current playing sound finishes.
  6482. */
  6483. this.onEndedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6484. this._panningModel = "equalpower";
  6485. this._playbackRate = 1;
  6486. this._streaming = false;
  6487. this._startTime = 0;
  6488. this._startOffset = 0;
  6489. this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  6490. /** @hidden */
  6491. this._positionInEmitterSpace = false;
  6492. this._localDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 0, 0);
  6493. this._volume = 1;
  6494. this._isReadyToPlay = false;
  6495. this._isDirectional = false;
  6496. // Used if you'd like to create a directional sound.
  6497. // If not set, the sound will be omnidirectional
  6498. this._coneInnerAngle = 360;
  6499. this._coneOuterAngle = 360;
  6500. this._coneOuterGain = 0;
  6501. this._isOutputConnected = false;
  6502. this._urlType = "Unknown";
  6503. this.name = name;
  6504. this._scene = scene;
  6505. Sound._SceneComponentInitialization(scene);
  6506. this._readyToPlayCallback = readyToPlayCallback;
  6507. // Default custom attenuation function is a linear attenuation
  6508. this._customAttenuationFunction = function (currentVolume, currentDistance, maxDistance, refDistance, rolloffFactor) {
  6509. if (currentDistance < maxDistance) {
  6510. return currentVolume * (1 - currentDistance / maxDistance);
  6511. }
  6512. else {
  6513. return 0;
  6514. }
  6515. };
  6516. if (options) {
  6517. this.autoplay = options.autoplay || false;
  6518. this.loop = options.loop || false;
  6519. // if volume === 0, we need another way to check this option
  6520. if (options.volume !== undefined) {
  6521. this._volume = options.volume;
  6522. }
  6523. this.spatialSound = options.spatialSound || false;
  6524. this.maxDistance = options.maxDistance || 100;
  6525. this.useCustomAttenuation = options.useCustomAttenuation || false;
  6526. this.rolloffFactor = options.rolloffFactor || 1;
  6527. this.refDistance = options.refDistance || 1;
  6528. this.distanceModel = options.distanceModel || "linear";
  6529. this._playbackRate = options.playbackRate || 1;
  6530. this._streaming = options.streaming || false;
  6531. }
  6532. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6533. this._soundGain = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createGain();
  6534. this._soundGain.gain.value = this._volume;
  6535. this._inputAudioNode = this._soundGain;
  6536. this._outputAudioNode = this._soundGain;
  6537. if (this.spatialSound) {
  6538. this._createSpatialParameters();
  6539. }
  6540. this._scene.mainSoundTrack.AddSound(this);
  6541. var validParameter = true;
  6542. // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound
  6543. if (urlOrArrayBuffer) {
  6544. try {
  6545. if (typeof (urlOrArrayBuffer) === "string") {
  6546. this._urlType = "String";
  6547. }
  6548. else if (urlOrArrayBuffer instanceof ArrayBuffer) {
  6549. this._urlType = "ArrayBuffer";
  6550. }
  6551. else if (urlOrArrayBuffer instanceof MediaStream) {
  6552. this._urlType = "MediaStream";
  6553. }
  6554. else if (Array.isArray(urlOrArrayBuffer)) {
  6555. this._urlType = "Array";
  6556. }
  6557. var urls = [];
  6558. var codecSupportedFound = false;
  6559. switch (this._urlType) {
  6560. case "MediaStream":
  6561. this._streaming = true;
  6562. this._isReadyToPlay = true;
  6563. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(urlOrArrayBuffer);
  6564. if (this.autoplay) {
  6565. this.play();
  6566. }
  6567. if (this._readyToPlayCallback) {
  6568. this._readyToPlayCallback();
  6569. }
  6570. break;
  6571. case "ArrayBuffer":
  6572. if (urlOrArrayBuffer.byteLength > 0) {
  6573. codecSupportedFound = true;
  6574. this._soundLoaded(urlOrArrayBuffer);
  6575. }
  6576. break;
  6577. case "String":
  6578. urls.push(urlOrArrayBuffer);
  6579. case "Array":
  6580. if (urls.length === 0) {
  6581. urls = urlOrArrayBuffer;
  6582. }
  6583. // If we found a supported format, we load it immediately and stop the loop
  6584. for (var i = 0; i < urls.length; i++) {
  6585. var url = urls[i];
  6586. if (url.indexOf(".mp3", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isMP3supported) {
  6587. codecSupportedFound = true;
  6588. }
  6589. if (url.indexOf(".ogg", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isOGGsupported) {
  6590. codecSupportedFound = true;
  6591. }
  6592. if (url.indexOf(".wav", url.length - 4) !== -1) {
  6593. codecSupportedFound = true;
  6594. }
  6595. if (url.indexOf("blob:") !== -1) {
  6596. codecSupportedFound = true;
  6597. }
  6598. if (codecSupportedFound) {
  6599. // Loading sound using XHR2
  6600. if (!this._streaming) {
  6601. this._scene._loadFile(url, function (data) {
  6602. _this._soundLoaded(data);
  6603. }, undefined, true, true, function (exception) {
  6604. if (exception) {
  6605. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("XHR " + exception.status + " error on: " + url + ".");
  6606. }
  6607. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Sound creation aborted.");
  6608. _this._scene.mainSoundTrack.RemoveSound(_this);
  6609. });
  6610. }
  6611. // Streaming sound using HTML5 Audio tag
  6612. else {
  6613. this._htmlAudioElement = new Audio(url);
  6614. this._htmlAudioElement.controls = false;
  6615. this._htmlAudioElement.loop = this.loop;
  6616. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetCorsBehavior(url, this._htmlAudioElement);
  6617. this._htmlAudioElement.preload = "auto";
  6618. this._htmlAudioElement.addEventListener("canplaythrough", function () {
  6619. _this._isReadyToPlay = true;
  6620. if (_this.autoplay) {
  6621. _this.play();
  6622. }
  6623. if (_this._readyToPlayCallback) {
  6624. _this._readyToPlayCallback();
  6625. }
  6626. });
  6627. document.body.appendChild(this._htmlAudioElement);
  6628. this._htmlAudioElement.load();
  6629. }
  6630. break;
  6631. }
  6632. }
  6633. break;
  6634. default:
  6635. validParameter = false;
  6636. break;
  6637. }
  6638. if (!validParameter) {
  6639. _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.");
  6640. }
  6641. else {
  6642. if (!codecSupportedFound) {
  6643. this._isReadyToPlay = true;
  6644. // Simulating a ready to play event to avoid breaking code path
  6645. if (this._readyToPlayCallback) {
  6646. window.setTimeout(function () {
  6647. if (_this._readyToPlayCallback) {
  6648. _this._readyToPlayCallback();
  6649. }
  6650. }, 1000);
  6651. }
  6652. }
  6653. }
  6654. }
  6655. catch (ex) {
  6656. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Unexpected error. Sound creation aborted.");
  6657. this._scene.mainSoundTrack.RemoveSound(this);
  6658. }
  6659. }
  6660. }
  6661. else {
  6662. // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers
  6663. this._scene.mainSoundTrack.AddSound(this);
  6664. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported) {
  6665. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Web Audio is not supported by your browser.");
  6666. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported = true;
  6667. }
  6668. // Simulating a ready to play event to avoid breaking code for non web audio browsers
  6669. if (this._readyToPlayCallback) {
  6670. window.setTimeout(function () {
  6671. if (_this._readyToPlayCallback) {
  6672. _this._readyToPlayCallback();
  6673. }
  6674. }, 1000);
  6675. }
  6676. }
  6677. }
  6678. /**
  6679. * Release the sound and its associated resources
  6680. */
  6681. Sound.prototype.dispose = function () {
  6682. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6683. if (this.isPlaying) {
  6684. this.stop();
  6685. }
  6686. this._isReadyToPlay = false;
  6687. if (this.soundTrackId === -1) {
  6688. this._scene.mainSoundTrack.RemoveSound(this);
  6689. }
  6690. else if (this._scene.soundTracks) {
  6691. this._scene.soundTracks[this.soundTrackId].RemoveSound(this);
  6692. }
  6693. if (this._soundGain) {
  6694. this._soundGain.disconnect();
  6695. this._soundGain = null;
  6696. }
  6697. if (this._soundPanner) {
  6698. this._soundPanner.disconnect();
  6699. this._soundPanner = null;
  6700. }
  6701. if (this._soundSource) {
  6702. this._soundSource.disconnect();
  6703. this._soundSource = null;
  6704. }
  6705. this._audioBuffer = null;
  6706. if (this._htmlAudioElement) {
  6707. this._htmlAudioElement.pause();
  6708. this._htmlAudioElement.src = "";
  6709. document.body.removeChild(this._htmlAudioElement);
  6710. }
  6711. if (this._streamingSource) {
  6712. this._streamingSource.disconnect();
  6713. }
  6714. if (this._connectedTransformNode && this._registerFunc) {
  6715. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  6716. this._connectedTransformNode = null;
  6717. }
  6718. }
  6719. };
  6720. /**
  6721. * Gets if the sounds is ready to be played or not.
  6722. * @returns true if ready, otherwise false
  6723. */
  6724. Sound.prototype.isReady = function () {
  6725. return this._isReadyToPlay;
  6726. };
  6727. Sound.prototype._soundLoaded = function (audioData) {
  6728. var _this = this;
  6729. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6730. return;
  6731. }
  6732. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.decodeAudioData(audioData, function (buffer) {
  6733. _this._audioBuffer = buffer;
  6734. _this._isReadyToPlay = true;
  6735. if (_this.autoplay) {
  6736. _this.play();
  6737. }
  6738. if (_this._readyToPlayCallback) {
  6739. _this._readyToPlayCallback();
  6740. }
  6741. }, function (err) { _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while decoding audio data for: " + _this.name + " / Error: " + err); });
  6742. };
  6743. /**
  6744. * Sets the data of the sound from an audiobuffer
  6745. * @param audioBuffer The audioBuffer containing the data
  6746. */
  6747. Sound.prototype.setAudioBuffer = function (audioBuffer) {
  6748. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6749. this._audioBuffer = audioBuffer;
  6750. this._isReadyToPlay = true;
  6751. }
  6752. };
  6753. /**
  6754. * Updates the current sounds options such as maxdistance, loop...
  6755. * @param options A JSON object containing values named as the object properties
  6756. */
  6757. Sound.prototype.updateOptions = function (options) {
  6758. if (options) {
  6759. this.loop = options.loop || this.loop;
  6760. this.maxDistance = options.maxDistance || this.maxDistance;
  6761. this.useCustomAttenuation = options.useCustomAttenuation || this.useCustomAttenuation;
  6762. this.rolloffFactor = options.rolloffFactor || this.rolloffFactor;
  6763. this.refDistance = options.refDistance || this.refDistance;
  6764. this.distanceModel = options.distanceModel || this.distanceModel;
  6765. this._playbackRate = options.playbackRate || this._playbackRate;
  6766. this._updateSpatialParameters();
  6767. if (this.isPlaying) {
  6768. if (this._streaming && this._htmlAudioElement) {
  6769. this._htmlAudioElement.playbackRate = this._playbackRate;
  6770. }
  6771. else {
  6772. if (this._soundSource) {
  6773. this._soundSource.playbackRate.value = this._playbackRate;
  6774. }
  6775. }
  6776. }
  6777. }
  6778. };
  6779. Sound.prototype._createSpatialParameters = function () {
  6780. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6781. if (this._scene.headphone) {
  6782. this._panningModel = "HRTF";
  6783. }
  6784. this._soundPanner = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createPanner();
  6785. this._updateSpatialParameters();
  6786. this._soundPanner.connect(this._outputAudioNode);
  6787. this._inputAudioNode = this._soundPanner;
  6788. }
  6789. };
  6790. Sound.prototype._updateSpatialParameters = function () {
  6791. if (this.spatialSound && this._soundPanner) {
  6792. if (this.useCustomAttenuation) {
  6793. // Tricks to disable in a way embedded Web Audio attenuation
  6794. this._soundPanner.distanceModel = "linear";
  6795. this._soundPanner.maxDistance = Number.MAX_VALUE;
  6796. this._soundPanner.refDistance = 1;
  6797. this._soundPanner.rolloffFactor = 1;
  6798. this._soundPanner.panningModel = this._panningModel;
  6799. }
  6800. else {
  6801. this._soundPanner.distanceModel = this.distanceModel;
  6802. this._soundPanner.maxDistance = this.maxDistance;
  6803. this._soundPanner.refDistance = this.refDistance;
  6804. this._soundPanner.rolloffFactor = this.rolloffFactor;
  6805. this._soundPanner.panningModel = this._panningModel;
  6806. }
  6807. }
  6808. };
  6809. /**
  6810. * Switch the panning model to HRTF:
  6811. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  6812. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6813. */
  6814. Sound.prototype.switchPanningModelToHRTF = function () {
  6815. this._panningModel = "HRTF";
  6816. this._switchPanningModel();
  6817. };
  6818. /**
  6819. * Switch the panning model to Equal Power:
  6820. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  6821. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6822. */
  6823. Sound.prototype.switchPanningModelToEqualPower = function () {
  6824. this._panningModel = "equalpower";
  6825. this._switchPanningModel();
  6826. };
  6827. Sound.prototype._switchPanningModel = function () {
  6828. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6829. this._soundPanner.panningModel = this._panningModel;
  6830. }
  6831. };
  6832. /**
  6833. * Connect this sound to a sound track audio node like gain...
  6834. * @param soundTrackAudioNode the sound track audio node to connect to
  6835. */
  6836. Sound.prototype.connectToSoundTrackAudioNode = function (soundTrackAudioNode) {
  6837. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6838. if (this._isOutputConnected) {
  6839. this._outputAudioNode.disconnect();
  6840. }
  6841. this._outputAudioNode.connect(soundTrackAudioNode);
  6842. this._isOutputConnected = true;
  6843. }
  6844. };
  6845. /**
  6846. * Transform this sound into a directional source
  6847. * @param coneInnerAngle Size of the inner cone in degree
  6848. * @param coneOuterAngle Size of the outer cone in degree
  6849. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  6850. */
  6851. Sound.prototype.setDirectionalCone = function (coneInnerAngle, coneOuterAngle, coneOuterGain) {
  6852. if (coneOuterAngle < coneInnerAngle) {
  6853. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
  6854. return;
  6855. }
  6856. this._coneInnerAngle = coneInnerAngle;
  6857. this._coneOuterAngle = coneOuterAngle;
  6858. this._coneOuterGain = coneOuterGain;
  6859. this._isDirectional = true;
  6860. if (this.isPlaying && this.loop) {
  6861. this.stop();
  6862. this.play();
  6863. }
  6864. };
  6865. Object.defineProperty(Sound.prototype, "directionalConeInnerAngle", {
  6866. /**
  6867. * Gets or sets the inner angle for the directional cone.
  6868. */
  6869. get: function () {
  6870. return this._coneInnerAngle;
  6871. },
  6872. /**
  6873. * Gets or sets the inner angle for the directional cone.
  6874. */
  6875. set: function (value) {
  6876. if (value != this._coneInnerAngle) {
  6877. if (this._coneOuterAngle < value) {
  6878. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6879. return;
  6880. }
  6881. this._coneInnerAngle = value;
  6882. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6883. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6884. }
  6885. }
  6886. },
  6887. enumerable: true,
  6888. configurable: true
  6889. });
  6890. Object.defineProperty(Sound.prototype, "directionalConeOuterAngle", {
  6891. /**
  6892. * Gets or sets the outer angle for the directional cone.
  6893. */
  6894. get: function () {
  6895. return this._coneOuterAngle;
  6896. },
  6897. /**
  6898. * Gets or sets the outer angle for the directional cone.
  6899. */
  6900. set: function (value) {
  6901. if (value != this._coneOuterAngle) {
  6902. if (value < this._coneInnerAngle) {
  6903. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6904. return;
  6905. }
  6906. this._coneOuterAngle = value;
  6907. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6908. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6909. }
  6910. }
  6911. },
  6912. enumerable: true,
  6913. configurable: true
  6914. });
  6915. /**
  6916. * Sets the position of the emitter if spatial sound is enabled
  6917. * @param newPosition Defines the new posisiton
  6918. */
  6919. Sound.prototype.setPosition = function (newPosition) {
  6920. this._position = newPosition;
  6921. 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)) {
  6922. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6923. }
  6924. };
  6925. /**
  6926. * Sets the local direction of the emitter if spatial sound is enabled
  6927. * @param newLocalDirection Defines the new local direction
  6928. */
  6929. Sound.prototype.setLocalDirectionToMesh = function (newLocalDirection) {
  6930. this._localDirection = newLocalDirection;
  6931. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {
  6932. this._updateDirection();
  6933. }
  6934. };
  6935. Sound.prototype._updateDirection = function () {
  6936. if (!this._connectedTransformNode || !this._soundPanner) {
  6937. return;
  6938. }
  6939. var mat = this._connectedTransformNode.getWorldMatrix();
  6940. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(this._localDirection, mat);
  6941. direction.normalize();
  6942. this._soundPanner.setOrientation(direction.x, direction.y, direction.z);
  6943. };
  6944. /** @hidden */
  6945. Sound.prototype.updateDistanceFromListener = function () {
  6946. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
  6947. var distance = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
  6948. this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);
  6949. }
  6950. };
  6951. /**
  6952. * Sets a new custom attenuation function for the sound.
  6953. * @param callback Defines the function used for the attenuation
  6954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6955. */
  6956. Sound.prototype.setAttenuationFunction = function (callback) {
  6957. this._customAttenuationFunction = callback;
  6958. };
  6959. /**
  6960. * Play the sound
  6961. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  6962. * @param offset (optional) Start the sound setting it at a specific time
  6963. */
  6964. Sound.prototype.play = function (time, offset) {
  6965. var _this = this;
  6966. if (this._isReadyToPlay && this._scene.audioEnabled && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6967. try {
  6968. if (this._startOffset < 0) {
  6969. time = -this._startOffset;
  6970. this._startOffset = 0;
  6971. }
  6972. var startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  6973. if (!this._soundSource || !this._streamingSource) {
  6974. if (this.spatialSound && this._soundPanner) {
  6975. if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
  6976. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6977. }
  6978. if (this._isDirectional) {
  6979. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6980. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6981. this._soundPanner.coneOuterGain = this._coneOuterGain;
  6982. if (this._connectedTransformNode) {
  6983. this._updateDirection();
  6984. }
  6985. else {
  6986. this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);
  6987. }
  6988. }
  6989. }
  6990. }
  6991. if (this._streaming) {
  6992. if (!this._streamingSource) {
  6993. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);
  6994. this._htmlAudioElement.onended = function () { _this._onended(); };
  6995. this._htmlAudioElement.playbackRate = this._playbackRate;
  6996. }
  6997. this._streamingSource.disconnect();
  6998. this._streamingSource.connect(this._inputAudioNode);
  6999. if (this._htmlAudioElement) {
  7000. // required to manage properly the new suspended default state of Chrome
  7001. // When the option 'streaming: true' is used, we need first to wait for
  7002. // the audio engine to be unlocked by a user gesture before trying to play
  7003. // an HTML Audio elememt
  7004. var tryToPlay = function () {
  7005. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.unlocked) {
  7006. var playPromise = _this._htmlAudioElement.play();
  7007. // In browsers that don’t yet support this functionality,
  7008. // playPromise won’t be defined.
  7009. if (playPromise !== undefined) {
  7010. playPromise.catch(function (error) {
  7011. // Automatic playback failed.
  7012. // Waiting for the audio engine to be unlocked by user click on unmute
  7013. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7014. if (_this.loop || _this.autoplay) {
  7015. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7016. }
  7017. });
  7018. }
  7019. }
  7020. else {
  7021. if (_this.loop || _this.autoplay) {
  7022. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7023. }
  7024. }
  7025. };
  7026. tryToPlay();
  7027. }
  7028. }
  7029. else {
  7030. var tryToPlay = function () {
  7031. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7032. _this._soundSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createBufferSource();
  7033. _this._soundSource.buffer = _this._audioBuffer;
  7034. _this._soundSource.connect(_this._inputAudioNode);
  7035. _this._soundSource.loop = _this.loop;
  7036. _this._soundSource.playbackRate.value = _this._playbackRate;
  7037. _this._soundSource.onended = function () { _this._onended(); };
  7038. startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7039. _this._soundSource.start(startTime, _this.isPaused ? _this._startOffset % _this._soundSource.buffer.duration : offset ? offset : 0);
  7040. }
  7041. };
  7042. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7043. // Wait a bit for FF as context seems late to be ready.
  7044. setTimeout(function () {
  7045. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7046. // Automatic playback failed.
  7047. // Waiting for the audio engine to be unlocked by user click on unmute
  7048. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7049. if (_this.loop || _this.autoplay) {
  7050. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7051. }
  7052. }
  7053. else {
  7054. tryToPlay();
  7055. }
  7056. }, 500);
  7057. }
  7058. else {
  7059. tryToPlay();
  7060. }
  7061. }
  7062. this._startTime = startTime;
  7063. this.isPlaying = true;
  7064. this.isPaused = false;
  7065. }
  7066. catch (ex) {
  7067. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while trying to play audio: " + this.name + ", " + ex.message);
  7068. }
  7069. }
  7070. };
  7071. Sound.prototype._onended = function () {
  7072. this.isPlaying = false;
  7073. if (this.onended) {
  7074. this.onended();
  7075. }
  7076. this.onEndedObservable.notifyObservers(this);
  7077. };
  7078. /**
  7079. * Stop the sound
  7080. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  7081. */
  7082. Sound.prototype.stop = function (time) {
  7083. if (this.isPlaying) {
  7084. if (this._streaming) {
  7085. if (this._htmlAudioElement) {
  7086. this._htmlAudioElement.pause();
  7087. // Test needed for Firefox or it will generate an Invalid State Error
  7088. if (this._htmlAudioElement.currentTime > 0) {
  7089. this._htmlAudioElement.currentTime = 0;
  7090. }
  7091. }
  7092. else {
  7093. this._streamingSource.disconnect();
  7094. }
  7095. }
  7096. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext && this._soundSource) {
  7097. var stopTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7098. this._soundSource.stop(stopTime);
  7099. this._soundSource.onended = function () { };
  7100. if (!this.isPaused) {
  7101. this._startOffset = 0;
  7102. }
  7103. }
  7104. this.isPlaying = false;
  7105. }
  7106. };
  7107. /**
  7108. * Put the sound in pause
  7109. */
  7110. Sound.prototype.pause = function () {
  7111. if (this.isPlaying) {
  7112. this.isPaused = true;
  7113. if (this._streaming) {
  7114. if (this._htmlAudioElement) {
  7115. this._htmlAudioElement.pause();
  7116. }
  7117. else {
  7118. this._streamingSource.disconnect();
  7119. }
  7120. }
  7121. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7122. this.stop(0);
  7123. this._startOffset += _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime - this._startTime;
  7124. }
  7125. }
  7126. };
  7127. /**
  7128. * Sets a dedicated volume for this sounds
  7129. * @param newVolume Define the new volume of the sound
  7130. * @param time Define in how long the sound should be at this value
  7131. */
  7132. Sound.prototype.setVolume = function (newVolume, time) {
  7133. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._soundGain) {
  7134. if (time && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7135. this._soundGain.gain.cancelScheduledValues(_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7136. this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7137. this._soundGain.gain.linearRampToValueAtTime(newVolume, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time);
  7138. }
  7139. else {
  7140. this._soundGain.gain.value = newVolume;
  7141. }
  7142. }
  7143. this._volume = newVolume;
  7144. };
  7145. /**
  7146. * Set the sound play back rate
  7147. * @param newPlaybackRate Define the playback rate the sound should be played at
  7148. */
  7149. Sound.prototype.setPlaybackRate = function (newPlaybackRate) {
  7150. this._playbackRate = newPlaybackRate;
  7151. if (this.isPlaying) {
  7152. if (this._streaming && this._htmlAudioElement) {
  7153. this._htmlAudioElement.playbackRate = this._playbackRate;
  7154. }
  7155. else if (this._soundSource) {
  7156. this._soundSource.playbackRate.value = this._playbackRate;
  7157. }
  7158. }
  7159. };
  7160. /**
  7161. * Gets the volume of the sound.
  7162. * @returns the volume of the sound
  7163. */
  7164. Sound.prototype.getVolume = function () {
  7165. return this._volume;
  7166. };
  7167. /**
  7168. * Attach the sound to a dedicated mesh
  7169. * @param transformNode The transform node to connect the sound with
  7170. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7171. */
  7172. Sound.prototype.attachToMesh = function (transformNode) {
  7173. var _this = this;
  7174. if (this._connectedTransformNode && this._registerFunc) {
  7175. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7176. this._registerFunc = null;
  7177. }
  7178. this._connectedTransformNode = transformNode;
  7179. if (!this.spatialSound) {
  7180. this.spatialSound = true;
  7181. this._createSpatialParameters();
  7182. if (this.isPlaying && this.loop) {
  7183. this.stop();
  7184. this.play();
  7185. }
  7186. }
  7187. this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode);
  7188. this._registerFunc = function (transformNode) { return _this._onRegisterAfterWorldMatrixUpdate(transformNode); };
  7189. this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);
  7190. };
  7191. /**
  7192. * Detach the sound from the previously attached mesh
  7193. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7194. */
  7195. Sound.prototype.detachFromMesh = function () {
  7196. if (this._connectedTransformNode && this._registerFunc) {
  7197. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7198. this._registerFunc = null;
  7199. this._connectedTransformNode = null;
  7200. }
  7201. };
  7202. Sound.prototype._onRegisterAfterWorldMatrixUpdate = function (node) {
  7203. if (!node.getBoundingInfo) {
  7204. return;
  7205. }
  7206. var mesh = node;
  7207. if (this._positionInEmitterSpace) {
  7208. mesh.worldMatrixFromCache.invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0]);
  7209. this.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0].getTranslation());
  7210. }
  7211. else {
  7212. var boundingInfo = mesh.getBoundingInfo();
  7213. this.setPosition(boundingInfo.boundingSphere.centerWorld);
  7214. }
  7215. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._isDirectional && this.isPlaying) {
  7216. this._updateDirection();
  7217. }
  7218. };
  7219. /**
  7220. * Clone the current sound in the scene.
  7221. * @returns the new sound clone
  7222. */
  7223. Sound.prototype.clone = function () {
  7224. var _this = this;
  7225. if (!this._streaming) {
  7226. var setBufferAndRun = function () {
  7227. if (_this._isReadyToPlay) {
  7228. clonedSound._audioBuffer = _this.getAudioBuffer();
  7229. clonedSound._isReadyToPlay = true;
  7230. if (clonedSound.autoplay) {
  7231. clonedSound.play();
  7232. }
  7233. }
  7234. else {
  7235. window.setTimeout(setBufferAndRun, 300);
  7236. }
  7237. };
  7238. var currentOptions = {
  7239. autoplay: this.autoplay, loop: this.loop,
  7240. volume: this._volume, spatialSound: this.spatialSound, maxDistance: this.maxDistance,
  7241. useCustomAttenuation: this.useCustomAttenuation, rolloffFactor: this.rolloffFactor,
  7242. refDistance: this.refDistance, distanceModel: this.distanceModel
  7243. };
  7244. var clonedSound = new Sound(this.name + "_cloned", new ArrayBuffer(0), this._scene, null, currentOptions);
  7245. if (this.useCustomAttenuation) {
  7246. clonedSound.setAttenuationFunction(this._customAttenuationFunction);
  7247. }
  7248. clonedSound.setPosition(this._position);
  7249. clonedSound.setPlaybackRate(this._playbackRate);
  7250. setBufferAndRun();
  7251. return clonedSound;
  7252. }
  7253. // Can't clone a streaming sound
  7254. else {
  7255. return null;
  7256. }
  7257. };
  7258. /**
  7259. * Gets the current underlying audio buffer containing the data
  7260. * @returns the audio buffer
  7261. */
  7262. Sound.prototype.getAudioBuffer = function () {
  7263. return this._audioBuffer;
  7264. };
  7265. /**
  7266. * Serializes the Sound in a JSON representation
  7267. * @returns the JSON representation of the sound
  7268. */
  7269. Sound.prototype.serialize = function () {
  7270. var serializationObject = {
  7271. name: this.name,
  7272. url: this.name,
  7273. autoplay: this.autoplay,
  7274. loop: this.loop,
  7275. volume: this._volume,
  7276. spatialSound: this.spatialSound,
  7277. maxDistance: this.maxDistance,
  7278. rolloffFactor: this.rolloffFactor,
  7279. refDistance: this.refDistance,
  7280. distanceModel: this.distanceModel,
  7281. playbackRate: this._playbackRate,
  7282. panningModel: this._panningModel,
  7283. soundTrackId: this.soundTrackId
  7284. };
  7285. if (this.spatialSound) {
  7286. if (this._connectedTransformNode) {
  7287. serializationObject.connectedMeshId = this._connectedTransformNode.id;
  7288. }
  7289. serializationObject.position = this._position.asArray();
  7290. serializationObject.refDistance = this.refDistance;
  7291. serializationObject.distanceModel = this.distanceModel;
  7292. serializationObject.isDirectional = this._isDirectional;
  7293. serializationObject.localDirectionToMesh = this._localDirection.asArray();
  7294. serializationObject.coneInnerAngle = this._coneInnerAngle;
  7295. serializationObject.coneOuterAngle = this._coneOuterAngle;
  7296. serializationObject.coneOuterGain = this._coneOuterGain;
  7297. }
  7298. return serializationObject;
  7299. };
  7300. /**
  7301. * Parse a JSON representation of a sound to innstantiate in a given scene
  7302. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  7303. * @param scene Define the scene the new parsed sound should be created in
  7304. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  7305. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  7306. * @returns the newly parsed sound
  7307. */
  7308. Sound.Parse = function (parsedSound, scene, rootUrl, sourceSound) {
  7309. var soundName = parsedSound.name;
  7310. var soundUrl;
  7311. if (parsedSound.url) {
  7312. soundUrl = rootUrl + parsedSound.url;
  7313. }
  7314. else {
  7315. soundUrl = rootUrl + soundName;
  7316. }
  7317. var options = {
  7318. autoplay: parsedSound.autoplay, loop: parsedSound.loop, volume: parsedSound.volume,
  7319. spatialSound: parsedSound.spatialSound, maxDistance: parsedSound.maxDistance,
  7320. rolloffFactor: parsedSound.rolloffFactor,
  7321. refDistance: parsedSound.refDistance,
  7322. distanceModel: parsedSound.distanceModel,
  7323. playbackRate: parsedSound.playbackRate
  7324. };
  7325. var newSound;
  7326. if (!sourceSound) {
  7327. newSound = new Sound(soundName, soundUrl, scene, function () { scene._removePendingData(newSound); }, options);
  7328. scene._addPendingData(newSound);
  7329. }
  7330. else {
  7331. var setBufferAndRun = function () {
  7332. if (sourceSound._isReadyToPlay) {
  7333. newSound._audioBuffer = sourceSound.getAudioBuffer();
  7334. newSound._isReadyToPlay = true;
  7335. if (newSound.autoplay) {
  7336. newSound.play();
  7337. }
  7338. }
  7339. else {
  7340. window.setTimeout(setBufferAndRun, 300);
  7341. }
  7342. };
  7343. newSound = new Sound(soundName, new ArrayBuffer(0), scene, null, options);
  7344. setBufferAndRun();
  7345. }
  7346. if (parsedSound.position) {
  7347. var soundPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.position);
  7348. newSound.setPosition(soundPosition);
  7349. }
  7350. if (parsedSound.isDirectional) {
  7351. newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);
  7352. if (parsedSound.localDirectionToMesh) {
  7353. var localDirectionToMesh = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.localDirectionToMesh);
  7354. newSound.setLocalDirectionToMesh(localDirectionToMesh);
  7355. }
  7356. }
  7357. if (parsedSound.connectedMeshId) {
  7358. var connectedMesh = scene.getMeshByID(parsedSound.connectedMeshId);
  7359. if (connectedMesh) {
  7360. newSound.attachToMesh(connectedMesh);
  7361. }
  7362. }
  7363. return newSound;
  7364. };
  7365. /** @hidden */
  7366. Sound._SceneComponentInitialization = function (_) {
  7367. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AudioSceneComponent");
  7368. };
  7369. return Sound;
  7370. }());
  7371. /***/ }),
  7372. /***/ "./Audio/soundTrack.ts":
  7373. /*!*****************************!*\
  7374. !*** ./Audio/soundTrack.ts ***!
  7375. \*****************************/
  7376. /*! exports provided: SoundTrack */
  7377. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7378. "use strict";
  7379. __webpack_require__.r(__webpack_exports__);
  7380. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return SoundTrack; });
  7381. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  7382. /**
  7383. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  7384. * It will be also used in a future release to apply effects on a specific track.
  7385. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7386. */
  7387. var SoundTrack = /** @class */ (function () {
  7388. /**
  7389. * Creates a new sound track.
  7390. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7391. * @param scene Define the scene the sound track belongs to
  7392. * @param options
  7393. */
  7394. function SoundTrack(scene, options) {
  7395. if (options === void 0) { options = {}; }
  7396. /**
  7397. * The unique identifier of the sound track in the scene.
  7398. */
  7399. this.id = -1;
  7400. this._isMainTrack = false;
  7401. this._isInitialized = false;
  7402. this._scene = scene;
  7403. this.soundCollection = new Array();
  7404. this._options = options;
  7405. if (!this._isMainTrack && this._scene.soundTracks) {
  7406. this._scene.soundTracks.push(this);
  7407. this.id = this._scene.soundTracks.length - 1;
  7408. }
  7409. }
  7410. SoundTrack.prototype._initializeSoundTrackAudioGraph = function () {
  7411. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext) {
  7412. this._outputAudioNode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext.createGain();
  7413. this._outputAudioNode.connect(_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7414. if (this._options) {
  7415. if (this._options.volume) {
  7416. this._outputAudioNode.gain.value = this._options.volume;
  7417. }
  7418. if (this._options.mainTrack) {
  7419. this._isMainTrack = this._options.mainTrack;
  7420. }
  7421. }
  7422. this._isInitialized = true;
  7423. }
  7424. };
  7425. /**
  7426. * Release the sound track and its associated resources
  7427. */
  7428. SoundTrack.prototype.dispose = function () {
  7429. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7430. if (this._connectedAnalyser) {
  7431. this._connectedAnalyser.stopDebugCanvas();
  7432. }
  7433. while (this.soundCollection.length) {
  7434. this.soundCollection[0].dispose();
  7435. }
  7436. if (this._outputAudioNode) {
  7437. this._outputAudioNode.disconnect();
  7438. }
  7439. this._outputAudioNode = null;
  7440. }
  7441. };
  7442. /**
  7443. * Adds a sound to this sound track
  7444. * @param sound define the cound to add
  7445. * @ignoreNaming
  7446. */
  7447. SoundTrack.prototype.AddSound = function (sound) {
  7448. if (!this._isInitialized) {
  7449. this._initializeSoundTrackAudioGraph();
  7450. }
  7451. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7452. sound.connectToSoundTrackAudioNode(this._outputAudioNode);
  7453. }
  7454. if (sound.soundTrackId) {
  7455. if (sound.soundTrackId === -1) {
  7456. this._scene.mainSoundTrack.RemoveSound(sound);
  7457. }
  7458. else if (this._scene.soundTracks) {
  7459. this._scene.soundTracks[sound.soundTrackId].RemoveSound(sound);
  7460. }
  7461. }
  7462. this.soundCollection.push(sound);
  7463. sound.soundTrackId = this.id;
  7464. };
  7465. /**
  7466. * Removes a sound to this sound track
  7467. * @param sound define the cound to remove
  7468. * @ignoreNaming
  7469. */
  7470. SoundTrack.prototype.RemoveSound = function (sound) {
  7471. var index = this.soundCollection.indexOf(sound);
  7472. if (index !== -1) {
  7473. this.soundCollection.splice(index, 1);
  7474. }
  7475. };
  7476. /**
  7477. * Set a global volume for the full sound track.
  7478. * @param newVolume Define the new volume of the sound track
  7479. */
  7480. SoundTrack.prototype.setVolume = function (newVolume) {
  7481. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7482. this._outputAudioNode.gain.value = newVolume;
  7483. }
  7484. };
  7485. /**
  7486. * Switch the panning model to HRTF:
  7487. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  7488. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7489. */
  7490. SoundTrack.prototype.switchPanningModelToHRTF = function () {
  7491. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7492. for (var i = 0; i < this.soundCollection.length; i++) {
  7493. this.soundCollection[i].switchPanningModelToHRTF();
  7494. }
  7495. }
  7496. };
  7497. /**
  7498. * Switch the panning model to Equal Power:
  7499. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  7500. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7501. */
  7502. SoundTrack.prototype.switchPanningModelToEqualPower = function () {
  7503. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7504. for (var i = 0; i < this.soundCollection.length; i++) {
  7505. this.soundCollection[i].switchPanningModelToEqualPower();
  7506. }
  7507. }
  7508. };
  7509. /**
  7510. * Connect the sound track to an audio analyser allowing some amazing
  7511. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  7512. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  7513. * @param analyser The analyser to connect to the engine
  7514. */
  7515. SoundTrack.prototype.connectToAnalyser = function (analyser) {
  7516. if (this._connectedAnalyser) {
  7517. this._connectedAnalyser.stopDebugCanvas();
  7518. }
  7519. this._connectedAnalyser = analyser;
  7520. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7521. this._outputAudioNode.disconnect();
  7522. this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7523. }
  7524. };
  7525. return SoundTrack;
  7526. }());
  7527. /***/ }),
  7528. /***/ "./Audio/weightedsound.ts":
  7529. /*!********************************!*\
  7530. !*** ./Audio/weightedsound.ts ***!
  7531. \********************************/
  7532. /*! exports provided: WeightedSound */
  7533. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7534. "use strict";
  7535. __webpack_require__.r(__webpack_exports__);
  7536. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return WeightedSound; });
  7537. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  7538. /**
  7539. * Wraps one or more Sound objects and selects one with random weight for playback.
  7540. */
  7541. var WeightedSound = /** @class */ (function () {
  7542. /**
  7543. * Creates a new WeightedSound from the list of sounds given.
  7544. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  7545. * @param sounds Array of Sounds that will be selected from.
  7546. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  7547. */
  7548. function WeightedSound(loop, sounds, weights) {
  7549. var _this = this;
  7550. /** When true a Sound will be selected and played when the current playing Sound completes. */
  7551. this.loop = false;
  7552. this._coneInnerAngle = 360;
  7553. this._coneOuterAngle = 360;
  7554. this._volume = 1;
  7555. /** A Sound is currently playing. */
  7556. this.isPlaying = false;
  7557. /** A Sound is currently paused. */
  7558. this.isPaused = false;
  7559. this._sounds = [];
  7560. this._weights = [];
  7561. if (sounds.length !== weights.length) {
  7562. throw new Error('Sounds length does not equal weights length');
  7563. }
  7564. this.loop = loop;
  7565. this._weights = weights;
  7566. // Normalize the weights
  7567. var weightSum = 0;
  7568. for (var _i = 0, weights_1 = weights; _i < weights_1.length; _i++) {
  7569. var weight = weights_1[_i];
  7570. weightSum += weight;
  7571. }
  7572. var invWeightSum = weightSum > 0 ? 1 / weightSum : 0;
  7573. for (var i = 0; i < this._weights.length; i++) {
  7574. this._weights[i] *= invWeightSum;
  7575. }
  7576. this._sounds = sounds;
  7577. for (var _a = 0, _b = this._sounds; _a < _b.length; _a++) {
  7578. var sound = _b[_a];
  7579. sound.onEndedObservable.add(function () { _this._onended(); });
  7580. }
  7581. }
  7582. Object.defineProperty(WeightedSound.prototype, "directionalConeInnerAngle", {
  7583. /**
  7584. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  7585. */
  7586. get: function () {
  7587. return this._coneInnerAngle;
  7588. },
  7589. /**
  7590. * The size of cone in degress for a directional sound in which there will be no attenuation.
  7591. */
  7592. set: function (value) {
  7593. if (value !== this._coneInnerAngle) {
  7594. if (this._coneOuterAngle < value) {
  7595. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7596. return;
  7597. }
  7598. this._coneInnerAngle = value;
  7599. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7600. var sound = _a[_i];
  7601. sound.directionalConeInnerAngle = value;
  7602. }
  7603. }
  7604. },
  7605. enumerable: true,
  7606. configurable: true
  7607. });
  7608. Object.defineProperty(WeightedSound.prototype, "directionalConeOuterAngle", {
  7609. /**
  7610. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7611. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7612. */
  7613. get: function () {
  7614. return this._coneOuterAngle;
  7615. },
  7616. /**
  7617. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7618. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7619. */
  7620. set: function (value) {
  7621. if (value !== this._coneOuterAngle) {
  7622. if (value < this._coneInnerAngle) {
  7623. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7624. return;
  7625. }
  7626. this._coneOuterAngle = value;
  7627. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7628. var sound = _a[_i];
  7629. sound.directionalConeOuterAngle = value;
  7630. }
  7631. }
  7632. },
  7633. enumerable: true,
  7634. configurable: true
  7635. });
  7636. Object.defineProperty(WeightedSound.prototype, "volume", {
  7637. /**
  7638. * Playback volume.
  7639. */
  7640. get: function () {
  7641. return this._volume;
  7642. },
  7643. /**
  7644. * Playback volume.
  7645. */
  7646. set: function (value) {
  7647. if (value !== this._volume) {
  7648. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7649. var sound = _a[_i];
  7650. sound.setVolume(value);
  7651. }
  7652. }
  7653. },
  7654. enumerable: true,
  7655. configurable: true
  7656. });
  7657. WeightedSound.prototype._onended = function () {
  7658. if (this._currentIndex !== undefined) {
  7659. this._sounds[this._currentIndex].autoplay = false;
  7660. }
  7661. if (this.loop && this.isPlaying) {
  7662. this.play();
  7663. }
  7664. else {
  7665. this.isPlaying = false;
  7666. }
  7667. };
  7668. /**
  7669. * Suspend playback
  7670. */
  7671. WeightedSound.prototype.pause = function () {
  7672. this.isPaused = true;
  7673. if (this._currentIndex !== undefined) {
  7674. this._sounds[this._currentIndex].pause();
  7675. }
  7676. };
  7677. /**
  7678. * Stop playback
  7679. */
  7680. WeightedSound.prototype.stop = function () {
  7681. this.isPlaying = false;
  7682. if (this._currentIndex !== undefined) {
  7683. this._sounds[this._currentIndex].stop();
  7684. }
  7685. };
  7686. /**
  7687. * Start playback.
  7688. * @param startOffset Position the clip head at a specific time in seconds.
  7689. */
  7690. WeightedSound.prototype.play = function (startOffset) {
  7691. if (!this.isPaused) {
  7692. this.stop();
  7693. var randomValue = Math.random();
  7694. var total = 0;
  7695. for (var i = 0; i < this._weights.length; i++) {
  7696. total += this._weights[i];
  7697. if (randomValue <= total) {
  7698. this._currentIndex = i;
  7699. break;
  7700. }
  7701. }
  7702. }
  7703. var sound = this._sounds[this._currentIndex];
  7704. if (sound.isReady()) {
  7705. sound.play(0, this.isPaused ? undefined : startOffset);
  7706. }
  7707. else {
  7708. sound.autoplay = true;
  7709. }
  7710. this.isPlaying = true;
  7711. this.isPaused = false;
  7712. };
  7713. return WeightedSound;
  7714. }());
  7715. /***/ }),
  7716. /***/ "./Behaviors/Cameras/autoRotationBehavior.ts":
  7717. /*!***************************************************!*\
  7718. !*** ./Behaviors/Cameras/autoRotationBehavior.ts ***!
  7719. \***************************************************/
  7720. /*! exports provided: AutoRotationBehavior */
  7721. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7722. "use strict";
  7723. __webpack_require__.r(__webpack_exports__);
  7724. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return AutoRotationBehavior; });
  7725. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  7726. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  7727. /**
  7728. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  7729. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7730. */
  7731. var AutoRotationBehavior = /** @class */ (function () {
  7732. function AutoRotationBehavior() {
  7733. this._zoomStopsAnimation = false;
  7734. this._idleRotationSpeed = 0.05;
  7735. this._idleRotationWaitTime = 2000;
  7736. this._idleRotationSpinupTime = 2000;
  7737. this._isPointerDown = false;
  7738. this._lastFrameTime = null;
  7739. this._lastInteractionTime = -Infinity;
  7740. this._cameraRotationSpeed = 0;
  7741. this._lastFrameRadius = 0;
  7742. }
  7743. Object.defineProperty(AutoRotationBehavior.prototype, "name", {
  7744. /**
  7745. * Gets the name of the behavior.
  7746. */
  7747. get: function () {
  7748. return "AutoRotation";
  7749. },
  7750. enumerable: true,
  7751. configurable: true
  7752. });
  7753. Object.defineProperty(AutoRotationBehavior.prototype, "zoomStopsAnimation", {
  7754. /**
  7755. * Gets the flag that indicates if user zooming should stop animation.
  7756. */
  7757. get: function () {
  7758. return this._zoomStopsAnimation;
  7759. },
  7760. /**
  7761. * Sets the flag that indicates if user zooming should stop animation.
  7762. */
  7763. set: function (flag) {
  7764. this._zoomStopsAnimation = flag;
  7765. },
  7766. enumerable: true,
  7767. configurable: true
  7768. });
  7769. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpeed", {
  7770. /**
  7771. * Gets the default speed at which the camera rotates around the model.
  7772. */
  7773. get: function () {
  7774. return this._idleRotationSpeed;
  7775. },
  7776. /**
  7777. * Sets the default speed at which the camera rotates around the model.
  7778. */
  7779. set: function (speed) {
  7780. this._idleRotationSpeed = speed;
  7781. },
  7782. enumerable: true,
  7783. configurable: true
  7784. });
  7785. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationWaitTime", {
  7786. /**
  7787. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  7788. */
  7789. get: function () {
  7790. return this._idleRotationWaitTime;
  7791. },
  7792. /**
  7793. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  7794. */
  7795. set: function (time) {
  7796. this._idleRotationWaitTime = time;
  7797. },
  7798. enumerable: true,
  7799. configurable: true
  7800. });
  7801. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpinupTime", {
  7802. /**
  7803. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7804. */
  7805. get: function () {
  7806. return this._idleRotationSpinupTime;
  7807. },
  7808. /**
  7809. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7810. */
  7811. set: function (time) {
  7812. this._idleRotationSpinupTime = time;
  7813. },
  7814. enumerable: true,
  7815. configurable: true
  7816. });
  7817. Object.defineProperty(AutoRotationBehavior.prototype, "rotationInProgress", {
  7818. /**
  7819. * Gets a value indicating if the camera is currently rotating because of this behavior
  7820. */
  7821. get: function () {
  7822. return Math.abs(this._cameraRotationSpeed) > 0;
  7823. },
  7824. enumerable: true,
  7825. configurable: true
  7826. });
  7827. /**
  7828. * Initializes the behavior.
  7829. */
  7830. AutoRotationBehavior.prototype.init = function () {
  7831. // Do notihng
  7832. };
  7833. /**
  7834. * Attaches the behavior to its arc rotate camera.
  7835. * @param camera Defines the camera to attach the behavior to
  7836. */
  7837. AutoRotationBehavior.prototype.attach = function (camera) {
  7838. var _this = this;
  7839. this._attachedCamera = camera;
  7840. var scene = this._attachedCamera.getScene();
  7841. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  7842. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  7843. _this._isPointerDown = true;
  7844. return;
  7845. }
  7846. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  7847. _this._isPointerDown = false;
  7848. }
  7849. });
  7850. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  7851. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7852. var dt = 0;
  7853. if (_this._lastFrameTime != null) {
  7854. dt = now - _this._lastFrameTime;
  7855. }
  7856. _this._lastFrameTime = now;
  7857. // Stop the animation if there is user interaction and the animation should stop for this interaction
  7858. _this._applyUserInteraction();
  7859. var timeToRotation = now - _this._lastInteractionTime - _this._idleRotationWaitTime;
  7860. var scale = Math.max(Math.min(timeToRotation / (_this._idleRotationSpinupTime), 1), 0);
  7861. _this._cameraRotationSpeed = _this._idleRotationSpeed * scale;
  7862. // Step camera rotation by rotation speed
  7863. if (_this._attachedCamera) {
  7864. _this._attachedCamera.alpha -= _this._cameraRotationSpeed * (dt / 1000);
  7865. }
  7866. });
  7867. };
  7868. /**
  7869. * Detaches the behavior from its current arc rotate camera.
  7870. */
  7871. AutoRotationBehavior.prototype.detach = function () {
  7872. if (!this._attachedCamera) {
  7873. return;
  7874. }
  7875. var scene = this._attachedCamera.getScene();
  7876. if (this._onPrePointerObservableObserver) {
  7877. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  7878. }
  7879. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  7880. this._attachedCamera = null;
  7881. };
  7882. /**
  7883. * Returns true if user is scrolling.
  7884. * @return true if user is scrolling.
  7885. */
  7886. AutoRotationBehavior.prototype._userIsZooming = function () {
  7887. if (!this._attachedCamera) {
  7888. return false;
  7889. }
  7890. return this._attachedCamera.inertialRadiusOffset !== 0;
  7891. };
  7892. AutoRotationBehavior.prototype._shouldAnimationStopForInteraction = function () {
  7893. if (!this._attachedCamera) {
  7894. return false;
  7895. }
  7896. var zoomHasHitLimit = false;
  7897. if (this._lastFrameRadius === this._attachedCamera.radius && this._attachedCamera.inertialRadiusOffset !== 0) {
  7898. zoomHasHitLimit = true;
  7899. }
  7900. // Update the record of previous radius - works as an approx. indicator of hitting radius limits
  7901. this._lastFrameRadius = this._attachedCamera.radius;
  7902. return this._zoomStopsAnimation ? zoomHasHitLimit : this._userIsZooming();
  7903. };
  7904. /**
  7905. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  7906. */
  7907. AutoRotationBehavior.prototype._applyUserInteraction = function () {
  7908. if (this._userIsMoving() && !this._shouldAnimationStopForInteraction()) {
  7909. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7910. }
  7911. };
  7912. // Tools
  7913. AutoRotationBehavior.prototype._userIsMoving = function () {
  7914. if (!this._attachedCamera) {
  7915. return false;
  7916. }
  7917. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  7918. this._attachedCamera.inertialBetaOffset !== 0 ||
  7919. this._attachedCamera.inertialRadiusOffset !== 0 ||
  7920. this._attachedCamera.inertialPanningX !== 0 ||
  7921. this._attachedCamera.inertialPanningY !== 0 ||
  7922. this._isPointerDown;
  7923. };
  7924. return AutoRotationBehavior;
  7925. }());
  7926. /***/ }),
  7927. /***/ "./Behaviors/Cameras/bouncingBehavior.ts":
  7928. /*!***********************************************!*\
  7929. !*** ./Behaviors/Cameras/bouncingBehavior.ts ***!
  7930. \***********************************************/
  7931. /*! exports provided: BouncingBehavior */
  7932. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7933. "use strict";
  7934. __webpack_require__.r(__webpack_exports__);
  7935. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return BouncingBehavior; });
  7936. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  7937. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  7938. /**
  7939. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  7940. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7941. */
  7942. var BouncingBehavior = /** @class */ (function () {
  7943. function BouncingBehavior() {
  7944. /**
  7945. * The duration of the animation, in milliseconds
  7946. */
  7947. this.transitionDuration = 450;
  7948. /**
  7949. * Length of the distance animated by the transition when lower radius is reached
  7950. */
  7951. this.lowerRadiusTransitionRange = 2;
  7952. /**
  7953. * Length of the distance animated by the transition when upper radius is reached
  7954. */
  7955. this.upperRadiusTransitionRange = -2;
  7956. this._autoTransitionRange = false;
  7957. // Animations
  7958. this._radiusIsAnimating = false;
  7959. this._radiusBounceTransition = null;
  7960. this._animatables = new Array();
  7961. }
  7962. Object.defineProperty(BouncingBehavior.prototype, "name", {
  7963. /**
  7964. * Gets the name of the behavior.
  7965. */
  7966. get: function () {
  7967. return "Bouncing";
  7968. },
  7969. enumerable: true,
  7970. configurable: true
  7971. });
  7972. Object.defineProperty(BouncingBehavior.prototype, "autoTransitionRange", {
  7973. /**
  7974. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7975. */
  7976. get: function () {
  7977. return this._autoTransitionRange;
  7978. },
  7979. /**
  7980. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7981. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  7982. */
  7983. set: function (value) {
  7984. var _this = this;
  7985. if (this._autoTransitionRange === value) {
  7986. return;
  7987. }
  7988. this._autoTransitionRange = value;
  7989. var camera = this._attachedCamera;
  7990. if (!camera) {
  7991. return;
  7992. }
  7993. if (value) {
  7994. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  7995. if (!mesh) {
  7996. return;
  7997. }
  7998. mesh.computeWorldMatrix(true);
  7999. var diagonal = mesh.getBoundingInfo().diagonalLength;
  8000. _this.lowerRadiusTransitionRange = diagonal * 0.05;
  8001. _this.upperRadiusTransitionRange = diagonal * 0.05;
  8002. });
  8003. }
  8004. else if (this._onMeshTargetChangedObserver) {
  8005. camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8006. }
  8007. },
  8008. enumerable: true,
  8009. configurable: true
  8010. });
  8011. /**
  8012. * Initializes the behavior.
  8013. */
  8014. BouncingBehavior.prototype.init = function () {
  8015. // Do notihng
  8016. };
  8017. /**
  8018. * Attaches the behavior to its arc rotate camera.
  8019. * @param camera Defines the camera to attach the behavior to
  8020. */
  8021. BouncingBehavior.prototype.attach = function (camera) {
  8022. var _this = this;
  8023. this._attachedCamera = camera;
  8024. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8025. if (!_this._attachedCamera) {
  8026. return;
  8027. }
  8028. // Add the bounce animation to the lower radius limit
  8029. if (_this._isRadiusAtLimit(_this._attachedCamera.lowerRadiusLimit)) {
  8030. _this._applyBoundRadiusAnimation(_this.lowerRadiusTransitionRange);
  8031. }
  8032. // Add the bounce animation to the upper radius limit
  8033. if (_this._isRadiusAtLimit(_this._attachedCamera.upperRadiusLimit)) {
  8034. _this._applyBoundRadiusAnimation(_this.upperRadiusTransitionRange);
  8035. }
  8036. });
  8037. };
  8038. /**
  8039. * Detaches the behavior from its current arc rotate camera.
  8040. */
  8041. BouncingBehavior.prototype.detach = function () {
  8042. if (!this._attachedCamera) {
  8043. return;
  8044. }
  8045. if (this._onAfterCheckInputsObserver) {
  8046. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8047. }
  8048. if (this._onMeshTargetChangedObserver) {
  8049. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8050. }
  8051. this._attachedCamera = null;
  8052. };
  8053. /**
  8054. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  8055. * @param radiusLimit The limit to check against.
  8056. * @return Bool to indicate if at limit.
  8057. */
  8058. BouncingBehavior.prototype._isRadiusAtLimit = function (radiusLimit) {
  8059. if (!this._attachedCamera) {
  8060. return false;
  8061. }
  8062. if (this._attachedCamera.radius === radiusLimit && !this._radiusIsAnimating) {
  8063. return true;
  8064. }
  8065. return false;
  8066. };
  8067. /**
  8068. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  8069. * @param radiusDelta The delta by which to animate to. Can be negative.
  8070. */
  8071. BouncingBehavior.prototype._applyBoundRadiusAnimation = function (radiusDelta) {
  8072. var _this = this;
  8073. if (!this._attachedCamera) {
  8074. return;
  8075. }
  8076. if (!this._radiusBounceTransition) {
  8077. BouncingBehavior.EasingFunction.setEasingMode(BouncingBehavior.EasingMode);
  8078. this._radiusBounceTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT, 60, BouncingBehavior.EasingFunction);
  8079. }
  8080. // Prevent zoom until bounce has completed
  8081. this._cachedWheelPrecision = this._attachedCamera.wheelPrecision;
  8082. this._attachedCamera.wheelPrecision = Infinity;
  8083. this._attachedCamera.inertialRadiusOffset = 0;
  8084. // Animate to the radius limit
  8085. this.stopAllAnimations();
  8086. this._radiusIsAnimating = true;
  8087. 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(); });
  8088. if (animatable) {
  8089. this._animatables.push(animatable);
  8090. }
  8091. };
  8092. /**
  8093. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  8094. */
  8095. BouncingBehavior.prototype._clearAnimationLocks = function () {
  8096. this._radiusIsAnimating = false;
  8097. if (this._attachedCamera) {
  8098. this._attachedCamera.wheelPrecision = this._cachedWheelPrecision;
  8099. }
  8100. };
  8101. /**
  8102. * Stops and removes all animations that have been applied to the camera
  8103. */
  8104. BouncingBehavior.prototype.stopAllAnimations = function () {
  8105. if (this._attachedCamera) {
  8106. this._attachedCamera.animations = [];
  8107. }
  8108. while (this._animatables.length) {
  8109. this._animatables[0].onAnimationEnd = null;
  8110. this._animatables[0].stop();
  8111. this._animatables.shift();
  8112. }
  8113. };
  8114. /**
  8115. * The easing function used by animations
  8116. */
  8117. BouncingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["BackEase"](0.3);
  8118. /**
  8119. * The easing mode used by animations
  8120. */
  8121. BouncingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEOUT;
  8122. return BouncingBehavior;
  8123. }());
  8124. /***/ }),
  8125. /***/ "./Behaviors/Cameras/framingBehavior.ts":
  8126. /*!**********************************************!*\
  8127. !*** ./Behaviors/Cameras/framingBehavior.ts ***!
  8128. \**********************************************/
  8129. /*! exports provided: FramingBehavior */
  8130. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8131. "use strict";
  8132. __webpack_require__.r(__webpack_exports__);
  8133. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return FramingBehavior; });
  8134. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  8135. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  8136. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  8137. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  8138. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8139. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  8140. /**
  8141. * 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.
  8142. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  8143. */
  8144. var FramingBehavior = /** @class */ (function () {
  8145. function FramingBehavior() {
  8146. this._mode = FramingBehavior.FitFrustumSidesMode;
  8147. this._radiusScale = 1.0;
  8148. this._positionScale = 0.5;
  8149. this._defaultElevation = 0.3;
  8150. this._elevationReturnTime = 1500;
  8151. this._elevationReturnWaitTime = 1000;
  8152. this._zoomStopsAnimation = false;
  8153. this._framingTime = 1500;
  8154. /**
  8155. * Define if the behavior should automatically change the configured
  8156. * camera limits and sensibilities.
  8157. */
  8158. this.autoCorrectCameraLimitsAndSensibility = true;
  8159. this._isPointerDown = false;
  8160. this._lastInteractionTime = -Infinity;
  8161. // Framing control
  8162. this._animatables = new Array();
  8163. this._betaIsAnimating = false;
  8164. }
  8165. Object.defineProperty(FramingBehavior.prototype, "name", {
  8166. /**
  8167. * Gets the name of the behavior.
  8168. */
  8169. get: function () {
  8170. return "Framing";
  8171. },
  8172. enumerable: true,
  8173. configurable: true
  8174. });
  8175. Object.defineProperty(FramingBehavior.prototype, "mode", {
  8176. /**
  8177. * Gets current mode used by the behavior.
  8178. */
  8179. get: function () {
  8180. return this._mode;
  8181. },
  8182. /**
  8183. * Sets the current mode used by the behavior
  8184. */
  8185. set: function (mode) {
  8186. this._mode = mode;
  8187. },
  8188. enumerable: true,
  8189. configurable: true
  8190. });
  8191. Object.defineProperty(FramingBehavior.prototype, "radiusScale", {
  8192. /**
  8193. * Gets the scale applied to the radius
  8194. */
  8195. get: function () {
  8196. return this._radiusScale;
  8197. },
  8198. /**
  8199. * Sets the scale applied to the radius (1 by default)
  8200. */
  8201. set: function (radius) {
  8202. this._radiusScale = radius;
  8203. },
  8204. enumerable: true,
  8205. configurable: true
  8206. });
  8207. Object.defineProperty(FramingBehavior.prototype, "positionScale", {
  8208. /**
  8209. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8210. */
  8211. get: function () {
  8212. return this._positionScale;
  8213. },
  8214. /**
  8215. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8216. */
  8217. set: function (scale) {
  8218. this._positionScale = scale;
  8219. },
  8220. enumerable: true,
  8221. configurable: true
  8222. });
  8223. Object.defineProperty(FramingBehavior.prototype, "defaultElevation", {
  8224. /**
  8225. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8226. * behaviour is triggered, in radians.
  8227. */
  8228. get: function () {
  8229. return this._defaultElevation;
  8230. },
  8231. /**
  8232. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8233. * behaviour is triggered, in radians.
  8234. */
  8235. set: function (elevation) {
  8236. this._defaultElevation = elevation;
  8237. },
  8238. enumerable: true,
  8239. configurable: true
  8240. });
  8241. Object.defineProperty(FramingBehavior.prototype, "elevationReturnTime", {
  8242. /**
  8243. * Gets the time (in milliseconds) taken to return to the default beta position.
  8244. * Negative value indicates camera should not return to default.
  8245. */
  8246. get: function () {
  8247. return this._elevationReturnTime;
  8248. },
  8249. /**
  8250. * Sets the time (in milliseconds) taken to return to the default beta position.
  8251. * Negative value indicates camera should not return to default.
  8252. */
  8253. set: function (speed) {
  8254. this._elevationReturnTime = speed;
  8255. },
  8256. enumerable: true,
  8257. configurable: true
  8258. });
  8259. Object.defineProperty(FramingBehavior.prototype, "elevationReturnWaitTime", {
  8260. /**
  8261. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8262. */
  8263. get: function () {
  8264. return this._elevationReturnWaitTime;
  8265. },
  8266. /**
  8267. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8268. */
  8269. set: function (time) {
  8270. this._elevationReturnWaitTime = time;
  8271. },
  8272. enumerable: true,
  8273. configurable: true
  8274. });
  8275. Object.defineProperty(FramingBehavior.prototype, "zoomStopsAnimation", {
  8276. /**
  8277. * Gets the flag that indicates if user zooming should stop animation.
  8278. */
  8279. get: function () {
  8280. return this._zoomStopsAnimation;
  8281. },
  8282. /**
  8283. * Sets the flag that indicates if user zooming should stop animation.
  8284. */
  8285. set: function (flag) {
  8286. this._zoomStopsAnimation = flag;
  8287. },
  8288. enumerable: true,
  8289. configurable: true
  8290. });
  8291. Object.defineProperty(FramingBehavior.prototype, "framingTime", {
  8292. /**
  8293. * Gets the transition time when framing the mesh, in milliseconds
  8294. */
  8295. get: function () {
  8296. return this._framingTime;
  8297. },
  8298. /**
  8299. * Sets the transition time when framing the mesh, in milliseconds
  8300. */
  8301. set: function (time) {
  8302. this._framingTime = time;
  8303. },
  8304. enumerable: true,
  8305. configurable: true
  8306. });
  8307. /**
  8308. * Initializes the behavior.
  8309. */
  8310. FramingBehavior.prototype.init = function () {
  8311. // Do notihng
  8312. };
  8313. /**
  8314. * Attaches the behavior to its arc rotate camera.
  8315. * @param camera Defines the camera to attach the behavior to
  8316. */
  8317. FramingBehavior.prototype.attach = function (camera) {
  8318. var _this = this;
  8319. this._attachedCamera = camera;
  8320. var scene = this._attachedCamera.getScene();
  8321. FramingBehavior.EasingFunction.setEasingMode(FramingBehavior.EasingMode);
  8322. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  8323. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  8324. _this._isPointerDown = true;
  8325. return;
  8326. }
  8327. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  8328. _this._isPointerDown = false;
  8329. }
  8330. });
  8331. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  8332. if (mesh) {
  8333. _this.zoomOnMesh(mesh);
  8334. }
  8335. });
  8336. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8337. // Stop the animation if there is user interaction and the animation should stop for this interaction
  8338. _this._applyUserInteraction();
  8339. // Maintain the camera above the ground. If the user pulls the camera beneath the ground plane, lift it
  8340. // back to the default position after a given timeout
  8341. _this._maintainCameraAboveGround();
  8342. });
  8343. };
  8344. /**
  8345. * Detaches the behavior from its current arc rotate camera.
  8346. */
  8347. FramingBehavior.prototype.detach = function () {
  8348. if (!this._attachedCamera) {
  8349. return;
  8350. }
  8351. var scene = this._attachedCamera.getScene();
  8352. if (this._onPrePointerObservableObserver) {
  8353. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  8354. }
  8355. if (this._onAfterCheckInputsObserver) {
  8356. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8357. }
  8358. if (this._onMeshTargetChangedObserver) {
  8359. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8360. }
  8361. this._attachedCamera = null;
  8362. };
  8363. /**
  8364. * Targets the given mesh and updates zoom level accordingly.
  8365. * @param mesh The mesh to target.
  8366. * @param radius Optional. If a cached radius position already exists, overrides default.
  8367. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8368. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8369. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8370. */
  8371. FramingBehavior.prototype.zoomOnMesh = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8372. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8373. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8374. mesh.computeWorldMatrix(true);
  8375. var boundingBox = mesh.getBoundingInfo().boundingBox;
  8376. this.zoomOnBoundingInfo(boundingBox.minimumWorld, boundingBox.maximumWorld, focusOnOriginXZ, onAnimationEnd);
  8377. };
  8378. /**
  8379. * Targets the given mesh with its children and updates zoom level accordingly.
  8380. * @param mesh The mesh to target.
  8381. * @param radius Optional. If a cached radius position already exists, overrides default.
  8382. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8383. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8384. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8385. */
  8386. FramingBehavior.prototype.zoomOnMeshHierarchy = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8387. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8388. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8389. mesh.computeWorldMatrix(true);
  8390. var boundingBox = mesh.getHierarchyBoundingVectors(true);
  8391. this.zoomOnBoundingInfo(boundingBox.min, boundingBox.max, focusOnOriginXZ, onAnimationEnd);
  8392. };
  8393. /**
  8394. * Targets the given meshes with their children and updates zoom level accordingly.
  8395. * @param meshes The mesh to target.
  8396. * @param radius Optional. If a cached radius position already exists, overrides default.
  8397. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8398. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8399. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8400. */
  8401. FramingBehavior.prototype.zoomOnMeshesHierarchy = function (meshes, focusOnOriginXZ, onAnimationEnd) {
  8402. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8403. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8404. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  8405. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  8406. for (var i = 0; i < meshes.length; i++) {
  8407. var boundingInfo = meshes[i].getHierarchyBoundingVectors(true);
  8408. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.min, min, max);
  8409. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.max, min, max);
  8410. }
  8411. this.zoomOnBoundingInfo(min, max, focusOnOriginXZ, onAnimationEnd);
  8412. };
  8413. /**
  8414. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  8415. * @param minimumWorld Determines the smaller position of the bounding box extend
  8416. * @param maximumWorld Determines the bigger position of the bounding box extend
  8417. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8418. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8419. */
  8420. FramingBehavior.prototype.zoomOnBoundingInfo = function (minimumWorld, maximumWorld, focusOnOriginXZ, onAnimationEnd) {
  8421. var _this = this;
  8422. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8423. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8424. var zoomTarget;
  8425. if (!this._attachedCamera) {
  8426. return;
  8427. }
  8428. // Find target by interpolating from bottom of bounding box in world-space to top via framingPositionY
  8429. var bottom = minimumWorld.y;
  8430. var top = maximumWorld.y;
  8431. var zoomTargetY = bottom + (top - bottom) * this._positionScale;
  8432. var radiusWorld = maximumWorld.subtract(minimumWorld).scale(0.5);
  8433. if (focusOnOriginXZ) {
  8434. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, zoomTargetY, 0);
  8435. }
  8436. else {
  8437. var centerWorld = minimumWorld.add(radiusWorld);
  8438. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](centerWorld.x, zoomTargetY, centerWorld.z);
  8439. }
  8440. if (!this._vectorTransition) {
  8441. this._vectorTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("target", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
  8442. }
  8443. this._betaIsAnimating = true;
  8444. var animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
  8445. if (animatable) {
  8446. this._animatables.push(animatable);
  8447. }
  8448. // sets the radius and lower radius bounds
  8449. // Small delta ensures camera is not always at lower zoom limit.
  8450. var radius = 0;
  8451. if (this._mode === FramingBehavior.FitFrustumSidesMode) {
  8452. var position = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8453. if (this.autoCorrectCameraLimitsAndSensibility) {
  8454. this._attachedCamera.lowerRadiusLimit = radiusWorld.length() + this._attachedCamera.minZ;
  8455. }
  8456. radius = position;
  8457. }
  8458. else if (this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8459. radius = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8460. if (this.autoCorrectCameraLimitsAndSensibility && this._attachedCamera.lowerRadiusLimit === null) {
  8461. this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ;
  8462. }
  8463. }
  8464. // Set sensibilities
  8465. if (this.autoCorrectCameraLimitsAndSensibility) {
  8466. var extend = maximumWorld.subtract(minimumWorld).length();
  8467. this._attachedCamera.panningSensibility = 5000 / extend;
  8468. this._attachedCamera.wheelPrecision = 100 / radius;
  8469. }
  8470. // transition to new radius
  8471. if (!this._radiusTransition) {
  8472. this._radiusTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8473. }
  8474. animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function () {
  8475. _this.stopAllAnimations();
  8476. if (onAnimationEnd) {
  8477. onAnimationEnd();
  8478. }
  8479. if (_this._attachedCamera && _this._attachedCamera.useInputToRestoreState) {
  8480. _this._attachedCamera.storeState();
  8481. }
  8482. });
  8483. if (animatable) {
  8484. this._animatables.push(animatable);
  8485. }
  8486. };
  8487. /**
  8488. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  8489. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  8490. * frustum width.
  8491. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  8492. * to fully enclose the mesh in the viewing frustum.
  8493. */
  8494. FramingBehavior.prototype._calculateLowerRadiusFromModelBoundingSphere = function (minimumWorld, maximumWorld) {
  8495. var size = maximumWorld.subtract(minimumWorld);
  8496. var boxVectorGlobalDiagonal = size.length();
  8497. var frustumSlope = this._getFrustumSlope();
  8498. // Formula for setting distance
  8499. // (Good explanation: http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene)
  8500. var radiusWithoutFraming = boxVectorGlobalDiagonal * 0.5;
  8501. // Horizon distance
  8502. var radius = radiusWithoutFraming * this._radiusScale;
  8503. var distanceForHorizontalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.x * frustumSlope.x));
  8504. var distanceForVerticalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.y * frustumSlope.y));
  8505. var distance = Math.max(distanceForHorizontalFrustum, distanceForVerticalFrustum);
  8506. var camera = this._attachedCamera;
  8507. if (!camera) {
  8508. return 0;
  8509. }
  8510. if (camera.lowerRadiusLimit && this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8511. // Don't exceed the requested limit
  8512. distance = distance < camera.lowerRadiusLimit ? camera.lowerRadiusLimit : distance;
  8513. }
  8514. // Don't exceed the upper radius limit
  8515. if (camera.upperRadiusLimit) {
  8516. distance = distance > camera.upperRadiusLimit ? camera.upperRadiusLimit : distance;
  8517. }
  8518. return distance;
  8519. };
  8520. /**
  8521. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  8522. * is automatically returned to its default position (expected to be above ground plane).
  8523. */
  8524. FramingBehavior.prototype._maintainCameraAboveGround = function () {
  8525. var _this = this;
  8526. if (this._elevationReturnTime < 0) {
  8527. return;
  8528. }
  8529. var timeSinceInteraction = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now - this._lastInteractionTime;
  8530. var defaultBeta = Math.PI * 0.5 - this._defaultElevation;
  8531. var limitBeta = Math.PI * 0.5;
  8532. // Bring the camera back up if below the ground plane
  8533. if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > limitBeta && timeSinceInteraction >= this._elevationReturnWaitTime) {
  8534. this._betaIsAnimating = true;
  8535. //Transition to new position
  8536. this.stopAllAnimations();
  8537. if (!this._betaTransition) {
  8538. this._betaTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("beta", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8539. }
  8540. var animatabe = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("beta", defaultBeta, this._attachedCamera, this._attachedCamera.getScene(), 60, this._betaTransition, this._elevationReturnTime, function () {
  8541. _this._clearAnimationLocks();
  8542. _this.stopAllAnimations();
  8543. });
  8544. if (animatabe) {
  8545. this._animatables.push(animatabe);
  8546. }
  8547. }
  8548. };
  8549. /**
  8550. * Returns the frustum slope based on the canvas ratio and camera FOV
  8551. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  8552. */
  8553. FramingBehavior.prototype._getFrustumSlope = function () {
  8554. // Calculate the viewport ratio
  8555. // Aspect Ratio is Height/Width.
  8556. var camera = this._attachedCamera;
  8557. if (!camera) {
  8558. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"].Zero();
  8559. }
  8560. var engine = camera.getScene().getEngine();
  8561. var aspectRatio = engine.getAspectRatio(camera);
  8562. // Camera FOV is the vertical field of view (top-bottom) in radians.
  8563. // Slope of the frustum top/bottom planes in view space, relative to the forward vector.
  8564. var frustumSlopeY = Math.tan(camera.fov / 2);
  8565. // Slope of the frustum left/right planes in view space, relative to the forward vector.
  8566. // Provides the amount that one side (e.g. left) of the frustum gets wider for every unit
  8567. // along the forward vector.
  8568. var frustumSlopeX = frustumSlopeY * aspectRatio;
  8569. return new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"](frustumSlopeX, frustumSlopeY);
  8570. };
  8571. /**
  8572. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  8573. */
  8574. FramingBehavior.prototype._clearAnimationLocks = function () {
  8575. this._betaIsAnimating = false;
  8576. };
  8577. /**
  8578. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  8579. */
  8580. FramingBehavior.prototype._applyUserInteraction = function () {
  8581. if (this.isUserIsMoving) {
  8582. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now;
  8583. this.stopAllAnimations();
  8584. this._clearAnimationLocks();
  8585. }
  8586. };
  8587. /**
  8588. * Stops and removes all animations that have been applied to the camera
  8589. */
  8590. FramingBehavior.prototype.stopAllAnimations = function () {
  8591. if (this._attachedCamera) {
  8592. this._attachedCamera.animations = [];
  8593. }
  8594. while (this._animatables.length) {
  8595. if (this._animatables[0]) {
  8596. this._animatables[0].onAnimationEnd = null;
  8597. this._animatables[0].stop();
  8598. }
  8599. this._animatables.shift();
  8600. }
  8601. };
  8602. Object.defineProperty(FramingBehavior.prototype, "isUserIsMoving", {
  8603. /**
  8604. * Gets a value indicating if the user is moving the camera
  8605. */
  8606. get: function () {
  8607. if (!this._attachedCamera) {
  8608. return false;
  8609. }
  8610. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  8611. this._attachedCamera.inertialBetaOffset !== 0 ||
  8612. this._attachedCamera.inertialRadiusOffset !== 0 ||
  8613. this._attachedCamera.inertialPanningX !== 0 ||
  8614. this._attachedCamera.inertialPanningY !== 0 ||
  8615. this._isPointerDown;
  8616. },
  8617. enumerable: true,
  8618. configurable: true
  8619. });
  8620. /**
  8621. * The easing function used by animations
  8622. */
  8623. FramingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]();
  8624. /**
  8625. * The easing mode used by animations
  8626. */
  8627. FramingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEINOUT;
  8628. // Statics
  8629. /**
  8630. * The camera can move all the way towards the mesh.
  8631. */
  8632. FramingBehavior.IgnoreBoundsSizeMode = 0;
  8633. /**
  8634. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  8635. */
  8636. FramingBehavior.FitFrustumSidesMode = 1;
  8637. return FramingBehavior;
  8638. }());
  8639. /***/ }),
  8640. /***/ "./Behaviors/Cameras/index.ts":
  8641. /*!************************************!*\
  8642. !*** ./Behaviors/Cameras/index.ts ***!
  8643. \************************************/
  8644. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior */
  8645. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8646. "use strict";
  8647. __webpack_require__.r(__webpack_exports__);
  8648. /* harmony import */ var _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  8649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  8650. /* harmony import */ var _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  8651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__["BouncingBehavior"]; });
  8652. /* harmony import */ var _framingBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  8653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _framingBehavior__WEBPACK_IMPORTED_MODULE_2__["FramingBehavior"]; });
  8654. /***/ }),
  8655. /***/ "./Behaviors/Meshes/attachToBoxBehavior.ts":
  8656. /*!*************************************************!*\
  8657. !*** ./Behaviors/Meshes/attachToBoxBehavior.ts ***!
  8658. \*************************************************/
  8659. /*! exports provided: AttachToBoxBehavior */
  8660. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8661. "use strict";
  8662. __webpack_require__.r(__webpack_exports__);
  8663. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return AttachToBoxBehavior; });
  8664. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8665. /**
  8666. * @hidden
  8667. */
  8668. var FaceDirectionInfo = /** @class */ (function () {
  8669. function FaceDirectionInfo(direction, rotatedDirection, diff, ignore) {
  8670. if (rotatedDirection === void 0) { rotatedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](); }
  8671. if (diff === void 0) { diff = 0; }
  8672. if (ignore === void 0) { ignore = false; }
  8673. this.direction = direction;
  8674. this.rotatedDirection = rotatedDirection;
  8675. this.diff = diff;
  8676. this.ignore = ignore;
  8677. }
  8678. return FaceDirectionInfo;
  8679. }());
  8680. /**
  8681. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  8682. */
  8683. var AttachToBoxBehavior = /** @class */ (function () {
  8684. /**
  8685. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  8686. * @param ui The transform node that should be attched to the mesh
  8687. */
  8688. function AttachToBoxBehavior(ui) {
  8689. this.ui = ui;
  8690. /**
  8691. * The name of the behavior
  8692. */
  8693. this.name = "AttachToBoxBehavior";
  8694. /**
  8695. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  8696. */
  8697. this.distanceAwayFromFace = 0.15;
  8698. /**
  8699. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  8700. */
  8701. this.distanceAwayFromBottomOfFace = 0.15;
  8702. 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))];
  8703. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8704. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  8705. this._zeroVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  8706. this._lookAtTmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8707. /* Does nothing */
  8708. }
  8709. /**
  8710. * Initializes the behavior
  8711. */
  8712. AttachToBoxBehavior.prototype.init = function () {
  8713. /* Does nothing */
  8714. };
  8715. AttachToBoxBehavior.prototype._closestFace = function (targetDirection) {
  8716. var _this = this;
  8717. // Go over each face and calculate the angle between the face's normal and targetDirection
  8718. this._faceVectors.forEach(function (v) {
  8719. if (!_this._target.rotationQuaternion) {
  8720. _this._target.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this._target.rotation.y, _this._target.rotation.x, _this._target.rotation.z);
  8721. }
  8722. _this._target.rotationQuaternion.toRotationMatrix(_this._tmpMatrix);
  8723. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(v.direction, _this._tmpMatrix, v.rotatedDirection);
  8724. v.diff = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetAngleBetweenVectors(v.rotatedDirection, targetDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v.rotatedDirection, targetDirection));
  8725. });
  8726. // Return the face information of the one with the normal closeset to target direction
  8727. return this._faceVectors.reduce(function (min, p) {
  8728. if (min.ignore) {
  8729. return p;
  8730. }
  8731. else if (p.ignore) {
  8732. return min;
  8733. }
  8734. else {
  8735. return min.diff < p.diff ? min : p;
  8736. }
  8737. }, this._faceVectors[0]);
  8738. };
  8739. AttachToBoxBehavior.prototype._lookAtToRef = function (pos, up, ref) {
  8740. if (up === void 0) { up = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0); }
  8741. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LookAtLHToRef(this._zeroVector, pos, up, this._lookAtTmpMatrix);
  8742. this._lookAtTmpMatrix.invert();
  8743. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._lookAtTmpMatrix, ref);
  8744. };
  8745. /**
  8746. * Attaches the AttachToBoxBehavior to the passed in mesh
  8747. * @param target The mesh that the specified node will be attached to
  8748. */
  8749. AttachToBoxBehavior.prototype.attach = function (target) {
  8750. var _this = this;
  8751. this._target = target;
  8752. this._scene = this._target.getScene();
  8753. // Every frame, update the app bars position
  8754. this._onRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  8755. if (!_this._scene.activeCamera) {
  8756. return;
  8757. }
  8758. // Find the face closest to the cameras position
  8759. var cameraPos = _this._scene.activeCamera.position;
  8760. if (_this._scene.activeCamera.devicePosition) {
  8761. cameraPos = _this._scene.activeCamera.devicePosition;
  8762. }
  8763. var facing = _this._closestFace(cameraPos.subtract(target.position));
  8764. if (_this._scene.activeCamera.leftCamera) {
  8765. _this._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8766. }
  8767. else {
  8768. _this._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8769. }
  8770. // Get camera up direction
  8771. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), _this._tmpMatrix, _this._tmpVector);
  8772. // Ignore faces to not select a parrelel face for the up vector of the UI
  8773. _this._faceVectors.forEach(function (v) {
  8774. if (facing.direction.x && v.direction.x) {
  8775. v.ignore = true;
  8776. }
  8777. if (facing.direction.y && v.direction.y) {
  8778. v.ignore = true;
  8779. }
  8780. if (facing.direction.z && v.direction.z) {
  8781. v.ignore = true;
  8782. }
  8783. });
  8784. var facingUp = _this._closestFace(_this._tmpVector);
  8785. // Unignore faces
  8786. _this._faceVectors.forEach(function (v) {
  8787. v.ignore = false;
  8788. });
  8789. // Position the app bar on that face
  8790. _this.ui.position.copyFrom(target.position);
  8791. if (facing.direction.x) {
  8792. facing.rotatedDirection.scaleToRef((target.scaling.x / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8793. _this.ui.position.addInPlace(_this._tmpVector);
  8794. }
  8795. if (facing.direction.y) {
  8796. facing.rotatedDirection.scaleToRef((target.scaling.y / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8797. _this.ui.position.addInPlace(_this._tmpVector);
  8798. }
  8799. if (facing.direction.z) {
  8800. facing.rotatedDirection.scaleToRef((target.scaling.z / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8801. _this.ui.position.addInPlace(_this._tmpVector);
  8802. }
  8803. // Rotate to be oriented properly to the camera
  8804. if (!_this.ui.rotationQuaternion) {
  8805. _this.ui.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this.ui.rotation.y, _this.ui.rotation.x, _this.ui.rotation.z);
  8806. }
  8807. facing.rotatedDirection.scaleToRef(-1, _this._tmpVector);
  8808. _this._lookAtToRef(_this._tmpVector, facingUp.rotatedDirection, _this.ui.rotationQuaternion);
  8809. // Place ui the correct distance from the bottom of the mesh
  8810. if (facingUp.direction.x) {
  8811. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.x / 2, _this._tmpVector);
  8812. }
  8813. if (facingUp.direction.y) {
  8814. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.y / 2, _this._tmpVector);
  8815. }
  8816. if (facingUp.direction.z) {
  8817. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.z / 2, _this._tmpVector);
  8818. }
  8819. _this.ui.position.addInPlace(_this._tmpVector);
  8820. });
  8821. };
  8822. /**
  8823. * Detaches the behavior from the mesh
  8824. */
  8825. AttachToBoxBehavior.prototype.detach = function () {
  8826. this._scene.onBeforeRenderObservable.remove(this._onRenderObserver);
  8827. };
  8828. return AttachToBoxBehavior;
  8829. }());
  8830. /***/ }),
  8831. /***/ "./Behaviors/Meshes/fadeInOutBehavior.ts":
  8832. /*!***********************************************!*\
  8833. !*** ./Behaviors/Meshes/fadeInOutBehavior.ts ***!
  8834. \***********************************************/
  8835. /*! exports provided: FadeInOutBehavior */
  8836. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8837. "use strict";
  8838. __webpack_require__.r(__webpack_exports__);
  8839. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return FadeInOutBehavior; });
  8840. /**
  8841. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  8842. */
  8843. var FadeInOutBehavior = /** @class */ (function () {
  8844. /**
  8845. * Instatiates the FadeInOutBehavior
  8846. */
  8847. function FadeInOutBehavior() {
  8848. var _this = this;
  8849. /**
  8850. * Time in milliseconds to delay before fading in (Default: 0)
  8851. */
  8852. this.delay = 0;
  8853. /**
  8854. * Time in milliseconds for the mesh to fade in (Default: 300)
  8855. */
  8856. this.fadeInTime = 300;
  8857. this._millisecondsPerFrame = 1000 / 60;
  8858. this._hovered = false;
  8859. this._hoverValue = 0;
  8860. this._ownerNode = null;
  8861. this._update = function () {
  8862. if (_this._ownerNode) {
  8863. _this._hoverValue += _this._hovered ? _this._millisecondsPerFrame : -_this._millisecondsPerFrame;
  8864. _this._setAllVisibility(_this._ownerNode, (_this._hoverValue - _this.delay) / _this.fadeInTime);
  8865. if (_this._ownerNode.visibility > 1) {
  8866. _this._setAllVisibility(_this._ownerNode, 1);
  8867. _this._hoverValue = _this.fadeInTime + _this.delay;
  8868. return;
  8869. }
  8870. else if (_this._ownerNode.visibility < 0) {
  8871. _this._setAllVisibility(_this._ownerNode, 0);
  8872. if (_this._hoverValue < 0) {
  8873. _this._hoverValue = 0;
  8874. return;
  8875. }
  8876. }
  8877. setTimeout(_this._update, _this._millisecondsPerFrame);
  8878. }
  8879. };
  8880. }
  8881. Object.defineProperty(FadeInOutBehavior.prototype, "name", {
  8882. /**
  8883. * The name of the behavior
  8884. */
  8885. get: function () {
  8886. return "FadeInOut";
  8887. },
  8888. enumerable: true,
  8889. configurable: true
  8890. });
  8891. /**
  8892. * Initializes the behavior
  8893. */
  8894. FadeInOutBehavior.prototype.init = function () {
  8895. };
  8896. /**
  8897. * Attaches the fade behavior on the passed in mesh
  8898. * @param ownerNode The mesh that will be faded in/out once attached
  8899. */
  8900. FadeInOutBehavior.prototype.attach = function (ownerNode) {
  8901. this._ownerNode = ownerNode;
  8902. this._setAllVisibility(this._ownerNode, 0);
  8903. };
  8904. /**
  8905. * Detaches the behavior from the mesh
  8906. */
  8907. FadeInOutBehavior.prototype.detach = function () {
  8908. this._ownerNode = null;
  8909. };
  8910. /**
  8911. * Triggers the mesh to begin fading in or out
  8912. * @param value if the object should fade in or out (true to fade in)
  8913. */
  8914. FadeInOutBehavior.prototype.fadeIn = function (value) {
  8915. this._hovered = value;
  8916. this._update();
  8917. };
  8918. FadeInOutBehavior.prototype._setAllVisibility = function (mesh, value) {
  8919. var _this = this;
  8920. mesh.visibility = value;
  8921. mesh.getChildMeshes().forEach(function (c) {
  8922. _this._setAllVisibility(c, value);
  8923. });
  8924. };
  8925. return FadeInOutBehavior;
  8926. }());
  8927. /***/ }),
  8928. /***/ "./Behaviors/Meshes/index.ts":
  8929. /*!***********************************!*\
  8930. !*** ./Behaviors/Meshes/index.ts ***!
  8931. \***********************************/
  8932. /*! exports provided: AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  8933. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8934. "use strict";
  8935. __webpack_require__.r(__webpack_exports__);
  8936. /* harmony import */ var _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./attachToBoxBehavior */ "./Behaviors/Meshes/attachToBoxBehavior.ts");
  8937. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  8938. /* harmony import */ var _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fadeInOutBehavior */ "./Behaviors/Meshes/fadeInOutBehavior.ts");
  8939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  8940. /* harmony import */ var _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./multiPointerScaleBehavior */ "./Behaviors/Meshes/multiPointerScaleBehavior.ts");
  8941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__["MultiPointerScaleBehavior"]; });
  8942. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__["PointerDragBehavior"]; });
  8944. /* harmony import */ var _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  8945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__["SixDofDragBehavior"]; });
  8946. /***/ }),
  8947. /***/ "./Behaviors/Meshes/multiPointerScaleBehavior.ts":
  8948. /*!*******************************************************!*\
  8949. !*** ./Behaviors/Meshes/multiPointerScaleBehavior.ts ***!
  8950. \*******************************************************/
  8951. /*! exports provided: MultiPointerScaleBehavior */
  8952. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8953. "use strict";
  8954. __webpack_require__.r(__webpack_exports__);
  8955. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return MultiPointerScaleBehavior; });
  8956. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8957. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8958. /**
  8959. * A behavior that when attached to a mesh will allow the mesh to be scaled
  8960. */
  8961. var MultiPointerScaleBehavior = /** @class */ (function () {
  8962. /**
  8963. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  8964. */
  8965. function MultiPointerScaleBehavior() {
  8966. this._startDistance = 0;
  8967. this._initialScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8968. this._targetScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8969. this._sceneRenderObserver = null;
  8970. this._dragBehaviorA = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8971. this._dragBehaviorA.moveAttached = false;
  8972. this._dragBehaviorB = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8973. this._dragBehaviorB.moveAttached = false;
  8974. }
  8975. Object.defineProperty(MultiPointerScaleBehavior.prototype, "name", {
  8976. /**
  8977. * The name of the behavior
  8978. */
  8979. get: function () {
  8980. return "MultiPointerScale";
  8981. },
  8982. enumerable: true,
  8983. configurable: true
  8984. });
  8985. /**
  8986. * Initializes the behavior
  8987. */
  8988. MultiPointerScaleBehavior.prototype.init = function () { };
  8989. MultiPointerScaleBehavior.prototype._getCurrentDistance = function () {
  8990. return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length();
  8991. };
  8992. /**
  8993. * Attaches the scale behavior the passed in mesh
  8994. * @param ownerNode The mesh that will be scaled around once attached
  8995. */
  8996. MultiPointerScaleBehavior.prototype.attach = function (ownerNode) {
  8997. var _this = this;
  8998. this._ownerNode = ownerNode;
  8999. // Create 2 drag behaviors such that each will only be triggered by a separate pointer
  9000. this._dragBehaviorA.onDragStartObservable.add(function (e) {
  9001. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9002. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9003. _this._dragBehaviorA.releaseDrag();
  9004. }
  9005. else {
  9006. _this._initialScale.copyFrom(ownerNode.scaling);
  9007. _this._startDistance = _this._getCurrentDistance();
  9008. }
  9009. }
  9010. });
  9011. this._dragBehaviorB.onDragStartObservable.add(function (e) {
  9012. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9013. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9014. _this._dragBehaviorB.releaseDrag();
  9015. }
  9016. else {
  9017. _this._initialScale.copyFrom(ownerNode.scaling);
  9018. _this._startDistance = _this._getCurrentDistance();
  9019. }
  9020. }
  9021. });
  9022. // Once both drag behaviors are active scale based on the distance between the two pointers
  9023. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9024. behavior.onDragObservable.add(function () {
  9025. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9026. var ratio = _this._getCurrentDistance() / _this._startDistance;
  9027. _this._initialScale.scaleToRef(ratio, _this._targetScale);
  9028. }
  9029. });
  9030. });
  9031. ownerNode.addBehavior(this._dragBehaviorA);
  9032. ownerNode.addBehavior(this._dragBehaviorB);
  9033. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9034. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9035. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9036. var change = _this._targetScale.subtract(ownerNode.scaling).scaleInPlace(0.1);
  9037. if (change.length() > 0.01) {
  9038. ownerNode.scaling.addInPlace(change);
  9039. }
  9040. }
  9041. });
  9042. };
  9043. /**
  9044. * Detaches the behavior from the mesh
  9045. */
  9046. MultiPointerScaleBehavior.prototype.detach = function () {
  9047. var _this = this;
  9048. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9049. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9050. behavior.onDragStartObservable.clear();
  9051. behavior.onDragObservable.clear();
  9052. _this._ownerNode.removeBehavior(behavior);
  9053. });
  9054. };
  9055. return MultiPointerScaleBehavior;
  9056. }());
  9057. /***/ }),
  9058. /***/ "./Behaviors/Meshes/pointerDragBehavior.ts":
  9059. /*!*************************************************!*\
  9060. !*** ./Behaviors/Meshes/pointerDragBehavior.ts ***!
  9061. \*************************************************/
  9062. /*! exports provided: PointerDragBehavior */
  9063. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9064. "use strict";
  9065. __webpack_require__.r(__webpack_exports__);
  9066. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return PointerDragBehavior; });
  9067. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  9068. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9069. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9070. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9071. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9072. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  9073. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9074. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  9075. /**
  9076. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  9077. */
  9078. var PointerDragBehavior = /** @class */ (function () {
  9079. /**
  9080. * Creates a pointer drag behavior that can be attached to a mesh
  9081. * @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)
  9082. */
  9083. function PointerDragBehavior(options) {
  9084. this._useAlternatePickedPointAboveMaxDragAngleDragSpeed = -1.1;
  9085. /**
  9086. * 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)
  9087. */
  9088. this.maxDragAngle = 0;
  9089. /**
  9090. * @hidden
  9091. */
  9092. this._useAlternatePickedPointAboveMaxDragAngle = false;
  9093. /**
  9094. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9095. */
  9096. this.currentDraggingPointerID = -1;
  9097. /**
  9098. * If the behavior is currently in a dragging state
  9099. */
  9100. this.dragging = false;
  9101. /**
  9102. * 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)
  9103. */
  9104. this.dragDeltaRatio = 0.2;
  9105. /**
  9106. * If the drag plane orientation should be updated during the dragging (Default: true)
  9107. */
  9108. this.updateDragPlane = true;
  9109. // Debug mode will display drag planes to help visualize behavior
  9110. this._debugMode = false;
  9111. this._moving = false;
  9112. /**
  9113. * Fires each time the attached mesh is dragged with the pointer
  9114. * * delta between last drag position and current drag position in world space
  9115. * * dragDistance along the drag axis
  9116. * * dragPlaneNormal normal of the current drag plane used during the drag
  9117. * * dragPlanePoint in world space where the drag intersects the drag plane
  9118. */
  9119. this.onDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9120. /**
  9121. * Fires each time a drag begins (eg. mouse down on mesh)
  9122. */
  9123. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9124. /**
  9125. * Fires each time a drag ends (eg. mouse release after drag)
  9126. */
  9127. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9128. /**
  9129. * If the attached mesh should be moved when dragged
  9130. */
  9131. this.moveAttached = true;
  9132. /**
  9133. * If the drag behavior will react to drag events (Default: true)
  9134. */
  9135. this.enabled = true;
  9136. /**
  9137. * If camera controls should be detached during the drag
  9138. */
  9139. this.detachCameraControls = true;
  9140. /**
  9141. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  9142. */
  9143. this.useObjectOrienationForDragging = true;
  9144. /**
  9145. * Predicate to determine if it is valid to move the object to a new position when it is moved
  9146. */
  9147. this.validateDrag = function (targetPosition) { return true; };
  9148. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9149. this._alternatePickedPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9150. this._worldDragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9151. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9152. this._attachedElement = null;
  9153. 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"]());
  9154. this._lastPointerRay = {};
  9155. this._dragDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  9156. // Variables to avoid instantiation in the below method
  9157. this._pointA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9158. this._pointB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9159. this._pointC = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9160. this._lineA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9161. this._lineB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9162. this._localAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9163. this._lookAt = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9164. this._options = options ? options : {};
  9165. var optionCount = 0;
  9166. if (this._options.dragAxis) {
  9167. optionCount++;
  9168. }
  9169. if (this._options.dragPlaneNormal) {
  9170. optionCount++;
  9171. }
  9172. if (optionCount > 1) {
  9173. throw "Multiple drag modes specified in dragBehavior options. Only one expected";
  9174. }
  9175. }
  9176. Object.defineProperty(PointerDragBehavior.prototype, "name", {
  9177. /**
  9178. * The name of the behavior
  9179. */
  9180. get: function () {
  9181. return "PointerDrag";
  9182. },
  9183. enumerable: true,
  9184. configurable: true
  9185. });
  9186. /**
  9187. * Initializes the behavior
  9188. */
  9189. PointerDragBehavior.prototype.init = function () { };
  9190. /**
  9191. * Attaches the drag behavior the passed in mesh
  9192. * @param ownerNode The mesh that will be dragged around once attached
  9193. */
  9194. PointerDragBehavior.prototype.attach = function (ownerNode) {
  9195. var _this = this;
  9196. this._scene = ownerNode.getScene();
  9197. this._attachedNode = ownerNode;
  9198. // Initialize drag plane to not interfere with existing scene
  9199. if (!PointerDragBehavior._planeScene) {
  9200. if (this._debugMode) {
  9201. PointerDragBehavior._planeScene = this._scene;
  9202. }
  9203. else {
  9204. PointerDragBehavior._planeScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9205. PointerDragBehavior._planeScene.detachControl();
  9206. this._scene.getEngine().scenes.pop();
  9207. this._scene.onDisposeObservable.addOnce(function () {
  9208. PointerDragBehavior._planeScene.dispose();
  9209. PointerDragBehavior._planeScene = null;
  9210. });
  9211. }
  9212. }
  9213. 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);
  9214. // State of the drag
  9215. this.lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9216. var pickPredicate = function (m) {
  9217. return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
  9218. };
  9219. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9220. if (!_this.enabled) {
  9221. return;
  9222. }
  9223. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN) {
  9224. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.pickedPoint && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9225. _this._startDrag(pointerInfo.event.pointerId, pointerInfo.pickInfo.ray, pointerInfo.pickInfo.pickedPoint);
  9226. }
  9227. }
  9228. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP) {
  9229. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9230. _this.releaseDrag();
  9231. }
  9232. }
  9233. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  9234. var pointerId = pointerInfo.event.pointerId;
  9235. // If drag was started with anyMouseID specified, set pointerID to the next mouse that moved
  9236. if (_this.currentDraggingPointerID === PointerDragBehavior._AnyMouseID && pointerId !== PointerDragBehavior._AnyMouseID && pointerInfo.event.pointerType == "mouse") {
  9237. if (_this._lastPointerRay[_this.currentDraggingPointerID]) {
  9238. _this._lastPointerRay[pointerId] = _this._lastPointerRay[_this.currentDraggingPointerID];
  9239. delete _this._lastPointerRay[_this.currentDraggingPointerID];
  9240. }
  9241. _this.currentDraggingPointerID = pointerId;
  9242. }
  9243. // Keep track of last pointer ray, this is used simulating the start of a drag in startDrag()
  9244. if (!_this._lastPointerRay[pointerId]) {
  9245. _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"]());
  9246. }
  9247. if (pointerInfo.pickInfo && pointerInfo.pickInfo.ray) {
  9248. _this._lastPointerRay[pointerId].origin.copyFrom(pointerInfo.pickInfo.ray.origin);
  9249. _this._lastPointerRay[pointerId].direction.copyFrom(pointerInfo.pickInfo.ray.direction);
  9250. if (_this.currentDraggingPointerID == pointerId && _this.dragging) {
  9251. _this._moveDrag(pointerInfo.pickInfo.ray);
  9252. }
  9253. }
  9254. }
  9255. });
  9256. this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  9257. if (_this._moving && _this.moveAttached) {
  9258. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(_this._attachedNode);
  9259. // Slowly move mesh to avoid jitter
  9260. _this._targetPosition.subtractToRef((_this._attachedNode).absolutePosition, _this._tmpVector);
  9261. _this._tmpVector.scaleInPlace(_this.dragDeltaRatio);
  9262. (_this._attachedNode).getAbsolutePosition().addToRef(_this._tmpVector, _this._tmpVector);
  9263. if (_this.validateDrag(_this._tmpVector)) {
  9264. (_this._attachedNode).setAbsolutePosition(_this._tmpVector);
  9265. }
  9266. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(_this._attachedNode);
  9267. }
  9268. });
  9269. };
  9270. /**
  9271. * Force relase the drag action by code.
  9272. */
  9273. PointerDragBehavior.prototype.releaseDrag = function () {
  9274. this.dragging = false;
  9275. this.onDragEndObservable.notifyObservers({ dragPlanePoint: this.lastDragPosition, pointerId: this.currentDraggingPointerID });
  9276. this.currentDraggingPointerID = -1;
  9277. this._moving = false;
  9278. // Reattach camera controls
  9279. if (this.detachCameraControls && this._attachedElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9280. this._scene.activeCamera.attachControl(this._attachedElement, true);
  9281. }
  9282. };
  9283. /**
  9284. * Simulates the start of a pointer drag event on the behavior
  9285. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  9286. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  9287. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  9288. */
  9289. PointerDragBehavior.prototype.startDrag = function (pointerId, fromRay, startPickedPoint) {
  9290. if (pointerId === void 0) { pointerId = PointerDragBehavior._AnyMouseID; }
  9291. this._startDrag(pointerId, fromRay, startPickedPoint);
  9292. var lastRay = this._lastPointerRay[pointerId];
  9293. if (pointerId === PointerDragBehavior._AnyMouseID) {
  9294. lastRay = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]];
  9295. }
  9296. if (lastRay) {
  9297. // if there was a last pointer ray drag the object there
  9298. this._moveDrag(lastRay);
  9299. }
  9300. };
  9301. PointerDragBehavior.prototype._startDrag = function (pointerId, fromRay, startPickedPoint) {
  9302. if (!this._scene.activeCamera || this.dragging || !this._attachedNode) {
  9303. return;
  9304. }
  9305. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(this._attachedNode);
  9306. // Create start ray from the camera to the object
  9307. if (fromRay) {
  9308. this._startDragRay.direction.copyFrom(fromRay.direction);
  9309. this._startDragRay.origin.copyFrom(fromRay.origin);
  9310. }
  9311. else {
  9312. this._startDragRay.origin.copyFrom(this._scene.activeCamera.position);
  9313. this._attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector);
  9314. this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction);
  9315. }
  9316. this._updateDragPlanePosition(this._startDragRay, startPickedPoint ? startPickedPoint : this._tmpVector);
  9317. var pickedPoint = this._pickWithRayOnDragPlane(this._startDragRay);
  9318. if (pickedPoint) {
  9319. this.dragging = true;
  9320. this.currentDraggingPointerID = pointerId;
  9321. this.lastDragPosition.copyFrom(pickedPoint);
  9322. this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: this.currentDraggingPointerID });
  9323. this._targetPosition.copyFrom((this._attachedNode).absolutePosition);
  9324. // Detatch camera controls
  9325. if (this.detachCameraControls && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9326. if (this._scene.activeCamera.inputs.attachedElement) {
  9327. this._attachedElement = this._scene.activeCamera.inputs.attachedElement;
  9328. this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement);
  9329. }
  9330. else {
  9331. this._attachedElement = null;
  9332. }
  9333. }
  9334. }
  9335. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(this._attachedNode);
  9336. };
  9337. PointerDragBehavior.prototype._moveDrag = function (ray) {
  9338. this._moving = true;
  9339. var pickedPoint = this._pickWithRayOnDragPlane(ray);
  9340. if (pickedPoint) {
  9341. if (this.updateDragPlane) {
  9342. this._updateDragPlanePosition(ray, pickedPoint);
  9343. }
  9344. var dragLength = 0;
  9345. // depending on the drag mode option drag accordingly
  9346. if (this._options.dragAxis) {
  9347. // Convert local drag axis to world
  9348. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragAxis, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis);
  9349. // Project delta drag from the drag plane onto the drag axis
  9350. pickedPoint.subtractToRef(this.lastDragPosition, this._tmpVector);
  9351. dragLength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._tmpVector, this._worldDragAxis);
  9352. this._worldDragAxis.scaleToRef(dragLength, this._dragDelta);
  9353. }
  9354. else {
  9355. dragLength = this._dragDelta.length();
  9356. pickedPoint.subtractToRef(this.lastDragPosition, this._dragDelta);
  9357. }
  9358. this._targetPosition.addInPlace(this._dragDelta);
  9359. this.onDragObservable.notifyObservers({ dragDistance: dragLength, delta: this._dragDelta, dragPlanePoint: pickedPoint, dragPlaneNormal: this._dragPlane.forward, pointerId: this.currentDraggingPointerID });
  9360. this.lastDragPosition.copyFrom(pickedPoint);
  9361. }
  9362. };
  9363. PointerDragBehavior.prototype._pickWithRayOnDragPlane = function (ray) {
  9364. var _this = this;
  9365. if (!ray) {
  9366. return null;
  9367. }
  9368. // Calculate angle between plane normal and ray
  9369. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, ray.direction));
  9370. // Correct if ray is casted from oposite side
  9371. if (angle > Math.PI / 2) {
  9372. angle = Math.PI - angle;
  9373. }
  9374. // If the angle is too perpendicular to the plane pick another point on the plane where it is looking
  9375. if (this.maxDragAngle > 0 && angle > this.maxDragAngle) {
  9376. if (this._useAlternatePickedPointAboveMaxDragAngle) {
  9377. // Invert ray direction along the towards object axis
  9378. this._tmpVector.copyFrom(ray.direction);
  9379. (this._attachedNode).absolutePosition.subtractToRef(ray.origin, this._alternatePickedPoint);
  9380. this._alternatePickedPoint.normalize();
  9381. this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._alternatePickedPoint, this._tmpVector));
  9382. this._tmpVector.addInPlace(this._alternatePickedPoint);
  9383. // Project resulting vector onto the drag plane and add it to the attached nodes absolute position to get a picked point
  9384. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, this._tmpVector);
  9385. this._dragPlane.forward.scaleToRef(-dot, this._alternatePickedPoint);
  9386. this._alternatePickedPoint.addInPlace(this._tmpVector);
  9387. this._alternatePickedPoint.addInPlace((this._attachedNode).absolutePosition);
  9388. return this._alternatePickedPoint;
  9389. }
  9390. else {
  9391. return null;
  9392. }
  9393. }
  9394. var pickResult = PointerDragBehavior._planeScene.pickWithRay(ray, function (m) { return m == _this._dragPlane; });
  9395. if (pickResult && pickResult.hit && pickResult.pickedMesh && pickResult.pickedPoint) {
  9396. return pickResult.pickedPoint;
  9397. }
  9398. else {
  9399. return null;
  9400. }
  9401. };
  9402. // Position the drag plane based on the attached mesh position, for single axis rotate the plane along the axis to face the camera
  9403. PointerDragBehavior.prototype._updateDragPlanePosition = function (ray, dragPlanePosition) {
  9404. this._pointA.copyFrom(dragPlanePosition);
  9405. if (this._options.dragAxis) {
  9406. 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);
  9407. // Calculate plane normal in direction of camera but perpendicular to drag axis
  9408. this._pointA.addToRef(this._localAxis, this._pointB); // towards drag axis
  9409. ray.origin.subtractToRef(this._pointA, this._pointC);
  9410. this._pointA.addToRef(this._pointC.normalize(), this._pointC); // towards camera
  9411. // Get perpendicular line from direction to camera and drag axis
  9412. this._pointB.subtractToRef(this._pointA, this._lineA);
  9413. this._pointC.subtractToRef(this._pointA, this._lineB);
  9414. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lineB, this._lookAt);
  9415. // Get perpendicular line from previous result and drag axis to adjust lineB to be perpendiculat to camera
  9416. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lookAt, this._lookAt);
  9417. this._lookAt.normalize();
  9418. this._dragPlane.position.copyFrom(this._pointA);
  9419. this._pointA.addToRef(this._lookAt, this._lookAt);
  9420. this._dragPlane.lookAt(this._lookAt);
  9421. }
  9422. else if (this._options.dragPlaneNormal) {
  9423. 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);
  9424. this._dragPlane.position.copyFrom(this._pointA);
  9425. this._pointA.addToRef(this._localAxis, this._lookAt);
  9426. this._dragPlane.lookAt(this._lookAt);
  9427. }
  9428. else {
  9429. this._dragPlane.position.copyFrom(this._pointA);
  9430. this._dragPlane.lookAt(ray.origin);
  9431. }
  9432. // 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)
  9433. this._dragPlane.position.copyFrom(this._attachedNode.absolutePosition);
  9434. this._dragPlane.computeWorldMatrix(true);
  9435. };
  9436. /**
  9437. * Detaches the behavior from the mesh
  9438. */
  9439. PointerDragBehavior.prototype.detach = function () {
  9440. if (this._pointerObserver) {
  9441. this._scene.onPointerObservable.remove(this._pointerObserver);
  9442. }
  9443. if (this._beforeRenderObserver) {
  9444. this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  9445. }
  9446. };
  9447. PointerDragBehavior._AnyMouseID = -2;
  9448. return PointerDragBehavior;
  9449. }());
  9450. /***/ }),
  9451. /***/ "./Behaviors/Meshes/sixDofDragBehavior.ts":
  9452. /*!************************************************!*\
  9453. !*** ./Behaviors/Meshes/sixDofDragBehavior.ts ***!
  9454. \************************************************/
  9455. /*! exports provided: SixDofDragBehavior */
  9456. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9457. "use strict";
  9458. __webpack_require__.r(__webpack_exports__);
  9459. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return SixDofDragBehavior; });
  9460. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  9461. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9462. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9463. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9464. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9465. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  9466. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9467. /**
  9468. * 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
  9469. */
  9470. var SixDofDragBehavior = /** @class */ (function () {
  9471. /**
  9472. * 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
  9473. */
  9474. function SixDofDragBehavior() {
  9475. this._sceneRenderObserver = null;
  9476. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9477. this._moving = false;
  9478. this._startingOrientation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9479. /**
  9480. * 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)
  9481. */
  9482. this.zDragFactor = 3;
  9483. /**
  9484. * If the object should rotate to face the drag origin
  9485. */
  9486. this.rotateDraggedObject = true;
  9487. /**
  9488. * If the behavior is currently in a dragging state
  9489. */
  9490. this.dragging = false;
  9491. /**
  9492. * 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)
  9493. */
  9494. this.dragDeltaRatio = 0.2;
  9495. /**
  9496. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9497. */
  9498. this.currentDraggingPointerID = -1;
  9499. /**
  9500. * If camera controls should be detached during the drag
  9501. */
  9502. this.detachCameraControls = true;
  9503. /**
  9504. * Fires each time a drag starts
  9505. */
  9506. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9507. /**
  9508. * Fires each time a drag ends (eg. mouse release after drag)
  9509. */
  9510. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9511. }
  9512. Object.defineProperty(SixDofDragBehavior.prototype, "name", {
  9513. /**
  9514. * The name of the behavior
  9515. */
  9516. get: function () {
  9517. return "SixDofDrag";
  9518. },
  9519. enumerable: true,
  9520. configurable: true
  9521. });
  9522. /**
  9523. * Initializes the behavior
  9524. */
  9525. SixDofDragBehavior.prototype.init = function () { };
  9526. /**
  9527. * Attaches the scale behavior the passed in mesh
  9528. * @param ownerNode The mesh that will be scaled around once attached
  9529. */
  9530. SixDofDragBehavior.prototype.attach = function (ownerNode) {
  9531. var _this = this;
  9532. this._ownerNode = ownerNode;
  9533. this._scene = this._ownerNode.getScene();
  9534. if (!SixDofDragBehavior._virtualScene) {
  9535. SixDofDragBehavior._virtualScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9536. SixDofDragBehavior._virtualScene.detachControl();
  9537. this._scene.getEngine().scenes.pop();
  9538. }
  9539. var pickedMesh = null;
  9540. var lastSixDofOriginPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9541. // Setup virtual meshes to be used for dragging without dirtying the existing scene
  9542. this._virtualOriginMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9543. this._virtualOriginMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9544. this._virtualDragMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9545. this._virtualDragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9546. var pickPredicate = function (m) {
  9547. return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
  9548. };
  9549. var attachedElement = null;
  9550. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9551. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  9552. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9553. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9554. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9555. }
  9556. pickedMesh = _this._ownerNode;
  9557. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9558. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9559. // Set position and orientation of the controller
  9560. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9561. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9562. // Attach the virtual drag mesh to the virtual origin mesh so it can be dragged
  9563. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9564. pickedMesh.computeWorldMatrix();
  9565. _this._virtualDragMesh.position.copyFrom(pickedMesh.absolutePosition);
  9566. if (!pickedMesh.rotationQuaternion) {
  9567. pickedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(pickedMesh.rotation.y, pickedMesh.rotation.x, pickedMesh.rotation.z);
  9568. }
  9569. var oldParent = pickedMesh.parent;
  9570. pickedMesh.setParent(null);
  9571. _this._virtualDragMesh.rotationQuaternion.copyFrom(pickedMesh.rotationQuaternion);
  9572. pickedMesh.setParent(oldParent);
  9573. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9574. // Update state
  9575. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9576. _this.dragging = true;
  9577. _this.currentDraggingPointerID = pointerInfo.event.pointerId;
  9578. // Detatch camera controls
  9579. if (_this.detachCameraControls && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9580. if (_this._scene.activeCamera.inputs.attachedElement) {
  9581. attachedElement = _this._scene.activeCamera.inputs.attachedElement;
  9582. _this._scene.activeCamera.detachControl(_this._scene.activeCamera.inputs.attachedElement);
  9583. }
  9584. else {
  9585. attachedElement = null;
  9586. }
  9587. }
  9588. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9589. _this.onDragStartObservable.notifyObservers({});
  9590. }
  9591. }
  9592. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP) {
  9593. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9594. _this.dragging = false;
  9595. _this._moving = false;
  9596. _this.currentDraggingPointerID = -1;
  9597. pickedMesh = null;
  9598. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9599. // Reattach camera controls
  9600. if (_this.detachCameraControls && attachedElement && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9601. _this._scene.activeCamera.attachControl(attachedElement, true);
  9602. }
  9603. _this.onDragEndObservable.notifyObservers({});
  9604. }
  9605. }
  9606. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE) {
  9607. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
  9608. var zDragFactor = _this.zDragFactor;
  9609. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9610. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9611. zDragFactor = 0;
  9612. }
  9613. // Calculate controller drag distance in controller space
  9614. var originDragDifference = pointerInfo.pickInfo.ray.origin.subtract(lastSixDofOriginPosition);
  9615. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9616. var localOriginDragDifference = -_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(originDragDifference, pointerInfo.pickInfo.ray.direction);
  9617. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9618. // Determine how much the controller moved to/away towards the dragged object and use this to move the object further when its further away
  9619. _this._virtualDragMesh.position.z -= _this._virtualDragMesh.position.z < 1 ? localOriginDragDifference * _this.zDragFactor : localOriginDragDifference * zDragFactor * _this._virtualDragMesh.position.z;
  9620. if (_this._virtualDragMesh.position.z < 0) {
  9621. _this._virtualDragMesh.position.z = 0;
  9622. }
  9623. // Update the controller position
  9624. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9625. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9626. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9627. // Move the virtualObjectsPosition into the picked mesh's space if needed
  9628. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9629. if (pickedMesh.parent) {
  9630. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._targetPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(pickedMesh.parent.getWorldMatrix()), _this._targetPosition);
  9631. }
  9632. if (!_this._moving) {
  9633. _this._startingOrientation.copyFrom(_this._virtualDragMesh.rotationQuaternion);
  9634. }
  9635. _this._moving = true;
  9636. }
  9637. }
  9638. });
  9639. var tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9640. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9641. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9642. if (_this.dragging && _this._moving && pickedMesh) {
  9643. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9644. // Slowly move mesh to avoid jitter
  9645. pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
  9646. if (_this.rotateDraggedObject) {
  9647. // Get change in rotation
  9648. tmpQuaternion.copyFrom(_this._startingOrientation);
  9649. tmpQuaternion.x = -tmpQuaternion.x;
  9650. tmpQuaternion.y = -tmpQuaternion.y;
  9651. tmpQuaternion.z = -tmpQuaternion.z;
  9652. _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
  9653. // Convert change in rotation to only y axis rotation
  9654. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
  9655. tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
  9656. // Slowly move mesh to avoid jitter
  9657. var oldParent = pickedMesh.parent;
  9658. // Only rotate the mesh if it's parent has uniform scaling
  9659. if (!oldParent || (oldParent.scaling && !oldParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  9660. pickedMesh.setParent(null);
  9661. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
  9662. pickedMesh.setParent(oldParent);
  9663. }
  9664. }
  9665. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9666. }
  9667. });
  9668. };
  9669. /**
  9670. * Detaches the behavior from the mesh
  9671. */
  9672. SixDofDragBehavior.prototype.detach = function () {
  9673. if (this._scene) {
  9674. this._scene.onPointerObservable.remove(this._pointerObserver);
  9675. }
  9676. if (this._ownerNode) {
  9677. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9678. }
  9679. if (this._virtualOriginMesh) {
  9680. this._virtualOriginMesh.dispose();
  9681. }
  9682. if (this._virtualDragMesh) {
  9683. this._virtualDragMesh.dispose();
  9684. }
  9685. this.onDragEndObservable.clear();
  9686. this.onDragStartObservable.clear();
  9687. };
  9688. return SixDofDragBehavior;
  9689. }());
  9690. /***/ }),
  9691. /***/ "./Behaviors/index.ts":
  9692. /*!****************************!*\
  9693. !*** ./Behaviors/index.ts ***!
  9694. \****************************/
  9695. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  9696. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9697. "use strict";
  9698. __webpack_require__.r(__webpack_exports__);
  9699. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Cameras/index */ "./Behaviors/Cameras/index.ts");
  9700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  9701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  9702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  9703. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Meshes/index */ "./Behaviors/Meshes/index.ts");
  9704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["AttachToBoxBehavior"]; });
  9705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  9706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["MultiPointerScaleBehavior"]; });
  9707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["PointerDragBehavior"]; });
  9708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["SixDofDragBehavior"]; });
  9709. /***/ }),
  9710. /***/ "./Bones/bone.ts":
  9711. /*!***********************!*\
  9712. !*** ./Bones/bone.ts ***!
  9713. \***********************/
  9714. /*! exports provided: Bone */
  9715. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9716. "use strict";
  9717. __webpack_require__.r(__webpack_exports__);
  9718. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return Bone; });
  9719. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  9720. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  9721. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  9722. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  9723. /**
  9724. * Class used to store bone information
  9725. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9726. */
  9727. var Bone = /** @class */ (function (_super) {
  9728. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Bone, _super);
  9729. /**
  9730. * Create a new bone
  9731. * @param name defines the bone name
  9732. * @param skeleton defines the parent skeleton
  9733. * @param parentBone defines the parent (can be null if the bone is the root)
  9734. * @param localMatrix defines the local matrix
  9735. * @param restPose defines the rest pose matrix
  9736. * @param baseMatrix defines the base matrix
  9737. * @param index defines index of the bone in the hiearchy
  9738. */
  9739. function Bone(
  9740. /**
  9741. * defines the bone name
  9742. */
  9743. name, skeleton, parentBone, localMatrix, restPose, baseMatrix, index) {
  9744. if (parentBone === void 0) { parentBone = null; }
  9745. if (localMatrix === void 0) { localMatrix = null; }
  9746. if (restPose === void 0) { restPose = null; }
  9747. if (baseMatrix === void 0) { baseMatrix = null; }
  9748. if (index === void 0) { index = null; }
  9749. var _this = _super.call(this, name, skeleton.getScene(), false) || this;
  9750. _this.name = name;
  9751. /**
  9752. * Gets the list of child bones
  9753. */
  9754. _this.children = new Array();
  9755. /** Gets the animations associated with this bone */
  9756. _this.animations = new Array();
  9757. /**
  9758. * @hidden Internal only
  9759. * Set this value to map this bone to a different index in the transform matrices
  9760. * Set this value to -1 to exclude the bone from the transform matrices
  9761. */
  9762. _this._index = null;
  9763. _this._absoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9764. _this._invertedAbsoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9765. _this._scalingDeterminant = 1;
  9766. _this._worldTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9767. _this._needToDecompose = true;
  9768. _this._needToCompose = false;
  9769. /** @hidden */
  9770. _this._linkedTransformNode = null;
  9771. _this._skeleton = skeleton;
  9772. _this._localMatrix = localMatrix ? localMatrix.clone() : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  9773. _this._restPose = restPose ? restPose : _this._localMatrix.clone();
  9774. _this._baseMatrix = baseMatrix ? baseMatrix : _this._localMatrix.clone();
  9775. _this._index = index;
  9776. skeleton.bones.push(_this);
  9777. _this.setParent(parentBone, false);
  9778. if (baseMatrix || localMatrix) {
  9779. _this._updateDifferenceMatrix();
  9780. }
  9781. return _this;
  9782. }
  9783. Object.defineProperty(Bone.prototype, "_matrix", {
  9784. /** @hidden */
  9785. get: function () {
  9786. this._compose();
  9787. return this._localMatrix;
  9788. },
  9789. /** @hidden */
  9790. set: function (value) {
  9791. this._localMatrix.copyFrom(value);
  9792. this._needToDecompose = true;
  9793. },
  9794. enumerable: true,
  9795. configurable: true
  9796. });
  9797. // Members
  9798. /**
  9799. * Gets the parent skeleton
  9800. * @returns a skeleton
  9801. */
  9802. Bone.prototype.getSkeleton = function () {
  9803. return this._skeleton;
  9804. };
  9805. /**
  9806. * Gets parent bone
  9807. * @returns a bone or null if the bone is the root of the bone hierarchy
  9808. */
  9809. Bone.prototype.getParent = function () {
  9810. return this._parent;
  9811. };
  9812. /**
  9813. * Sets the parent bone
  9814. * @param parent defines the parent (can be null if the bone is the root)
  9815. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9816. */
  9817. Bone.prototype.setParent = function (parent, updateDifferenceMatrix) {
  9818. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9819. if (this._parent === parent) {
  9820. return;
  9821. }
  9822. if (this._parent) {
  9823. var index = this._parent.children.indexOf(this);
  9824. if (index !== -1) {
  9825. this._parent.children.splice(index, 1);
  9826. }
  9827. }
  9828. this._parent = parent;
  9829. if (this._parent) {
  9830. this._parent.children.push(this);
  9831. }
  9832. if (updateDifferenceMatrix) {
  9833. this._updateDifferenceMatrix();
  9834. }
  9835. this.markAsDirty();
  9836. };
  9837. /**
  9838. * Gets the local matrix
  9839. * @returns a matrix
  9840. */
  9841. Bone.prototype.getLocalMatrix = function () {
  9842. this._compose();
  9843. return this._localMatrix;
  9844. };
  9845. /**
  9846. * Gets the base matrix (initial matrix which remains unchanged)
  9847. * @returns a matrix
  9848. */
  9849. Bone.prototype.getBaseMatrix = function () {
  9850. return this._baseMatrix;
  9851. };
  9852. /**
  9853. * Gets the rest pose matrix
  9854. * @returns a matrix
  9855. */
  9856. Bone.prototype.getRestPose = function () {
  9857. return this._restPose;
  9858. };
  9859. /**
  9860. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9861. */
  9862. Bone.prototype.getWorldMatrix = function () {
  9863. return this._worldTransform;
  9864. };
  9865. /**
  9866. * Sets the local matrix to rest pose matrix
  9867. */
  9868. Bone.prototype.returnToRest = function () {
  9869. this.updateMatrix(this._restPose.clone());
  9870. };
  9871. /**
  9872. * Gets the inverse of the absolute transform matrix.
  9873. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9874. * @returns a matrix
  9875. */
  9876. Bone.prototype.getInvertedAbsoluteTransform = function () {
  9877. return this._invertedAbsoluteTransform;
  9878. };
  9879. /**
  9880. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9881. * @returns a matrix
  9882. */
  9883. Bone.prototype.getAbsoluteTransform = function () {
  9884. return this._absoluteTransform;
  9885. };
  9886. /**
  9887. * Links with the given transform node.
  9888. * The local matrix of this bone is copied from the transform node every frame.
  9889. * @param transformNode defines the transform node to link to
  9890. */
  9891. Bone.prototype.linkTransformNode = function (transformNode) {
  9892. if (this._linkedTransformNode) {
  9893. this._skeleton._numBonesWithLinkedTransformNode--;
  9894. }
  9895. this._linkedTransformNode = transformNode;
  9896. if (this._linkedTransformNode) {
  9897. this._skeleton._numBonesWithLinkedTransformNode++;
  9898. }
  9899. };
  9900. Object.defineProperty(Bone.prototype, "position", {
  9901. // Properties (matches AbstractMesh properties)
  9902. /** Gets or sets current position (in local space) */
  9903. get: function () {
  9904. this._decompose();
  9905. return this._localPosition;
  9906. },
  9907. set: function (newPosition) {
  9908. this._decompose();
  9909. this._localPosition.copyFrom(newPosition);
  9910. this._markAsDirtyAndCompose();
  9911. },
  9912. enumerable: true,
  9913. configurable: true
  9914. });
  9915. Object.defineProperty(Bone.prototype, "rotation", {
  9916. /** Gets or sets current rotation (in local space) */
  9917. get: function () {
  9918. return this.getRotation();
  9919. },
  9920. set: function (newRotation) {
  9921. this.setRotation(newRotation);
  9922. },
  9923. enumerable: true,
  9924. configurable: true
  9925. });
  9926. Object.defineProperty(Bone.prototype, "rotationQuaternion", {
  9927. /** Gets or sets current rotation quaternion (in local space) */
  9928. get: function () {
  9929. this._decompose();
  9930. return this._localRotation;
  9931. },
  9932. set: function (newRotation) {
  9933. this.setRotationQuaternion(newRotation);
  9934. },
  9935. enumerable: true,
  9936. configurable: true
  9937. });
  9938. Object.defineProperty(Bone.prototype, "scaling", {
  9939. /** Gets or sets current scaling (in local space) */
  9940. get: function () {
  9941. return this.getScale();
  9942. },
  9943. set: function (newScaling) {
  9944. this.setScale(newScaling);
  9945. },
  9946. enumerable: true,
  9947. configurable: true
  9948. });
  9949. Object.defineProperty(Bone.prototype, "animationPropertiesOverride", {
  9950. /**
  9951. * Gets the animation properties override
  9952. */
  9953. get: function () {
  9954. return this._skeleton.animationPropertiesOverride;
  9955. },
  9956. enumerable: true,
  9957. configurable: true
  9958. });
  9959. // Methods
  9960. Bone.prototype._decompose = function () {
  9961. if (!this._needToDecompose) {
  9962. return;
  9963. }
  9964. this._needToDecompose = false;
  9965. if (!this._localScaling) {
  9966. this._localScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9967. this._localRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Zero();
  9968. this._localPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9969. }
  9970. this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition);
  9971. };
  9972. Bone.prototype._compose = function () {
  9973. if (!this._needToCompose) {
  9974. return;
  9975. }
  9976. this._needToCompose = false;
  9977. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix);
  9978. };
  9979. /**
  9980. * Update the base and local matrices
  9981. * @param matrix defines the new base or local matrix
  9982. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9983. * @param updateLocalMatrix defines if the local matrix should be updated
  9984. */
  9985. Bone.prototype.updateMatrix = function (matrix, updateDifferenceMatrix, updateLocalMatrix) {
  9986. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9987. if (updateLocalMatrix === void 0) { updateLocalMatrix = true; }
  9988. this._baseMatrix.copyFrom(matrix);
  9989. if (updateDifferenceMatrix) {
  9990. this._updateDifferenceMatrix();
  9991. }
  9992. if (updateLocalMatrix) {
  9993. this._localMatrix.copyFrom(matrix);
  9994. this._markAsDirtyAndDecompose();
  9995. }
  9996. else {
  9997. this.markAsDirty();
  9998. }
  9999. };
  10000. /** @hidden */
  10001. Bone.prototype._updateDifferenceMatrix = function (rootMatrix, updateChildren) {
  10002. if (updateChildren === void 0) { updateChildren = true; }
  10003. if (!rootMatrix) {
  10004. rootMatrix = this._baseMatrix;
  10005. }
  10006. if (this._parent) {
  10007. rootMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10008. }
  10009. else {
  10010. this._absoluteTransform.copyFrom(rootMatrix);
  10011. }
  10012. this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);
  10013. if (updateChildren) {
  10014. for (var index = 0; index < this.children.length; index++) {
  10015. this.children[index]._updateDifferenceMatrix();
  10016. }
  10017. }
  10018. this._scalingDeterminant = (this._absoluteTransform.determinant() < 0 ? -1 : 1);
  10019. };
  10020. /**
  10021. * Flag the bone as dirty (Forcing it to update everything)
  10022. */
  10023. Bone.prototype.markAsDirty = function () {
  10024. this._currentRenderId++;
  10025. this._childRenderId++;
  10026. this._skeleton._markAsDirty();
  10027. };
  10028. Bone.prototype._markAsDirtyAndCompose = function () {
  10029. this.markAsDirty();
  10030. this._needToCompose = true;
  10031. };
  10032. Bone.prototype._markAsDirtyAndDecompose = function () {
  10033. this.markAsDirty();
  10034. this._needToDecompose = true;
  10035. };
  10036. /**
  10037. * Translate the bone in local or world space
  10038. * @param vec The amount to translate the bone
  10039. * @param space The space that the translation is in
  10040. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10041. */
  10042. Bone.prototype.translate = function (vec, space, mesh) {
  10043. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10044. var lm = this.getLocalMatrix();
  10045. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10046. lm.addAtIndex(12, vec.x);
  10047. lm.addAtIndex(13, vec.y);
  10048. lm.addAtIndex(14, vec.z);
  10049. }
  10050. else {
  10051. var wm = null;
  10052. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10053. if (mesh) {
  10054. wm = mesh.getWorldMatrix();
  10055. }
  10056. this._skeleton.computeAbsoluteTransforms();
  10057. var tmat = Bone._tmpMats[0];
  10058. var tvec = Bone._tmpVecs[0];
  10059. if (this._parent) {
  10060. if (mesh && wm) {
  10061. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10062. tmat.multiplyToRef(wm, tmat);
  10063. }
  10064. else {
  10065. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10066. }
  10067. }
  10068. tmat.setTranslationFromFloats(0, 0, 0);
  10069. tmat.invert();
  10070. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vec, tmat, tvec);
  10071. lm.addAtIndex(12, tvec.x);
  10072. lm.addAtIndex(13, tvec.y);
  10073. lm.addAtIndex(14, tvec.z);
  10074. }
  10075. this._markAsDirtyAndDecompose();
  10076. };
  10077. /**
  10078. * Set the postion of the bone in local or world space
  10079. * @param position The position to set the bone
  10080. * @param space The space that the position is in
  10081. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10082. */
  10083. Bone.prototype.setPosition = function (position, space, mesh) {
  10084. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10085. var lm = this.getLocalMatrix();
  10086. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10087. lm.setTranslationFromFloats(position.x, position.y, position.z);
  10088. }
  10089. else {
  10090. var wm = null;
  10091. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10092. if (mesh) {
  10093. wm = mesh.getWorldMatrix();
  10094. }
  10095. this._skeleton.computeAbsoluteTransforms();
  10096. var tmat = Bone._tmpMats[0];
  10097. var vec = Bone._tmpVecs[0];
  10098. if (this._parent) {
  10099. if (mesh && wm) {
  10100. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10101. tmat.multiplyToRef(wm, tmat);
  10102. }
  10103. else {
  10104. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10105. }
  10106. }
  10107. tmat.invert();
  10108. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, vec);
  10109. lm.setTranslationFromFloats(vec.x, vec.y, vec.z);
  10110. }
  10111. this._markAsDirtyAndDecompose();
  10112. };
  10113. /**
  10114. * Set the absolute position of the bone (world space)
  10115. * @param position The position to set the bone
  10116. * @param mesh The mesh that this bone is attached to
  10117. */
  10118. Bone.prototype.setAbsolutePosition = function (position, mesh) {
  10119. this.setPosition(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh);
  10120. };
  10121. /**
  10122. * Scale the bone on the x, y and z axes (in local space)
  10123. * @param x The amount to scale the bone on the x axis
  10124. * @param y The amount to scale the bone on the y axis
  10125. * @param z The amount to scale the bone on the z axis
  10126. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  10127. */
  10128. Bone.prototype.scale = function (x, y, z, scaleChildren) {
  10129. if (scaleChildren === void 0) { scaleChildren = false; }
  10130. var locMat = this.getLocalMatrix();
  10131. // Apply new scaling on top of current local matrix
  10132. var scaleMat = Bone._tmpMats[0];
  10133. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(x, y, z, scaleMat);
  10134. scaleMat.multiplyToRef(locMat, locMat);
  10135. // Invert scaling matrix and apply the inverse to all children
  10136. scaleMat.invert();
  10137. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  10138. var child = _a[_i];
  10139. var cm = child.getLocalMatrix();
  10140. cm.multiplyToRef(scaleMat, cm);
  10141. cm.multiplyAtIndex(12, x);
  10142. cm.multiplyAtIndex(13, y);
  10143. cm.multiplyAtIndex(14, z);
  10144. child._markAsDirtyAndDecompose();
  10145. }
  10146. this._markAsDirtyAndDecompose();
  10147. if (scaleChildren) {
  10148. for (var _b = 0, _c = this.children; _b < _c.length; _b++) {
  10149. var child = _c[_b];
  10150. child.scale(x, y, z, scaleChildren);
  10151. }
  10152. }
  10153. };
  10154. /**
  10155. * Set the bone scaling in local space
  10156. * @param scale defines the scaling vector
  10157. */
  10158. Bone.prototype.setScale = function (scale) {
  10159. this._decompose();
  10160. this._localScaling.copyFrom(scale);
  10161. this._markAsDirtyAndCompose();
  10162. };
  10163. /**
  10164. * Gets the current scaling in local space
  10165. * @returns the current scaling vector
  10166. */
  10167. Bone.prototype.getScale = function () {
  10168. this._decompose();
  10169. return this._localScaling;
  10170. };
  10171. /**
  10172. * Gets the current scaling in local space and stores it in a target vector
  10173. * @param result defines the target vector
  10174. */
  10175. Bone.prototype.getScaleToRef = function (result) {
  10176. this._decompose();
  10177. result.copyFrom(this._localScaling);
  10178. };
  10179. /**
  10180. * Set the yaw, pitch, and roll of the bone in local or world space
  10181. * @param yaw The rotation of the bone on the y axis
  10182. * @param pitch The rotation of the bone on the x axis
  10183. * @param roll The rotation of the bone on the z axis
  10184. * @param space The space that the axes of rotation are in
  10185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10186. */
  10187. Bone.prototype.setYawPitchRoll = function (yaw, pitch, roll, space, mesh) {
  10188. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10189. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10190. var quat = Bone._tmpQuat;
  10191. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationYawPitchRollToRef(yaw, pitch, roll, quat);
  10192. this.setRotationQuaternion(quat, space, mesh);
  10193. return;
  10194. }
  10195. var rotMatInv = Bone._tmpMats[0];
  10196. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10197. return;
  10198. }
  10199. var rotMat = Bone._tmpMats[1];
  10200. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yaw, pitch, roll, rotMat);
  10201. rotMatInv.multiplyToRef(rotMat, rotMat);
  10202. this._rotateWithMatrix(rotMat, space, mesh);
  10203. };
  10204. /**
  10205. * Add a rotation to the bone on an axis in local or world space
  10206. * @param axis The axis to rotate the bone on
  10207. * @param amount The amount to rotate the bone
  10208. * @param space The space that the axis is in
  10209. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10210. */
  10211. Bone.prototype.rotate = function (axis, amount, space, mesh) {
  10212. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10213. var rmat = Bone._tmpMats[0];
  10214. rmat.setTranslationFromFloats(0, 0, 0);
  10215. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, amount, rmat);
  10216. this._rotateWithMatrix(rmat, space, mesh);
  10217. };
  10218. /**
  10219. * Set the rotation of the bone to a particular axis angle in local or world space
  10220. * @param axis The axis to rotate the bone on
  10221. * @param angle The angle that the bone should be rotated to
  10222. * @param space The space that the axis is in
  10223. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10224. */
  10225. Bone.prototype.setAxisAngle = function (axis, angle, space, mesh) {
  10226. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10227. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10228. var quat = Bone._tmpQuat;
  10229. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationAxisToRef(axis, angle, quat);
  10230. this.setRotationQuaternion(quat, space, mesh);
  10231. return;
  10232. }
  10233. var rotMatInv = Bone._tmpMats[0];
  10234. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10235. return;
  10236. }
  10237. var rotMat = Bone._tmpMats[1];
  10238. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, angle, rotMat);
  10239. rotMatInv.multiplyToRef(rotMat, rotMat);
  10240. this._rotateWithMatrix(rotMat, space, mesh);
  10241. };
  10242. /**
  10243. * Set the euler rotation of the bone in local of world space
  10244. * @param rotation The euler rotation that the bone should be set to
  10245. * @param space The space that the rotation is in
  10246. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10247. */
  10248. Bone.prototype.setRotation = function (rotation, space, mesh) {
  10249. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10250. this.setYawPitchRoll(rotation.y, rotation.x, rotation.z, space, mesh);
  10251. };
  10252. /**
  10253. * Set the quaternion rotation of the bone in local of world space
  10254. * @param quat The quaternion rotation that the bone should be set to
  10255. * @param space The space that the rotation is in
  10256. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10257. */
  10258. Bone.prototype.setRotationQuaternion = function (quat, space, mesh) {
  10259. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10260. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10261. this._decompose();
  10262. this._localRotation.copyFrom(quat);
  10263. this._markAsDirtyAndCompose();
  10264. return;
  10265. }
  10266. var rotMatInv = Bone._tmpMats[0];
  10267. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10268. return;
  10269. }
  10270. var rotMat = Bone._tmpMats[1];
  10271. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromQuaternionToRef(quat, rotMat);
  10272. rotMatInv.multiplyToRef(rotMat, rotMat);
  10273. this._rotateWithMatrix(rotMat, space, mesh);
  10274. };
  10275. /**
  10276. * Set the rotation matrix of the bone in local of world space
  10277. * @param rotMat The rotation matrix that the bone should be set to
  10278. * @param space The space that the rotation is in
  10279. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10280. */
  10281. Bone.prototype.setRotationMatrix = function (rotMat, space, mesh) {
  10282. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10283. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10284. var quat = Bone._tmpQuat;
  10285. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(rotMat, quat);
  10286. this.setRotationQuaternion(quat, space, mesh);
  10287. return;
  10288. }
  10289. var rotMatInv = Bone._tmpMats[0];
  10290. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10291. return;
  10292. }
  10293. var rotMat2 = Bone._tmpMats[1];
  10294. rotMat2.copyFrom(rotMat);
  10295. rotMatInv.multiplyToRef(rotMat, rotMat2);
  10296. this._rotateWithMatrix(rotMat2, space, mesh);
  10297. };
  10298. Bone.prototype._rotateWithMatrix = function (rmat, space, mesh) {
  10299. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10300. var lmat = this.getLocalMatrix();
  10301. var lx = lmat.m[12];
  10302. var ly = lmat.m[13];
  10303. var lz = lmat.m[14];
  10304. var parent = this.getParent();
  10305. var parentScale = Bone._tmpMats[3];
  10306. var parentScaleInv = Bone._tmpMats[4];
  10307. if (parent && space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD) {
  10308. if (mesh) {
  10309. parentScale.copyFrom(mesh.getWorldMatrix());
  10310. parent.getAbsoluteTransform().multiplyToRef(parentScale, parentScale);
  10311. }
  10312. else {
  10313. parentScale.copyFrom(parent.getAbsoluteTransform());
  10314. }
  10315. parentScaleInv.copyFrom(parentScale);
  10316. parentScaleInv.invert();
  10317. lmat.multiplyToRef(parentScale, lmat);
  10318. lmat.multiplyToRef(rmat, lmat);
  10319. lmat.multiplyToRef(parentScaleInv, lmat);
  10320. }
  10321. else {
  10322. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD && mesh) {
  10323. parentScale.copyFrom(mesh.getWorldMatrix());
  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. lmat.multiplyToRef(rmat, lmat);
  10332. }
  10333. }
  10334. lmat.setTranslationFromFloats(lx, ly, lz);
  10335. this.computeAbsoluteTransforms();
  10336. this._markAsDirtyAndDecompose();
  10337. };
  10338. Bone.prototype._getNegativeRotationToRef = function (rotMatInv, mesh) {
  10339. var scaleMatrix = Bone._tmpMats[2];
  10340. rotMatInv.copyFrom(this.getAbsoluteTransform());
  10341. if (mesh) {
  10342. rotMatInv.multiplyToRef(mesh.getWorldMatrix(), rotMatInv);
  10343. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(mesh.scaling.x, mesh.scaling.y, mesh.scaling.z, scaleMatrix);
  10344. }
  10345. rotMatInv.invert();
  10346. if (isNaN(rotMatInv.m[0])) {
  10347. // Matrix failed to invert.
  10348. // This can happen if scale is zero for example.
  10349. return false;
  10350. }
  10351. scaleMatrix.multiplyAtIndex(0, this._scalingDeterminant);
  10352. rotMatInv.multiplyToRef(scaleMatrix, rotMatInv);
  10353. return true;
  10354. };
  10355. /**
  10356. * Get the position of the bone in local or world space
  10357. * @param space The space that the returned position is in
  10358. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10359. * @returns The position of the bone
  10360. */
  10361. Bone.prototype.getPosition = function (space, mesh) {
  10362. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10363. if (mesh === void 0) { mesh = null; }
  10364. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10365. this.getPositionToRef(space, mesh, pos);
  10366. return pos;
  10367. };
  10368. /**
  10369. * Copy the position of the bone to a vector3 in local or world space
  10370. * @param space The space that the returned position is in
  10371. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10372. * @param result The vector3 to copy the position to
  10373. */
  10374. Bone.prototype.getPositionToRef = function (space, mesh, result) {
  10375. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10376. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10377. var lm = this.getLocalMatrix();
  10378. result.x = lm.m[12];
  10379. result.y = lm.m[13];
  10380. result.z = lm.m[14];
  10381. }
  10382. else {
  10383. var wm = null;
  10384. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10385. if (mesh) {
  10386. wm = mesh.getWorldMatrix();
  10387. }
  10388. this._skeleton.computeAbsoluteTransforms();
  10389. var tmat = Bone._tmpMats[0];
  10390. if (mesh && wm) {
  10391. tmat.copyFrom(this.getAbsoluteTransform());
  10392. tmat.multiplyToRef(wm, tmat);
  10393. }
  10394. else {
  10395. tmat = this.getAbsoluteTransform();
  10396. }
  10397. result.x = tmat.m[12];
  10398. result.y = tmat.m[13];
  10399. result.z = tmat.m[14];
  10400. }
  10401. };
  10402. /**
  10403. * Get the absolute position of the bone (world space)
  10404. * @param mesh The mesh that this bone is attached to
  10405. * @returns The absolute position of the bone
  10406. */
  10407. Bone.prototype.getAbsolutePosition = function (mesh) {
  10408. if (mesh === void 0) { mesh = null; }
  10409. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10410. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, pos);
  10411. return pos;
  10412. };
  10413. /**
  10414. * Copy the absolute position of the bone (world space) to the result param
  10415. * @param mesh The mesh that this bone is attached to
  10416. * @param result The vector3 to copy the absolute position to
  10417. */
  10418. Bone.prototype.getAbsolutePositionToRef = function (mesh, result) {
  10419. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, result);
  10420. };
  10421. /**
  10422. * Compute the absolute transforms of this bone and its children
  10423. */
  10424. Bone.prototype.computeAbsoluteTransforms = function () {
  10425. this._compose();
  10426. if (this._parent) {
  10427. this._localMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10428. }
  10429. else {
  10430. this._absoluteTransform.copyFrom(this._localMatrix);
  10431. var poseMatrix = this._skeleton.getPoseMatrix();
  10432. if (poseMatrix) {
  10433. this._absoluteTransform.multiplyToRef(poseMatrix, this._absoluteTransform);
  10434. }
  10435. }
  10436. var children = this.children;
  10437. var len = children.length;
  10438. for (var i = 0; i < len; i++) {
  10439. children[i].computeAbsoluteTransforms();
  10440. }
  10441. };
  10442. /**
  10443. * Get the world direction from an axis that is in the local space of the bone
  10444. * @param localAxis The local direction that is used to compute the world direction
  10445. * @param mesh The mesh that this bone is attached to
  10446. * @returns The world direction
  10447. */
  10448. Bone.prototype.getDirection = function (localAxis, mesh) {
  10449. if (mesh === void 0) { mesh = null; }
  10450. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10451. this.getDirectionToRef(localAxis, mesh, result);
  10452. return result;
  10453. };
  10454. /**
  10455. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  10456. * @param localAxis The local direction that is used to compute the world direction
  10457. * @param mesh The mesh that this bone is attached to
  10458. * @param result The vector3 that the world direction will be copied to
  10459. */
  10460. Bone.prototype.getDirectionToRef = function (localAxis, mesh, result) {
  10461. if (mesh === void 0) { mesh = null; }
  10462. var wm = null;
  10463. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10464. if (mesh) {
  10465. wm = mesh.getWorldMatrix();
  10466. }
  10467. this._skeleton.computeAbsoluteTransforms();
  10468. var mat = Bone._tmpMats[0];
  10469. mat.copyFrom(this.getAbsoluteTransform());
  10470. if (mesh && wm) {
  10471. mat.multiplyToRef(wm, mat);
  10472. }
  10473. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(localAxis, mat, result);
  10474. result.normalize();
  10475. };
  10476. /**
  10477. * Get the euler rotation of the bone in local or world space
  10478. * @param space The space that the rotation should be in
  10479. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10480. * @returns The euler rotation
  10481. */
  10482. Bone.prototype.getRotation = function (space, mesh) {
  10483. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10484. if (mesh === void 0) { mesh = null; }
  10485. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10486. this.getRotationToRef(space, mesh, result);
  10487. return result;
  10488. };
  10489. /**
  10490. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  10491. * @param space The space that the rotation should be in
  10492. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10493. * @param result The vector3 that the rotation should be copied to
  10494. */
  10495. Bone.prototype.getRotationToRef = function (space, mesh, result) {
  10496. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10497. if (mesh === void 0) { mesh = null; }
  10498. var quat = Bone._tmpQuat;
  10499. this.getRotationQuaternionToRef(space, mesh, quat);
  10500. quat.toEulerAnglesToRef(result);
  10501. };
  10502. /**
  10503. * Get the quaternion rotation of the bone in either local or world space
  10504. * @param space The space that the rotation should be in
  10505. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10506. * @returns The quaternion rotation
  10507. */
  10508. Bone.prototype.getRotationQuaternion = function (space, mesh) {
  10509. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10510. if (mesh === void 0) { mesh = null; }
  10511. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10512. this.getRotationQuaternionToRef(space, mesh, result);
  10513. return result;
  10514. };
  10515. /**
  10516. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  10517. * @param space The space that the rotation should be in
  10518. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10519. * @param result The quaternion that the rotation should be copied to
  10520. */
  10521. Bone.prototype.getRotationQuaternionToRef = function (space, mesh, result) {
  10522. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10523. if (mesh === void 0) { mesh = null; }
  10524. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10525. this._decompose();
  10526. result.copyFrom(this._localRotation);
  10527. }
  10528. else {
  10529. var mat = Bone._tmpMats[0];
  10530. var amat = this.getAbsoluteTransform();
  10531. if (mesh) {
  10532. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10533. }
  10534. else {
  10535. mat.copyFrom(amat);
  10536. }
  10537. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10538. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10539. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10540. mat.decompose(undefined, result, undefined);
  10541. }
  10542. };
  10543. /**
  10544. * Get the rotation matrix of the bone in local or world space
  10545. * @param space The space that the rotation should be in
  10546. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10547. * @returns The rotation matrix
  10548. */
  10549. Bone.prototype.getRotationMatrix = function (space, mesh) {
  10550. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10551. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  10552. this.getRotationMatrixToRef(space, mesh, result);
  10553. return result;
  10554. };
  10555. /**
  10556. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  10557. * @param space The space that the rotation should be in
  10558. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10559. * @param result The quaternion that the rotation should be copied to
  10560. */
  10561. Bone.prototype.getRotationMatrixToRef = function (space, mesh, result) {
  10562. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10563. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10564. this.getLocalMatrix().getRotationMatrixToRef(result);
  10565. }
  10566. else {
  10567. var mat = Bone._tmpMats[0];
  10568. var amat = this.getAbsoluteTransform();
  10569. if (mesh) {
  10570. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10571. }
  10572. else {
  10573. mat.copyFrom(amat);
  10574. }
  10575. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10576. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10577. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10578. mat.getRotationMatrixToRef(result);
  10579. }
  10580. };
  10581. /**
  10582. * Get the world position of a point that is in the local space of the bone
  10583. * @param position The local position
  10584. * @param mesh The mesh that this bone is attached to
  10585. * @returns The world position
  10586. */
  10587. Bone.prototype.getAbsolutePositionFromLocal = function (position, mesh) {
  10588. if (mesh === void 0) { mesh = null; }
  10589. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10590. this.getAbsolutePositionFromLocalToRef(position, mesh, result);
  10591. return result;
  10592. };
  10593. /**
  10594. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  10595. * @param position The local position
  10596. * @param mesh The mesh that this bone is attached to
  10597. * @param result The vector3 that the world position should be copied to
  10598. */
  10599. Bone.prototype.getAbsolutePositionFromLocalToRef = function (position, mesh, result) {
  10600. if (mesh === void 0) { mesh = null; }
  10601. var wm = null;
  10602. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10603. if (mesh) {
  10604. wm = mesh.getWorldMatrix();
  10605. }
  10606. this._skeleton.computeAbsoluteTransforms();
  10607. var tmat = Bone._tmpMats[0];
  10608. if (mesh && wm) {
  10609. tmat.copyFrom(this.getAbsoluteTransform());
  10610. tmat.multiplyToRef(wm, tmat);
  10611. }
  10612. else {
  10613. tmat = this.getAbsoluteTransform();
  10614. }
  10615. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10616. };
  10617. /**
  10618. * Get the local position of a point that is in world space
  10619. * @param position The world position
  10620. * @param mesh The mesh that this bone is attached to
  10621. * @returns The local position
  10622. */
  10623. Bone.prototype.getLocalPositionFromAbsolute = function (position, mesh) {
  10624. if (mesh === void 0) { mesh = null; }
  10625. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10626. this.getLocalPositionFromAbsoluteToRef(position, mesh, result);
  10627. return result;
  10628. };
  10629. /**
  10630. * Get the local position of a point that is in world space and copy it to the result param
  10631. * @param position The world position
  10632. * @param mesh The mesh that this bone is attached to
  10633. * @param result The vector3 that the local position should be copied to
  10634. */
  10635. Bone.prototype.getLocalPositionFromAbsoluteToRef = function (position, mesh, result) {
  10636. if (mesh === void 0) { mesh = null; }
  10637. var wm = null;
  10638. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10639. if (mesh) {
  10640. wm = mesh.getWorldMatrix();
  10641. }
  10642. this._skeleton.computeAbsoluteTransforms();
  10643. var tmat = Bone._tmpMats[0];
  10644. tmat.copyFrom(this.getAbsoluteTransform());
  10645. if (mesh && wm) {
  10646. tmat.multiplyToRef(wm, tmat);
  10647. }
  10648. tmat.invert();
  10649. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10650. };
  10651. Bone._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  10652. Bone._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10653. Bone._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  10654. return Bone;
  10655. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  10656. /***/ }),
  10657. /***/ "./Bones/boneIKController.ts":
  10658. /*!***********************************!*\
  10659. !*** ./Bones/boneIKController.ts ***!
  10660. \***********************************/
  10661. /*! exports provided: BoneIKController */
  10662. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10663. "use strict";
  10664. __webpack_require__.r(__webpack_exports__);
  10665. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return BoneIKController; });
  10666. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10667. /**
  10668. * Class used to apply inverse kinematics to bones
  10669. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  10670. */
  10671. var BoneIKController = /** @class */ (function () {
  10672. /**
  10673. * Creates a new BoneIKController
  10674. * @param mesh defines the mesh to control
  10675. * @param bone defines the bone to control
  10676. * @param options defines options to set up the controller
  10677. */
  10678. function BoneIKController(mesh, bone, options) {
  10679. /**
  10680. * Gets or sets the target position
  10681. */
  10682. this.targetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10683. /**
  10684. * Gets or sets the pole target position
  10685. */
  10686. this.poleTargetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10687. /**
  10688. * Gets or sets the pole target local offset
  10689. */
  10690. this.poleTargetLocalOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10691. /**
  10692. * Gets or sets the pole angle
  10693. */
  10694. this.poleAngle = 0;
  10695. /**
  10696. * 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)
  10697. */
  10698. this.slerpAmount = 1;
  10699. this._bone1Quat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10700. this._bone1Mat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  10701. this._bone2Ang = Math.PI;
  10702. this._maxAngle = Math.PI;
  10703. this._rightHandedSystem = false;
  10704. this._bendAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right();
  10705. this._slerping = false;
  10706. this._adjustRoll = 0;
  10707. this._bone2 = bone;
  10708. this._bone1 = bone.getParent();
  10709. if (!this._bone1) {
  10710. return;
  10711. }
  10712. this.mesh = mesh;
  10713. var bonePos = bone.getPosition();
  10714. if (bone.getAbsoluteTransform().determinant() > 0) {
  10715. this._rightHandedSystem = true;
  10716. this._bendAxis.x = 0;
  10717. this._bendAxis.y = 0;
  10718. this._bendAxis.z = -1;
  10719. if (bonePos.x > bonePos.y && bonePos.x > bonePos.z) {
  10720. this._adjustRoll = Math.PI * .5;
  10721. this._bendAxis.z = 1;
  10722. }
  10723. }
  10724. if (this._bone1.length) {
  10725. var boneScale1 = this._bone1.getScale();
  10726. var boneScale2 = this._bone2.getScale();
  10727. this._bone1Length = this._bone1.length * boneScale1.y * this.mesh.scaling.y;
  10728. this._bone2Length = this._bone2.length * boneScale2.y * this.mesh.scaling.y;
  10729. }
  10730. else if (this._bone1.children[0]) {
  10731. mesh.computeWorldMatrix(true);
  10732. var pos1 = this._bone2.children[0].getAbsolutePosition(mesh);
  10733. var pos2 = this._bone2.getAbsolutePosition(mesh);
  10734. var pos3 = this._bone1.getAbsolutePosition(mesh);
  10735. this._bone1Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos1, pos2);
  10736. this._bone2Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos2, pos3);
  10737. }
  10738. this._bone1.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, mesh, this._bone1Mat);
  10739. this.maxAngle = Math.PI;
  10740. if (options) {
  10741. if (options.targetMesh) {
  10742. this.targetMesh = options.targetMesh;
  10743. this.targetMesh.computeWorldMatrix(true);
  10744. }
  10745. if (options.poleTargetMesh) {
  10746. this.poleTargetMesh = options.poleTargetMesh;
  10747. this.poleTargetMesh.computeWorldMatrix(true);
  10748. }
  10749. else if (options.poleTargetBone) {
  10750. this.poleTargetBone = options.poleTargetBone;
  10751. }
  10752. else if (this._bone1.getParent()) {
  10753. this.poleTargetBone = this._bone1.getParent();
  10754. }
  10755. if (options.poleTargetLocalOffset) {
  10756. this.poleTargetLocalOffset.copyFrom(options.poleTargetLocalOffset);
  10757. }
  10758. if (options.poleAngle) {
  10759. this.poleAngle = options.poleAngle;
  10760. }
  10761. if (options.bendAxis) {
  10762. this._bendAxis.copyFrom(options.bendAxis);
  10763. }
  10764. if (options.maxAngle) {
  10765. this.maxAngle = options.maxAngle;
  10766. }
  10767. if (options.slerpAmount) {
  10768. this.slerpAmount = options.slerpAmount;
  10769. }
  10770. }
  10771. }
  10772. Object.defineProperty(BoneIKController.prototype, "maxAngle", {
  10773. /**
  10774. * Gets or sets maximum allowed angle
  10775. */
  10776. get: function () {
  10777. return this._maxAngle;
  10778. },
  10779. set: function (value) {
  10780. this._setMaxAngle(value);
  10781. },
  10782. enumerable: true,
  10783. configurable: true
  10784. });
  10785. BoneIKController.prototype._setMaxAngle = function (ang) {
  10786. if (ang < 0) {
  10787. ang = 0;
  10788. }
  10789. if (ang > Math.PI || ang == undefined) {
  10790. ang = Math.PI;
  10791. }
  10792. this._maxAngle = ang;
  10793. var a = this._bone1Length;
  10794. var b = this._bone2Length;
  10795. this._maxReach = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(ang));
  10796. };
  10797. /**
  10798. * Force the controller to update the bones
  10799. */
  10800. BoneIKController.prototype.update = function () {
  10801. var bone1 = this._bone1;
  10802. if (!bone1) {
  10803. return;
  10804. }
  10805. var target = this.targetPosition;
  10806. var poleTarget = this.poleTargetPosition;
  10807. var mat1 = BoneIKController._tmpMats[0];
  10808. var mat2 = BoneIKController._tmpMats[1];
  10809. if (this.targetMesh) {
  10810. target.copyFrom(this.targetMesh.getAbsolutePosition());
  10811. }
  10812. if (this.poleTargetBone) {
  10813. this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset, this.mesh, poleTarget);
  10814. }
  10815. else if (this.poleTargetMesh) {
  10816. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this.poleTargetLocalOffset, this.poleTargetMesh.getWorldMatrix(), poleTarget);
  10817. }
  10818. var bonePos = BoneIKController._tmpVecs[0];
  10819. var zaxis = BoneIKController._tmpVecs[1];
  10820. var xaxis = BoneIKController._tmpVecs[2];
  10821. var yaxis = BoneIKController._tmpVecs[3];
  10822. var upAxis = BoneIKController._tmpVecs[4];
  10823. var _tmpQuat = BoneIKController._tmpQuat;
  10824. bone1.getAbsolutePositionToRef(this.mesh, bonePos);
  10825. poleTarget.subtractToRef(bonePos, upAxis);
  10826. if (upAxis.x == 0 && upAxis.y == 0 && upAxis.z == 0) {
  10827. upAxis.y = 1;
  10828. }
  10829. else {
  10830. upAxis.normalize();
  10831. }
  10832. target.subtractToRef(bonePos, yaxis);
  10833. yaxis.normalize();
  10834. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, upAxis, zaxis);
  10835. zaxis.normalize();
  10836. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, zaxis, xaxis);
  10837. xaxis.normalize();
  10838. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, mat1);
  10839. var a = this._bone1Length;
  10840. var b = this._bone2Length;
  10841. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(bonePos, target);
  10842. if (this._maxReach > 0) {
  10843. c = Math.min(this._maxReach, c);
  10844. }
  10845. var acosa = (b * b + c * c - a * a) / (2 * b * c);
  10846. var acosb = (c * c + a * a - b * b) / (2 * c * a);
  10847. if (acosa > 1) {
  10848. acosa = 1;
  10849. }
  10850. if (acosb > 1) {
  10851. acosb = 1;
  10852. }
  10853. if (acosa < -1) {
  10854. acosa = -1;
  10855. }
  10856. if (acosb < -1) {
  10857. acosb = -1;
  10858. }
  10859. var angA = Math.acos(acosa);
  10860. var angB = Math.acos(acosb);
  10861. var angC = -angA - angB;
  10862. if (this._rightHandedSystem) {
  10863. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationYawPitchRollToRef(0, 0, this._adjustRoll, mat2);
  10864. mat2.multiplyToRef(mat1, mat1);
  10865. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(this._bendAxis, angB, mat2);
  10866. mat2.multiplyToRef(mat1, mat1);
  10867. }
  10868. else {
  10869. var _tmpVec = BoneIKController._tmpVecs[5];
  10870. _tmpVec.copyFrom(this._bendAxis);
  10871. _tmpVec.x *= -1;
  10872. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(_tmpVec, -angB, mat2);
  10873. mat2.multiplyToRef(mat1, mat1);
  10874. }
  10875. if (this.poleAngle) {
  10876. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(yaxis, this.poleAngle, mat2);
  10877. mat1.multiplyToRef(mat2, mat1);
  10878. }
  10879. if (this._bone1) {
  10880. if (this.slerpAmount < 1) {
  10881. if (!this._slerping) {
  10882. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._bone1Mat, this._bone1Quat);
  10883. }
  10884. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(mat1, _tmpQuat);
  10885. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].SlerpToRef(this._bone1Quat, _tmpQuat, this.slerpAmount, this._bone1Quat);
  10886. angC = this._bone2Ang * (1.0 - this.slerpAmount) + angC * this.slerpAmount;
  10887. this._bone1.setRotationQuaternion(this._bone1Quat, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10888. this._slerping = true;
  10889. }
  10890. else {
  10891. this._bone1.setRotationMatrix(mat1, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10892. this._bone1Mat.copyFrom(mat1);
  10893. this._slerping = false;
  10894. }
  10895. }
  10896. this._bone2.setAxisAngle(this._bendAxis, angC, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].LOCAL);
  10897. this._bone2Ang = angC;
  10898. };
  10899. 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()];
  10900. BoneIKController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10901. BoneIKController._tmpMats = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity()];
  10902. return BoneIKController;
  10903. }());
  10904. /***/ }),
  10905. /***/ "./Bones/boneLookController.ts":
  10906. /*!*************************************!*\
  10907. !*** ./Bones/boneLookController.ts ***!
  10908. \*************************************/
  10909. /*! exports provided: BoneLookController */
  10910. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10911. "use strict";
  10912. __webpack_require__.r(__webpack_exports__);
  10913. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return BoneLookController; });
  10914. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  10915. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10916. /**
  10917. * Class used to make a bone look toward a point in space
  10918. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  10919. */
  10920. var BoneLookController = /** @class */ (function () {
  10921. /**
  10922. * Create a BoneLookController
  10923. * @param mesh the mesh that the bone belongs to
  10924. * @param bone the bone that will be looking to the target
  10925. * @param target the target Vector3 to look at
  10926. * @param options optional settings:
  10927. * * maxYaw: the maximum angle the bone will yaw to
  10928. * * minYaw: the minimum angle the bone will yaw to
  10929. * * maxPitch: the maximum angle the bone will pitch to
  10930. * * minPitch: the minimum angle the bone will yaw to
  10931. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  10932. * * upAxis: the up axis of the coordinate system
  10933. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  10934. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  10935. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  10936. * * adjustYaw: used to make an adjustment to the yaw of the bone
  10937. * * adjustPitch: used to make an adjustment to the pitch of the bone
  10938. * * adjustRoll: used to make an adjustment to the roll of the bone
  10939. **/
  10940. function BoneLookController(mesh, bone, target, options) {
  10941. /**
  10942. * The up axis of the coordinate system that is used when the bone is rotated
  10943. */
  10944. this.upAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up();
  10945. /**
  10946. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  10947. */
  10948. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  10949. /**
  10950. * Used to make an adjustment to the yaw of the bone
  10951. */
  10952. this.adjustYaw = 0;
  10953. /**
  10954. * Used to make an adjustment to the pitch of the bone
  10955. */
  10956. this.adjustPitch = 0;
  10957. /**
  10958. * Used to make an adjustment to the roll of the bone
  10959. */
  10960. this.adjustRoll = 0;
  10961. /**
  10962. * 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)
  10963. */
  10964. this.slerpAmount = 1;
  10965. this._boneQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10966. this._slerping = false;
  10967. this._firstFrameSkipped = false;
  10968. this._fowardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Forward();
  10969. this.mesh = mesh;
  10970. this.bone = bone;
  10971. this.target = target;
  10972. if (options) {
  10973. if (options.adjustYaw) {
  10974. this.adjustYaw = options.adjustYaw;
  10975. }
  10976. if (options.adjustPitch) {
  10977. this.adjustPitch = options.adjustPitch;
  10978. }
  10979. if (options.adjustRoll) {
  10980. this.adjustRoll = options.adjustRoll;
  10981. }
  10982. if (options.maxYaw != null) {
  10983. this.maxYaw = options.maxYaw;
  10984. }
  10985. else {
  10986. this.maxYaw = Math.PI;
  10987. }
  10988. if (options.minYaw != null) {
  10989. this.minYaw = options.minYaw;
  10990. }
  10991. else {
  10992. this.minYaw = -Math.PI;
  10993. }
  10994. if (options.maxPitch != null) {
  10995. this.maxPitch = options.maxPitch;
  10996. }
  10997. else {
  10998. this.maxPitch = Math.PI;
  10999. }
  11000. if (options.minPitch != null) {
  11001. this.minPitch = options.minPitch;
  11002. }
  11003. else {
  11004. this.minPitch = -Math.PI;
  11005. }
  11006. if (options.slerpAmount != null) {
  11007. this.slerpAmount = options.slerpAmount;
  11008. }
  11009. if (options.upAxis != null) {
  11010. this.upAxis = options.upAxis;
  11011. }
  11012. if (options.upAxisSpace != null) {
  11013. this.upAxisSpace = options.upAxisSpace;
  11014. }
  11015. if (options.yawAxis != null || options.pitchAxis != null) {
  11016. var newYawAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y;
  11017. var newPitchAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].X;
  11018. if (options.yawAxis != null) {
  11019. newYawAxis = options.yawAxis.clone();
  11020. newYawAxis.normalize();
  11021. }
  11022. if (options.pitchAxis != null) {
  11023. newPitchAxis = options.pitchAxis.clone();
  11024. newPitchAxis.normalize();
  11025. }
  11026. var newRollAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(newPitchAxis, newYawAxis);
  11027. this._transformYawPitch = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  11028. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(newPitchAxis, newYawAxis, newRollAxis, this._transformYawPitch);
  11029. this._transformYawPitchInv = this._transformYawPitch.clone();
  11030. this._transformYawPitch.invert();
  11031. }
  11032. }
  11033. if (!bone.getParent() && this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE) {
  11034. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  11035. }
  11036. }
  11037. Object.defineProperty(BoneLookController.prototype, "minYaw", {
  11038. /**
  11039. * Gets or sets the minimum yaw angle that the bone can look to
  11040. */
  11041. get: function () {
  11042. return this._minYaw;
  11043. },
  11044. set: function (value) {
  11045. this._minYaw = value;
  11046. this._minYawSin = Math.sin(value);
  11047. this._minYawCos = Math.cos(value);
  11048. if (this._maxYaw != null) {
  11049. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11050. this._yawRange = this._maxYaw - this._minYaw;
  11051. }
  11052. },
  11053. enumerable: true,
  11054. configurable: true
  11055. });
  11056. Object.defineProperty(BoneLookController.prototype, "maxYaw", {
  11057. /**
  11058. * Gets or sets the maximum yaw angle that the bone can look to
  11059. */
  11060. get: function () {
  11061. return this._maxYaw;
  11062. },
  11063. set: function (value) {
  11064. this._maxYaw = value;
  11065. this._maxYawSin = Math.sin(value);
  11066. this._maxYawCos = Math.cos(value);
  11067. if (this._minYaw != null) {
  11068. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11069. this._yawRange = this._maxYaw - this._minYaw;
  11070. }
  11071. },
  11072. enumerable: true,
  11073. configurable: true
  11074. });
  11075. Object.defineProperty(BoneLookController.prototype, "minPitch", {
  11076. /**
  11077. * Gets or sets the minimum pitch angle that the bone can look to
  11078. */
  11079. get: function () {
  11080. return this._minPitch;
  11081. },
  11082. set: function (value) {
  11083. this._minPitch = value;
  11084. this._minPitchTan = Math.tan(value);
  11085. },
  11086. enumerable: true,
  11087. configurable: true
  11088. });
  11089. Object.defineProperty(BoneLookController.prototype, "maxPitch", {
  11090. /**
  11091. * Gets or sets the maximum pitch angle that the bone can look to
  11092. */
  11093. get: function () {
  11094. return this._maxPitch;
  11095. },
  11096. set: function (value) {
  11097. this._maxPitch = value;
  11098. this._maxPitchTan = Math.tan(value);
  11099. },
  11100. enumerable: true,
  11101. configurable: true
  11102. });
  11103. /**
  11104. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  11105. */
  11106. BoneLookController.prototype.update = function () {
  11107. //skip the first frame when slerping so that the mesh rotation is correct
  11108. if (this.slerpAmount < 1 && !this._firstFrameSkipped) {
  11109. this._firstFrameSkipped = true;
  11110. return;
  11111. }
  11112. var bone = this.bone;
  11113. var bonePos = BoneLookController._tmpVecs[0];
  11114. bone.getAbsolutePositionToRef(this.mesh, bonePos);
  11115. var target = this.target;
  11116. var _tmpMat1 = BoneLookController._tmpMats[0];
  11117. var _tmpMat2 = BoneLookController._tmpMats[1];
  11118. var mesh = this.mesh;
  11119. var parentBone = bone.getParent();
  11120. var upAxis = BoneLookController._tmpVecs[1];
  11121. upAxis.copyFrom(this.upAxis);
  11122. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && parentBone) {
  11123. if (this._transformYawPitch) {
  11124. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(upAxis, this._transformYawPitchInv, upAxis);
  11125. }
  11126. parentBone.getDirectionToRef(upAxis, this.mesh, upAxis);
  11127. }
  11128. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  11129. mesh.getDirectionToRef(upAxis, upAxis);
  11130. if (mesh.scaling.x != 1 || mesh.scaling.y != 1 || mesh.scaling.z != 1) {
  11131. upAxis.normalize();
  11132. }
  11133. }
  11134. var checkYaw = false;
  11135. var checkPitch = false;
  11136. if (this._maxYaw != Math.PI || this._minYaw != -Math.PI) {
  11137. checkYaw = true;
  11138. }
  11139. if (this._maxPitch != Math.PI || this._minPitch != -Math.PI) {
  11140. checkPitch = true;
  11141. }
  11142. if (checkYaw || checkPitch) {
  11143. var spaceMat = BoneLookController._tmpMats[2];
  11144. var spaceMatInv = BoneLookController._tmpMats[3];
  11145. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && upAxis.y == 1 && parentBone) {
  11146. parentBone.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, spaceMat);
  11147. }
  11148. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL && upAxis.y == 1 && !parentBone) {
  11149. spaceMat.copyFrom(mesh.getWorldMatrix());
  11150. }
  11151. else {
  11152. var forwardAxis = BoneLookController._tmpVecs[2];
  11153. forwardAxis.copyFrom(this._fowardAxis);
  11154. if (this._transformYawPitch) {
  11155. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(forwardAxis, this._transformYawPitchInv, forwardAxis);
  11156. }
  11157. if (parentBone) {
  11158. parentBone.getDirectionToRef(forwardAxis, this.mesh, forwardAxis);
  11159. }
  11160. else {
  11161. mesh.getDirectionToRef(forwardAxis, forwardAxis);
  11162. }
  11163. var rightAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(upAxis, forwardAxis);
  11164. rightAxis.normalize();
  11165. var forwardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(rightAxis, upAxis);
  11166. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(rightAxis, upAxis, forwardAxis, spaceMat);
  11167. }
  11168. spaceMat.invertToRef(spaceMatInv);
  11169. var xzlen = null;
  11170. if (checkPitch) {
  11171. var localTarget = BoneLookController._tmpVecs[3];
  11172. target.subtractToRef(bonePos, localTarget);
  11173. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11174. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11175. var pitch = Math.atan2(localTarget.y, xzlen);
  11176. var newPitch = pitch;
  11177. if (pitch > this._maxPitch) {
  11178. localTarget.y = this._maxPitchTan * xzlen;
  11179. newPitch = this._maxPitch;
  11180. }
  11181. else if (pitch < this._minPitch) {
  11182. localTarget.y = this._minPitchTan * xzlen;
  11183. newPitch = this._minPitch;
  11184. }
  11185. if (pitch != newPitch) {
  11186. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11187. localTarget.addInPlace(bonePos);
  11188. target = localTarget;
  11189. }
  11190. }
  11191. if (checkYaw) {
  11192. var localTarget = BoneLookController._tmpVecs[4];
  11193. target.subtractToRef(bonePos, localTarget);
  11194. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11195. var yaw = Math.atan2(localTarget.x, localTarget.z);
  11196. var newYaw = yaw;
  11197. if (yaw > this._maxYaw || yaw < this._minYaw) {
  11198. if (xzlen == null) {
  11199. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11200. }
  11201. if (this._yawRange > Math.PI) {
  11202. if (this._isAngleBetween(yaw, this._maxYaw, this._midYawConstraint)) {
  11203. localTarget.z = this._maxYawCos * xzlen;
  11204. localTarget.x = this._maxYawSin * xzlen;
  11205. newYaw = this._maxYaw;
  11206. }
  11207. else if (this._isAngleBetween(yaw, this._midYawConstraint, this._minYaw)) {
  11208. localTarget.z = this._minYawCos * xzlen;
  11209. localTarget.x = this._minYawSin * xzlen;
  11210. newYaw = this._minYaw;
  11211. }
  11212. }
  11213. else {
  11214. if (yaw > this._maxYaw) {
  11215. localTarget.z = this._maxYawCos * xzlen;
  11216. localTarget.x = this._maxYawSin * xzlen;
  11217. newYaw = this._maxYaw;
  11218. }
  11219. else if (yaw < this._minYaw) {
  11220. localTarget.z = this._minYawCos * xzlen;
  11221. localTarget.x = this._minYawSin * xzlen;
  11222. newYaw = this._minYaw;
  11223. }
  11224. }
  11225. }
  11226. if (this._slerping && this._yawRange > Math.PI) {
  11227. //are we going to be crossing into the min/max region?
  11228. var boneFwd = BoneLookController._tmpVecs[8];
  11229. boneFwd.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Z);
  11230. if (this._transformYawPitch) {
  11231. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, this._transformYawPitchInv, boneFwd);
  11232. }
  11233. var boneRotMat = BoneLookController._tmpMats[4];
  11234. this._boneQuat.toRotationMatrix(boneRotMat);
  11235. this.mesh.getWorldMatrix().multiplyToRef(boneRotMat, boneRotMat);
  11236. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, boneRotMat, boneFwd);
  11237. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, spaceMatInv, boneFwd);
  11238. var boneYaw = Math.atan2(boneFwd.x, boneFwd.z);
  11239. var angBtwTar = this._getAngleBetween(boneYaw, yaw);
  11240. var angBtwMidYaw = this._getAngleBetween(boneYaw, this._midYawConstraint);
  11241. if (angBtwTar > angBtwMidYaw) {
  11242. if (xzlen == null) {
  11243. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11244. }
  11245. var angBtwMax = this._getAngleBetween(boneYaw, this._maxYaw);
  11246. var angBtwMin = this._getAngleBetween(boneYaw, this._minYaw);
  11247. if (angBtwMin < angBtwMax) {
  11248. newYaw = boneYaw + Math.PI * .75;
  11249. localTarget.z = Math.cos(newYaw) * xzlen;
  11250. localTarget.x = Math.sin(newYaw) * xzlen;
  11251. }
  11252. else {
  11253. newYaw = boneYaw - Math.PI * .75;
  11254. localTarget.z = Math.cos(newYaw) * xzlen;
  11255. localTarget.x = Math.sin(newYaw) * xzlen;
  11256. }
  11257. }
  11258. }
  11259. if (yaw != newYaw) {
  11260. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11261. localTarget.addInPlace(bonePos);
  11262. target = localTarget;
  11263. }
  11264. }
  11265. }
  11266. var zaxis = BoneLookController._tmpVecs[5];
  11267. var xaxis = BoneLookController._tmpVecs[6];
  11268. var yaxis = BoneLookController._tmpVecs[7];
  11269. var _tmpQuat = BoneLookController._tmpQuat;
  11270. target.subtractToRef(bonePos, zaxis);
  11271. zaxis.normalize();
  11272. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(upAxis, zaxis, xaxis);
  11273. xaxis.normalize();
  11274. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(zaxis, xaxis, yaxis);
  11275. yaxis.normalize();
  11276. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, _tmpMat1);
  11277. if (xaxis.x === 0 && xaxis.y === 0 && xaxis.z === 0) {
  11278. return;
  11279. }
  11280. if (yaxis.x === 0 && yaxis.y === 0 && yaxis.z === 0) {
  11281. return;
  11282. }
  11283. if (zaxis.x === 0 && zaxis.y === 0 && zaxis.z === 0) {
  11284. return;
  11285. }
  11286. if (this.adjustYaw || this.adjustPitch || this.adjustRoll) {
  11287. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(this.adjustYaw, this.adjustPitch, this.adjustRoll, _tmpMat2);
  11288. _tmpMat2.multiplyToRef(_tmpMat1, _tmpMat1);
  11289. }
  11290. if (this.slerpAmount < 1) {
  11291. if (!this._slerping) {
  11292. this.bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, this._boneQuat);
  11293. }
  11294. if (this._transformYawPitch) {
  11295. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11296. }
  11297. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(_tmpMat1, _tmpQuat);
  11298. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].SlerpToRef(this._boneQuat, _tmpQuat, this.slerpAmount, this._boneQuat);
  11299. this.bone.setRotationQuaternion(this._boneQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11300. this._slerping = true;
  11301. }
  11302. else {
  11303. if (this._transformYawPitch) {
  11304. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11305. }
  11306. this.bone.setRotationMatrix(_tmpMat1, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11307. this._slerping = false;
  11308. }
  11309. };
  11310. BoneLookController.prototype._getAngleDiff = function (ang1, ang2) {
  11311. var angDiff = ang2 - ang1;
  11312. angDiff %= Math.PI * 2;
  11313. if (angDiff > Math.PI) {
  11314. angDiff -= Math.PI * 2;
  11315. }
  11316. else if (angDiff < -Math.PI) {
  11317. angDiff += Math.PI * 2;
  11318. }
  11319. return angDiff;
  11320. };
  11321. BoneLookController.prototype._getAngleBetween = function (ang1, ang2) {
  11322. ang1 %= (2 * Math.PI);
  11323. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11324. ang2 %= (2 * Math.PI);
  11325. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11326. var ab = 0;
  11327. if (ang1 < ang2) {
  11328. ab = ang2 - ang1;
  11329. }
  11330. else {
  11331. ab = ang1 - ang2;
  11332. }
  11333. if (ab > Math.PI) {
  11334. ab = Math.PI * 2 - ab;
  11335. }
  11336. return ab;
  11337. };
  11338. BoneLookController.prototype._isAngleBetween = function (ang, ang1, ang2) {
  11339. ang %= (2 * Math.PI);
  11340. ang = (ang < 0) ? ang + (2 * Math.PI) : ang;
  11341. ang1 %= (2 * Math.PI);
  11342. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11343. ang2 %= (2 * Math.PI);
  11344. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11345. if (ang1 < ang2) {
  11346. if (ang > ang1 && ang < ang2) {
  11347. return true;
  11348. }
  11349. }
  11350. else {
  11351. if (ang > ang2 && ang < ang1) {
  11352. return true;
  11353. }
  11354. }
  11355. return false;
  11356. };
  11357. BoneLookController._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(10, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  11358. BoneLookController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  11359. BoneLookController._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  11360. return BoneLookController;
  11361. }());
  11362. /***/ }),
  11363. /***/ "./Bones/index.ts":
  11364. /*!************************!*\
  11365. !*** ./Bones/index.ts ***!
  11366. \************************/
  11367. /*! exports provided: Bone, BoneIKController, BoneLookController, Skeleton */
  11368. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11369. "use strict";
  11370. __webpack_require__.r(__webpack_exports__);
  11371. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  11373. /* harmony import */ var _boneIKController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneIKController */ "./Bones/boneIKController.ts");
  11374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _boneIKController__WEBPACK_IMPORTED_MODULE_1__["BoneIKController"]; });
  11375. /* harmony import */ var _boneLookController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boneLookController */ "./Bones/boneLookController.ts");
  11376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _boneLookController__WEBPACK_IMPORTED_MODULE_2__["BoneLookController"]; });
  11377. /* harmony import */ var _skeleton__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./skeleton */ "./Bones/skeleton.ts");
  11378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _skeleton__WEBPACK_IMPORTED_MODULE_3__["Skeleton"]; });
  11379. /***/ }),
  11380. /***/ "./Bones/skeleton.ts":
  11381. /*!***************************!*\
  11382. !*** ./Bones/skeleton.ts ***!
  11383. \***************************/
  11384. /*! exports provided: Skeleton */
  11385. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11386. "use strict";
  11387. __webpack_require__.r(__webpack_exports__);
  11388. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return Skeleton; });
  11389. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11390. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  11391. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  11392. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  11393. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  11394. /* harmony import */ var _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animationRange */ "./Animations/animationRange.ts");
  11395. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  11396. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  11397. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  11398. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  11399. /**
  11400. * Class used to handle skinning animations
  11401. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  11402. */
  11403. var Skeleton = /** @class */ (function () {
  11404. /**
  11405. * Creates a new skeleton
  11406. * @param name defines the skeleton name
  11407. * @param id defines the skeleton Id
  11408. * @param scene defines the hosting scene
  11409. */
  11410. function Skeleton(
  11411. /** defines the skeleton name */
  11412. name,
  11413. /** defines the skeleton Id */
  11414. id, scene) {
  11415. this.name = name;
  11416. this.id = id;
  11417. /**
  11418. * Defines the list of child bones
  11419. */
  11420. this.bones = new Array();
  11421. /**
  11422. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  11423. */
  11424. this.needInitialSkinMatrix = false;
  11425. /**
  11426. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  11427. */
  11428. this.overrideMesh = null;
  11429. this._isDirty = true;
  11430. this._meshesWithPoseMatrix = new Array();
  11431. this._identity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  11432. this._ranges = {};
  11433. this._lastAbsoluteTransformsUpdateId = -1;
  11434. this._canUseTextureForBones = false;
  11435. /** @hidden */
  11436. this._numBonesWithLinkedTransformNode = 0;
  11437. /**
  11438. * Specifies if the skeleton should be serialized
  11439. */
  11440. this.doNotSerialize = false;
  11441. /**
  11442. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  11443. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  11444. */
  11445. this.useTextureToStoreBoneMatrices = true;
  11446. this._animationPropertiesOverride = null;
  11447. // Events
  11448. /**
  11449. * An observable triggered before computing the skeleton's matrices
  11450. */
  11451. this.onBeforeComputeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11452. this.bones = [];
  11453. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  11454. this._scene.skeletons.push(this);
  11455. //make sure it will recalculate the matrix next time prepare is called.
  11456. this._isDirty = true;
  11457. var engineCaps = this._scene.getEngine().getCaps();
  11458. this._canUseTextureForBones = engineCaps.textureFloat && engineCaps.maxVertexTextureImageUnits > 0;
  11459. }
  11460. Object.defineProperty(Skeleton.prototype, "animationPropertiesOverride", {
  11461. /**
  11462. * Gets or sets the animation properties override
  11463. */
  11464. get: function () {
  11465. if (!this._animationPropertiesOverride) {
  11466. return this._scene.animationPropertiesOverride;
  11467. }
  11468. return this._animationPropertiesOverride;
  11469. },
  11470. set: function (value) {
  11471. this._animationPropertiesOverride = value;
  11472. },
  11473. enumerable: true,
  11474. configurable: true
  11475. });
  11476. Object.defineProperty(Skeleton.prototype, "isUsingTextureForMatrices", {
  11477. /**
  11478. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  11479. */
  11480. get: function () {
  11481. return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones && !this.needInitialSkinMatrix;
  11482. },
  11483. enumerable: true,
  11484. configurable: true
  11485. });
  11486. // Members
  11487. /**
  11488. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  11489. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  11490. * @returns a Float32Array containing matrices data
  11491. */
  11492. Skeleton.prototype.getTransformMatrices = function (mesh) {
  11493. if (this.needInitialSkinMatrix && mesh._bonesTransformMatrices) {
  11494. return mesh._bonesTransformMatrices;
  11495. }
  11496. if (!this._transformMatrices) {
  11497. this.prepare();
  11498. }
  11499. return this._transformMatrices;
  11500. };
  11501. /**
  11502. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  11503. * @returns a raw texture containing the data
  11504. */
  11505. Skeleton.prototype.getTransformMatrixTexture = function () {
  11506. return this._transformMatrixTexture;
  11507. };
  11508. /**
  11509. * Gets the current hosting scene
  11510. * @returns a scene object
  11511. */
  11512. Skeleton.prototype.getScene = function () {
  11513. return this._scene;
  11514. };
  11515. // Methods
  11516. /**
  11517. * Gets a string representing the current skeleton data
  11518. * @param fullDetails defines a boolean indicating if we want a verbose version
  11519. * @returns a string representing the current skeleton data
  11520. */
  11521. Skeleton.prototype.toString = function (fullDetails) {
  11522. var ret = "Name: " + this.name + ", nBones: " + this.bones.length;
  11523. ret += ", nAnimationRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  11524. if (fullDetails) {
  11525. ret += ", Ranges: {";
  11526. var first = true;
  11527. for (var name_1 in this._ranges) {
  11528. if (first) {
  11529. ret += ", ";
  11530. first = false;
  11531. }
  11532. ret += name_1;
  11533. }
  11534. ret += "}";
  11535. }
  11536. return ret;
  11537. };
  11538. /**
  11539. * Get bone's index searching by name
  11540. * @param name defines bone's name to search for
  11541. * @return the indice of the bone. Returns -1 if not found
  11542. */
  11543. Skeleton.prototype.getBoneIndexByName = function (name) {
  11544. for (var boneIndex = 0, cache = this.bones.length; boneIndex < cache; boneIndex++) {
  11545. if (this.bones[boneIndex].name === name) {
  11546. return boneIndex;
  11547. }
  11548. }
  11549. return -1;
  11550. };
  11551. /**
  11552. * Creater a new animation range
  11553. * @param name defines the name of the range
  11554. * @param from defines the start key
  11555. * @param to defines the end key
  11556. */
  11557. Skeleton.prototype.createAnimationRange = function (name, from, to) {
  11558. // check name not already in use
  11559. if (!this._ranges[name]) {
  11560. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  11561. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11562. if (this.bones[i].animations[0]) {
  11563. this.bones[i].animations[0].createRange(name, from, to);
  11564. }
  11565. }
  11566. }
  11567. };
  11568. /**
  11569. * Delete a specific animation range
  11570. * @param name defines the name of the range
  11571. * @param deleteFrames defines if frames must be removed as well
  11572. */
  11573. Skeleton.prototype.deleteAnimationRange = function (name, deleteFrames) {
  11574. if (deleteFrames === void 0) { deleteFrames = true; }
  11575. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11576. if (this.bones[i].animations[0]) {
  11577. this.bones[i].animations[0].deleteRange(name, deleteFrames);
  11578. }
  11579. }
  11580. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  11581. };
  11582. /**
  11583. * Gets a specific animation range
  11584. * @param name defines the name of the range to look for
  11585. * @returns the requested animation range or null if not found
  11586. */
  11587. Skeleton.prototype.getAnimationRange = function (name) {
  11588. return this._ranges[name];
  11589. };
  11590. /**
  11591. * Gets the list of all animation ranges defined on this skeleton
  11592. * @returns an array
  11593. */
  11594. Skeleton.prototype.getAnimationRanges = function () {
  11595. var animationRanges = [];
  11596. var name;
  11597. var i = 0;
  11598. for (name in this._ranges) {
  11599. animationRanges[i] = this._ranges[name];
  11600. i++;
  11601. }
  11602. return animationRanges;
  11603. };
  11604. /**
  11605. * Copy animation range from a source skeleton.
  11606. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  11607. * @param source defines the source skeleton
  11608. * @param name defines the name of the range to copy
  11609. * @param rescaleAsRequired defines if rescaling must be applied if required
  11610. * @returns true if operation was successful
  11611. */
  11612. Skeleton.prototype.copyAnimationRange = function (source, name, rescaleAsRequired) {
  11613. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  11614. if (this._ranges[name] || !source.getAnimationRange(name)) {
  11615. return false;
  11616. }
  11617. var ret = true;
  11618. var frameOffset = this._getHighestAnimationFrame() + 1;
  11619. // make a dictionary of source skeleton's bones, so exact same order or doublely nested loop is not required
  11620. var boneDict = {};
  11621. var sourceBones = source.bones;
  11622. var nBones;
  11623. var i;
  11624. for (i = 0, nBones = sourceBones.length; i < nBones; i++) {
  11625. boneDict[sourceBones[i].name] = sourceBones[i];
  11626. }
  11627. if (this.bones.length !== sourceBones.length) {
  11628. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: this rig has " + this.bones.length + " bones, while source as " + sourceBones.length);
  11629. ret = false;
  11630. }
  11631. var skelDimensionsRatio = (rescaleAsRequired && this.dimensionsAtRest && source.dimensionsAtRest) ? this.dimensionsAtRest.divide(source.dimensionsAtRest) : null;
  11632. for (i = 0, nBones = this.bones.length; i < nBones; i++) {
  11633. var boneName = this.bones[i].name;
  11634. var sourceBone = boneDict[boneName];
  11635. if (sourceBone) {
  11636. ret = ret && this.bones[i].copyAnimationRange(sourceBone, name, frameOffset, rescaleAsRequired, skelDimensionsRatio);
  11637. }
  11638. else {
  11639. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: not same rig, missing source bone " + boneName);
  11640. ret = false;
  11641. }
  11642. }
  11643. // do not call createAnimationRange(), since it also is done to bones, which was already done
  11644. var range = source.getAnimationRange(name);
  11645. if (range) {
  11646. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, range.from + frameOffset, range.to + frameOffset);
  11647. }
  11648. return ret;
  11649. };
  11650. /**
  11651. * Forces the skeleton to go to rest pose
  11652. */
  11653. Skeleton.prototype.returnToRest = function () {
  11654. for (var index = 0; index < this.bones.length; index++) {
  11655. this.bones[index].returnToRest();
  11656. }
  11657. };
  11658. Skeleton.prototype._getHighestAnimationFrame = function () {
  11659. var ret = 0;
  11660. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11661. if (this.bones[i].animations[0]) {
  11662. var highest = this.bones[i].animations[0].getHighestFrame();
  11663. if (ret < highest) {
  11664. ret = highest;
  11665. }
  11666. }
  11667. }
  11668. return ret;
  11669. };
  11670. /**
  11671. * Begin a specific animation range
  11672. * @param name defines the name of the range to start
  11673. * @param loop defines if looping must be turned on (false by default)
  11674. * @param speedRatio defines the speed ratio to apply (1 by default)
  11675. * @param onAnimationEnd defines a callback which will be called when animation will end
  11676. * @returns a new animatable
  11677. */
  11678. Skeleton.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  11679. var range = this.getAnimationRange(name);
  11680. if (!range) {
  11681. return null;
  11682. }
  11683. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  11684. };
  11685. /** @hidden */
  11686. Skeleton.prototype._markAsDirty = function () {
  11687. this._isDirty = true;
  11688. };
  11689. /** @hidden */
  11690. Skeleton.prototype._registerMeshWithPoseMatrix = function (mesh) {
  11691. this._meshesWithPoseMatrix.push(mesh);
  11692. };
  11693. /** @hidden */
  11694. Skeleton.prototype._unregisterMeshWithPoseMatrix = function (mesh) {
  11695. var index = this._meshesWithPoseMatrix.indexOf(mesh);
  11696. if (index > -1) {
  11697. this._meshesWithPoseMatrix.splice(index, 1);
  11698. }
  11699. };
  11700. Skeleton.prototype._computeTransformMatrices = function (targetMatrix, initialSkinMatrix) {
  11701. this.onBeforeComputeObservable.notifyObservers(this);
  11702. for (var index = 0; index < this.bones.length; index++) {
  11703. var bone = this.bones[index];
  11704. var parentBone = bone.getParent();
  11705. if (parentBone) {
  11706. bone.getLocalMatrix().multiplyToRef(parentBone.getWorldMatrix(), bone.getWorldMatrix());
  11707. }
  11708. else {
  11709. if (initialSkinMatrix) {
  11710. bone.getLocalMatrix().multiplyToRef(initialSkinMatrix, bone.getWorldMatrix());
  11711. }
  11712. else {
  11713. bone.getWorldMatrix().copyFrom(bone.getLocalMatrix());
  11714. }
  11715. }
  11716. if (bone._index !== -1) {
  11717. var mappedIndex = bone._index === null ? index : bone._index;
  11718. bone.getInvertedAbsoluteTransform().multiplyToArray(bone.getWorldMatrix(), targetMatrix, mappedIndex * 16);
  11719. }
  11720. }
  11721. this._identity.copyToArray(targetMatrix, this.bones.length * 16);
  11722. };
  11723. /**
  11724. * Build all resources required to render a skeleton
  11725. */
  11726. Skeleton.prototype.prepare = function () {
  11727. // Update the local matrix of bones with linked transform nodes.
  11728. if (this._numBonesWithLinkedTransformNode > 0) {
  11729. for (var _i = 0, _a = this.bones; _i < _a.length; _i++) {
  11730. var bone_1 = _a[_i];
  11731. if (bone_1._linkedTransformNode) {
  11732. // Computing the world matrix also computes the local matrix.
  11733. bone_1._linkedTransformNode.computeWorldMatrix();
  11734. bone_1._matrix = bone_1._linkedTransformNode._localMatrix;
  11735. bone_1.markAsDirty();
  11736. }
  11737. }
  11738. }
  11739. if (!this._isDirty) {
  11740. return;
  11741. }
  11742. if (this.needInitialSkinMatrix) {
  11743. for (var index = 0; index < this._meshesWithPoseMatrix.length; index++) {
  11744. var mesh = this._meshesWithPoseMatrix[index];
  11745. var poseMatrix = mesh.getPoseMatrix();
  11746. if (!mesh._bonesTransformMatrices || mesh._bonesTransformMatrices.length !== 16 * (this.bones.length + 1)) {
  11747. mesh._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11748. }
  11749. if (this._synchronizedWithMesh !== mesh) {
  11750. this._synchronizedWithMesh = mesh;
  11751. // Prepare bones
  11752. for (var boneIndex = 0; boneIndex < this.bones.length; boneIndex++) {
  11753. var bone = this.bones[boneIndex];
  11754. if (!bone.getParent()) {
  11755. var matrix = bone.getBaseMatrix();
  11756. matrix.multiplyToRef(poseMatrix, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11757. bone._updateDifferenceMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11758. }
  11759. }
  11760. }
  11761. this._computeTransformMatrices(mesh._bonesTransformMatrices, poseMatrix);
  11762. }
  11763. }
  11764. else {
  11765. if (!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) {
  11766. this._transformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11767. if (this.isUsingTextureForMatrices) {
  11768. if (this._transformMatrixTexture) {
  11769. this._transformMatrixTexture.dispose();
  11770. }
  11771. 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);
  11772. }
  11773. }
  11774. this._computeTransformMatrices(this._transformMatrices, null);
  11775. if (this.isUsingTextureForMatrices && this._transformMatrixTexture) {
  11776. this._transformMatrixTexture.update(this._transformMatrices);
  11777. }
  11778. }
  11779. this._isDirty = false;
  11780. this._scene._activeBones.addCount(this.bones.length, false);
  11781. };
  11782. /**
  11783. * Gets the list of animatables currently running for this skeleton
  11784. * @returns an array of animatables
  11785. */
  11786. Skeleton.prototype.getAnimatables = function () {
  11787. if (!this._animatables || this._animatables.length !== this.bones.length) {
  11788. this._animatables = [];
  11789. for (var index = 0; index < this.bones.length; index++) {
  11790. this._animatables.push(this.bones[index]);
  11791. }
  11792. }
  11793. return this._animatables;
  11794. };
  11795. /**
  11796. * Clone the current skeleton
  11797. * @param name defines the name of the new skeleton
  11798. * @param id defines the id of the enw skeleton
  11799. * @returns the new skeleton
  11800. */
  11801. Skeleton.prototype.clone = function (name, id) {
  11802. var result = new Skeleton(name, id || name, this._scene);
  11803. result.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11804. for (var index = 0; index < this.bones.length; index++) {
  11805. var source = this.bones[index];
  11806. var parentBone = null;
  11807. var parent_1 = source.getParent();
  11808. if (parent_1) {
  11809. var parentIndex = this.bones.indexOf(parent_1);
  11810. parentBone = result.bones[parentIndex];
  11811. }
  11812. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](source.name, result, parentBone, source.getBaseMatrix().clone(), source.getRestPose().clone());
  11813. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source.animations, bone.animations);
  11814. }
  11815. if (this._ranges) {
  11816. result._ranges = {};
  11817. for (var rangeName in this._ranges) {
  11818. var range = this._ranges[rangeName];
  11819. if (range) {
  11820. result._ranges[rangeName] = range.clone();
  11821. }
  11822. }
  11823. }
  11824. this._isDirty = true;
  11825. return result;
  11826. };
  11827. /**
  11828. * Enable animation blending for this skeleton
  11829. * @param blendingSpeed defines the blending speed to apply
  11830. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  11831. */
  11832. Skeleton.prototype.enableBlending = function (blendingSpeed) {
  11833. if (blendingSpeed === void 0) { blendingSpeed = 0.01; }
  11834. this.bones.forEach(function (bone) {
  11835. bone.animations.forEach(function (animation) {
  11836. animation.enableBlending = true;
  11837. animation.blendingSpeed = blendingSpeed;
  11838. });
  11839. });
  11840. };
  11841. /**
  11842. * Releases all resources associated with the current skeleton
  11843. */
  11844. Skeleton.prototype.dispose = function () {
  11845. this._meshesWithPoseMatrix = [];
  11846. // Animations
  11847. this.getScene().stopAnimation(this);
  11848. // Remove from scene
  11849. this.getScene().removeSkeleton(this);
  11850. if (this._transformMatrixTexture) {
  11851. this._transformMatrixTexture.dispose();
  11852. this._transformMatrixTexture = null;
  11853. }
  11854. };
  11855. /**
  11856. * Serialize the skeleton in a JSON object
  11857. * @returns a JSON object
  11858. */
  11859. Skeleton.prototype.serialize = function () {
  11860. var serializationObject = {};
  11861. serializationObject.name = this.name;
  11862. serializationObject.id = this.id;
  11863. if (this.dimensionsAtRest) {
  11864. serializationObject.dimensionsAtRest = this.dimensionsAtRest.asArray();
  11865. }
  11866. serializationObject.bones = [];
  11867. serializationObject.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11868. for (var index = 0; index < this.bones.length; index++) {
  11869. var bone = this.bones[index];
  11870. var parent_2 = bone.getParent();
  11871. var serializedBone = {
  11872. parentBoneIndex: parent_2 ? this.bones.indexOf(parent_2) : -1,
  11873. name: bone.name,
  11874. matrix: bone.getBaseMatrix().toArray(),
  11875. rest: bone.getRestPose().toArray()
  11876. };
  11877. serializationObject.bones.push(serializedBone);
  11878. if (bone.length) {
  11879. serializedBone.length = bone.length;
  11880. }
  11881. if (bone.metadata) {
  11882. serializedBone.metadata = bone.metadata;
  11883. }
  11884. if (bone.animations && bone.animations.length > 0) {
  11885. serializedBone.animation = bone.animations[0].serialize();
  11886. }
  11887. serializationObject.ranges = [];
  11888. for (var name in this._ranges) {
  11889. var source = this._ranges[name];
  11890. if (!source) {
  11891. continue;
  11892. }
  11893. var range = {};
  11894. range.name = name;
  11895. range.from = source.from;
  11896. range.to = source.to;
  11897. serializationObject.ranges.push(range);
  11898. }
  11899. }
  11900. return serializationObject;
  11901. };
  11902. /**
  11903. * Creates a new skeleton from serialized data
  11904. * @param parsedSkeleton defines the serialized data
  11905. * @param scene defines the hosting scene
  11906. * @returns a new skeleton
  11907. */
  11908. Skeleton.Parse = function (parsedSkeleton, scene) {
  11909. var skeleton = new Skeleton(parsedSkeleton.name, parsedSkeleton.id, scene);
  11910. if (parsedSkeleton.dimensionsAtRest) {
  11911. skeleton.dimensionsAtRest = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSkeleton.dimensionsAtRest);
  11912. }
  11913. skeleton.needInitialSkinMatrix = parsedSkeleton.needInitialSkinMatrix;
  11914. var index;
  11915. for (index = 0; index < parsedSkeleton.bones.length; index++) {
  11916. var parsedBone = parsedSkeleton.bones[index];
  11917. var parentBone = null;
  11918. if (parsedBone.parentBoneIndex > -1) {
  11919. parentBone = skeleton.bones[parsedBone.parentBoneIndex];
  11920. }
  11921. var rest = parsedBone.rest ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.rest) : null;
  11922. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](parsedBone.name, skeleton, parentBone, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.matrix), rest);
  11923. if (parsedBone.id !== undefined && parsedBone.id !== null) {
  11924. bone.id = parsedBone.id;
  11925. }
  11926. if (parsedBone.length) {
  11927. bone.length = parsedBone.length;
  11928. }
  11929. if (parsedBone.metadata) {
  11930. bone.metadata = parsedBone.metadata;
  11931. }
  11932. if (parsedBone.animation) {
  11933. bone.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].Parse(parsedBone.animation));
  11934. }
  11935. }
  11936. // placed after bones, so createAnimationRange can cascade down
  11937. if (parsedSkeleton.ranges) {
  11938. for (index = 0; index < parsedSkeleton.ranges.length; index++) {
  11939. var data = parsedSkeleton.ranges[index];
  11940. skeleton.createAnimationRange(data.name, data.from, data.to);
  11941. }
  11942. }
  11943. return skeleton;
  11944. };
  11945. /**
  11946. * Compute all node absolute transforms
  11947. * @param forceUpdate defines if computation must be done even if cache is up to date
  11948. */
  11949. Skeleton.prototype.computeAbsoluteTransforms = function (forceUpdate) {
  11950. if (forceUpdate === void 0) { forceUpdate = false; }
  11951. var renderId = this._scene.getRenderId();
  11952. if (this._lastAbsoluteTransformsUpdateId != renderId || forceUpdate) {
  11953. this.bones[0].computeAbsoluteTransforms();
  11954. this._lastAbsoluteTransformsUpdateId = renderId;
  11955. }
  11956. };
  11957. /**
  11958. * Gets the root pose matrix
  11959. * @returns a matrix
  11960. */
  11961. Skeleton.prototype.getPoseMatrix = function () {
  11962. var poseMatrix = null;
  11963. if (this._meshesWithPoseMatrix.length > 0) {
  11964. poseMatrix = this._meshesWithPoseMatrix[0].getPoseMatrix();
  11965. }
  11966. return poseMatrix;
  11967. };
  11968. /**
  11969. * Sorts bones per internal index
  11970. */
  11971. Skeleton.prototype.sortBones = function () {
  11972. var bones = new Array();
  11973. var visited = new Array(this.bones.length);
  11974. for (var index = 0; index < this.bones.length; index++) {
  11975. this._sortBones(index, bones, visited);
  11976. }
  11977. this.bones = bones;
  11978. };
  11979. Skeleton.prototype._sortBones = function (index, bones, visited) {
  11980. if (visited[index]) {
  11981. return;
  11982. }
  11983. visited[index] = true;
  11984. var bone = this.bones[index];
  11985. if (bone._index === undefined) {
  11986. bone._index = index;
  11987. }
  11988. var parentBone = bone.getParent();
  11989. if (parentBone) {
  11990. this._sortBones(this.bones.indexOf(parentBone), bones, visited);
  11991. }
  11992. bones.push(bone);
  11993. };
  11994. return Skeleton;
  11995. }());
  11996. /***/ }),
  11997. /***/ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts":
  11998. /*!*******************************************************!*\
  11999. !*** ./Cameras/Inputs/arcRotateCameraGamepadInput.ts ***!
  12000. \*******************************************************/
  12001. /*! exports provided: ArcRotateCameraGamepadInput */
  12002. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12003. "use strict";
  12004. __webpack_require__.r(__webpack_exports__);
  12005. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return ArcRotateCameraGamepadInput; });
  12006. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12007. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12008. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12009. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  12010. /**
  12011. * Manage the gamepad inputs to control an arc rotate camera.
  12012. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12013. */
  12014. var ArcRotateCameraGamepadInput = /** @class */ (function () {
  12015. function ArcRotateCameraGamepadInput() {
  12016. /**
  12017. * Defines the gamepad rotation sensiblity.
  12018. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  12019. */
  12020. this.gamepadRotationSensibility = 80;
  12021. /**
  12022. * Defines the gamepad move sensiblity.
  12023. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  12024. */
  12025. this.gamepadMoveSensibility = 40;
  12026. }
  12027. /**
  12028. * Attach the input controls to a specific dom element to get the input from.
  12029. * @param element Defines the element the controls should be listened from
  12030. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12031. */
  12032. ArcRotateCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  12033. var _this = this;
  12034. var manager = this.camera.getScene().gamepadManager;
  12035. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  12036. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].POSE_ENABLED) {
  12037. // prioritize XBOX gamepads.
  12038. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX) {
  12039. _this.gamepad = gamepad;
  12040. }
  12041. }
  12042. });
  12043. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  12044. if (_this.gamepad === gamepad) {
  12045. _this.gamepad = null;
  12046. }
  12047. });
  12048. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX);
  12049. };
  12050. /**
  12051. * Detach the current controls from the specified dom element.
  12052. * @param element Defines the element to stop listening the inputs from
  12053. */
  12054. ArcRotateCameraGamepadInput.prototype.detachControl = function (element) {
  12055. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  12056. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  12057. this.gamepad = null;
  12058. };
  12059. /**
  12060. * Update the current camera state depending on the inputs that have been used this frame.
  12061. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12062. */
  12063. ArcRotateCameraGamepadInput.prototype.checkInputs = function () {
  12064. if (this.gamepad) {
  12065. var camera = this.camera;
  12066. var RSValues = this.gamepad.rightStick;
  12067. if (RSValues) {
  12068. if (RSValues.x != 0) {
  12069. var normalizedRX = RSValues.x / this.gamepadRotationSensibility;
  12070. if (normalizedRX != 0 && Math.abs(normalizedRX) > 0.005) {
  12071. camera.inertialAlphaOffset += normalizedRX;
  12072. }
  12073. }
  12074. if (RSValues.y != 0) {
  12075. var normalizedRY = RSValues.y / this.gamepadRotationSensibility;
  12076. if (normalizedRY != 0 && Math.abs(normalizedRY) > 0.005) {
  12077. camera.inertialBetaOffset += normalizedRY;
  12078. }
  12079. }
  12080. }
  12081. var LSValues = this.gamepad.leftStick;
  12082. if (LSValues && LSValues.y != 0) {
  12083. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  12084. if (normalizedLY != 0 && Math.abs(normalizedLY) > 0.005) {
  12085. this.camera.inertialRadiusOffset -= normalizedLY;
  12086. }
  12087. }
  12088. }
  12089. };
  12090. /**
  12091. * Gets the class name of the current intput.
  12092. * @returns the class name
  12093. */
  12094. ArcRotateCameraGamepadInput.prototype.getClassName = function () {
  12095. return "ArcRotateCameraGamepadInput";
  12096. };
  12097. /**
  12098. * Get the friendly name associated with the input class.
  12099. * @returns the input friendly name
  12100. */
  12101. ArcRotateCameraGamepadInput.prototype.getSimpleName = function () {
  12102. return "gamepad";
  12103. };
  12104. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12105. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12106. ], ArcRotateCameraGamepadInput.prototype, "gamepadRotationSensibility", void 0);
  12107. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12108. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12109. ], ArcRotateCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  12110. return ArcRotateCameraGamepadInput;
  12111. }());
  12112. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraGamepadInput"] = ArcRotateCameraGamepadInput;
  12113. /***/ }),
  12114. /***/ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts":
  12115. /*!************************************************************!*\
  12116. !*** ./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts ***!
  12117. \************************************************************/
  12118. /*! exports provided: ArcRotateCameraKeyboardMoveInput */
  12119. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12120. "use strict";
  12121. __webpack_require__.r(__webpack_exports__);
  12122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return ArcRotateCameraKeyboardMoveInput; });
  12123. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12124. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12125. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12126. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  12127. /**
  12128. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  12129. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12130. */
  12131. var ArcRotateCameraKeyboardMoveInput = /** @class */ (function () {
  12132. function ArcRotateCameraKeyboardMoveInput() {
  12133. /**
  12134. * Defines the list of key codes associated with the up action (increase alpha)
  12135. */
  12136. this.keysUp = [38];
  12137. /**
  12138. * Defines the list of key codes associated with the down action (decrease alpha)
  12139. */
  12140. this.keysDown = [40];
  12141. /**
  12142. * Defines the list of key codes associated with the left action (increase beta)
  12143. */
  12144. this.keysLeft = [37];
  12145. /**
  12146. * Defines the list of key codes associated with the right action (decrease beta)
  12147. */
  12148. this.keysRight = [39];
  12149. /**
  12150. * Defines the list of key codes associated with the reset action.
  12151. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  12152. */
  12153. this.keysReset = [220];
  12154. /**
  12155. * Defines the panning sensibility of the inputs.
  12156. * (How fast is the camera paning)
  12157. */
  12158. this.panningSensibility = 50.0;
  12159. /**
  12160. * Defines the zooming sensibility of the inputs.
  12161. * (How fast is the camera zooming)
  12162. */
  12163. this.zoomingSensibility = 25.0;
  12164. /**
  12165. * Defines wether maintaining the alt key down switch the movement mode from
  12166. * orientation to zoom.
  12167. */
  12168. this.useAltToZoom = true;
  12169. /**
  12170. * Rotation speed of the camera
  12171. */
  12172. this.angularSpeed = 0.01;
  12173. this._keys = new Array();
  12174. }
  12175. /**
  12176. * Attach the input controls to a specific dom element to get the input from.
  12177. * @param element Defines the element the controls should be listened from
  12178. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12179. */
  12180. ArcRotateCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  12181. var _this = this;
  12182. if (this._onCanvasBlurObserver) {
  12183. return;
  12184. }
  12185. this._scene = this.camera.getScene();
  12186. this._engine = this._scene.getEngine();
  12187. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  12188. _this._keys = [];
  12189. });
  12190. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  12191. var evt = info.event;
  12192. if (!evt.metaKey) {
  12193. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  12194. _this._ctrlPressed = evt.ctrlKey;
  12195. _this._altPressed = evt.altKey;
  12196. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12197. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12198. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12199. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12200. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12201. var index = _this._keys.indexOf(evt.keyCode);
  12202. if (index === -1) {
  12203. _this._keys.push(evt.keyCode);
  12204. }
  12205. if (evt.preventDefault) {
  12206. if (!noPreventDefault) {
  12207. evt.preventDefault();
  12208. }
  12209. }
  12210. }
  12211. }
  12212. else {
  12213. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12214. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12215. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12216. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12217. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12218. var index = _this._keys.indexOf(evt.keyCode);
  12219. if (index >= 0) {
  12220. _this._keys.splice(index, 1);
  12221. }
  12222. if (evt.preventDefault) {
  12223. if (!noPreventDefault) {
  12224. evt.preventDefault();
  12225. }
  12226. }
  12227. }
  12228. }
  12229. }
  12230. });
  12231. };
  12232. /**
  12233. * Detach the current controls from the specified dom element.
  12234. * @param element Defines the element to stop listening the inputs from
  12235. */
  12236. ArcRotateCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  12237. if (this._scene) {
  12238. if (this._onKeyboardObserver) {
  12239. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  12240. }
  12241. if (this._onCanvasBlurObserver) {
  12242. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  12243. }
  12244. this._onKeyboardObserver = null;
  12245. this._onCanvasBlurObserver = null;
  12246. }
  12247. this._keys = [];
  12248. };
  12249. /**
  12250. * Update the current camera state depending on the inputs that have been used this frame.
  12251. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12252. */
  12253. ArcRotateCameraKeyboardMoveInput.prototype.checkInputs = function () {
  12254. if (this._onKeyboardObserver) {
  12255. var camera = this.camera;
  12256. for (var index = 0; index < this._keys.length; index++) {
  12257. var keyCode = this._keys[index];
  12258. if (this.keysLeft.indexOf(keyCode) !== -1) {
  12259. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12260. camera.inertialPanningX -= 1 / this.panningSensibility;
  12261. }
  12262. else {
  12263. camera.inertialAlphaOffset -= this.angularSpeed;
  12264. }
  12265. }
  12266. else if (this.keysUp.indexOf(keyCode) !== -1) {
  12267. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12268. camera.inertialPanningY += 1 / this.panningSensibility;
  12269. }
  12270. else if (this._altPressed && this.useAltToZoom) {
  12271. camera.inertialRadiusOffset += 1 / this.zoomingSensibility;
  12272. }
  12273. else {
  12274. camera.inertialBetaOffset -= this.angularSpeed;
  12275. }
  12276. }
  12277. else if (this.keysRight.indexOf(keyCode) !== -1) {
  12278. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12279. camera.inertialPanningX += 1 / this.panningSensibility;
  12280. }
  12281. else {
  12282. camera.inertialAlphaOffset += this.angularSpeed;
  12283. }
  12284. }
  12285. else if (this.keysDown.indexOf(keyCode) !== -1) {
  12286. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12287. camera.inertialPanningY -= 1 / this.panningSensibility;
  12288. }
  12289. else if (this._altPressed && this.useAltToZoom) {
  12290. camera.inertialRadiusOffset -= 1 / this.zoomingSensibility;
  12291. }
  12292. else {
  12293. camera.inertialBetaOffset += this.angularSpeed;
  12294. }
  12295. }
  12296. else if (this.keysReset.indexOf(keyCode) !== -1) {
  12297. if (camera.useInputToRestoreState) {
  12298. camera.restoreState();
  12299. }
  12300. }
  12301. }
  12302. }
  12303. };
  12304. /**
  12305. * Gets the class name of the current intput.
  12306. * @returns the class name
  12307. */
  12308. ArcRotateCameraKeyboardMoveInput.prototype.getClassName = function () {
  12309. return "ArcRotateCameraKeyboardMoveInput";
  12310. };
  12311. /**
  12312. * Get the friendly name associated with the input class.
  12313. * @returns the input friendly name
  12314. */
  12315. ArcRotateCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  12316. return "keyboard";
  12317. };
  12318. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12319. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12320. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  12321. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12322. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12323. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  12324. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12325. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12326. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  12327. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12328. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12329. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  12330. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12331. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12332. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysReset", void 0);
  12333. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12334. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12335. ], ArcRotateCameraKeyboardMoveInput.prototype, "panningSensibility", void 0);
  12336. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12337. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12338. ], ArcRotateCameraKeyboardMoveInput.prototype, "zoomingSensibility", void 0);
  12339. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12340. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12341. ], ArcRotateCameraKeyboardMoveInput.prototype, "useAltToZoom", void 0);
  12342. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12343. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12344. ], ArcRotateCameraKeyboardMoveInput.prototype, "angularSpeed", void 0);
  12345. return ArcRotateCameraKeyboardMoveInput;
  12346. }());
  12347. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraKeyboardMoveInput"] = ArcRotateCameraKeyboardMoveInput;
  12348. /***/ }),
  12349. /***/ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts":
  12350. /*!**********************************************************!*\
  12351. !*** ./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts ***!
  12352. \**********************************************************/
  12353. /*! exports provided: ArcRotateCameraMouseWheelInput */
  12354. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12355. "use strict";
  12356. __webpack_require__.r(__webpack_exports__);
  12357. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return ArcRotateCameraMouseWheelInput; });
  12358. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12359. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12360. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12361. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12362. /**
  12363. * Manage the mouse wheel inputs to control an arc rotate camera.
  12364. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12365. */
  12366. var ArcRotateCameraMouseWheelInput = /** @class */ (function () {
  12367. function ArcRotateCameraMouseWheelInput() {
  12368. /**
  12369. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  12370. */
  12371. this.wheelPrecision = 3.0;
  12372. /**
  12373. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  12374. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  12375. */
  12376. this.wheelDeltaPercentage = 0;
  12377. }
  12378. /**
  12379. * Attach the input controls to a specific dom element to get the input from.
  12380. * @param element Defines the element the controls should be listened from
  12381. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12382. */
  12383. ArcRotateCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  12384. var _this = this;
  12385. this._wheel = function (p, s) {
  12386. //sanity check - this should be a PointerWheel event.
  12387. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  12388. return;
  12389. }
  12390. var event = p.event;
  12391. var delta = 0;
  12392. var mouseWheelLegacyEvent = event;
  12393. if (mouseWheelLegacyEvent.wheelDelta) {
  12394. if (_this.wheelDeltaPercentage) {
  12395. var wheelDelta = (mouseWheelLegacyEvent.wheelDelta * 0.01 * _this.wheelDeltaPercentage) * _this.camera.radius;
  12396. if (mouseWheelLegacyEvent.wheelDelta > 0) {
  12397. delta = wheelDelta / (1.0 + _this.wheelDeltaPercentage);
  12398. }
  12399. else {
  12400. delta = wheelDelta * (1.0 + _this.wheelDeltaPercentage);
  12401. }
  12402. }
  12403. else {
  12404. delta = mouseWheelLegacyEvent.wheelDelta / (_this.wheelPrecision * 40);
  12405. }
  12406. }
  12407. else {
  12408. var deltaValue = event.deltaY || event.detail;
  12409. delta = -deltaValue / _this.wheelPrecision;
  12410. }
  12411. if (delta) {
  12412. _this.camera.inertialRadiusOffset += delta;
  12413. }
  12414. if (event.preventDefault) {
  12415. if (!noPreventDefault) {
  12416. event.preventDefault();
  12417. }
  12418. }
  12419. };
  12420. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  12421. };
  12422. /**
  12423. * Detach the current controls from the specified dom element.
  12424. * @param element Defines the element to stop listening the inputs from
  12425. */
  12426. ArcRotateCameraMouseWheelInput.prototype.detachControl = function (element) {
  12427. if (this._observer && element) {
  12428. this.camera.getScene().onPointerObservable.remove(this._observer);
  12429. this._observer = null;
  12430. this._wheel = null;
  12431. }
  12432. };
  12433. /**
  12434. * Gets the class name of the current intput.
  12435. * @returns the class name
  12436. */
  12437. ArcRotateCameraMouseWheelInput.prototype.getClassName = function () {
  12438. return "ArcRotateCameraMouseWheelInput";
  12439. };
  12440. /**
  12441. * Get the friendly name associated with the input class.
  12442. * @returns the input friendly name
  12443. */
  12444. ArcRotateCameraMouseWheelInput.prototype.getSimpleName = function () {
  12445. return "mousewheel";
  12446. };
  12447. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12448. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12449. ], ArcRotateCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  12450. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12451. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12452. ], ArcRotateCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  12453. return ArcRotateCameraMouseWheelInput;
  12454. }());
  12455. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraMouseWheelInput"] = ArcRotateCameraMouseWheelInput;
  12456. /***/ }),
  12457. /***/ "./Cameras/Inputs/arcRotateCameraPointersInput.ts":
  12458. /*!********************************************************!*\
  12459. !*** ./Cameras/Inputs/arcRotateCameraPointersInput.ts ***!
  12460. \********************************************************/
  12461. /*! exports provided: ArcRotateCameraPointersInput */
  12462. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12463. "use strict";
  12464. __webpack_require__.r(__webpack_exports__);
  12465. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return ArcRotateCameraPointersInput; });
  12466. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12467. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12468. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  12469. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12470. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12471. /**
  12472. * Manage the pointers inputs to control an arc rotate camera.
  12473. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12474. */
  12475. var ArcRotateCameraPointersInput = /** @class */ (function () {
  12476. function ArcRotateCameraPointersInput() {
  12477. /**
  12478. * Defines the buttons associated with the input to handle camera move.
  12479. */
  12480. this.buttons = [0, 1, 2];
  12481. /**
  12482. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  12483. */
  12484. this.angularSensibilityX = 1000.0;
  12485. /**
  12486. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  12487. */
  12488. this.angularSensibilityY = 1000.0;
  12489. /**
  12490. * Defines the pointer pinch precision or how fast is the camera zooming.
  12491. */
  12492. this.pinchPrecision = 12.0;
  12493. /**
  12494. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  12495. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  12496. */
  12497. this.pinchDeltaPercentage = 0;
  12498. /**
  12499. * Defines the pointer panning sensibility or how fast is the camera moving.
  12500. */
  12501. this.panningSensibility = 1000.0;
  12502. /**
  12503. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  12504. */
  12505. this.multiTouchPanning = true;
  12506. /**
  12507. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  12508. */
  12509. this.multiTouchPanAndZoom = true;
  12510. /**
  12511. * Revers pinch action direction.
  12512. */
  12513. this.pinchInwards = true;
  12514. this._isPanClick = false;
  12515. }
  12516. /**
  12517. * Attach the input controls to a specific dom element to get the input from.
  12518. * @param element Defines the element the controls should be listened from
  12519. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12520. */
  12521. ArcRotateCameraPointersInput.prototype.attachControl = function (element, noPreventDefault) {
  12522. var _this = this;
  12523. var engine = this.camera.getEngine();
  12524. var cacheSoloPointer; // cache pointer object for better perf on camera rotation
  12525. var pointA = null;
  12526. var pointB = null;
  12527. var previousPinchSquaredDistance = 0;
  12528. var initialDistance = 0;
  12529. var twoFingerActivityCount = 0;
  12530. var previousMultiTouchPanPosition = { x: 0, y: 0, isPaning: false, isPinching: false };
  12531. this._pointerInput = function (p, s) {
  12532. var evt = p.event;
  12533. var isTouch = p.event.pointerType === "touch";
  12534. if (engine.isInVRExclusivePointerMode) {
  12535. return;
  12536. }
  12537. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  12538. return;
  12539. }
  12540. var srcElement = (evt.srcElement || evt.target);
  12541. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN && srcElement) {
  12542. try {
  12543. srcElement.setPointerCapture(evt.pointerId);
  12544. }
  12545. catch (e) {
  12546. //Nothing to do with the error. Execution will continue.
  12547. }
  12548. // Manage panning with pan button click
  12549. _this._isPanClick = evt.button === _this.camera._panningMouseButton;
  12550. // manage pointers
  12551. cacheSoloPointer = { x: evt.clientX, y: evt.clientY, pointerId: evt.pointerId, type: evt.pointerType };
  12552. if (pointA === null) {
  12553. pointA = cacheSoloPointer;
  12554. }
  12555. else if (pointB === null) {
  12556. pointB = cacheSoloPointer;
  12557. }
  12558. if (!noPreventDefault) {
  12559. evt.preventDefault();
  12560. element.focus();
  12561. }
  12562. }
  12563. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOUBLETAP) {
  12564. if (_this.camera.useInputToRestoreState) {
  12565. _this.camera.restoreState();
  12566. }
  12567. }
  12568. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP && srcElement) {
  12569. try {
  12570. srcElement.releasePointerCapture(evt.pointerId);
  12571. }
  12572. catch (e) {
  12573. //Nothing to do with the error.
  12574. }
  12575. cacheSoloPointer = null;
  12576. previousPinchSquaredDistance = 0;
  12577. previousMultiTouchPanPosition.isPaning = false;
  12578. previousMultiTouchPanPosition.isPinching = false;
  12579. twoFingerActivityCount = 0;
  12580. initialDistance = 0;
  12581. if (!isTouch) {
  12582. pointB = null; // Mouse and pen are mono pointer
  12583. }
  12584. //would be better to use pointers.remove(evt.pointerId) for multitouch gestures,
  12585. //but emptying completly pointers collection is required to fix a bug on iPhone :
  12586. //when changing orientation while pinching camera, one pointer stay pressed forever if we don't release all pointers
  12587. //will be ok to put back pointers.remove(evt.pointerId); when iPhone bug corrected
  12588. if (engine._badOS) {
  12589. pointA = pointB = null;
  12590. }
  12591. else {
  12592. //only remove the impacted pointer in case of multitouch allowing on most
  12593. //platforms switching from rotate to zoom and pan seamlessly.
  12594. if (pointB && pointA && pointA.pointerId == evt.pointerId) {
  12595. pointA = pointB;
  12596. pointB = null;
  12597. cacheSoloPointer = { x: pointA.x, y: pointA.y, pointerId: pointA.pointerId, type: evt.pointerType };
  12598. }
  12599. else if (pointA && pointB && pointB.pointerId == evt.pointerId) {
  12600. pointB = null;
  12601. cacheSoloPointer = { x: pointA.x, y: pointA.y, pointerId: pointA.pointerId, type: evt.pointerType };
  12602. }
  12603. else {
  12604. pointA = pointB = null;
  12605. }
  12606. }
  12607. if (!noPreventDefault) {
  12608. evt.preventDefault();
  12609. }
  12610. }
  12611. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  12612. if (!noPreventDefault) {
  12613. evt.preventDefault();
  12614. }
  12615. // One button down
  12616. if (pointA && pointB === null && cacheSoloPointer) {
  12617. if (_this.panningSensibility !== 0 &&
  12618. ((evt.ctrlKey && _this.camera._useCtrlForPanning) || _this._isPanClick)) {
  12619. _this.camera.inertialPanningX += -(evt.clientX - cacheSoloPointer.x) / _this.panningSensibility;
  12620. _this.camera.inertialPanningY += (evt.clientY - cacheSoloPointer.y) / _this.panningSensibility;
  12621. }
  12622. else {
  12623. var offsetX = evt.clientX - cacheSoloPointer.x;
  12624. var offsetY = evt.clientY - cacheSoloPointer.y;
  12625. _this.camera.inertialAlphaOffset -= offsetX / _this.angularSensibilityX;
  12626. _this.camera.inertialBetaOffset -= offsetY / _this.angularSensibilityY;
  12627. }
  12628. cacheSoloPointer.x = evt.clientX;
  12629. cacheSoloPointer.y = evt.clientY;
  12630. }
  12631. // Two buttons down: pinch/pan
  12632. else if (pointA && pointB) {
  12633. //if (noPreventDefault) { evt.preventDefault(); } //if pinch gesture, could be useful to force preventDefault to avoid html page scroll/zoom in some mobile browsers
  12634. var ed = (pointA.pointerId === evt.pointerId) ? pointA : pointB;
  12635. ed.x = evt.clientX;
  12636. ed.y = evt.clientY;
  12637. var direction = _this.pinchInwards ? 1 : -1;
  12638. var distX = pointA.x - pointB.x;
  12639. var distY = pointA.y - pointB.y;
  12640. var pinchSquaredDistance = (distX * distX) + (distY * distY);
  12641. var pinchDistance = Math.sqrt(pinchSquaredDistance);
  12642. if (previousPinchSquaredDistance === 0) {
  12643. initialDistance = pinchDistance;
  12644. previousPinchSquaredDistance = pinchSquaredDistance;
  12645. previousMultiTouchPanPosition.x = (pointA.x + pointB.x) / 2;
  12646. previousMultiTouchPanPosition.y = (pointA.y + pointB.y) / 2;
  12647. return;
  12648. }
  12649. if (_this.multiTouchPanAndZoom) {
  12650. if (_this.pinchDeltaPercentage) {
  12651. _this.camera.inertialRadiusOffset += ((pinchSquaredDistance - previousPinchSquaredDistance) * 0.001) * _this.camera.radius * _this.pinchDeltaPercentage;
  12652. }
  12653. else {
  12654. _this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
  12655. (_this.pinchPrecision *
  12656. ((_this.angularSensibilityX + _this.angularSensibilityY) / 2) *
  12657. direction);
  12658. }
  12659. if (_this.panningSensibility !== 0) {
  12660. var pointersCenterX = (pointA.x + pointB.x) / 2;
  12661. var pointersCenterY = (pointA.y + pointB.y) / 2;
  12662. var pointersCenterDistX = pointersCenterX - previousMultiTouchPanPosition.x;
  12663. var pointersCenterDistY = pointersCenterY - previousMultiTouchPanPosition.y;
  12664. previousMultiTouchPanPosition.x = pointersCenterX;
  12665. previousMultiTouchPanPosition.y = pointersCenterY;
  12666. _this.camera.inertialPanningX += -(pointersCenterDistX) / (_this.panningSensibility);
  12667. _this.camera.inertialPanningY += (pointersCenterDistY) / (_this.panningSensibility);
  12668. }
  12669. }
  12670. else {
  12671. twoFingerActivityCount++;
  12672. if (previousMultiTouchPanPosition.isPinching || (twoFingerActivityCount < 20 && Math.abs(pinchDistance - initialDistance) > _this.camera.pinchToPanMaxDistance)) {
  12673. if (_this.pinchDeltaPercentage) {
  12674. _this.camera.inertialRadiusOffset += ((pinchSquaredDistance - previousPinchSquaredDistance) * 0.001) * _this.camera.radius * _this.pinchDeltaPercentage;
  12675. }
  12676. else {
  12677. _this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
  12678. (_this.pinchPrecision *
  12679. ((_this.angularSensibilityX + _this.angularSensibilityY) / 2) *
  12680. direction);
  12681. }
  12682. previousMultiTouchPanPosition.isPaning = false;
  12683. previousMultiTouchPanPosition.isPinching = true;
  12684. }
  12685. else {
  12686. if (cacheSoloPointer && cacheSoloPointer.pointerId === ed.pointerId && _this.panningSensibility !== 0 && _this.multiTouchPanning) {
  12687. if (!previousMultiTouchPanPosition.isPaning) {
  12688. previousMultiTouchPanPosition.isPaning = true;
  12689. previousMultiTouchPanPosition.isPinching = false;
  12690. previousMultiTouchPanPosition.x = ed.x;
  12691. previousMultiTouchPanPosition.y = ed.y;
  12692. return;
  12693. }
  12694. _this.camera.inertialPanningX += -(ed.x - previousMultiTouchPanPosition.x) / (_this.panningSensibility);
  12695. _this.camera.inertialPanningY += (ed.y - previousMultiTouchPanPosition.y) / (_this.panningSensibility);
  12696. }
  12697. }
  12698. if (cacheSoloPointer && cacheSoloPointer.pointerId === evt.pointerId) {
  12699. previousMultiTouchPanPosition.x = ed.x;
  12700. previousMultiTouchPanPosition.y = ed.y;
  12701. }
  12702. }
  12703. previousPinchSquaredDistance = pinchSquaredDistance;
  12704. }
  12705. }
  12706. };
  12707. 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);
  12708. this._onContextMenu = function (evt) {
  12709. evt.preventDefault();
  12710. };
  12711. if (!this.camera._useCtrlForPanning) {
  12712. element.addEventListener("contextmenu", this._onContextMenu, false);
  12713. }
  12714. this._onLostFocus = function () {
  12715. //this._keys = [];
  12716. pointA = pointB = null;
  12717. previousPinchSquaredDistance = 0;
  12718. previousMultiTouchPanPosition.isPaning = false;
  12719. previousMultiTouchPanPosition.isPinching = false;
  12720. twoFingerActivityCount = 0;
  12721. cacheSoloPointer = null;
  12722. initialDistance = 0;
  12723. };
  12724. this._onMouseMove = function (evt) {
  12725. if (!engine.isPointerLock) {
  12726. return;
  12727. }
  12728. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  12729. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  12730. _this.camera.inertialAlphaOffset -= offsetX / _this.angularSensibilityX;
  12731. _this.camera.inertialBetaOffset -= offsetY / _this.angularSensibilityY;
  12732. if (!noPreventDefault) {
  12733. evt.preventDefault();
  12734. }
  12735. };
  12736. this._onGestureStart = function (e) {
  12737. if (window.MSGesture === undefined) {
  12738. return;
  12739. }
  12740. if (!_this._MSGestureHandler) {
  12741. _this._MSGestureHandler = new MSGesture();
  12742. _this._MSGestureHandler.target = element;
  12743. }
  12744. _this._MSGestureHandler.addPointer(e.pointerId);
  12745. };
  12746. this._onGesture = function (e) {
  12747. _this.camera.radius *= e.scale;
  12748. if (e.preventDefault) {
  12749. if (!noPreventDefault) {
  12750. e.stopPropagation();
  12751. e.preventDefault();
  12752. }
  12753. }
  12754. };
  12755. element.addEventListener("mousemove", this._onMouseMove, false);
  12756. element.addEventListener("MSPointerDown", this._onGestureStart, false);
  12757. element.addEventListener("MSGestureChange", this._onGesture, false);
  12758. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RegisterTopRootEvents([
  12759. { name: "blur", handler: this._onLostFocus }
  12760. ]);
  12761. };
  12762. /**
  12763. * Detach the current controls from the specified dom element.
  12764. * @param element Defines the element to stop listening the inputs from
  12765. */
  12766. ArcRotateCameraPointersInput.prototype.detachControl = function (element) {
  12767. if (this._onLostFocus) {
  12768. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].UnregisterTopRootEvents([
  12769. { name: "blur", handler: this._onLostFocus }
  12770. ]);
  12771. }
  12772. if (element && this._observer) {
  12773. this.camera.getScene().onPointerObservable.remove(this._observer);
  12774. this._observer = null;
  12775. if (this._onContextMenu) {
  12776. element.removeEventListener("contextmenu", this._onContextMenu);
  12777. }
  12778. if (this._onMouseMove) {
  12779. element.removeEventListener("mousemove", this._onMouseMove);
  12780. }
  12781. if (this._onGestureStart) {
  12782. element.removeEventListener("MSPointerDown", this._onGestureStart);
  12783. }
  12784. if (this._onGesture) {
  12785. element.removeEventListener("MSGestureChange", this._onGesture);
  12786. }
  12787. this._isPanClick = false;
  12788. this.pinchInwards = true;
  12789. this._onMouseMove = null;
  12790. this._onGestureStart = null;
  12791. this._onGesture = null;
  12792. this._MSGestureHandler = null;
  12793. this._onLostFocus = null;
  12794. this._onContextMenu = null;
  12795. }
  12796. };
  12797. /**
  12798. * Gets the class name of the current intput.
  12799. * @returns the class name
  12800. */
  12801. ArcRotateCameraPointersInput.prototype.getClassName = function () {
  12802. return "ArcRotateCameraPointersInput";
  12803. };
  12804. /**
  12805. * Get the friendly name associated with the input class.
  12806. * @returns the input friendly name
  12807. */
  12808. ArcRotateCameraPointersInput.prototype.getSimpleName = function () {
  12809. return "pointers";
  12810. };
  12811. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12812. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12813. ], ArcRotateCameraPointersInput.prototype, "buttons", void 0);
  12814. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12815. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12816. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityX", void 0);
  12817. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12818. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12819. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityY", void 0);
  12820. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12821. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12822. ], ArcRotateCameraPointersInput.prototype, "pinchPrecision", void 0);
  12823. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12824. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12825. ], ArcRotateCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  12826. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12827. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12828. ], ArcRotateCameraPointersInput.prototype, "panningSensibility", void 0);
  12829. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12830. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12831. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanning", void 0);
  12832. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12833. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12834. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanAndZoom", void 0);
  12835. return ArcRotateCameraPointersInput;
  12836. }());
  12837. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["CameraInputTypes"]["ArcRotateCameraPointersInput"] = ArcRotateCameraPointersInput;
  12838. /***/ }),
  12839. /***/ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts":
  12840. /*!*******************************************************************!*\
  12841. !*** ./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts ***!
  12842. \*******************************************************************/
  12843. /*! exports provided: ArcRotateCameraVRDeviceOrientationInput */
  12844. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12845. "use strict";
  12846. __webpack_require__.r(__webpack_exports__);
  12847. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return ArcRotateCameraVRDeviceOrientationInput; });
  12848. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12849. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  12850. /**
  12851. * Add orientation input support to the input manager.
  12852. * @returns the current input manager
  12853. */
  12854. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraInputsManager"].prototype.addVRDeviceOrientation = function () {
  12855. this.add(new ArcRotateCameraVRDeviceOrientationInput());
  12856. return this;
  12857. };
  12858. /**
  12859. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  12860. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12861. */
  12862. var ArcRotateCameraVRDeviceOrientationInput = /** @class */ (function () {
  12863. /**
  12864. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  12865. */
  12866. function ArcRotateCameraVRDeviceOrientationInput() {
  12867. /**
  12868. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  12869. */
  12870. this.alphaCorrection = 1;
  12871. /**
  12872. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  12873. */
  12874. this.gammaCorrection = 1;
  12875. this._alpha = 0;
  12876. this._gamma = 0;
  12877. this._dirty = false;
  12878. this._deviceOrientationHandler = this._onOrientationEvent.bind(this);
  12879. }
  12880. /**
  12881. * Attach the input controls to a specific dom element to get the input from.
  12882. * @param element Defines the element the controls should be listened from
  12883. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12884. */
  12885. ArcRotateCameraVRDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  12886. this.camera.attachControl(element, noPreventDefault);
  12887. window.addEventListener("deviceorientation", this._deviceOrientationHandler);
  12888. };
  12889. /** @hidden */
  12890. ArcRotateCameraVRDeviceOrientationInput.prototype._onOrientationEvent = function (evt) {
  12891. if (evt.alpha !== null) {
  12892. this._alpha = (+evt.alpha | 0) * this.alphaCorrection;
  12893. }
  12894. if (evt.gamma !== null) {
  12895. this._gamma = (+evt.gamma | 0) * this.gammaCorrection;
  12896. }
  12897. this._dirty = true;
  12898. };
  12899. /**
  12900. * Update the current camera state depending on the inputs that have been used this frame.
  12901. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12902. */
  12903. ArcRotateCameraVRDeviceOrientationInput.prototype.checkInputs = function () {
  12904. if (this._dirty) {
  12905. this._dirty = false;
  12906. if (this._gamma < 0) {
  12907. this._gamma = 180 + this._gamma;
  12908. }
  12909. this.camera.alpha = (-this._alpha / 180.0 * Math.PI) % Math.PI * 2;
  12910. this.camera.beta = (this._gamma / 180.0 * Math.PI);
  12911. }
  12912. };
  12913. /**
  12914. * Detach the current controls from the specified dom element.
  12915. * @param element Defines the element to stop listening the inputs from
  12916. */
  12917. ArcRotateCameraVRDeviceOrientationInput.prototype.detachControl = function (element) {
  12918. window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
  12919. };
  12920. /**
  12921. * Gets the class name of the current intput.
  12922. * @returns the class name
  12923. */
  12924. ArcRotateCameraVRDeviceOrientationInput.prototype.getClassName = function () {
  12925. return "ArcRotateCameraVRDeviceOrientationInput";
  12926. };
  12927. /**
  12928. * Get the friendly name associated with the input class.
  12929. * @returns the input friendly name
  12930. */
  12931. ArcRotateCameraVRDeviceOrientationInput.prototype.getSimpleName = function () {
  12932. return "VRDeviceOrientation";
  12933. };
  12934. return ArcRotateCameraVRDeviceOrientationInput;
  12935. }());
  12936. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["ArcRotateCameraVRDeviceOrientationInput"] = ArcRotateCameraVRDeviceOrientationInput;
  12937. /***/ }),
  12938. /***/ "./Cameras/Inputs/flyCameraKeyboardInput.ts":
  12939. /*!**************************************************!*\
  12940. !*** ./Cameras/Inputs/flyCameraKeyboardInput.ts ***!
  12941. \**************************************************/
  12942. /*! exports provided: FlyCameraKeyboardInput */
  12943. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12944. "use strict";
  12945. __webpack_require__.r(__webpack_exports__);
  12946. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return FlyCameraKeyboardInput; });
  12947. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12948. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12949. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12950. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  12951. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  12952. /**
  12953. * Listen to keyboard events to control the camera.
  12954. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12955. */
  12956. var FlyCameraKeyboardInput = /** @class */ (function () {
  12957. function FlyCameraKeyboardInput() {
  12958. /**
  12959. * The list of keyboard keys used to control the forward move of the camera.
  12960. */
  12961. this.keysForward = [87];
  12962. /**
  12963. * The list of keyboard keys used to control the backward move of the camera.
  12964. */
  12965. this.keysBackward = [83];
  12966. /**
  12967. * The list of keyboard keys used to control the forward move of the camera.
  12968. */
  12969. this.keysUp = [69];
  12970. /**
  12971. * The list of keyboard keys used to control the backward move of the camera.
  12972. */
  12973. this.keysDown = [81];
  12974. /**
  12975. * The list of keyboard keys used to control the right strafe move of the camera.
  12976. */
  12977. this.keysRight = [68];
  12978. /**
  12979. * The list of keyboard keys used to control the left strafe move of the camera.
  12980. */
  12981. this.keysLeft = [65];
  12982. this._keys = new Array();
  12983. }
  12984. /**
  12985. * Attach the input controls to a specific dom element to get the input from.
  12986. * @param element Defines the element the controls should be listened from
  12987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12988. */
  12989. FlyCameraKeyboardInput.prototype.attachControl = function (element, noPreventDefault) {
  12990. var _this = this;
  12991. if (this._onCanvasBlurObserver) {
  12992. return;
  12993. }
  12994. this._scene = this.camera.getScene();
  12995. this._engine = this._scene.getEngine();
  12996. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  12997. _this._keys = [];
  12998. });
  12999. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13000. var evt = info.event;
  13001. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13002. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13003. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13004. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13005. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13006. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13007. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13008. var index = _this._keys.indexOf(evt.keyCode);
  13009. if (index === -1) {
  13010. _this._keys.push(evt.keyCode);
  13011. }
  13012. if (!noPreventDefault) {
  13013. evt.preventDefault();
  13014. }
  13015. }
  13016. }
  13017. else {
  13018. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13019. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13020. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13021. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13022. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13023. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13024. var index = _this._keys.indexOf(evt.keyCode);
  13025. if (index >= 0) {
  13026. _this._keys.splice(index, 1);
  13027. }
  13028. if (!noPreventDefault) {
  13029. evt.preventDefault();
  13030. }
  13031. }
  13032. }
  13033. });
  13034. };
  13035. /**
  13036. * Detach the current controls from the specified dom element.
  13037. * @param element Defines the element to stop listening the inputs from
  13038. */
  13039. FlyCameraKeyboardInput.prototype.detachControl = function (element) {
  13040. if (this._scene) {
  13041. if (this._onKeyboardObserver) {
  13042. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13043. }
  13044. if (this._onCanvasBlurObserver) {
  13045. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13046. }
  13047. this._onKeyboardObserver = null;
  13048. this._onCanvasBlurObserver = null;
  13049. }
  13050. this._keys = [];
  13051. };
  13052. /**
  13053. * Gets the class name of the current intput.
  13054. * @returns the class name
  13055. */
  13056. FlyCameraKeyboardInput.prototype.getClassName = function () {
  13057. return "FlyCameraKeyboardInput";
  13058. };
  13059. /** @hidden */
  13060. FlyCameraKeyboardInput.prototype._onLostFocus = function (e) {
  13061. this._keys = [];
  13062. };
  13063. /**
  13064. * Get the friendly name associated with the input class.
  13065. * @returns the input friendly name
  13066. */
  13067. FlyCameraKeyboardInput.prototype.getSimpleName = function () {
  13068. return "keyboard";
  13069. };
  13070. /**
  13071. * Update the current camera state depending on the inputs that have been used this frame.
  13072. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13073. */
  13074. FlyCameraKeyboardInput.prototype.checkInputs = function () {
  13075. if (this._onKeyboardObserver) {
  13076. var camera = this.camera;
  13077. // Keyboard
  13078. for (var index = 0; index < this._keys.length; index++) {
  13079. var keyCode = this._keys[index];
  13080. var speed = camera._computeLocalCameraSpeed();
  13081. if (this.keysForward.indexOf(keyCode) !== -1) {
  13082. camera._localDirection.copyFromFloats(0, 0, speed);
  13083. }
  13084. else if (this.keysBackward.indexOf(keyCode) !== -1) {
  13085. camera._localDirection.copyFromFloats(0, 0, -speed);
  13086. }
  13087. else if (this.keysUp.indexOf(keyCode) !== -1) {
  13088. camera._localDirection.copyFromFloats(0, speed, 0);
  13089. }
  13090. else if (this.keysDown.indexOf(keyCode) !== -1) {
  13091. camera._localDirection.copyFromFloats(0, -speed, 0);
  13092. }
  13093. else if (this.keysRight.indexOf(keyCode) !== -1) {
  13094. camera._localDirection.copyFromFloats(speed, 0, 0);
  13095. }
  13096. else if (this.keysLeft.indexOf(keyCode) !== -1) {
  13097. camera._localDirection.copyFromFloats(-speed, 0, 0);
  13098. }
  13099. if (camera.getScene().useRightHandedSystem) {
  13100. camera._localDirection.z *= -1;
  13101. }
  13102. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  13103. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  13104. camera.cameraDirection.addInPlace(camera._transformedDirection);
  13105. }
  13106. }
  13107. };
  13108. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13109. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13110. ], FlyCameraKeyboardInput.prototype, "keysForward", void 0);
  13111. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13112. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13113. ], FlyCameraKeyboardInput.prototype, "keysBackward", void 0);
  13114. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13115. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13116. ], FlyCameraKeyboardInput.prototype, "keysUp", void 0);
  13117. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13118. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13119. ], FlyCameraKeyboardInput.prototype, "keysDown", void 0);
  13120. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13121. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13122. ], FlyCameraKeyboardInput.prototype, "keysRight", void 0);
  13123. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13124. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13125. ], FlyCameraKeyboardInput.prototype, "keysLeft", void 0);
  13126. return FlyCameraKeyboardInput;
  13127. }());
  13128. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraKeyboardInput"] = FlyCameraKeyboardInput;
  13129. /***/ }),
  13130. /***/ "./Cameras/Inputs/flyCameraMouseInput.ts":
  13131. /*!***********************************************!*\
  13132. !*** ./Cameras/Inputs/flyCameraMouseInput.ts ***!
  13133. \***********************************************/
  13134. /*! exports provided: FlyCameraMouseInput */
  13135. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13136. "use strict";
  13137. __webpack_require__.r(__webpack_exports__);
  13138. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return FlyCameraMouseInput; });
  13139. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13140. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13141. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13142. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13143. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13144. /**
  13145. * Listen to mouse events to control the camera.
  13146. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13147. */
  13148. var FlyCameraMouseInput = /** @class */ (function () {
  13149. /**
  13150. * Listen to mouse events to control the camera.
  13151. * @param touchEnabled Define if touch is enabled. (Default is true.)
  13152. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13153. */
  13154. function FlyCameraMouseInput(touchEnabled) {
  13155. if (touchEnabled === void 0) { touchEnabled = true; }
  13156. /**
  13157. * Defines the buttons associated with the input to handle camera rotation.
  13158. */
  13159. this.buttons = [0, 1, 2];
  13160. /**
  13161. * Assign buttons for Yaw control.
  13162. */
  13163. this.buttonsYaw = [-1, 0, 1];
  13164. /**
  13165. * Assign buttons for Pitch control.
  13166. */
  13167. this.buttonsPitch = [-1, 0, 1];
  13168. /**
  13169. * Assign buttons for Roll control.
  13170. */
  13171. this.buttonsRoll = [2];
  13172. /**
  13173. * Detect if any button is being pressed while mouse is moved.
  13174. * -1 = Mouse locked.
  13175. * 0 = Left button.
  13176. * 1 = Middle Button.
  13177. * 2 = Right Button.
  13178. */
  13179. this.activeButton = -1;
  13180. /**
  13181. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  13182. * Higher values reduce its sensitivity.
  13183. */
  13184. this.angularSensibility = 1000.0;
  13185. this.previousPosition = null;
  13186. }
  13187. /**
  13188. * Attach the mouse control to the HTML DOM element.
  13189. * @param element Defines the element that listens to the input events.
  13190. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  13191. */
  13192. FlyCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  13193. var _this = this;
  13194. this.element = element;
  13195. this.noPreventDefault = noPreventDefault;
  13196. this._observer = this.camera.getScene().onPointerObservable.add(function (p, s) {
  13197. _this._pointerInput(p, s);
  13198. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  13199. // Correct Roll by rate, if enabled.
  13200. this._rollObserver = this.camera.getScene().onBeforeRenderObservable.add(function () {
  13201. if (_this.camera.rollCorrect) {
  13202. _this.camera.restoreRoll(_this.camera.rollCorrect);
  13203. }
  13204. });
  13205. // Helper function to keep 'this'.
  13206. this._mousemoveCallback = function (e) {
  13207. _this._onMouseMove(e);
  13208. };
  13209. element.addEventListener("mousemove", this._mousemoveCallback, false);
  13210. };
  13211. /**
  13212. * Detach the current controls from the specified dom element.
  13213. * @param element Defines the element to stop listening the inputs from
  13214. */
  13215. FlyCameraMouseInput.prototype.detachControl = function (element) {
  13216. if (this._observer && element) {
  13217. this.camera.getScene().onPointerObservable.remove(this._observer);
  13218. this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver);
  13219. if (this._mousemoveCallback) {
  13220. element.removeEventListener("mousemove", this._mousemoveCallback);
  13221. }
  13222. this._observer = null;
  13223. this._rollObserver = null;
  13224. this.previousPosition = null;
  13225. this.noPreventDefault = undefined;
  13226. }
  13227. };
  13228. /**
  13229. * Gets the class name of the current input.
  13230. * @returns the class name.
  13231. */
  13232. FlyCameraMouseInput.prototype.getClassName = function () {
  13233. return "FlyCameraMouseInput";
  13234. };
  13235. /**
  13236. * Get the friendly name associated with the input class.
  13237. * @returns the input's friendly name.
  13238. */
  13239. FlyCameraMouseInput.prototype.getSimpleName = function () {
  13240. return "mouse";
  13241. };
  13242. // Track mouse movement, when the pointer is not locked.
  13243. FlyCameraMouseInput.prototype._pointerInput = function (p, s) {
  13244. var e = p.event;
  13245. var camera = this.camera;
  13246. var engine = camera.getEngine();
  13247. if (engine.isInVRExclusivePointerMode) {
  13248. return;
  13249. }
  13250. if (!this.touchEnabled && e.pointerType === "touch") {
  13251. return;
  13252. }
  13253. // Mouse is moved but an unknown mouse button is pressed.
  13254. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && this.buttons.indexOf(e.button) === -1) {
  13255. return;
  13256. }
  13257. var srcElement = (e.srcElement || e.target);
  13258. // Mouse down.
  13259. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  13260. try {
  13261. srcElement.setPointerCapture(e.pointerId);
  13262. }
  13263. catch (e) {
  13264. // Nothing to do with the error. Execution continues.
  13265. }
  13266. this.previousPosition = {
  13267. x: e.clientX,
  13268. y: e.clientY
  13269. };
  13270. this.activeButton = e.button;
  13271. if (!this.noPreventDefault) {
  13272. e.preventDefault();
  13273. this.element.focus();
  13274. }
  13275. }
  13276. else
  13277. // Mouse up.
  13278. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  13279. try {
  13280. srcElement.releasePointerCapture(e.pointerId);
  13281. }
  13282. catch (e) {
  13283. // Nothing to do with the error. Execution continues.
  13284. }
  13285. this.activeButton = -1;
  13286. this.previousPosition = null;
  13287. if (!this.noPreventDefault) {
  13288. e.preventDefault();
  13289. }
  13290. }
  13291. else
  13292. // Mouse move.
  13293. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  13294. if (!this.previousPosition || engine.isPointerLock) {
  13295. return;
  13296. }
  13297. var offsetX = e.clientX - this.previousPosition.x;
  13298. var offsetY = e.clientY - this.previousPosition.y;
  13299. this.rotateCamera(offsetX, offsetY);
  13300. this.previousPosition = {
  13301. x: e.clientX,
  13302. y: e.clientY
  13303. };
  13304. if (!this.noPreventDefault) {
  13305. e.preventDefault();
  13306. }
  13307. }
  13308. };
  13309. // Track mouse movement, when pointer is locked.
  13310. FlyCameraMouseInput.prototype._onMouseMove = function (e) {
  13311. var camera = this.camera;
  13312. var engine = camera.getEngine();
  13313. if (!engine.isPointerLock || engine.isInVRExclusivePointerMode) {
  13314. return;
  13315. }
  13316. var offsetX = e.movementX || e.mozMovementX || e.webkitMovementX || e.msMovementX || 0;
  13317. var offsetY = e.movementY || e.mozMovementY || e.webkitMovementY || e.msMovementY || 0;
  13318. this.rotateCamera(offsetX, offsetY);
  13319. this.previousPosition = null;
  13320. if (!this.noPreventDefault) {
  13321. e.preventDefault();
  13322. }
  13323. };
  13324. /**
  13325. * Rotate camera by mouse offset.
  13326. */
  13327. FlyCameraMouseInput.prototype.rotateCamera = function (offsetX, offsetY) {
  13328. var _this = this;
  13329. var camera = this.camera;
  13330. var scene = this.camera.getScene();
  13331. if (scene.useRightHandedSystem) {
  13332. offsetX *= -1;
  13333. }
  13334. if (camera.parent && camera.parent._getWorldMatrixDeterminant() < 0) {
  13335. offsetX *= -1;
  13336. }
  13337. var x = offsetX / this.angularSensibility;
  13338. var y = offsetY / this.angularSensibility;
  13339. // Initialize to current rotation.
  13340. var currentRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, camera.rotation.z);
  13341. var rotationChange;
  13342. // Pitch.
  13343. if (this.buttonsPitch.some(function (v) { return v === _this.activeButton; })) {
  13344. // Apply change in Radians to vector Angle.
  13345. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].X, y);
  13346. // Apply Pitch to quaternion.
  13347. currentRotation.multiplyInPlace(rotationChange);
  13348. }
  13349. // Yaw.
  13350. if (this.buttonsYaw.some(function (v) { return v === _this.activeButton; })) {
  13351. // Apply change in Radians to vector Angle.
  13352. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Y, x);
  13353. // Apply Yaw to quaternion.
  13354. currentRotation.multiplyInPlace(rotationChange);
  13355. // Add Roll, if banked turning is enabled, within Roll limit.
  13356. var limit = (camera.bankedTurnLimit) + camera._trackRoll; // Defaults to 90° plus manual roll.
  13357. if (camera.bankedTurn && -limit < camera.rotation.z && camera.rotation.z < limit) {
  13358. var bankingDelta = camera.bankedTurnMultiplier * -x;
  13359. // Apply change in Radians to vector Angle.
  13360. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, bankingDelta);
  13361. // Apply Yaw to quaternion.
  13362. currentRotation.multiplyInPlace(rotationChange);
  13363. }
  13364. }
  13365. // Roll.
  13366. if (this.buttonsRoll.some(function (v) { return v === _this.activeButton; })) {
  13367. // Apply change in Radians to vector Angle.
  13368. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, -x);
  13369. // Track Rolling.
  13370. camera._trackRoll -= x;
  13371. // Apply Pitch to quaternion.
  13372. currentRotation.multiplyInPlace(rotationChange);
  13373. }
  13374. // Apply rotationQuaternion to Euler camera.rotation.
  13375. currentRotation.toEulerAnglesToRef(camera.rotation);
  13376. };
  13377. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13378. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13379. ], FlyCameraMouseInput.prototype, "buttons", void 0);
  13380. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13381. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13382. ], FlyCameraMouseInput.prototype, "angularSensibility", void 0);
  13383. return FlyCameraMouseInput;
  13384. }());
  13385. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraMouseInput"] = FlyCameraMouseInput;
  13386. /***/ }),
  13387. /***/ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts":
  13388. /*!*********************************************************!*\
  13389. !*** ./Cameras/Inputs/followCameraKeyboardMoveInput.ts ***!
  13390. \*********************************************************/
  13391. /*! exports provided: FollowCameraKeyboardMoveInput */
  13392. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13393. "use strict";
  13394. __webpack_require__.r(__webpack_exports__);
  13395. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return FollowCameraKeyboardMoveInput; });
  13396. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13397. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13398. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13399. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13400. /**
  13401. * Manage the keyboard inputs to control the movement of a follow camera.
  13402. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13403. */
  13404. var FollowCameraKeyboardMoveInput = /** @class */ (function () {
  13405. function FollowCameraKeyboardMoveInput() {
  13406. /**
  13407. * Defines the list of key codes associated with the up action (increase heightOffset)
  13408. */
  13409. this.keysHeightOffsetIncr = [38];
  13410. /**
  13411. * Defines the list of key codes associated with the down action (decrease heightOffset)
  13412. */
  13413. this.keysHeightOffsetDecr = [40];
  13414. /**
  13415. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  13416. */
  13417. this.keysHeightOffsetModifierAlt = false;
  13418. /**
  13419. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  13420. */
  13421. this.keysHeightOffsetModifierCtrl = false;
  13422. /**
  13423. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  13424. */
  13425. this.keysHeightOffsetModifierShift = false;
  13426. /**
  13427. * Defines the list of key codes associated with the left action (increase rotationOffset)
  13428. */
  13429. this.keysRotationOffsetIncr = [37];
  13430. /**
  13431. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  13432. */
  13433. this.keysRotationOffsetDecr = [39];
  13434. /**
  13435. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  13436. */
  13437. this.keysRotationOffsetModifierAlt = false;
  13438. /**
  13439. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  13440. */
  13441. this.keysRotationOffsetModifierCtrl = false;
  13442. /**
  13443. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  13444. */
  13445. this.keysRotationOffsetModifierShift = false;
  13446. /**
  13447. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  13448. */
  13449. this.keysRadiusIncr = [40];
  13450. /**
  13451. * Defines the list of key codes associated with the zoom-out action (increase radius)
  13452. */
  13453. this.keysRadiusDecr = [38];
  13454. /**
  13455. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  13456. */
  13457. this.keysRadiusModifierAlt = true;
  13458. /**
  13459. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  13460. */
  13461. this.keysRadiusModifierCtrl = false;
  13462. /**
  13463. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  13464. */
  13465. this.keysRadiusModifierShift = false;
  13466. /**
  13467. * Defines the rate of change of heightOffset.
  13468. */
  13469. this.heightSensibility = 1;
  13470. /**
  13471. * Defines the rate of change of rotationOffset.
  13472. */
  13473. this.rotationSensibility = 1;
  13474. /**
  13475. * Defines the rate of change of radius.
  13476. */
  13477. this.radiusSensibility = 1;
  13478. this._keys = new Array();
  13479. }
  13480. /**
  13481. * Attach the input controls to a specific dom element to get the input from.
  13482. * @param element Defines the element the controls should be listened from
  13483. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13484. */
  13485. FollowCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  13486. var _this = this;
  13487. if (this._onCanvasBlurObserver) {
  13488. return;
  13489. }
  13490. this._scene = this.camera.getScene();
  13491. this._engine = this._scene.getEngine();
  13492. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13493. _this._keys = [];
  13494. });
  13495. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13496. var evt = info.event;
  13497. if (!evt.metaKey) {
  13498. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13499. _this._ctrlPressed = evt.ctrlKey;
  13500. _this._altPressed = evt.altKey;
  13501. _this._shiftPressed = evt.shiftKey;
  13502. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13503. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13504. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13505. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13506. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13507. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13508. var index = _this._keys.indexOf(evt.keyCode);
  13509. if (index === -1) {
  13510. _this._keys.push(evt.keyCode);
  13511. }
  13512. if (evt.preventDefault) {
  13513. if (!noPreventDefault) {
  13514. evt.preventDefault();
  13515. }
  13516. }
  13517. }
  13518. }
  13519. else {
  13520. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13521. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13522. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13523. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13524. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13525. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13526. var index = _this._keys.indexOf(evt.keyCode);
  13527. if (index >= 0) {
  13528. _this._keys.splice(index, 1);
  13529. }
  13530. if (evt.preventDefault) {
  13531. if (!noPreventDefault) {
  13532. evt.preventDefault();
  13533. }
  13534. }
  13535. }
  13536. }
  13537. }
  13538. });
  13539. };
  13540. /**
  13541. * Detach the current controls from the specified dom element.
  13542. * @param element Defines the element to stop listening the inputs from
  13543. */
  13544. FollowCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  13545. if (this._scene) {
  13546. if (this._onKeyboardObserver) {
  13547. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13548. }
  13549. if (this._onCanvasBlurObserver) {
  13550. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13551. }
  13552. this._onKeyboardObserver = null;
  13553. this._onCanvasBlurObserver = null;
  13554. }
  13555. this._keys = [];
  13556. };
  13557. /**
  13558. * Update the current camera state depending on the inputs that have been used this frame.
  13559. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13560. */
  13561. FollowCameraKeyboardMoveInput.prototype.checkInputs = function () {
  13562. var _this = this;
  13563. if (this._onKeyboardObserver) {
  13564. this._keys.forEach(function (keyCode) {
  13565. if (_this.keysHeightOffsetIncr.indexOf(keyCode) !== -1 &&
  13566. _this._modifierHeightOffset()) {
  13567. _this.camera.heightOffset += _this.heightSensibility;
  13568. }
  13569. else if (_this.keysHeightOffsetDecr.indexOf(keyCode) !== -1 &&
  13570. _this._modifierHeightOffset()) {
  13571. _this.camera.heightOffset -= _this.heightSensibility;
  13572. }
  13573. else if (_this.keysRotationOffsetIncr.indexOf(keyCode) !== -1 &&
  13574. _this._modifierRotationOffset()) {
  13575. _this.camera.rotationOffset += _this.rotationSensibility;
  13576. _this.camera.rotationOffset %= 360;
  13577. }
  13578. else if (_this.keysRotationOffsetDecr.indexOf(keyCode) !== -1 &&
  13579. _this._modifierRotationOffset()) {
  13580. _this.camera.rotationOffset -= _this.rotationSensibility;
  13581. _this.camera.rotationOffset %= 360;
  13582. }
  13583. else if (_this.keysRadiusIncr.indexOf(keyCode) !== -1 &&
  13584. _this._modifierRadius()) {
  13585. _this.camera.radius += _this.radiusSensibility;
  13586. }
  13587. else if (_this.keysRadiusDecr.indexOf(keyCode) !== -1 &&
  13588. _this._modifierRadius()) {
  13589. _this.camera.radius -= _this.radiusSensibility;
  13590. }
  13591. });
  13592. }
  13593. };
  13594. /**
  13595. * Gets the class name of the current input.
  13596. * @returns the class name
  13597. */
  13598. FollowCameraKeyboardMoveInput.prototype.getClassName = function () {
  13599. return "FollowCameraKeyboardMoveInput";
  13600. };
  13601. /**
  13602. * Get the friendly name associated with the input class.
  13603. * @returns the input friendly name
  13604. */
  13605. FollowCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  13606. return "keyboard";
  13607. };
  13608. /**
  13609. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13610. * allow modification of the heightOffset value.
  13611. */
  13612. FollowCameraKeyboardMoveInput.prototype._modifierHeightOffset = function () {
  13613. return (this.keysHeightOffsetModifierAlt === this._altPressed &&
  13614. this.keysHeightOffsetModifierCtrl === this._ctrlPressed &&
  13615. this.keysHeightOffsetModifierShift === this._shiftPressed);
  13616. };
  13617. /**
  13618. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13619. * allow modification of the rotationOffset value.
  13620. */
  13621. FollowCameraKeyboardMoveInput.prototype._modifierRotationOffset = function () {
  13622. return (this.keysRotationOffsetModifierAlt === this._altPressed &&
  13623. this.keysRotationOffsetModifierCtrl === this._ctrlPressed &&
  13624. this.keysRotationOffsetModifierShift === this._shiftPressed);
  13625. };
  13626. /**
  13627. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13628. * allow modification of the radius value.
  13629. */
  13630. FollowCameraKeyboardMoveInput.prototype._modifierRadius = function () {
  13631. return (this.keysRadiusModifierAlt === this._altPressed &&
  13632. this.keysRadiusModifierCtrl === this._ctrlPressed &&
  13633. this.keysRadiusModifierShift === this._shiftPressed);
  13634. };
  13635. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13636. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13637. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetIncr", void 0);
  13638. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13639. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13640. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetDecr", void 0);
  13641. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13642. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13643. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierAlt", void 0);
  13644. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13645. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13646. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierCtrl", void 0);
  13647. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13648. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13649. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierShift", void 0);
  13650. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13651. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13652. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetIncr", void 0);
  13653. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13654. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13655. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetDecr", void 0);
  13656. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13657. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13658. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierAlt", void 0);
  13659. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13660. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13661. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierCtrl", void 0);
  13662. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13663. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13664. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierShift", void 0);
  13665. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13666. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13667. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusIncr", void 0);
  13668. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13669. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13670. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusDecr", void 0);
  13671. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13672. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13673. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierAlt", void 0);
  13674. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13675. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13676. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierCtrl", void 0);
  13677. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13678. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13679. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierShift", void 0);
  13680. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13681. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13682. ], FollowCameraKeyboardMoveInput.prototype, "heightSensibility", void 0);
  13683. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13684. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13685. ], FollowCameraKeyboardMoveInput.prototype, "rotationSensibility", void 0);
  13686. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13687. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13688. ], FollowCameraKeyboardMoveInput.prototype, "radiusSensibility", void 0);
  13689. return FollowCameraKeyboardMoveInput;
  13690. }());
  13691. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FollowCameraKeyboardMoveInput"] = FollowCameraKeyboardMoveInput;
  13692. /***/ }),
  13693. /***/ "./Cameras/Inputs/followCameraMouseWheelInput.ts":
  13694. /*!*******************************************************!*\
  13695. !*** ./Cameras/Inputs/followCameraMouseWheelInput.ts ***!
  13696. \*******************************************************/
  13697. /*! exports provided: FollowCameraMouseWheelInput */
  13698. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13699. "use strict";
  13700. __webpack_require__.r(__webpack_exports__);
  13701. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return FollowCameraMouseWheelInput; });
  13702. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13703. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13704. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13705. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13706. /**
  13707. * Manage the mouse wheel inputs to control a follow camera.
  13708. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13709. */
  13710. var FollowCameraMouseWheelInput = /** @class */ (function () {
  13711. function FollowCameraMouseWheelInput() {
  13712. /**
  13713. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  13714. */
  13715. this.axisControlRadius = true;
  13716. /**
  13717. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  13718. */
  13719. this.axisControlHeight = false;
  13720. /**
  13721. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  13722. */
  13723. this.axisControlRotation = false;
  13724. /**
  13725. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  13726. * relation to mouseWheel events.
  13727. */
  13728. this.wheelPrecision = 3.0;
  13729. /**
  13730. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  13731. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  13732. */
  13733. this.wheelDeltaPercentage = 0;
  13734. }
  13735. /**
  13736. * Attach the input controls to a specific dom element to get the input from.
  13737. * @param element Defines the element the controls should be listened from
  13738. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13739. */
  13740. FollowCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  13741. var _this = this;
  13742. this._wheel = function (p, s) {
  13743. // sanity check - this should be a PointerWheel event.
  13744. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  13745. return;
  13746. }
  13747. var event = p.event;
  13748. var delta = 0;
  13749. // Chrome, Safari: event.deltaY
  13750. // IE: event.wheelDelta
  13751. // Firefox: event.detail (inverted)
  13752. var wheelDelta = Math.max(-1, Math.min(1, (event.deltaY || event.wheelDelta || -event.detail)));
  13753. if (_this.wheelDeltaPercentage) {
  13754. console.assert((_this.axisControlRadius +
  13755. _this.axisControlHeight +
  13756. _this.axisControlRotation) <= 1, "wheelDeltaPercentage only usable when mouse wheel " +
  13757. "controlls ONE axis. " +
  13758. "Currently enabled: " +
  13759. "axisControlRadius: " + _this.axisControlRadius +
  13760. ", axisControlHeightOffset: " + _this.axisControlHeight +
  13761. ", axisControlRotationOffset: " + _this.axisControlRotation);
  13762. if (_this.axisControlRadius) {
  13763. delta =
  13764. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13765. _this.camera.radius;
  13766. }
  13767. else if (_this.axisControlHeight) {
  13768. delta =
  13769. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13770. _this.camera.heightOffset;
  13771. }
  13772. else if (_this.axisControlRotation) {
  13773. delta =
  13774. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13775. _this.camera.rotationOffset;
  13776. }
  13777. }
  13778. else {
  13779. delta = wheelDelta * _this.wheelPrecision;
  13780. }
  13781. if (delta) {
  13782. if (_this.axisControlRadius) {
  13783. _this.camera.radius += delta;
  13784. }
  13785. else if (_this.axisControlHeight) {
  13786. _this.camera.heightOffset -= delta;
  13787. }
  13788. else if (_this.axisControlRotation) {
  13789. _this.camera.rotationOffset -= delta;
  13790. }
  13791. }
  13792. if (event.preventDefault) {
  13793. if (!noPreventDefault) {
  13794. event.preventDefault();
  13795. }
  13796. }
  13797. };
  13798. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  13799. };
  13800. /**
  13801. * Detach the current controls from the specified dom element.
  13802. * @param element Defines the element to stop listening the inputs from
  13803. */
  13804. FollowCameraMouseWheelInput.prototype.detachControl = function (element) {
  13805. if (this._observer && element) {
  13806. this.camera.getScene().onPointerObservable.remove(this._observer);
  13807. this._observer = null;
  13808. this._wheel = null;
  13809. }
  13810. };
  13811. /**
  13812. * Gets the class name of the current intput.
  13813. * @returns the class name
  13814. */
  13815. FollowCameraMouseWheelInput.prototype.getClassName = function () {
  13816. return "ArcRotateCameraMouseWheelInput";
  13817. };
  13818. /**
  13819. * Get the friendly name associated with the input class.
  13820. * @returns the input friendly name
  13821. */
  13822. FollowCameraMouseWheelInput.prototype.getSimpleName = function () {
  13823. return "mousewheel";
  13824. };
  13825. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13826. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13827. ], FollowCameraMouseWheelInput.prototype, "axisControlRadius", void 0);
  13828. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13829. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13830. ], FollowCameraMouseWheelInput.prototype, "axisControlHeight", void 0);
  13831. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13832. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13833. ], FollowCameraMouseWheelInput.prototype, "axisControlRotation", void 0);
  13834. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13835. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13836. ], FollowCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  13837. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13838. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13839. ], FollowCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  13840. return FollowCameraMouseWheelInput;
  13841. }());
  13842. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraMouseWheelInput"] = FollowCameraMouseWheelInput;
  13843. /***/ }),
  13844. /***/ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts":
  13845. /*!************************************************************!*\
  13846. !*** ./Cameras/Inputs/freeCameraDeviceOrientationInput.ts ***!
  13847. \************************************************************/
  13848. /*! exports provided: FreeCameraDeviceOrientationInput */
  13849. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13850. "use strict";
  13851. __webpack_require__.r(__webpack_exports__);
  13852. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return FreeCameraDeviceOrientationInput; });
  13853. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13854. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13855. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  13856. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  13857. /**
  13858. * Add orientation input support to the input manager.
  13859. * @returns the current input manager
  13860. */
  13861. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addDeviceOrientation = function () {
  13862. this.add(new FreeCameraDeviceOrientationInput());
  13863. return this;
  13864. };
  13865. /**
  13866. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  13867. * Screen rotation is taken into account.
  13868. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13869. */
  13870. var FreeCameraDeviceOrientationInput = /** @class */ (function () {
  13871. /**
  13872. * Instantiates a new input
  13873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13874. */
  13875. function FreeCameraDeviceOrientationInput() {
  13876. var _this = this;
  13877. this._screenOrientationAngle = 0;
  13878. this._screenQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  13879. this._alpha = 0;
  13880. this._beta = 0;
  13881. this._gamma = 0;
  13882. this._orientationChanged = function () {
  13883. _this._screenOrientationAngle = (window.orientation !== undefined ? +window.orientation : (window.screen.orientation && (window.screen.orientation)['angle'] ? (window.screen.orientation).angle : 0));
  13884. _this._screenOrientationAngle = -_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(_this._screenOrientationAngle / 2);
  13885. _this._screenQuaternion.copyFromFloats(0, Math.sin(_this._screenOrientationAngle), 0, Math.cos(_this._screenOrientationAngle));
  13886. };
  13887. this._deviceOrientation = function (evt) {
  13888. _this._alpha = evt.alpha !== null ? evt.alpha : 0;
  13889. _this._beta = evt.beta !== null ? evt.beta : 0;
  13890. _this._gamma = evt.gamma !== null ? evt.gamma : 0;
  13891. };
  13892. this._constantTranform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-Math.sqrt(0.5), 0, 0, Math.sqrt(0.5));
  13893. this._orientationChanged();
  13894. }
  13895. Object.defineProperty(FreeCameraDeviceOrientationInput.prototype, "camera", {
  13896. /**
  13897. * Define the camera controlled by the input.
  13898. */
  13899. get: function () {
  13900. return this._camera;
  13901. },
  13902. set: function (camera) {
  13903. this._camera = camera;
  13904. if (this._camera != null && !this._camera.rotationQuaternion) {
  13905. this._camera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  13906. }
  13907. },
  13908. enumerable: true,
  13909. configurable: true
  13910. });
  13911. /**
  13912. * Attach the input controls to a specific dom element to get the input from.
  13913. * @param element Defines the element the controls should be listened from
  13914. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13915. */
  13916. FreeCameraDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  13917. window.addEventListener("orientationchange", this._orientationChanged);
  13918. window.addEventListener("deviceorientation", this._deviceOrientation);
  13919. //In certain cases, the attach control is called AFTER orientation was changed,
  13920. //So this is needed.
  13921. this._orientationChanged();
  13922. };
  13923. /**
  13924. * Detach the current controls from the specified dom element.
  13925. * @param element Defines the element to stop listening the inputs from
  13926. */
  13927. FreeCameraDeviceOrientationInput.prototype.detachControl = function (element) {
  13928. window.removeEventListener("orientationchange", this._orientationChanged);
  13929. window.removeEventListener("deviceorientation", this._deviceOrientation);
  13930. };
  13931. /**
  13932. * Update the current camera state depending on the inputs that have been used this frame.
  13933. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13934. */
  13935. FreeCameraDeviceOrientationInput.prototype.checkInputs = function () {
  13936. //if no device orientation provided, don't update the rotation.
  13937. //Only testing against alpha under the assumption thatnorientation will never be so exact when set.
  13938. if (!this._alpha) {
  13939. return;
  13940. }
  13941. _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);
  13942. this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion);
  13943. this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform);
  13944. //Mirror on XY Plane
  13945. this._camera.rotationQuaternion.z *= -1;
  13946. this._camera.rotationQuaternion.w *= -1;
  13947. };
  13948. /**
  13949. * Gets the class name of the current intput.
  13950. * @returns the class name
  13951. */
  13952. FreeCameraDeviceOrientationInput.prototype.getClassName = function () {
  13953. return "FreeCameraDeviceOrientationInput";
  13954. };
  13955. /**
  13956. * Get the friendly name associated with the input class.
  13957. * @returns the input friendly name
  13958. */
  13959. FreeCameraDeviceOrientationInput.prototype.getSimpleName = function () {
  13960. return "deviceOrientation";
  13961. };
  13962. return FreeCameraDeviceOrientationInput;
  13963. }());
  13964. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["FreeCameraDeviceOrientationInput"] = FreeCameraDeviceOrientationInput;
  13965. /***/ }),
  13966. /***/ "./Cameras/Inputs/freeCameraGamepadInput.ts":
  13967. /*!**************************************************!*\
  13968. !*** ./Cameras/Inputs/freeCameraGamepadInput.ts ***!
  13969. \**************************************************/
  13970. /*! exports provided: FreeCameraGamepadInput */
  13971. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13972. "use strict";
  13973. __webpack_require__.r(__webpack_exports__);
  13974. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return FreeCameraGamepadInput; });
  13975. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13976. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13977. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13978. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13979. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  13980. /**
  13981. * Manage the gamepad inputs to control a free camera.
  13982. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13983. */
  13984. var FreeCameraGamepadInput = /** @class */ (function () {
  13985. function FreeCameraGamepadInput() {
  13986. /**
  13987. * Defines the gamepad rotation sensiblity.
  13988. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  13989. */
  13990. this.gamepadAngularSensibility = 200;
  13991. /**
  13992. * Defines the gamepad move sensiblity.
  13993. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  13994. */
  13995. this.gamepadMoveSensibility = 40;
  13996. this._cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  13997. this._deltaTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  13998. this._vector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  13999. this._vector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  14000. }
  14001. /**
  14002. * Attach the input controls to a specific dom element to get the input from.
  14003. * @param element Defines the element the controls should be listened from
  14004. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14005. */
  14006. FreeCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  14007. var _this = this;
  14008. var manager = this.camera.getScene().gamepadManager;
  14009. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  14010. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].POSE_ENABLED) {
  14011. // prioritize XBOX gamepads.
  14012. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX) {
  14013. _this.gamepad = gamepad;
  14014. }
  14015. }
  14016. });
  14017. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  14018. if (_this.gamepad === gamepad) {
  14019. _this.gamepad = null;
  14020. }
  14021. });
  14022. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX);
  14023. };
  14024. /**
  14025. * Detach the current controls from the specified dom element.
  14026. * @param element Defines the element to stop listening the inputs from
  14027. */
  14028. FreeCameraGamepadInput.prototype.detachControl = function (element) {
  14029. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  14030. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  14031. this.gamepad = null;
  14032. };
  14033. /**
  14034. * Update the current camera state depending on the inputs that have been used this frame.
  14035. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14036. */
  14037. FreeCameraGamepadInput.prototype.checkInputs = function () {
  14038. if (this.gamepad && this.gamepad.leftStick) {
  14039. var camera = this.camera;
  14040. var LSValues = this.gamepad.leftStick;
  14041. var normalizedLX = LSValues.x / this.gamepadMoveSensibility;
  14042. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  14043. LSValues.x = Math.abs(normalizedLX) > 0.005 ? 0 + normalizedLX : 0;
  14044. LSValues.y = Math.abs(normalizedLY) > 0.005 ? 0 + normalizedLY : 0;
  14045. var RSValues = this.gamepad.rightStick;
  14046. if (RSValues) {
  14047. var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
  14048. var normalizedRY = RSValues.y / this.gamepadAngularSensibility;
  14049. RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
  14050. RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
  14051. }
  14052. else {
  14053. RSValues = { x: 0, y: 0 };
  14054. }
  14055. if (!camera.rotationQuaternion) {
  14056. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, this._cameraTransform);
  14057. }
  14058. else {
  14059. camera.rotationQuaternion.toRotationMatrix(this._cameraTransform);
  14060. }
  14061. var speed = camera._computeLocalCameraSpeed() * 50.0;
  14062. this._vector3.copyFromFloats(LSValues.x * speed, 0, -LSValues.y * speed);
  14063. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._vector3, this._cameraTransform, this._deltaTransform);
  14064. camera.cameraDirection.addInPlace(this._deltaTransform);
  14065. this._vector2.copyFromFloats(RSValues.y, RSValues.x);
  14066. camera.cameraRotation.addInPlace(this._vector2);
  14067. }
  14068. };
  14069. /**
  14070. * Gets the class name of the current intput.
  14071. * @returns the class name
  14072. */
  14073. FreeCameraGamepadInput.prototype.getClassName = function () {
  14074. return "FreeCameraGamepadInput";
  14075. };
  14076. /**
  14077. * Get the friendly name associated with the input class.
  14078. * @returns the input friendly name
  14079. */
  14080. FreeCameraGamepadInput.prototype.getSimpleName = function () {
  14081. return "gamepad";
  14082. };
  14083. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14084. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14085. ], FreeCameraGamepadInput.prototype, "gamepadAngularSensibility", void 0);
  14086. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14087. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14088. ], FreeCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  14089. return FreeCameraGamepadInput;
  14090. }());
  14091. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraGamepadInput"] = FreeCameraGamepadInput;
  14092. /***/ }),
  14093. /***/ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts":
  14094. /*!*******************************************************!*\
  14095. !*** ./Cameras/Inputs/freeCameraKeyboardMoveInput.ts ***!
  14096. \*******************************************************/
  14097. /*! exports provided: FreeCameraKeyboardMoveInput */
  14098. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14099. "use strict";
  14100. __webpack_require__.r(__webpack_exports__);
  14101. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return FreeCameraKeyboardMoveInput; });
  14102. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14103. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14104. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14105. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  14106. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14107. /**
  14108. * Manage the keyboard inputs to control the movement of a free camera.
  14109. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14110. */
  14111. var FreeCameraKeyboardMoveInput = /** @class */ (function () {
  14112. function FreeCameraKeyboardMoveInput() {
  14113. /**
  14114. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  14115. */
  14116. this.keysUp = [38];
  14117. /**
  14118. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  14119. */
  14120. this.keysDown = [40];
  14121. /**
  14122. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  14123. */
  14124. this.keysLeft = [37];
  14125. /**
  14126. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  14127. */
  14128. this.keysRight = [39];
  14129. this._keys = new Array();
  14130. }
  14131. /**
  14132. * Attach the input controls to a specific dom element to get the input from.
  14133. * @param element Defines the element the controls should be listened from
  14134. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14135. */
  14136. FreeCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  14137. var _this = this;
  14138. if (this._onCanvasBlurObserver) {
  14139. return;
  14140. }
  14141. this._scene = this.camera.getScene();
  14142. this._engine = this._scene.getEngine();
  14143. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  14144. _this._keys = [];
  14145. });
  14146. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  14147. var evt = info.event;
  14148. if (!evt.metaKey) {
  14149. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  14150. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14151. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14152. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14153. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14154. var index = _this._keys.indexOf(evt.keyCode);
  14155. if (index === -1) {
  14156. _this._keys.push(evt.keyCode);
  14157. }
  14158. if (!noPreventDefault) {
  14159. evt.preventDefault();
  14160. }
  14161. }
  14162. }
  14163. else {
  14164. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14165. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14166. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14167. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14168. var index = _this._keys.indexOf(evt.keyCode);
  14169. if (index >= 0) {
  14170. _this._keys.splice(index, 1);
  14171. }
  14172. if (!noPreventDefault) {
  14173. evt.preventDefault();
  14174. }
  14175. }
  14176. }
  14177. }
  14178. });
  14179. };
  14180. /**
  14181. * Detach the current controls from the specified dom element.
  14182. * @param element Defines the element to stop listening the inputs from
  14183. */
  14184. FreeCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  14185. if (this._scene) {
  14186. if (this._onKeyboardObserver) {
  14187. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  14188. }
  14189. if (this._onCanvasBlurObserver) {
  14190. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  14191. }
  14192. this._onKeyboardObserver = null;
  14193. this._onCanvasBlurObserver = null;
  14194. }
  14195. this._keys = [];
  14196. };
  14197. /**
  14198. * Update the current camera state depending on the inputs that have been used this frame.
  14199. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14200. */
  14201. FreeCameraKeyboardMoveInput.prototype.checkInputs = function () {
  14202. if (this._onKeyboardObserver) {
  14203. var camera = this.camera;
  14204. // Keyboard
  14205. for (var index = 0; index < this._keys.length; index++) {
  14206. var keyCode = this._keys[index];
  14207. var speed = camera._computeLocalCameraSpeed();
  14208. if (this.keysLeft.indexOf(keyCode) !== -1) {
  14209. camera._localDirection.copyFromFloats(-speed, 0, 0);
  14210. }
  14211. else if (this.keysUp.indexOf(keyCode) !== -1) {
  14212. camera._localDirection.copyFromFloats(0, 0, speed);
  14213. }
  14214. else if (this.keysRight.indexOf(keyCode) !== -1) {
  14215. camera._localDirection.copyFromFloats(speed, 0, 0);
  14216. }
  14217. else if (this.keysDown.indexOf(keyCode) !== -1) {
  14218. camera._localDirection.copyFromFloats(0, 0, -speed);
  14219. }
  14220. if (camera.getScene().useRightHandedSystem) {
  14221. camera._localDirection.z *= -1;
  14222. }
  14223. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  14224. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  14225. camera.cameraDirection.addInPlace(camera._transformedDirection);
  14226. }
  14227. }
  14228. };
  14229. /**
  14230. * Gets the class name of the current intput.
  14231. * @returns the class name
  14232. */
  14233. FreeCameraKeyboardMoveInput.prototype.getClassName = function () {
  14234. return "FreeCameraKeyboardMoveInput";
  14235. };
  14236. /** @hidden */
  14237. FreeCameraKeyboardMoveInput.prototype._onLostFocus = function () {
  14238. this._keys = [];
  14239. };
  14240. /**
  14241. * Get the friendly name associated with the input class.
  14242. * @returns the input friendly name
  14243. */
  14244. FreeCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  14245. return "keyboard";
  14246. };
  14247. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14248. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14249. ], FreeCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  14250. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14251. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14252. ], FreeCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  14253. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14254. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14255. ], FreeCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  14256. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14257. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14258. ], FreeCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  14259. return FreeCameraKeyboardMoveInput;
  14260. }());
  14261. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraKeyboardMoveInput"] = FreeCameraKeyboardMoveInput;
  14262. /***/ }),
  14263. /***/ "./Cameras/Inputs/freeCameraMouseInput.ts":
  14264. /*!************************************************!*\
  14265. !*** ./Cameras/Inputs/freeCameraMouseInput.ts ***!
  14266. \************************************************/
  14267. /*! exports provided: FreeCameraMouseInput */
  14268. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14269. "use strict";
  14270. __webpack_require__.r(__webpack_exports__);
  14271. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return FreeCameraMouseInput; });
  14272. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14273. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14274. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14275. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14276. /**
  14277. * Manage the mouse inputs to control the movement of a free camera.
  14278. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14279. */
  14280. var FreeCameraMouseInput = /** @class */ (function () {
  14281. /**
  14282. * Manage the mouse inputs to control the movement of a free camera.
  14283. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14284. * @param touchEnabled Defines if touch is enabled or not
  14285. */
  14286. function FreeCameraMouseInput(
  14287. /**
  14288. * Define if touch is enabled in the mouse input
  14289. */
  14290. touchEnabled) {
  14291. if (touchEnabled === void 0) { touchEnabled = true; }
  14292. this.touchEnabled = touchEnabled;
  14293. /**
  14294. * Defines the buttons associated with the input to handle camera move.
  14295. */
  14296. this.buttons = [0, 1, 2];
  14297. /**
  14298. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  14299. */
  14300. this.angularSensibility = 2000.0;
  14301. this.previousPosition = null;
  14302. }
  14303. /**
  14304. * Attach the input controls to a specific dom element to get the input from.
  14305. * @param element Defines the element the controls should be listened from
  14306. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14307. */
  14308. FreeCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  14309. var _this = this;
  14310. var engine = this.camera.getEngine();
  14311. if (!this._pointerInput) {
  14312. this._pointerInput = function (p) {
  14313. var evt = p.event;
  14314. if (engine.isInVRExclusivePointerMode) {
  14315. return;
  14316. }
  14317. if (!_this.touchEnabled && evt.pointerType === "touch") {
  14318. return;
  14319. }
  14320. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  14321. return;
  14322. }
  14323. var srcElement = (evt.srcElement || evt.target);
  14324. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  14325. try {
  14326. srcElement.setPointerCapture(evt.pointerId);
  14327. }
  14328. catch (e) {
  14329. //Nothing to do with the error. Execution will continue.
  14330. }
  14331. _this.previousPosition = {
  14332. x: evt.clientX,
  14333. y: evt.clientY
  14334. };
  14335. if (!noPreventDefault) {
  14336. evt.preventDefault();
  14337. element.focus();
  14338. }
  14339. }
  14340. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  14341. try {
  14342. srcElement.releasePointerCapture(evt.pointerId);
  14343. }
  14344. catch (e) {
  14345. //Nothing to do with the error.
  14346. }
  14347. _this.previousPosition = null;
  14348. if (!noPreventDefault) {
  14349. evt.preventDefault();
  14350. }
  14351. }
  14352. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  14353. if (!_this.previousPosition || engine.isPointerLock) {
  14354. return;
  14355. }
  14356. var offsetX = evt.clientX - _this.previousPosition.x;
  14357. if (_this.camera.getScene().useRightHandedSystem) {
  14358. offsetX *= -1;
  14359. }
  14360. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14361. offsetX *= -1;
  14362. }
  14363. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14364. var offsetY = evt.clientY - _this.previousPosition.y;
  14365. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14366. _this.previousPosition = {
  14367. x: evt.clientX,
  14368. y: evt.clientY
  14369. };
  14370. if (!noPreventDefault) {
  14371. evt.preventDefault();
  14372. }
  14373. }
  14374. };
  14375. }
  14376. this._onMouseMove = function (evt) {
  14377. if (!engine.isPointerLock) {
  14378. return;
  14379. }
  14380. if (engine.isInVRExclusivePointerMode) {
  14381. return;
  14382. }
  14383. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  14384. if (_this.camera.getScene().useRightHandedSystem) {
  14385. offsetX *= -1;
  14386. }
  14387. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14388. offsetX *= -1;
  14389. }
  14390. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14391. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  14392. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14393. _this.previousPosition = null;
  14394. if (!noPreventDefault) {
  14395. evt.preventDefault();
  14396. }
  14397. };
  14398. 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);
  14399. element.addEventListener("mousemove", this._onMouseMove, false);
  14400. };
  14401. /**
  14402. * Detach the current controls from the specified dom element.
  14403. * @param element Defines the element to stop listening the inputs from
  14404. */
  14405. FreeCameraMouseInput.prototype.detachControl = function (element) {
  14406. if (this._observer && element) {
  14407. this.camera.getScene().onPointerObservable.remove(this._observer);
  14408. if (this._onMouseMove) {
  14409. element.removeEventListener("mousemove", this._onMouseMove);
  14410. }
  14411. this._observer = null;
  14412. this._onMouseMove = null;
  14413. this.previousPosition = null;
  14414. }
  14415. };
  14416. /**
  14417. * Gets the class name of the current intput.
  14418. * @returns the class name
  14419. */
  14420. FreeCameraMouseInput.prototype.getClassName = function () {
  14421. return "FreeCameraMouseInput";
  14422. };
  14423. /**
  14424. * Get the friendly name associated with the input class.
  14425. * @returns the input friendly name
  14426. */
  14427. FreeCameraMouseInput.prototype.getSimpleName = function () {
  14428. return "mouse";
  14429. };
  14430. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14431. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14432. ], FreeCameraMouseInput.prototype, "buttons", void 0);
  14433. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14434. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14435. ], FreeCameraMouseInput.prototype, "angularSensibility", void 0);
  14436. return FreeCameraMouseInput;
  14437. }());
  14438. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraMouseInput"] = FreeCameraMouseInput;
  14439. /***/ }),
  14440. /***/ "./Cameras/Inputs/freeCameraTouchInput.ts":
  14441. /*!************************************************!*\
  14442. !*** ./Cameras/Inputs/freeCameraTouchInput.ts ***!
  14443. \************************************************/
  14444. /*! exports provided: FreeCameraTouchInput */
  14445. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14446. "use strict";
  14447. __webpack_require__.r(__webpack_exports__);
  14448. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return FreeCameraTouchInput; });
  14449. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14450. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14451. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14452. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14453. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14454. /**
  14455. * Manage the touch inputs to control the movement of a free camera.
  14456. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14457. */
  14458. var FreeCameraTouchInput = /** @class */ (function () {
  14459. function FreeCameraTouchInput() {
  14460. /**
  14461. * Defines the touch sensibility for rotation.
  14462. * The higher the faster.
  14463. */
  14464. this.touchAngularSensibility = 200000.0;
  14465. /**
  14466. * Defines the touch sensibility for move.
  14467. * The higher the faster.
  14468. */
  14469. this.touchMoveSensibility = 250.0;
  14470. this._offsetX = null;
  14471. this._offsetY = null;
  14472. this._pointerPressed = new Array();
  14473. }
  14474. /**
  14475. * Attach the input controls to a specific dom element to get the input from.
  14476. * @param element Defines the element the controls should be listened from
  14477. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14478. */
  14479. FreeCameraTouchInput.prototype.attachControl = function (element, noPreventDefault) {
  14480. var _this = this;
  14481. var previousPosition = null;
  14482. if (this._pointerInput === undefined) {
  14483. this._onLostFocus = function () {
  14484. _this._offsetX = null;
  14485. _this._offsetY = null;
  14486. };
  14487. this._pointerInput = function (p) {
  14488. var evt = p.event;
  14489. if (evt.pointerType === "mouse") {
  14490. return;
  14491. }
  14492. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN) {
  14493. if (!noPreventDefault) {
  14494. evt.preventDefault();
  14495. }
  14496. _this._pointerPressed.push(evt.pointerId);
  14497. if (_this._pointerPressed.length !== 1) {
  14498. return;
  14499. }
  14500. previousPosition = {
  14501. x: evt.clientX,
  14502. y: evt.clientY
  14503. };
  14504. }
  14505. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP) {
  14506. if (!noPreventDefault) {
  14507. evt.preventDefault();
  14508. }
  14509. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14510. if (index === -1) {
  14511. return;
  14512. }
  14513. _this._pointerPressed.splice(index, 1);
  14514. if (index != 0) {
  14515. return;
  14516. }
  14517. previousPosition = null;
  14518. _this._offsetX = null;
  14519. _this._offsetY = null;
  14520. }
  14521. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  14522. if (!noPreventDefault) {
  14523. evt.preventDefault();
  14524. }
  14525. if (!previousPosition) {
  14526. return;
  14527. }
  14528. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14529. if (index != 0) {
  14530. return;
  14531. }
  14532. _this._offsetX = evt.clientX - previousPosition.x;
  14533. _this._offsetY = -(evt.clientY - previousPosition.y);
  14534. }
  14535. };
  14536. }
  14537. 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);
  14538. if (this._onLostFocus) {
  14539. element.addEventListener("blur", this._onLostFocus);
  14540. }
  14541. };
  14542. /**
  14543. * Detach the current controls from the specified dom element.
  14544. * @param element Defines the element to stop listening the inputs from
  14545. */
  14546. FreeCameraTouchInput.prototype.detachControl = function (element) {
  14547. if (this._pointerInput && element) {
  14548. if (this._observer) {
  14549. this.camera.getScene().onPointerObservable.remove(this._observer);
  14550. this._observer = null;
  14551. }
  14552. if (this._onLostFocus) {
  14553. element.removeEventListener("blur", this._onLostFocus);
  14554. this._onLostFocus = null;
  14555. }
  14556. this._pointerPressed = [];
  14557. this._offsetX = null;
  14558. this._offsetY = null;
  14559. }
  14560. };
  14561. /**
  14562. * Update the current camera state depending on the inputs that have been used this frame.
  14563. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14564. */
  14565. FreeCameraTouchInput.prototype.checkInputs = function () {
  14566. if (this._offsetX && this._offsetY) {
  14567. var camera = this.camera;
  14568. camera.cameraRotation.y += this._offsetX / this.touchAngularSensibility;
  14569. if (this._pointerPressed.length > 1) {
  14570. camera.cameraRotation.x += -this._offsetY / this.touchAngularSensibility;
  14571. }
  14572. else {
  14573. var speed = camera._computeLocalCameraSpeed();
  14574. var direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, speed * this._offsetY / this.touchMoveSensibility);
  14575. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);
  14576. camera.cameraDirection.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(direction, camera._cameraRotationMatrix));
  14577. }
  14578. }
  14579. };
  14580. /**
  14581. * Gets the class name of the current intput.
  14582. * @returns the class name
  14583. */
  14584. FreeCameraTouchInput.prototype.getClassName = function () {
  14585. return "FreeCameraTouchInput";
  14586. };
  14587. /**
  14588. * Get the friendly name associated with the input class.
  14589. * @returns the input friendly name
  14590. */
  14591. FreeCameraTouchInput.prototype.getSimpleName = function () {
  14592. return "touch";
  14593. };
  14594. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14595. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14596. ], FreeCameraTouchInput.prototype, "touchAngularSensibility", void 0);
  14597. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14598. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14599. ], FreeCameraTouchInput.prototype, "touchMoveSensibility", void 0);
  14600. return FreeCameraTouchInput;
  14601. }());
  14602. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraTouchInput"] = FreeCameraTouchInput;
  14603. /***/ }),
  14604. /***/ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts":
  14605. /*!**********************************************************!*\
  14606. !*** ./Cameras/Inputs/freeCameraVirtualJoystickInput.ts ***!
  14607. \**********************************************************/
  14608. /*! exports provided: FreeCameraVirtualJoystickInput */
  14609. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14610. "use strict";
  14611. __webpack_require__.r(__webpack_exports__);
  14612. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return FreeCameraVirtualJoystickInput; });
  14613. /* harmony import */ var _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/virtualJoystick */ "./Misc/virtualJoystick.ts");
  14614. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14615. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14616. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  14617. /**
  14618. * Add virtual joystick input support to the input manager.
  14619. * @returns the current input manager
  14620. */
  14621. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addVirtualJoystick = function () {
  14622. this.add(new FreeCameraVirtualJoystickInput());
  14623. return this;
  14624. };
  14625. /**
  14626. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  14627. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14628. */
  14629. var FreeCameraVirtualJoystickInput = /** @class */ (function () {
  14630. function FreeCameraVirtualJoystickInput() {
  14631. }
  14632. /**
  14633. * Gets the left stick of the virtual joystick.
  14634. * @returns The virtual Joystick
  14635. */
  14636. FreeCameraVirtualJoystickInput.prototype.getLeftJoystick = function () {
  14637. return this._leftjoystick;
  14638. };
  14639. /**
  14640. * Gets the right stick of the virtual joystick.
  14641. * @returns The virtual Joystick
  14642. */
  14643. FreeCameraVirtualJoystickInput.prototype.getRightJoystick = function () {
  14644. return this._rightjoystick;
  14645. };
  14646. /**
  14647. * Update the current camera state depending on the inputs that have been used this frame.
  14648. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14649. */
  14650. FreeCameraVirtualJoystickInput.prototype.checkInputs = function () {
  14651. if (this._leftjoystick) {
  14652. var camera = this.camera;
  14653. var speed = camera._computeLocalCameraSpeed() * 50;
  14654. var cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, 0);
  14655. 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);
  14656. camera.cameraDirection = camera.cameraDirection.add(deltaTransform);
  14657. camera.cameraRotation = camera.cameraRotation.addVector3(this._rightjoystick.deltaPosition);
  14658. if (!this._leftjoystick.pressed) {
  14659. this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(0.9);
  14660. }
  14661. if (!this._rightjoystick.pressed) {
  14662. this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(0.9);
  14663. }
  14664. }
  14665. };
  14666. /**
  14667. * Attach the input controls to a specific dom element to get the input from.
  14668. * @param element Defines the element the controls should be listened from
  14669. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14670. */
  14671. FreeCameraVirtualJoystickInput.prototype.attachControl = function (element, noPreventDefault) {
  14672. this._leftjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](true);
  14673. this._leftjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Z);
  14674. this._leftjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  14675. this._leftjoystick.setJoystickSensibility(0.15);
  14676. this._rightjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](false);
  14677. this._rightjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  14678. this._rightjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Y);
  14679. this._rightjoystick.reverseUpDown = true;
  14680. this._rightjoystick.setJoystickSensibility(0.05);
  14681. this._rightjoystick.setJoystickColor("yellow");
  14682. };
  14683. /**
  14684. * Detach the current controls from the specified dom element.
  14685. * @param element Defines the element to stop listening the inputs from
  14686. */
  14687. FreeCameraVirtualJoystickInput.prototype.detachControl = function (element) {
  14688. this._leftjoystick.releaseCanvas();
  14689. this._rightjoystick.releaseCanvas();
  14690. };
  14691. /**
  14692. * Gets the class name of the current intput.
  14693. * @returns the class name
  14694. */
  14695. FreeCameraVirtualJoystickInput.prototype.getClassName = function () {
  14696. return "FreeCameraVirtualJoystickInput";
  14697. };
  14698. /**
  14699. * Get the friendly name associated with the input class.
  14700. * @returns the input friendly name
  14701. */
  14702. FreeCameraVirtualJoystickInput.prototype.getSimpleName = function () {
  14703. return "virtualJoystick";
  14704. };
  14705. return FreeCameraVirtualJoystickInput;
  14706. }());
  14707. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FreeCameraVirtualJoystickInput"] = FreeCameraVirtualJoystickInput;
  14708. /***/ }),
  14709. /***/ "./Cameras/Inputs/index.ts":
  14710. /*!*********************************!*\
  14711. !*** ./Cameras/Inputs/index.ts ***!
  14712. \*********************************/
  14713. /*! exports provided: ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput */
  14714. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14715. "use strict";
  14716. __webpack_require__.r(__webpack_exports__);
  14717. /* harmony import */ var _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  14718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  14719. /* harmony import */ var _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  14720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraKeyboardMoveInput"]; });
  14721. /* harmony import */ var _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  14722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraMouseWheelInput"]; });
  14723. /* harmony import */ var _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  14724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraPointersInput"]; });
  14725. /* harmony import */ var _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  14726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__["ArcRotateCameraVRDeviceOrientationInput"]; });
  14727. /* harmony import */ var _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  14728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__["FlyCameraKeyboardInput"]; });
  14729. /* harmony import */ var _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  14730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__["FlyCameraMouseInput"]; });
  14731. /* harmony import */ var _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  14732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  14733. /* harmony import */ var _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  14734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_8__["FreeCameraGamepadInput"]; });
  14735. /* harmony import */ var _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  14736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_9__["FreeCameraKeyboardMoveInput"]; });
  14737. /* harmony import */ var _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  14738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_10__["FreeCameraMouseInput"]; });
  14739. /* harmony import */ var _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  14740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_11__["FreeCameraTouchInput"]; });
  14741. /* harmony import */ var _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  14742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_12__["FreeCameraVirtualJoystickInput"]; });
  14743. /***/ }),
  14744. /***/ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts":
  14745. /*!*********************************************************!*\
  14746. !*** ./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts ***!
  14747. \*********************************************************/
  14748. /*! no exports provided */
  14749. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14750. "use strict";
  14751. __webpack_require__.r(__webpack_exports__);
  14752. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14753. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  14754. /* harmony import */ var _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  14755. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicAnaglyphRigMode = function (camera) {
  14756. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  14757. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__["AnaglyphPostProcess"](camera.name + "_anaglyph", 1.0, camera._rigCameras);
  14758. };
  14759. /***/ }),
  14760. /***/ "./Cameras/RigModes/stereoscopicRigMode.ts":
  14761. /*!*************************************************!*\
  14762. !*** ./Cameras/RigModes/stereoscopicRigMode.ts ***!
  14763. \*************************************************/
  14764. /*! no exports provided */
  14765. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14766. "use strict";
  14767. __webpack_require__.r(__webpack_exports__);
  14768. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14769. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  14770. /* harmony import */ var _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  14771. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicRigMode = function (camera) {
  14772. 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;
  14773. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  14774. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__["StereoscopicInterlacePostProcess"](camera.name + "_stereoInterlace", camera._rigCameras, isStereoscopicHoriz);
  14775. };
  14776. /***/ }),
  14777. /***/ "./Cameras/RigModes/vrRigMode.ts":
  14778. /*!***************************************!*\
  14779. !*** ./Cameras/RigModes/vrRigMode.ts ***!
  14780. \***************************************/
  14781. /*! no exports provided */
  14782. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14783. "use strict";
  14784. __webpack_require__.r(__webpack_exports__);
  14785. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14786. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14787. /* harmony import */ var _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  14788. /* harmony import */ var _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  14789. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setVRRigMode = function (camera, rigParams) {
  14790. var metrics = rigParams.vrCameraMetrics || _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault();
  14791. camera._rigCameras[0]._cameraRigParams.vrMetrics = metrics;
  14792. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  14793. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14794. camera._rigCameras[0]._cameraRigParams.vrHMatrix = metrics.leftHMatrix;
  14795. camera._rigCameras[0]._cameraRigParams.vrPreViewMatrix = metrics.leftPreViewMatrix;
  14796. camera._rigCameras[0].getProjectionMatrix = camera._rigCameras[0]._getVRProjectionMatrix;
  14797. camera._rigCameras[1]._cameraRigParams.vrMetrics = metrics;
  14798. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  14799. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14800. camera._rigCameras[1]._cameraRigParams.vrHMatrix = metrics.rightHMatrix;
  14801. camera._rigCameras[1]._cameraRigParams.vrPreViewMatrix = metrics.rightPreViewMatrix;
  14802. camera._rigCameras[1].getProjectionMatrix = camera._rigCameras[1]._getVRProjectionMatrix;
  14803. if (metrics.compensateDistortion) {
  14804. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Left", camera._rigCameras[0], false, metrics);
  14805. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Right", camera._rigCameras[1], true, metrics);
  14806. }
  14807. };
  14808. /***/ }),
  14809. /***/ "./Cameras/RigModes/webVRRigMode.ts":
  14810. /*!******************************************!*\
  14811. !*** ./Cameras/RigModes/webVRRigMode.ts ***!
  14812. \******************************************/
  14813. /*! no exports provided */
  14814. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14815. "use strict";
  14816. __webpack_require__.r(__webpack_exports__);
  14817. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14818. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14819. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setWebVRRigMode = function (camera, rigParams) {
  14820. if (rigParams.vrDisplay) {
  14821. var leftEye = rigParams.vrDisplay.getEyeParameters('left');
  14822. var rightEye = rigParams.vrDisplay.getEyeParameters('right');
  14823. //Left eye
  14824. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  14825. camera._rigCameras[0].setCameraRigParameter("left", true);
  14826. //leaving this for future reference
  14827. camera._rigCameras[0].setCameraRigParameter("specs", rigParams.specs);
  14828. camera._rigCameras[0].setCameraRigParameter("eyeParameters", leftEye);
  14829. camera._rigCameras[0].setCameraRigParameter("frameData", rigParams.frameData);
  14830. camera._rigCameras[0].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  14831. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14832. camera._rigCameras[0].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  14833. camera._rigCameras[0].parent = camera;
  14834. camera._rigCameras[0]._getViewMatrix = camera._getWebVRViewMatrix;
  14835. //Right eye
  14836. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  14837. camera._rigCameras[1].setCameraRigParameter('eyeParameters', rightEye);
  14838. camera._rigCameras[1].setCameraRigParameter("specs", rigParams.specs);
  14839. camera._rigCameras[1].setCameraRigParameter("frameData", rigParams.frameData);
  14840. camera._rigCameras[1].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  14841. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14842. camera._rigCameras[1].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  14843. camera._rigCameras[1].parent = camera;
  14844. camera._rigCameras[1]._getViewMatrix = camera._getWebVRViewMatrix;
  14845. if (_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].UseAlternateWebVRRendering) {
  14846. camera._rigCameras[1]._skipRendering = true;
  14847. camera._rigCameras[0]._alternateCamera = camera._rigCameras[1];
  14848. }
  14849. }
  14850. };
  14851. /***/ }),
  14852. /***/ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts":
  14853. /*!*********************************************************!*\
  14854. !*** ./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts ***!
  14855. \*********************************************************/
  14856. /*! exports provided: AnaglyphArcRotateCamera */
  14857. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14858. "use strict";
  14859. __webpack_require__.r(__webpack_exports__);
  14860. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return AnaglyphArcRotateCamera; });
  14861. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14862. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14863. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  14864. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14865. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14866. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14867. // Side effect import to define the stereoscopic mode.
  14868. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphArcRotateCamera", function (name, scene, options) {
  14869. return function () { return new AnaglyphArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14870. });
  14871. /**
  14872. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  14873. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14874. */
  14875. var AnaglyphArcRotateCamera = /** @class */ (function (_super) {
  14876. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphArcRotateCamera, _super);
  14877. /**
  14878. * Creates a new AnaglyphArcRotateCamera
  14879. * @param name defines camera name
  14880. * @param alpha defines alpha angle (in radians)
  14881. * @param beta defines beta angle (in radians)
  14882. * @param radius defines radius
  14883. * @param target defines camera target
  14884. * @param interaxialDistance defines distance between each color axis
  14885. * @param scene defines the hosting scene
  14886. */
  14887. function AnaglyphArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, scene) {
  14888. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  14889. _this.interaxialDistance = interaxialDistance;
  14890. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14891. return _this;
  14892. }
  14893. /**
  14894. * Gets camera class name
  14895. * @returns AnaglyphArcRotateCamera
  14896. */
  14897. AnaglyphArcRotateCamera.prototype.getClassName = function () {
  14898. return "AnaglyphArcRotateCamera";
  14899. };
  14900. return AnaglyphArcRotateCamera;
  14901. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  14902. /***/ }),
  14903. /***/ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts":
  14904. /*!****************************************************!*\
  14905. !*** ./Cameras/Stereoscopic/anaglyphFreeCamera.ts ***!
  14906. \****************************************************/
  14907. /*! exports provided: AnaglyphFreeCamera */
  14908. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14909. "use strict";
  14910. __webpack_require__.r(__webpack_exports__);
  14911. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return AnaglyphFreeCamera; });
  14912. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14913. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14914. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  14915. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14916. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14917. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14918. // Side effect import to define the stereoscopic mode.
  14919. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphFreeCamera", function (name, scene, options) {
  14920. return function () { return new AnaglyphFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14921. });
  14922. /**
  14923. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  14924. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14925. */
  14926. var AnaglyphFreeCamera = /** @class */ (function (_super) {
  14927. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphFreeCamera, _super);
  14928. /**
  14929. * Creates a new AnaglyphFreeCamera
  14930. * @param name defines camera name
  14931. * @param position defines initial position
  14932. * @param interaxialDistance defines distance between each color axis
  14933. * @param scene defines the hosting scene
  14934. */
  14935. function AnaglyphFreeCamera(name, position, interaxialDistance, scene) {
  14936. var _this = _super.call(this, name, position, scene) || this;
  14937. _this.interaxialDistance = interaxialDistance;
  14938. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14939. return _this;
  14940. }
  14941. /**
  14942. * Gets camera class name
  14943. * @returns AnaglyphFreeCamera
  14944. */
  14945. AnaglyphFreeCamera.prototype.getClassName = function () {
  14946. return "AnaglyphFreeCamera";
  14947. };
  14948. return AnaglyphFreeCamera;
  14949. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  14950. /***/ }),
  14951. /***/ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts":
  14952. /*!*******************************************************!*\
  14953. !*** ./Cameras/Stereoscopic/anaglyphGamepadCamera.ts ***!
  14954. \*******************************************************/
  14955. /*! exports provided: AnaglyphGamepadCamera */
  14956. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14957. "use strict";
  14958. __webpack_require__.r(__webpack_exports__);
  14959. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return AnaglyphGamepadCamera; });
  14960. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14961. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14962. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  14963. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14964. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14965. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14966. // Side effect import to define the stereoscopic mode.
  14967. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphGamepadCamera", function (name, scene, options) {
  14968. return function () { return new AnaglyphGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14969. });
  14970. /**
  14971. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  14972. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14973. */
  14974. var AnaglyphGamepadCamera = /** @class */ (function (_super) {
  14975. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphGamepadCamera, _super);
  14976. /**
  14977. * Creates a new AnaglyphGamepadCamera
  14978. * @param name defines camera name
  14979. * @param position defines initial position
  14980. * @param interaxialDistance defines distance between each color axis
  14981. * @param scene defines the hosting scene
  14982. */
  14983. function AnaglyphGamepadCamera(name, position, interaxialDistance, scene) {
  14984. var _this = _super.call(this, name, position, scene) || this;
  14985. _this.interaxialDistance = interaxialDistance;
  14986. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14987. return _this;
  14988. }
  14989. /**
  14990. * Gets camera class name
  14991. * @returns AnaglyphGamepadCamera
  14992. */
  14993. AnaglyphGamepadCamera.prototype.getClassName = function () {
  14994. return "AnaglyphGamepadCamera";
  14995. };
  14996. return AnaglyphGamepadCamera;
  14997. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  14998. /***/ }),
  14999. /***/ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts":
  15000. /*!*********************************************************!*\
  15001. !*** ./Cameras/Stereoscopic/anaglyphUniversalCamera.ts ***!
  15002. \*********************************************************/
  15003. /*! exports provided: AnaglyphUniversalCamera */
  15004. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15005. "use strict";
  15006. __webpack_require__.r(__webpack_exports__);
  15007. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return AnaglyphUniversalCamera; });
  15008. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15009. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15010. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15011. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15012. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15013. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15014. // Side effect import to define the stereoscopic mode.
  15015. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphUniversalCamera", function (name, scene, options) {
  15016. return function () { return new AnaglyphUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15017. });
  15018. /**
  15019. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  15020. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15021. */
  15022. var AnaglyphUniversalCamera = /** @class */ (function (_super) {
  15023. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphUniversalCamera, _super);
  15024. /**
  15025. * Creates a new AnaglyphUniversalCamera
  15026. * @param name defines camera name
  15027. * @param position defines initial position
  15028. * @param interaxialDistance defines distance between each color axis
  15029. * @param scene defines the hosting scene
  15030. */
  15031. function AnaglyphUniversalCamera(name, position, interaxialDistance, scene) {
  15032. var _this = _super.call(this, name, position, scene) || this;
  15033. _this.interaxialDistance = interaxialDistance;
  15034. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15035. return _this;
  15036. }
  15037. /**
  15038. * Gets camera class name
  15039. * @returns AnaglyphUniversalCamera
  15040. */
  15041. AnaglyphUniversalCamera.prototype.getClassName = function () {
  15042. return "AnaglyphUniversalCamera";
  15043. };
  15044. return AnaglyphUniversalCamera;
  15045. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15046. /***/ }),
  15047. /***/ "./Cameras/Stereoscopic/index.ts":
  15048. /*!***************************************!*\
  15049. !*** ./Cameras/Stereoscopic/index.ts ***!
  15050. \***************************************/
  15051. /*! exports provided: AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera */
  15052. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15053. "use strict";
  15054. __webpack_require__.r(__webpack_exports__);
  15055. /* harmony import */ var _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphArcRotateCamera */ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts");
  15056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  15057. /* harmony import */ var _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./anaglyphFreeCamera */ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts");
  15058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__["AnaglyphFreeCamera"]; });
  15059. /* harmony import */ var _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./anaglyphGamepadCamera */ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts");
  15060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__["AnaglyphGamepadCamera"]; });
  15061. /* harmony import */ var _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./anaglyphUniversalCamera */ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts");
  15062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__["AnaglyphUniversalCamera"]; });
  15063. /* harmony import */ var _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./stereoscopicArcRotateCamera */ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts");
  15064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__["StereoscopicArcRotateCamera"]; });
  15065. /* harmony import */ var _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./stereoscopicFreeCamera */ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts");
  15066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__["StereoscopicFreeCamera"]; });
  15067. /* harmony import */ var _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./stereoscopicGamepadCamera */ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts");
  15068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__["StereoscopicGamepadCamera"]; });
  15069. /* harmony import */ var _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./stereoscopicUniversalCamera */ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts");
  15070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  15071. /***/ }),
  15072. /***/ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts":
  15073. /*!*************************************************************!*\
  15074. !*** ./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts ***!
  15075. \*************************************************************/
  15076. /*! exports provided: StereoscopicArcRotateCamera */
  15077. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15078. "use strict";
  15079. __webpack_require__.r(__webpack_exports__);
  15080. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return StereoscopicArcRotateCamera; });
  15081. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15082. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15083. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15084. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15085. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15086. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15087. // Side effect import to define the stereoscopic mode.
  15088. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicArcRotateCamera", function (name, scene, options) {
  15089. return function () { return new StereoscopicArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15090. });
  15091. /**
  15092. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  15093. * @see http://doc.babylonjs.com/features/cameras
  15094. */
  15095. var StereoscopicArcRotateCamera = /** @class */ (function (_super) {
  15096. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicArcRotateCamera, _super);
  15097. /**
  15098. * Creates a new StereoscopicArcRotateCamera
  15099. * @param name defines camera name
  15100. * @param alpha defines alpha angle (in radians)
  15101. * @param beta defines beta angle (in radians)
  15102. * @param radius defines radius
  15103. * @param target defines camera target
  15104. * @param interaxialDistance defines distance between each color axis
  15105. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15106. * @param scene defines the hosting scene
  15107. */
  15108. function StereoscopicArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, isStereoscopicSideBySide, scene) {
  15109. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15110. _this.interaxialDistance = interaxialDistance;
  15111. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15112. _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 });
  15113. return _this;
  15114. }
  15115. /**
  15116. * Gets camera class name
  15117. * @returns StereoscopicArcRotateCamera
  15118. */
  15119. StereoscopicArcRotateCamera.prototype.getClassName = function () {
  15120. return "StereoscopicArcRotateCamera";
  15121. };
  15122. return StereoscopicArcRotateCamera;
  15123. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15124. /***/ }),
  15125. /***/ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts":
  15126. /*!********************************************************!*\
  15127. !*** ./Cameras/Stereoscopic/stereoscopicFreeCamera.ts ***!
  15128. \********************************************************/
  15129. /*! exports provided: StereoscopicFreeCamera */
  15130. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15131. "use strict";
  15132. __webpack_require__.r(__webpack_exports__);
  15133. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return StereoscopicFreeCamera; });
  15134. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15135. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15136. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15137. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15138. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15139. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15140. // Side effect import to define the stereoscopic mode.
  15141. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15142. return function () { return new StereoscopicFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15143. });
  15144. /**
  15145. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  15146. * @see http://doc.babylonjs.com/features/cameras
  15147. */
  15148. var StereoscopicFreeCamera = /** @class */ (function (_super) {
  15149. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicFreeCamera, _super);
  15150. /**
  15151. * Creates a new StereoscopicFreeCamera
  15152. * @param name defines camera name
  15153. * @param position defines initial position
  15154. * @param interaxialDistance defines distance between each color axis
  15155. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15156. * @param scene defines the hosting scene
  15157. */
  15158. function StereoscopicFreeCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15159. var _this = _super.call(this, name, position, scene) || this;
  15160. _this.interaxialDistance = interaxialDistance;
  15161. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15162. _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 });
  15163. return _this;
  15164. }
  15165. /**
  15166. * Gets camera class name
  15167. * @returns StereoscopicFreeCamera
  15168. */
  15169. StereoscopicFreeCamera.prototype.getClassName = function () {
  15170. return "StereoscopicFreeCamera";
  15171. };
  15172. return StereoscopicFreeCamera;
  15173. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15174. /***/ }),
  15175. /***/ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts":
  15176. /*!***********************************************************!*\
  15177. !*** ./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts ***!
  15178. \***********************************************************/
  15179. /*! exports provided: StereoscopicGamepadCamera */
  15180. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15181. "use strict";
  15182. __webpack_require__.r(__webpack_exports__);
  15183. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return StereoscopicGamepadCamera; });
  15184. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15185. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15186. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  15187. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15188. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15189. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15190. // Side effect import to define the stereoscopic mode.
  15191. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicGamepadCamera", function (name, scene, options) {
  15192. return function () { return new StereoscopicGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15193. });
  15194. /**
  15195. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  15196. * @see http://doc.babylonjs.com/features/cameras
  15197. */
  15198. var StereoscopicGamepadCamera = /** @class */ (function (_super) {
  15199. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicGamepadCamera, _super);
  15200. /**
  15201. * Creates a new StereoscopicGamepadCamera
  15202. * @param name defines camera name
  15203. * @param position defines initial position
  15204. * @param interaxialDistance defines distance between each color axis
  15205. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15206. * @param scene defines the hosting scene
  15207. */
  15208. function StereoscopicGamepadCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15209. var _this = _super.call(this, name, position, scene) || this;
  15210. _this.interaxialDistance = interaxialDistance;
  15211. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15212. _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 });
  15213. return _this;
  15214. }
  15215. /**
  15216. * Gets camera class name
  15217. * @returns StereoscopicGamepadCamera
  15218. */
  15219. StereoscopicGamepadCamera.prototype.getClassName = function () {
  15220. return "StereoscopicGamepadCamera";
  15221. };
  15222. return StereoscopicGamepadCamera;
  15223. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15224. /***/ }),
  15225. /***/ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts":
  15226. /*!*************************************************************!*\
  15227. !*** ./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts ***!
  15228. \*************************************************************/
  15229. /*! exports provided: StereoscopicUniversalCamera */
  15230. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15231. "use strict";
  15232. __webpack_require__.r(__webpack_exports__);
  15233. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return StereoscopicUniversalCamera; });
  15234. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15235. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15236. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15237. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15238. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15239. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15240. // Side effect import to define the stereoscopic mode.
  15241. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15242. return function () { return new StereoscopicUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15243. });
  15244. /**
  15245. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  15246. * @see http://doc.babylonjs.com/features/cameras
  15247. */
  15248. var StereoscopicUniversalCamera = /** @class */ (function (_super) {
  15249. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicUniversalCamera, _super);
  15250. /**
  15251. * Creates a new StereoscopicUniversalCamera
  15252. * @param name defines camera name
  15253. * @param position defines initial position
  15254. * @param interaxialDistance defines distance between each color axis
  15255. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15256. * @param scene defines the hosting scene
  15257. */
  15258. function StereoscopicUniversalCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15259. var _this = _super.call(this, name, position, scene) || this;
  15260. _this.interaxialDistance = interaxialDistance;
  15261. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15262. _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 });
  15263. return _this;
  15264. }
  15265. /**
  15266. * Gets camera class name
  15267. * @returns StereoscopicUniversalCamera
  15268. */
  15269. StereoscopicUniversalCamera.prototype.getClassName = function () {
  15270. return "StereoscopicUniversalCamera";
  15271. };
  15272. return StereoscopicUniversalCamera;
  15273. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15274. /***/ }),
  15275. /***/ "./Cameras/VR/index.ts":
  15276. /*!*****************************!*\
  15277. !*** ./Cameras/VR/index.ts ***!
  15278. \*****************************/
  15279. /*! exports provided: VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera */
  15280. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15281. "use strict";
  15282. __webpack_require__.r(__webpack_exports__);
  15283. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  15285. /* harmony import */ var _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationArcRotateCamera */ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts");
  15286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationArcRotateCamera"]; });
  15287. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__["VRDeviceOrientationFreeCamera"]; });
  15289. /* harmony import */ var _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrDeviceOrientationGamepadCamera */ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts");
  15290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__["VRDeviceOrientationGamepadCamera"]; });
  15291. /* harmony import */ var _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  15292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["VRExperienceHelper"]; });
  15293. /* harmony import */ var _webVRCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _webVRCamera__WEBPACK_IMPORTED_MODULE_5__["WebVRFreeCamera"]; });
  15295. /***/ }),
  15296. /***/ "./Cameras/VR/vrCameraMetrics.ts":
  15297. /*!***************************************!*\
  15298. !*** ./Cameras/VR/vrCameraMetrics.ts ***!
  15299. \***************************************/
  15300. /*! exports provided: VRCameraMetrics */
  15301. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15302. "use strict";
  15303. __webpack_require__.r(__webpack_exports__);
  15304. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return VRCameraMetrics; });
  15305. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15306. /**
  15307. * This represents all the required metrics to create a VR camera.
  15308. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  15309. */
  15310. var VRCameraMetrics = /** @class */ (function () {
  15311. function VRCameraMetrics() {
  15312. /**
  15313. * Define if the current vr camera should compensate the distortion of the lense or not.
  15314. */
  15315. this.compensateDistortion = true;
  15316. }
  15317. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatio", {
  15318. /**
  15319. * Gets the rendering aspect ratio based on the provided resolutions.
  15320. */
  15321. get: function () {
  15322. return this.hResolution / (2 * this.vResolution);
  15323. },
  15324. enumerable: true,
  15325. configurable: true
  15326. });
  15327. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatioFov", {
  15328. /**
  15329. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  15330. */
  15331. get: function () {
  15332. return (2 * Math.atan((this.postProcessScaleFactor * this.vScreenSize) / (2 * this.eyeToScreenDistance)));
  15333. },
  15334. enumerable: true,
  15335. configurable: true
  15336. });
  15337. Object.defineProperty(VRCameraMetrics.prototype, "leftHMatrix", {
  15338. /**
  15339. * @hidden
  15340. */
  15341. get: function () {
  15342. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15343. var h = (4 * meters) / this.hScreenSize;
  15344. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(h, 0, 0);
  15345. },
  15346. enumerable: true,
  15347. configurable: true
  15348. });
  15349. Object.defineProperty(VRCameraMetrics.prototype, "rightHMatrix", {
  15350. /**
  15351. * @hidden
  15352. */
  15353. get: function () {
  15354. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15355. var h = (4 * meters) / this.hScreenSize;
  15356. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-h, 0, 0);
  15357. },
  15358. enumerable: true,
  15359. configurable: true
  15360. });
  15361. Object.defineProperty(VRCameraMetrics.prototype, "leftPreViewMatrix", {
  15362. /**
  15363. * @hidden
  15364. */
  15365. get: function () {
  15366. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(0.5 * this.interpupillaryDistance, 0, 0);
  15367. },
  15368. enumerable: true,
  15369. configurable: true
  15370. });
  15371. Object.defineProperty(VRCameraMetrics.prototype, "rightPreViewMatrix", {
  15372. /**
  15373. * @hidden
  15374. */
  15375. get: function () {
  15376. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-0.5 * this.interpupillaryDistance, 0, 0);
  15377. },
  15378. enumerable: true,
  15379. configurable: true
  15380. });
  15381. /**
  15382. * Get the default VRMetrics based on the most generic setup.
  15383. * @returns the default vr metrics
  15384. */
  15385. VRCameraMetrics.GetDefault = function () {
  15386. var result = new VRCameraMetrics();
  15387. result.hResolution = 1280;
  15388. result.vResolution = 800;
  15389. result.hScreenSize = 0.149759993;
  15390. result.vScreenSize = 0.0935999975;
  15391. result.vScreenCenter = 0.0467999987;
  15392. result.eyeToScreenDistance = 0.0410000011;
  15393. result.lensSeparationDistance = 0.0635000020;
  15394. result.interpupillaryDistance = 0.0640000030;
  15395. result.distortionK = [1.0, 0.219999999, 0.239999995, 0.0];
  15396. result.chromaAbCorrection = [0.995999992, -0.00400000019, 1.01400006, 0.0];
  15397. result.postProcessScaleFactor = 1.714605507808412;
  15398. result.lensCenterOffset = 0.151976421;
  15399. return result;
  15400. };
  15401. return VRCameraMetrics;
  15402. }());
  15403. /***/ }),
  15404. /***/ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts":
  15405. /*!**********************************************************!*\
  15406. !*** ./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts ***!
  15407. \**********************************************************/
  15408. /*! exports provided: VRDeviceOrientationArcRotateCamera */
  15409. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15410. "use strict";
  15411. __webpack_require__.r(__webpack_exports__);
  15412. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return VRDeviceOrientationArcRotateCamera; });
  15413. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15414. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15415. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15416. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15417. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15418. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15419. /* harmony import */ var _Inputs_arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Inputs/arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15420. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15421. // Side effect import to define the stereoscopic mode.
  15422. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15423. return function () { return new VRDeviceOrientationArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15424. });
  15425. /**
  15426. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  15427. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15428. */
  15429. var VRDeviceOrientationArcRotateCamera = /** @class */ (function (_super) {
  15430. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationArcRotateCamera, _super);
  15431. /**
  15432. * Creates a new VRDeviceOrientationArcRotateCamera
  15433. * @param name defines camera name
  15434. * @param alpha defines the camera rotation along the logitudinal axis
  15435. * @param beta defines the camera rotation along the latitudinal axis
  15436. * @param radius defines the camera distance from its target
  15437. * @param target defines the camera target
  15438. * @param scene defines the scene the camera belongs to
  15439. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15440. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15441. */
  15442. function VRDeviceOrientationArcRotateCamera(name, alpha, beta, radius, target, scene, compensateDistortion, vrCameraMetrics) {
  15443. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15444. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15445. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15446. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15447. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15448. _this.inputs.addVRDeviceOrientation();
  15449. return _this;
  15450. }
  15451. /**
  15452. * Gets camera class name
  15453. * @returns VRDeviceOrientationArcRotateCamera
  15454. */
  15455. VRDeviceOrientationArcRotateCamera.prototype.getClassName = function () {
  15456. return "VRDeviceOrientationArcRotateCamera";
  15457. };
  15458. return VRDeviceOrientationArcRotateCamera;
  15459. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15460. /***/ }),
  15461. /***/ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts":
  15462. /*!*****************************************************!*\
  15463. !*** ./Cameras/VR/vrDeviceOrientationFreeCamera.ts ***!
  15464. \*****************************************************/
  15465. /*! exports provided: VRDeviceOrientationFreeCamera */
  15466. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15467. "use strict";
  15468. __webpack_require__.r(__webpack_exports__);
  15469. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return VRDeviceOrientationFreeCamera; });
  15470. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15471. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15472. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15473. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15474. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15475. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15476. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15477. // Side effect import to define the stereoscopic mode.
  15478. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15479. return function () { return new VRDeviceOrientationFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15480. });
  15481. /**
  15482. * Camera used to simulate VR rendering (based on FreeCamera)
  15483. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15484. */
  15485. var VRDeviceOrientationFreeCamera = /** @class */ (function (_super) {
  15486. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationFreeCamera, _super);
  15487. /**
  15488. * Creates a new VRDeviceOrientationFreeCamera
  15489. * @param name defines camera name
  15490. * @param position defines the start position of the camera
  15491. * @param scene defines the scene the camera belongs to
  15492. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15493. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15494. */
  15495. function VRDeviceOrientationFreeCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  15496. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15497. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15498. var _this = _super.call(this, name, position, scene) || this;
  15499. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15500. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15501. return _this;
  15502. }
  15503. /**
  15504. * Gets camera class name
  15505. * @returns VRDeviceOrientationFreeCamera
  15506. */
  15507. VRDeviceOrientationFreeCamera.prototype.getClassName = function () {
  15508. return "VRDeviceOrientationFreeCamera";
  15509. };
  15510. return VRDeviceOrientationFreeCamera;
  15511. }(_Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__["DeviceOrientationCamera"]));
  15512. /***/ }),
  15513. /***/ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts":
  15514. /*!********************************************************!*\
  15515. !*** ./Cameras/VR/vrDeviceOrientationGamepadCamera.ts ***!
  15516. \********************************************************/
  15517. /*! exports provided: VRDeviceOrientationGamepadCamera */
  15518. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15519. "use strict";
  15520. __webpack_require__.r(__webpack_exports__);
  15521. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return VRDeviceOrientationGamepadCamera; });
  15522. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15523. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15524. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15525. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15526. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15527. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("VRDeviceOrientationGamepadCamera", function (name, scene) {
  15528. return function () { return new VRDeviceOrientationGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  15529. });
  15530. /**
  15531. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  15532. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15533. */
  15534. var VRDeviceOrientationGamepadCamera = /** @class */ (function (_super) {
  15535. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationGamepadCamera, _super);
  15536. /**
  15537. * Creates a new VRDeviceOrientationGamepadCamera
  15538. * @param name defines camera name
  15539. * @param position defines the start position of the camera
  15540. * @param scene defines the scene the camera belongs to
  15541. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15542. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15543. */
  15544. function VRDeviceOrientationGamepadCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  15545. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15546. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__["VRCameraMetrics"].GetDefault(); }
  15547. var _this = _super.call(this, name, position, scene, compensateDistortion, vrCameraMetrics) || this;
  15548. _this.inputs.addGamepad();
  15549. return _this;
  15550. }
  15551. /**
  15552. * Gets camera class name
  15553. * @returns VRDeviceOrientationGamepadCamera
  15554. */
  15555. VRDeviceOrientationGamepadCamera.prototype.getClassName = function () {
  15556. return "VRDeviceOrientationGamepadCamera";
  15557. };
  15558. return VRDeviceOrientationGamepadCamera;
  15559. }(_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationFreeCamera"]));
  15560. /***/ }),
  15561. /***/ "./Cameras/VR/vrExperienceHelper.ts":
  15562. /*!******************************************!*\
  15563. !*** ./Cameras/VR/vrExperienceHelper.ts ***!
  15564. \******************************************/
  15565. /*! exports provided: VRExperienceHelper */
  15566. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15567. "use strict";
  15568. __webpack_require__.r(__webpack_exports__);
  15569. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return VRExperienceHelper; });
  15570. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15571. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  15572. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  15573. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15574. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  15575. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15576. /* harmony import */ var _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Cameras/VR/vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15577. /* harmony import */ var _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Cameras/VR/webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15578. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  15579. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15580. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  15581. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  15582. /* harmony import */ var _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Gamepads/Controllers/webVRController */ "./Gamepads/Controllers/webVRController.ts");
  15583. /* harmony import */ var _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Gamepads/xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  15584. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  15585. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  15586. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  15587. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  15588. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  15589. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  15590. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  15591. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  15592. /* harmony import */ var _Meshes_Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Meshes/Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  15593. /* harmony import */ var _Meshes_Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../Meshes/Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  15594. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  15595. /* harmony import */ var _Gamepads_gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../../Gamepads/gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  15596. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../../Animations/animatable */ "./Animations/animatable.ts");
  15597. var VRExperienceHelperGazer = /** @class */ (function () {
  15598. function VRExperienceHelperGazer(scene, gazeTrackerToClone) {
  15599. if (gazeTrackerToClone === void 0) { gazeTrackerToClone = null; }
  15600. this.scene = scene;
  15601. /** @hidden */
  15602. this._pointerDownOnMeshAsked = false;
  15603. /** @hidden */
  15604. this._isActionableMesh = false;
  15605. /** @hidden */
  15606. this._teleportationRequestInitiated = false;
  15607. /** @hidden */
  15608. this._teleportationBackRequestInitiated = false;
  15609. /** @hidden */
  15610. this._rotationRightAsked = false;
  15611. /** @hidden */
  15612. this._rotationLeftAsked = false;
  15613. /** @hidden */
  15614. this._dpadPressed = true;
  15615. /** @hidden */
  15616. this._activePointer = false;
  15617. this._id = VRExperienceHelperGazer._idCounter++;
  15618. // Gaze tracker
  15619. if (!gazeTrackerToClone) {
  15620. this._gazeTracker = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("gazeTracker", 0.0035, 0.0025, 20, scene, false);
  15621. this._gazeTracker.bakeCurrentTransformIntoVertices();
  15622. this._gazeTracker.isPickable = false;
  15623. this._gazeTracker.isVisible = false;
  15624. var targetMat = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("targetMat", scene);
  15625. targetMat.specularColor = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"].Black();
  15626. targetMat.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  15627. targetMat.backFaceCulling = false;
  15628. this._gazeTracker.material = targetMat;
  15629. }
  15630. else {
  15631. this._gazeTracker = gazeTrackerToClone.clone("gazeTracker");
  15632. }
  15633. }
  15634. /** @hidden */
  15635. VRExperienceHelperGazer.prototype._getForwardRay = function (length) {
  15636. 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));
  15637. };
  15638. /** @hidden */
  15639. VRExperienceHelperGazer.prototype._selectionPointerDown = function () {
  15640. this._pointerDownOnMeshAsked = true;
  15641. if (this._currentHit) {
  15642. this.scene.simulatePointerDown(this._currentHit, { pointerId: this._id });
  15643. }
  15644. };
  15645. /** @hidden */
  15646. VRExperienceHelperGazer.prototype._selectionPointerUp = function () {
  15647. if (this._currentHit) {
  15648. this.scene.simulatePointerUp(this._currentHit, { pointerId: this._id });
  15649. }
  15650. this._pointerDownOnMeshAsked = false;
  15651. };
  15652. /** @hidden */
  15653. VRExperienceHelperGazer.prototype._activatePointer = function () {
  15654. this._activePointer = true;
  15655. };
  15656. /** @hidden */
  15657. VRExperienceHelperGazer.prototype._deactivatePointer = function () {
  15658. this._activePointer = false;
  15659. };
  15660. /** @hidden */
  15661. VRExperienceHelperGazer.prototype._updatePointerDistance = function (distance) {
  15662. if (distance === void 0) { distance = 100; }
  15663. };
  15664. VRExperienceHelperGazer.prototype.dispose = function () {
  15665. this._interactionsEnabled = false;
  15666. this._teleportationEnabled = false;
  15667. if (this._gazeTracker) {
  15668. this._gazeTracker.dispose();
  15669. }
  15670. };
  15671. VRExperienceHelperGazer._idCounter = 0;
  15672. return VRExperienceHelperGazer;
  15673. }());
  15674. var VRExperienceHelperControllerGazer = /** @class */ (function (_super) {
  15675. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperControllerGazer, _super);
  15676. function VRExperienceHelperControllerGazer(webVRController, scene, gazeTrackerToClone) {
  15677. var _this = _super.call(this, scene, gazeTrackerToClone) || this;
  15678. _this.webVRController = webVRController;
  15679. // Laser pointer
  15680. _this._laserPointer = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateCylinder("laserPointer", 1, 0.004, 0.0002, 20, 1, scene, false);
  15681. var laserPointerMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("laserPointerMat", scene);
  15682. laserPointerMaterial.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  15683. laserPointerMaterial.alpha = 0.6;
  15684. _this._laserPointer.material = laserPointerMaterial;
  15685. _this._laserPointer.rotation.x = Math.PI / 2;
  15686. _this._laserPointer.position.z = -0.5;
  15687. _this._laserPointer.isVisible = false;
  15688. _this._laserPointer.isPickable = false;
  15689. if (!webVRController.mesh) {
  15690. // Create an empty mesh that is used prior to loading the high quality model
  15691. var preloadMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"]("preloadControllerMesh", scene);
  15692. var preloadPointerPose = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"](_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE, scene);
  15693. preloadPointerPose.rotation.x = -0.7;
  15694. preloadMesh.addChild(preloadPointerPose);
  15695. webVRController.attachToMesh(preloadMesh);
  15696. }
  15697. _this._setLaserPointerParent(webVRController.mesh);
  15698. _this._meshAttachedObserver = webVRController._meshAttachedObservable.add(function (mesh) {
  15699. _this._setLaserPointerParent(mesh);
  15700. });
  15701. return _this;
  15702. }
  15703. VRExperienceHelperControllerGazer.prototype._getForwardRay = function (length) {
  15704. return this.webVRController.getForwardRay(length);
  15705. };
  15706. /** @hidden */
  15707. VRExperienceHelperControllerGazer.prototype._activatePointer = function () {
  15708. _super.prototype._activatePointer.call(this);
  15709. this._laserPointer.isVisible = true;
  15710. };
  15711. /** @hidden */
  15712. VRExperienceHelperControllerGazer.prototype._deactivatePointer = function () {
  15713. _super.prototype._deactivatePointer.call(this);
  15714. this._laserPointer.isVisible = false;
  15715. };
  15716. /** @hidden */
  15717. VRExperienceHelperControllerGazer.prototype._setLaserPointerColor = function (color) {
  15718. this._laserPointer.material.emissiveColor = color;
  15719. };
  15720. /** @hidden */
  15721. VRExperienceHelperControllerGazer.prototype._setLaserPointerParent = function (mesh) {
  15722. var makeNotPick = function (root) {
  15723. root.isPickable = false;
  15724. root.getChildMeshes().forEach(function (c) {
  15725. makeNotPick(c);
  15726. });
  15727. };
  15728. makeNotPick(mesh);
  15729. var meshChildren = mesh.getChildren(undefined, false);
  15730. var laserParent = mesh;
  15731. this.webVRController._pointingPoseNode = null;
  15732. for (var i = 0; i < meshChildren.length; i++) {
  15733. if (meshChildren[i].name && meshChildren[i].name.indexOf(_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE) >= 0) {
  15734. laserParent = meshChildren[i];
  15735. this.webVRController._pointingPoseNode = laserParent;
  15736. break;
  15737. }
  15738. }
  15739. this._laserPointer.parent = laserParent;
  15740. };
  15741. VRExperienceHelperControllerGazer.prototype._updatePointerDistance = function (distance) {
  15742. if (distance === void 0) { distance = 100; }
  15743. this._laserPointer.scaling.y = distance;
  15744. this._laserPointer.position.z = -distance / 2;
  15745. };
  15746. VRExperienceHelperControllerGazer.prototype.dispose = function () {
  15747. _super.prototype.dispose.call(this);
  15748. this._laserPointer.dispose();
  15749. if (this._meshAttachedObserver) {
  15750. this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver);
  15751. }
  15752. };
  15753. return VRExperienceHelperControllerGazer;
  15754. }(VRExperienceHelperGazer));
  15755. var VRExperienceHelperCameraGazer = /** @class */ (function (_super) {
  15756. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperCameraGazer, _super);
  15757. function VRExperienceHelperCameraGazer(getCamera, scene) {
  15758. var _this = _super.call(this, scene) || this;
  15759. _this.getCamera = getCamera;
  15760. return _this;
  15761. }
  15762. VRExperienceHelperCameraGazer.prototype._getForwardRay = function (length) {
  15763. var camera = this.getCamera();
  15764. if (camera) {
  15765. return camera.getForwardRay(length);
  15766. }
  15767. else {
  15768. 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());
  15769. }
  15770. };
  15771. return VRExperienceHelperCameraGazer;
  15772. }(VRExperienceHelperGazer));
  15773. /**
  15774. * Helps to quickly add VR support to an existing scene.
  15775. * See http://doc.babylonjs.com/how_to/webvr_helper
  15776. */
  15777. var VRExperienceHelper = /** @class */ (function () {
  15778. /**
  15779. * Instantiates a VRExperienceHelper.
  15780. * Helps to quickly add VR support to an existing scene.
  15781. * @param scene The scene the VRExperienceHelper belongs to.
  15782. * @param webVROptions Options to modify the vr experience helper's behavior.
  15783. */
  15784. function VRExperienceHelper(scene,
  15785. /** Options to modify the vr experience helper's behavior. */
  15786. webVROptions) {
  15787. if (webVROptions === void 0) { webVROptions = {}; }
  15788. var _this = this;
  15789. this.webVROptions = webVROptions;
  15790. // Can the system support WebVR, even if a headset isn't plugged in?
  15791. this._webVRsupported = false;
  15792. // If WebVR is supported, is a headset plugged in and are we ready to present?
  15793. this._webVRready = false;
  15794. // Are we waiting for the requestPresent callback to complete?
  15795. this._webVRrequesting = false;
  15796. // Are we presenting to the headset right now? (this is the vrDevice state)
  15797. this._webVRpresenting = false;
  15798. // Are we presenting in the fullscreen fallback?
  15799. this._fullscreenVRpresenting = false;
  15800. /**
  15801. * Observable raised when entering VR.
  15802. */
  15803. this.onEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15804. /**
  15805. * Observable raised when exiting VR.
  15806. */
  15807. this.onExitingVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15808. /**
  15809. * Observable raised when controller mesh is loaded.
  15810. */
  15811. this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15812. this._useCustomVRButton = false;
  15813. this._teleportationRequested = false;
  15814. this._teleportActive = false;
  15815. this._floorMeshesCollection = [];
  15816. this._rotationAllowed = true;
  15817. this._teleportBackwardsVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, -1, -1);
  15818. this._isDefaultTeleportationTarget = true;
  15819. this._teleportationFillColor = "#444444";
  15820. this._teleportationBorderColor = "#FFFFFF";
  15821. this._rotationAngle = 0;
  15822. this._haloCenter = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, 0, 0);
  15823. this._padSensibilityUp = 0.65;
  15824. this._padSensibilityDown = 0.35;
  15825. this._leftController = null;
  15826. this._rightController = null;
  15827. /**
  15828. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  15829. */
  15830. this.onNewMeshSelected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15831. /**
  15832. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  15833. */
  15834. this.onNewMeshPicked = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15835. /**
  15836. * Observable raised before camera teleportation
  15837. */
  15838. this.onBeforeCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15839. /**
  15840. * Observable raised after camera teleportation
  15841. */
  15842. this.onAfterCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15843. /**
  15844. * Observable raised when current selected mesh gets unselected
  15845. */
  15846. this.onSelectedMeshUnselected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15847. /**
  15848. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  15849. */
  15850. this.teleportationEnabled = true;
  15851. this._teleportationInitialized = false;
  15852. this._interactionsEnabled = false;
  15853. this._interactionsRequested = false;
  15854. this._displayGaze = true;
  15855. this._displayLaserPointer = true;
  15856. /**
  15857. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  15858. */
  15859. this.updateGazeTrackerScale = true;
  15860. /**
  15861. * If the gaze trackers color should be updated when selecting meshes
  15862. */
  15863. this.updateGazeTrackerColor = true;
  15864. /**
  15865. * Defines wether or not Pointer lock should be requested when switching to
  15866. * full screen.
  15867. */
  15868. this.requestPointerLockOnFullScreen = true;
  15869. this._onResize = function () {
  15870. _this.moveButtonToBottomRight();
  15871. if (_this._fullscreenVRpresenting && _this._webVRready) {
  15872. _this.exitVR();
  15873. }
  15874. };
  15875. this._onFullscreenChange = function () {
  15876. if (document.fullscreen !== undefined) {
  15877. _this._fullscreenVRpresenting = document.fullscreen;
  15878. }
  15879. else if (document.mozFullScreen !== undefined) {
  15880. _this._fullscreenVRpresenting = document.mozFullScreen;
  15881. }
  15882. else if (document.webkitIsFullScreen !== undefined) {
  15883. _this._fullscreenVRpresenting = document.webkitIsFullScreen;
  15884. }
  15885. else if (document.msIsFullScreen !== undefined) {
  15886. _this._fullscreenVRpresenting = document.msIsFullScreen;
  15887. }
  15888. else if (document.msFullscreenElement !== undefined) {
  15889. _this._fullscreenVRpresenting = document.msFullscreenElement;
  15890. }
  15891. if (!_this._fullscreenVRpresenting && _this._canvas) {
  15892. _this.exitVR();
  15893. if (!_this._useCustomVRButton) {
  15894. _this._btnVR.style.top = _this._canvas.offsetTop + _this._canvas.offsetHeight - 70 + "px";
  15895. _this._btnVR.style.left = _this._canvas.offsetLeft + _this._canvas.offsetWidth - 100 + "px";
  15896. }
  15897. }
  15898. };
  15899. this._cachedAngularSensibility = { angularSensibilityX: null, angularSensibilityY: null, angularSensibility: null };
  15900. this.beforeRender = function () {
  15901. if (_this._leftController && _this._leftController._activePointer) {
  15902. _this._castRayAndSelectObject(_this._leftController);
  15903. }
  15904. if (_this._rightController && _this._rightController._activePointer) {
  15905. _this._castRayAndSelectObject(_this._rightController);
  15906. }
  15907. if (_this._noControllerIsActive) {
  15908. _this._castRayAndSelectObject(_this._cameraGazer);
  15909. }
  15910. else {
  15911. _this._cameraGazer._gazeTracker.isVisible = false;
  15912. }
  15913. };
  15914. this._onNewGamepadConnected = function (gamepad) {
  15915. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].POSE_ENABLED) {
  15916. if (gamepad.leftStick) {
  15917. gamepad.onleftstickchanged(function (stickValues) {
  15918. if (_this._teleportationInitialized && _this.teleportationEnabled) {
  15919. // Listening to classic/xbox gamepad only if no VR controller is active
  15920. if ((!_this._leftController && !_this._rightController) ||
  15921. ((_this._leftController && !_this._leftController._activePointer) &&
  15922. (_this._rightController && !_this._rightController._activePointer))) {
  15923. _this._checkTeleportWithRay(stickValues, _this._cameraGazer);
  15924. _this._checkTeleportBackwards(stickValues, _this._cameraGazer);
  15925. }
  15926. }
  15927. });
  15928. }
  15929. if (gamepad.rightStick) {
  15930. gamepad.onrightstickchanged(function (stickValues) {
  15931. if (_this._teleportationInitialized) {
  15932. _this._checkRotate(stickValues, _this._cameraGazer);
  15933. }
  15934. });
  15935. }
  15936. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].XBOX) {
  15937. gamepad.onbuttondown(function (buttonPressed) {
  15938. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  15939. _this._cameraGazer._selectionPointerDown();
  15940. }
  15941. });
  15942. gamepad.onbuttonup(function (buttonPressed) {
  15943. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  15944. _this._cameraGazer._selectionPointerUp();
  15945. }
  15946. });
  15947. }
  15948. }
  15949. else {
  15950. var webVRController = gamepad;
  15951. var controller = new VRExperienceHelperControllerGazer(webVRController, _this._scene, _this._cameraGazer._gazeTracker);
  15952. if (webVRController.hand === "right" || (_this._leftController && _this._leftController.webVRController != webVRController)) {
  15953. _this._rightController = controller;
  15954. }
  15955. else {
  15956. _this._leftController = controller;
  15957. }
  15958. _this._tryEnableInteractionOnController(controller);
  15959. }
  15960. };
  15961. // 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
  15962. this._tryEnableInteractionOnController = function (controller) {
  15963. if (_this._interactionsRequested && !controller._interactionsEnabled) {
  15964. _this._enableInteractionOnController(controller);
  15965. }
  15966. if (_this._teleportationRequested && !controller._teleportationEnabled) {
  15967. _this._enableTeleportationOnController(controller);
  15968. }
  15969. };
  15970. this._onNewGamepadDisconnected = function (gamepad) {
  15971. if (gamepad instanceof _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__["WebVRController"]) {
  15972. if (gamepad.hand === "left" && _this._leftController != null) {
  15973. _this._leftController.dispose();
  15974. _this._leftController = null;
  15975. }
  15976. if (gamepad.hand === "right" && _this._rightController != null) {
  15977. _this._rightController.dispose();
  15978. _this._rightController = null;
  15979. }
  15980. }
  15981. };
  15982. this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Zero();
  15983. this._workingQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].Identity();
  15984. this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].Identity();
  15985. this._scene = scene;
  15986. this._canvas = scene.getEngine().getRenderingCanvas();
  15987. // Parse options
  15988. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera === undefined) {
  15989. webVROptions.createFallbackVRDeviceOrientationFreeCamera = true;
  15990. }
  15991. if (webVROptions.createDeviceOrientationCamera === undefined) {
  15992. webVROptions.createDeviceOrientationCamera = true;
  15993. }
  15994. if (webVROptions.laserToggle === undefined) {
  15995. webVROptions.laserToggle = true;
  15996. }
  15997. if (webVROptions.defaultHeight === undefined) {
  15998. webVROptions.defaultHeight = 1.7;
  15999. }
  16000. if (webVROptions.useCustomVRButton) {
  16001. this._useCustomVRButton = true;
  16002. if (webVROptions.customVRButton) {
  16003. this._btnVR = webVROptions.customVRButton;
  16004. }
  16005. }
  16006. if (webVROptions.rayLength) {
  16007. this._rayLength = webVROptions.rayLength;
  16008. }
  16009. this._defaultHeight = webVROptions.defaultHeight;
  16010. if (webVROptions.positionScale) {
  16011. this._rayLength *= webVROptions.positionScale;
  16012. this._defaultHeight *= webVROptions.positionScale;
  16013. }
  16014. this._hasEnteredVR = false;
  16015. // Set position
  16016. if (this._scene.activeCamera) {
  16017. this._position = this._scene.activeCamera.position.clone();
  16018. }
  16019. else {
  16020. this._position = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, this._defaultHeight, 0);
  16021. }
  16022. // Set non-vr camera
  16023. if (webVROptions.createDeviceOrientationCamera || !this._scene.activeCamera) {
  16024. this._deviceOrientationCamera = new _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__["DeviceOrientationCamera"]("deviceOrientationVRHelper", this._position.clone(), scene);
  16025. // Copy data from existing camera
  16026. if (this._scene.activeCamera) {
  16027. this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16028. this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
  16029. // Set rotation from previous camera
  16030. if (this._scene.activeCamera instanceof _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"] && this._scene.activeCamera.rotation) {
  16031. var targetCamera = this._scene.activeCamera;
  16032. if (targetCamera.rotationQuaternion) {
  16033. this._deviceOrientationCamera.rotationQuaternion.copyFrom(targetCamera.rotationQuaternion);
  16034. }
  16035. else {
  16036. this._deviceOrientationCamera.rotationQuaternion.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRoll(targetCamera.rotation.y, targetCamera.rotation.x, targetCamera.rotation.z));
  16037. }
  16038. this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
  16039. }
  16040. }
  16041. this._scene.activeCamera = this._deviceOrientationCamera;
  16042. if (this._canvas) {
  16043. this._scene.activeCamera.attachControl(this._canvas);
  16044. }
  16045. }
  16046. else {
  16047. this._existingCamera = this._scene.activeCamera;
  16048. }
  16049. // Create VR cameras
  16050. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16051. this._vrDeviceOrientationCamera = new _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__["VRDeviceOrientationFreeCamera"]("VRDeviceOrientationVRHelper", this._position, this._scene, true, webVROptions.vrDeviceOrientationCameraMetrics);
  16052. this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16053. }
  16054. this._webVRCamera = new _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]("WebVRHelper", this._position, this._scene, webVROptions);
  16055. this._webVRCamera.useStandingMatrix();
  16056. this._cameraGazer = new VRExperienceHelperCameraGazer(function () { return _this.currentVRCamera; }, scene);
  16057. // Create default button
  16058. if (!this._useCustomVRButton) {
  16059. this._btnVR = document.createElement("BUTTON");
  16060. this._btnVR.className = "babylonVRicon";
  16061. this._btnVR.id = "babylonVRiconbtn";
  16062. this._btnVR.title = "Click to switch to VR";
  16063. 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) }";
  16064. css += ".babylonVRicon.vrdisplaypresenting { display: none; }";
  16065. // TODO: Add user feedback so that they know what state the VRDisplay is in (disconnected, connected, entering-VR)
  16066. // css += ".babylonVRicon.vrdisplaysupported { }";
  16067. // css += ".babylonVRicon.vrdisplayready { }";
  16068. // css += ".babylonVRicon.vrdisplayrequesting { }";
  16069. var style = document.createElement('style');
  16070. style.appendChild(document.createTextNode(css));
  16071. document.getElementsByTagName('head')[0].appendChild(style);
  16072. this.moveButtonToBottomRight();
  16073. }
  16074. // VR button click event
  16075. if (this._btnVR) {
  16076. this._btnVR.addEventListener("click", function () {
  16077. if (!_this.isInVRMode) {
  16078. _this.enterVR();
  16079. }
  16080. else {
  16081. _this.exitVR();
  16082. }
  16083. });
  16084. }
  16085. // Window events
  16086. window.addEventListener("resize", this._onResize);
  16087. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  16088. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  16089. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  16090. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  16091. document.onmsfullscreenchange = this._onFullscreenChange;
  16092. // Display vr button when headset is connected
  16093. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16094. this.displayVRButton();
  16095. }
  16096. else {
  16097. this._scene.getEngine().onVRDisplayChangedObservable.add(function (e) {
  16098. if (e.vrDisplay) {
  16099. _this.displayVRButton();
  16100. }
  16101. });
  16102. }
  16103. // Exiting VR mode using 'ESC' key on desktop
  16104. this._onKeyDown = function (event) {
  16105. if (event.keyCode === 27 && _this.isInVRMode) {
  16106. _this.exitVR();
  16107. }
  16108. };
  16109. document.addEventListener("keydown", this._onKeyDown);
  16110. // Exiting VR mode double tapping the touch screen
  16111. this._scene.onPrePointerObservable.add(function () {
  16112. if (_this.isInVRMode) {
  16113. _this.exitVR();
  16114. if (_this._fullscreenVRpresenting) {
  16115. _this._scene.getEngine().exitFullscreen();
  16116. }
  16117. }
  16118. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__["PointerEventTypes"].POINTERDOUBLETAP, false);
  16119. // Listen for WebVR display changes
  16120. this._onVRDisplayChanged = function (eventArgs) { return _this.onVRDisplayChanged(eventArgs); };
  16121. this._onVrDisplayPresentChange = function () { return _this.onVrDisplayPresentChange(); };
  16122. this._onVRRequestPresentStart = function () {
  16123. _this._webVRrequesting = true;
  16124. _this.updateButtonVisibility();
  16125. };
  16126. this._onVRRequestPresentComplete = function () {
  16127. _this._webVRrequesting = false;
  16128. _this.updateButtonVisibility();
  16129. };
  16130. scene.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged);
  16131. scene.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart);
  16132. scene.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete);
  16133. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  16134. scene.onDisposeObservable.add(function () {
  16135. _this.dispose();
  16136. });
  16137. // Gamepad connection events
  16138. this._webVRCamera.onControllerMeshLoadedObservable.add(function (webVRController) { return _this._onDefaultMeshLoaded(webVRController); });
  16139. this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected);
  16140. this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected);
  16141. this.updateButtonVisibility();
  16142. //create easing functions
  16143. this._circleEase = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["CircleEase"]();
  16144. this._circleEase.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  16145. if (this.webVROptions.floorMeshes) {
  16146. this.enableTeleportation({ floorMeshes: this.webVROptions.floorMeshes });
  16147. }
  16148. }
  16149. Object.defineProperty(VRExperienceHelper.prototype, "onEnteringVR", {
  16150. /** Return this.onEnteringVRObservable
  16151. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  16152. */
  16153. get: function () {
  16154. return this.onEnteringVRObservable;
  16155. },
  16156. enumerable: true,
  16157. configurable: true
  16158. });
  16159. Object.defineProperty(VRExperienceHelper.prototype, "onExitingVR", {
  16160. /** Return this.onExitingVRObservable
  16161. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  16162. */
  16163. get: function () {
  16164. return this.onExitingVRObservable;
  16165. },
  16166. enumerable: true,
  16167. configurable: true
  16168. });
  16169. Object.defineProperty(VRExperienceHelper.prototype, "onControllerMeshLoaded", {
  16170. /** Return this.onControllerMeshLoadedObservable
  16171. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  16172. */
  16173. get: function () {
  16174. return this.onControllerMeshLoadedObservable;
  16175. },
  16176. enumerable: true,
  16177. configurable: true
  16178. });
  16179. Object.defineProperty(VRExperienceHelper.prototype, "teleportationTarget", {
  16180. /**
  16181. * The mesh used to display where the user is going to teleport.
  16182. */
  16183. get: function () {
  16184. return this._teleportationTarget;
  16185. },
  16186. /**
  16187. * Sets the mesh to be used to display where the user is going to teleport.
  16188. */
  16189. set: function (value) {
  16190. if (value) {
  16191. value.name = "teleportationTarget";
  16192. this._isDefaultTeleportationTarget = false;
  16193. this._teleportationTarget = value;
  16194. }
  16195. },
  16196. enumerable: true,
  16197. configurable: true
  16198. });
  16199. Object.defineProperty(VRExperienceHelper.prototype, "gazeTrackerMesh", {
  16200. /**
  16201. * 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
  16202. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  16203. * See http://doc.babylonjs.com/resources/baking_transformations
  16204. */
  16205. get: function () {
  16206. return this._cameraGazer._gazeTracker;
  16207. },
  16208. set: function (value) {
  16209. if (value) {
  16210. // Dispose of existing meshes
  16211. if (this._cameraGazer._gazeTracker) {
  16212. this._cameraGazer._gazeTracker.dispose();
  16213. }
  16214. if (this._leftController && this._leftController._gazeTracker) {
  16215. this._leftController._gazeTracker.dispose();
  16216. }
  16217. if (this._rightController && this._rightController._gazeTracker) {
  16218. this._rightController._gazeTracker.dispose();
  16219. }
  16220. // Set and create gaze trackers on head and controllers
  16221. this._cameraGazer._gazeTracker = value;
  16222. this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices();
  16223. this._cameraGazer._gazeTracker.isPickable = false;
  16224. this._cameraGazer._gazeTracker.isVisible = false;
  16225. this._cameraGazer._gazeTracker.name = "gazeTracker";
  16226. if (this._leftController) {
  16227. this._leftController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16228. }
  16229. if (this._rightController) {
  16230. this._rightController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16231. }
  16232. }
  16233. },
  16234. enumerable: true,
  16235. configurable: true
  16236. });
  16237. Object.defineProperty(VRExperienceHelper.prototype, "leftControllerGazeTrackerMesh", {
  16238. /**
  16239. * The gaze tracking mesh corresponding to the left controller
  16240. */
  16241. get: function () {
  16242. if (this._leftController) {
  16243. return this._leftController._gazeTracker;
  16244. }
  16245. return null;
  16246. },
  16247. enumerable: true,
  16248. configurable: true
  16249. });
  16250. Object.defineProperty(VRExperienceHelper.prototype, "rightControllerGazeTrackerMesh", {
  16251. /**
  16252. * The gaze tracking mesh corresponding to the right controller
  16253. */
  16254. get: function () {
  16255. if (this._rightController) {
  16256. return this._rightController._gazeTracker;
  16257. }
  16258. return null;
  16259. },
  16260. enumerable: true,
  16261. configurable: true
  16262. });
  16263. Object.defineProperty(VRExperienceHelper.prototype, "displayGaze", {
  16264. /**
  16265. * If the ray of the gaze should be displayed.
  16266. */
  16267. get: function () {
  16268. return this._displayGaze;
  16269. },
  16270. /**
  16271. * Sets if the ray of the gaze should be displayed.
  16272. */
  16273. set: function (value) {
  16274. this._displayGaze = value;
  16275. if (!value) {
  16276. this._cameraGazer._gazeTracker.isVisible = false;
  16277. if (this._leftController) {
  16278. this._leftController._gazeTracker.isVisible = false;
  16279. }
  16280. if (this._rightController) {
  16281. this._rightController._gazeTracker.isVisible = false;
  16282. }
  16283. }
  16284. },
  16285. enumerable: true,
  16286. configurable: true
  16287. });
  16288. Object.defineProperty(VRExperienceHelper.prototype, "displayLaserPointer", {
  16289. /**
  16290. * If the ray of the LaserPointer should be displayed.
  16291. */
  16292. get: function () {
  16293. return this._displayLaserPointer;
  16294. },
  16295. /**
  16296. * Sets if the ray of the LaserPointer should be displayed.
  16297. */
  16298. set: function (value) {
  16299. this._displayLaserPointer = value;
  16300. if (!value) {
  16301. if (this._rightController) {
  16302. this._rightController._deactivatePointer();
  16303. this._rightController._gazeTracker.isVisible = false;
  16304. }
  16305. if (this._leftController) {
  16306. this._leftController._deactivatePointer();
  16307. this._leftController._gazeTracker.isVisible = false;
  16308. }
  16309. }
  16310. else {
  16311. if (this._rightController) {
  16312. this._rightController._activatePointer();
  16313. }
  16314. if (this._leftController) {
  16315. this._leftController._activatePointer();
  16316. }
  16317. }
  16318. },
  16319. enumerable: true,
  16320. configurable: true
  16321. });
  16322. Object.defineProperty(VRExperienceHelper.prototype, "deviceOrientationCamera", {
  16323. /**
  16324. * The deviceOrientationCamera used as the camera when not in VR.
  16325. */
  16326. get: function () {
  16327. return this._deviceOrientationCamera;
  16328. },
  16329. enumerable: true,
  16330. configurable: true
  16331. });
  16332. Object.defineProperty(VRExperienceHelper.prototype, "currentVRCamera", {
  16333. /**
  16334. * Based on the current WebVR support, returns the current VR camera used.
  16335. */
  16336. get: function () {
  16337. if (this._webVRready) {
  16338. return this._webVRCamera;
  16339. }
  16340. else {
  16341. return this._scene.activeCamera;
  16342. }
  16343. },
  16344. enumerable: true,
  16345. configurable: true
  16346. });
  16347. Object.defineProperty(VRExperienceHelper.prototype, "webVRCamera", {
  16348. /**
  16349. * The webVRCamera which is used when in VR.
  16350. */
  16351. get: function () {
  16352. return this._webVRCamera;
  16353. },
  16354. enumerable: true,
  16355. configurable: true
  16356. });
  16357. Object.defineProperty(VRExperienceHelper.prototype, "vrDeviceOrientationCamera", {
  16358. /**
  16359. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  16360. */
  16361. get: function () {
  16362. return this._vrDeviceOrientationCamera;
  16363. },
  16364. enumerable: true,
  16365. configurable: true
  16366. });
  16367. Object.defineProperty(VRExperienceHelper.prototype, "_teleportationRequestInitiated", {
  16368. get: function () {
  16369. var result = this._cameraGazer._teleportationRequestInitiated
  16370. || (this._leftController !== null && this._leftController._teleportationRequestInitiated)
  16371. || (this._rightController !== null && this._rightController._teleportationRequestInitiated);
  16372. return result;
  16373. },
  16374. enumerable: true,
  16375. configurable: true
  16376. });
  16377. // Raised when one of the controller has loaded successfully its associated default mesh
  16378. VRExperienceHelper.prototype._onDefaultMeshLoaded = function (webVRController) {
  16379. if (this._leftController && this._leftController.webVRController == webVRController) {
  16380. if (webVRController.mesh) {
  16381. this._leftController._setLaserPointerParent(webVRController.mesh);
  16382. }
  16383. }
  16384. if (this._rightController && this._rightController.webVRController == webVRController) {
  16385. if (webVRController.mesh) {
  16386. this._rightController._setLaserPointerParent(webVRController.mesh);
  16387. }
  16388. }
  16389. try {
  16390. this.onControllerMeshLoadedObservable.notifyObservers(webVRController);
  16391. }
  16392. catch (err) {
  16393. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onControllerMeshLoaded: " + err);
  16394. }
  16395. };
  16396. Object.defineProperty(VRExperienceHelper.prototype, "isInVRMode", {
  16397. /**
  16398. * Gets a value indicating if we are currently in VR mode.
  16399. */
  16400. get: function () {
  16401. return this._webVRpresenting || this._fullscreenVRpresenting;
  16402. },
  16403. enumerable: true,
  16404. configurable: true
  16405. });
  16406. VRExperienceHelper.prototype.onVrDisplayPresentChange = function () {
  16407. var vrDisplay = this._scene.getEngine().getVRDevice();
  16408. if (vrDisplay) {
  16409. var wasPresenting = this._webVRpresenting;
  16410. this._webVRpresenting = vrDisplay.isPresenting;
  16411. if (wasPresenting && !this._webVRpresenting) {
  16412. this.exitVR();
  16413. }
  16414. }
  16415. else {
  16416. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?');
  16417. }
  16418. this.updateButtonVisibility();
  16419. };
  16420. VRExperienceHelper.prototype.onVRDisplayChanged = function (eventArgs) {
  16421. this._webVRsupported = eventArgs.vrSupported;
  16422. this._webVRready = !!eventArgs.vrDisplay;
  16423. this._webVRpresenting = eventArgs.vrDisplay && eventArgs.vrDisplay.isPresenting;
  16424. this.updateButtonVisibility();
  16425. };
  16426. VRExperienceHelper.prototype.moveButtonToBottomRight = function () {
  16427. if (this._canvas && !this._useCustomVRButton) {
  16428. this._btnVR.style.top = this._canvas.offsetTop + this._canvas.offsetHeight - 70 + "px";
  16429. this._btnVR.style.left = this._canvas.offsetLeft + this._canvas.offsetWidth - 100 + "px";
  16430. }
  16431. };
  16432. VRExperienceHelper.prototype.displayVRButton = function () {
  16433. if (!this._useCustomVRButton && !this._btnVRDisplayed) {
  16434. document.body.appendChild(this._btnVR);
  16435. this._btnVRDisplayed = true;
  16436. }
  16437. };
  16438. VRExperienceHelper.prototype.updateButtonVisibility = function () {
  16439. if (!this._btnVR || this._useCustomVRButton) {
  16440. return;
  16441. }
  16442. this._btnVR.className = "babylonVRicon";
  16443. if (this.isInVRMode) {
  16444. this._btnVR.className += " vrdisplaypresenting";
  16445. }
  16446. else {
  16447. if (this._webVRready) {
  16448. this._btnVR.className += " vrdisplayready";
  16449. }
  16450. if (this._webVRsupported) {
  16451. this._btnVR.className += " vrdisplaysupported";
  16452. }
  16453. if (this._webVRrequesting) {
  16454. this._btnVR.className += " vrdisplayrequesting";
  16455. }
  16456. }
  16457. };
  16458. /**
  16459. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  16460. * Otherwise, will use the fullscreen API.
  16461. */
  16462. VRExperienceHelper.prototype.enterVR = function () {
  16463. if (this.onEnteringVRObservable) {
  16464. try {
  16465. this.onEnteringVRObservable.notifyObservers(this);
  16466. }
  16467. catch (err) {
  16468. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onEnteringVR: " + err);
  16469. }
  16470. }
  16471. if (this._scene.activeCamera) {
  16472. this._position = this._scene.activeCamera.position.clone();
  16473. if (this.vrDeviceOrientationCamera) {
  16474. this.vrDeviceOrientationCamera.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles();
  16475. this.vrDeviceOrientationCamera.angularSensibility = 2000;
  16476. }
  16477. if (this.webVRCamera) {
  16478. var currentYRotation = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y;
  16479. var desiredYRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y;
  16480. var delta = desiredYRotation - currentYRotation;
  16481. var currentGlobalRotation = this.webVRCamera.rotationQuaternion.toEulerAngles().y;
  16482. this.webVRCamera.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromEulerAngles(0, currentGlobalRotation + delta, 0);
  16483. }
  16484. // make sure that we return to the last active camera
  16485. this._existingCamera = this._scene.activeCamera;
  16486. // Remove and cache angular sensability to avoid camera rotation when in VR
  16487. if (this._existingCamera.angularSensibilityX) {
  16488. this._cachedAngularSensibility.angularSensibilityX = this._existingCamera.angularSensibilityX;
  16489. this._existingCamera.angularSensibilityX = Number.MAX_VALUE;
  16490. }
  16491. if (this._existingCamera.angularSensibilityY) {
  16492. this._cachedAngularSensibility.angularSensibilityY = this._existingCamera.angularSensibilityY;
  16493. this._existingCamera.angularSensibilityY = Number.MAX_VALUE;
  16494. }
  16495. if (this._existingCamera.angularSensibility) {
  16496. this._cachedAngularSensibility.angularSensibility = this._existingCamera.angularSensibility;
  16497. this._existingCamera.angularSensibility = Number.MAX_VALUE;
  16498. }
  16499. }
  16500. if (this._webVRrequesting) {
  16501. return;
  16502. }
  16503. // If WebVR is supported and a headset is connected
  16504. if (this._webVRready) {
  16505. if (!this._webVRpresenting) {
  16506. this._webVRCamera.position = this._position;
  16507. this._scene.activeCamera = this._webVRCamera;
  16508. }
  16509. }
  16510. else if (this._vrDeviceOrientationCamera) {
  16511. this._vrDeviceOrientationCamera.position = this._position;
  16512. if (this._scene.activeCamera) {
  16513. this._vrDeviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16514. }
  16515. this._scene.activeCamera = this._vrDeviceOrientationCamera;
  16516. this._scene.getEngine().enterFullscreen(this.requestPointerLockOnFullScreen);
  16517. this.updateButtonVisibility();
  16518. }
  16519. if (this._scene.activeCamera && this._canvas) {
  16520. this._scene.activeCamera.attachControl(this._canvas);
  16521. }
  16522. if (this._interactionsEnabled) {
  16523. this._scene.registerBeforeRender(this.beforeRender);
  16524. }
  16525. if (this._displayLaserPointer) {
  16526. [this._leftController, this._rightController].forEach(function (controller) {
  16527. if (controller) {
  16528. controller._activatePointer();
  16529. }
  16530. });
  16531. }
  16532. this._hasEnteredVR = true;
  16533. };
  16534. /**
  16535. * Attempt to exit VR, or fullscreen.
  16536. */
  16537. VRExperienceHelper.prototype.exitVR = function () {
  16538. if (this._hasEnteredVR) {
  16539. if (this.onExitingVRObservable) {
  16540. try {
  16541. this.onExitingVRObservable.notifyObservers(this);
  16542. }
  16543. catch (err) {
  16544. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onExitingVR: " + err);
  16545. }
  16546. }
  16547. if (this._webVRpresenting) {
  16548. this._scene.getEngine().disableVR();
  16549. }
  16550. if (this._scene.activeCamera) {
  16551. this._position = this._scene.activeCamera.position.clone();
  16552. }
  16553. if (this.vrDeviceOrientationCamera) {
  16554. this.vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16555. }
  16556. if (this._deviceOrientationCamera) {
  16557. this._deviceOrientationCamera.position = this._position;
  16558. this._scene.activeCamera = this._deviceOrientationCamera;
  16559. if (this._canvas) {
  16560. this._scene.activeCamera.attachControl(this._canvas);
  16561. }
  16562. // Restore angular sensibility
  16563. if (this._cachedAngularSensibility.angularSensibilityX) {
  16564. this._deviceOrientationCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  16565. this._cachedAngularSensibility.angularSensibilityX = null;
  16566. }
  16567. if (this._cachedAngularSensibility.angularSensibilityY) {
  16568. this._deviceOrientationCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  16569. this._cachedAngularSensibility.angularSensibilityY = null;
  16570. }
  16571. if (this._cachedAngularSensibility.angularSensibility) {
  16572. this._deviceOrientationCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  16573. this._cachedAngularSensibility.angularSensibility = null;
  16574. }
  16575. }
  16576. else if (this._existingCamera) {
  16577. this._existingCamera.position = this._position;
  16578. this._scene.activeCamera = this._existingCamera;
  16579. // Restore angular sensibility
  16580. if (this._cachedAngularSensibility.angularSensibilityX) {
  16581. this._existingCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  16582. this._cachedAngularSensibility.angularSensibilityX = null;
  16583. }
  16584. if (this._cachedAngularSensibility.angularSensibilityY) {
  16585. this._existingCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  16586. this._cachedAngularSensibility.angularSensibilityY = null;
  16587. }
  16588. if (this._cachedAngularSensibility.angularSensibility) {
  16589. this._existingCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  16590. this._cachedAngularSensibility.angularSensibility = null;
  16591. }
  16592. }
  16593. this.updateButtonVisibility();
  16594. if (this._interactionsEnabled) {
  16595. this._scene.unregisterBeforeRender(this.beforeRender);
  16596. this._cameraGazer._gazeTracker.isVisible = false;
  16597. if (this._leftController) {
  16598. this._leftController._gazeTracker.isVisible = false;
  16599. }
  16600. if (this._rightController) {
  16601. this._rightController._gazeTracker.isVisible = false;
  16602. }
  16603. }
  16604. // resize to update width and height when exiting vr exits fullscreen
  16605. this._scene.getEngine().resize();
  16606. [this._leftController, this._rightController].forEach(function (controller) {
  16607. if (controller) {
  16608. controller._deactivatePointer();
  16609. }
  16610. });
  16611. this._hasEnteredVR = false;
  16612. }
  16613. };
  16614. Object.defineProperty(VRExperienceHelper.prototype, "position", {
  16615. /**
  16616. * The position of the vr experience helper.
  16617. */
  16618. get: function () {
  16619. return this._position;
  16620. },
  16621. /**
  16622. * Sets the position of the vr experience helper.
  16623. */
  16624. set: function (value) {
  16625. this._position = value;
  16626. if (this._scene.activeCamera) {
  16627. this._scene.activeCamera.position = value;
  16628. }
  16629. },
  16630. enumerable: true,
  16631. configurable: true
  16632. });
  16633. /**
  16634. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  16635. */
  16636. VRExperienceHelper.prototype.enableInteractions = function () {
  16637. var _this = this;
  16638. if (!this._interactionsEnabled) {
  16639. this._interactionsRequested = true;
  16640. if (this._leftController) {
  16641. this._enableInteractionOnController(this._leftController);
  16642. }
  16643. if (this._rightController) {
  16644. this._enableInteractionOnController(this._rightController);
  16645. }
  16646. this.raySelectionPredicate = function (mesh) {
  16647. return mesh.isVisible && (mesh.isPickable || mesh.name === _this._floorMeshName);
  16648. };
  16649. this.meshSelectionPredicate = function () {
  16650. return true;
  16651. };
  16652. this._raySelectionPredicate = function (mesh) {
  16653. if (_this._isTeleportationFloor(mesh) || (mesh.name.indexOf("gazeTracker") === -1
  16654. && mesh.name.indexOf("teleportationTarget") === -1
  16655. && mesh.name.indexOf("torusTeleportation") === -1)) {
  16656. return _this.raySelectionPredicate(mesh);
  16657. }
  16658. return false;
  16659. };
  16660. this._interactionsEnabled = true;
  16661. }
  16662. };
  16663. Object.defineProperty(VRExperienceHelper.prototype, "_noControllerIsActive", {
  16664. get: function () {
  16665. return !(this._leftController && this._leftController._activePointer) && !(this._rightController && this._rightController._activePointer);
  16666. },
  16667. enumerable: true,
  16668. configurable: true
  16669. });
  16670. VRExperienceHelper.prototype._isTeleportationFloor = function (mesh) {
  16671. for (var i = 0; i < this._floorMeshesCollection.length; i++) {
  16672. if (this._floorMeshesCollection[i].id === mesh.id) {
  16673. return true;
  16674. }
  16675. }
  16676. if (this._floorMeshName && mesh.name === this._floorMeshName) {
  16677. return true;
  16678. }
  16679. return false;
  16680. };
  16681. /**
  16682. * Adds a floor mesh to be used for teleportation.
  16683. * @param floorMesh the mesh to be used for teleportation.
  16684. */
  16685. VRExperienceHelper.prototype.addFloorMesh = function (floorMesh) {
  16686. if (!this._floorMeshesCollection) {
  16687. return;
  16688. }
  16689. if (this._floorMeshesCollection.indexOf(floorMesh) > -1) {
  16690. return;
  16691. }
  16692. this._floorMeshesCollection.push(floorMesh);
  16693. };
  16694. /**
  16695. * Removes a floor mesh from being used for teleportation.
  16696. * @param floorMesh the mesh to be removed.
  16697. */
  16698. VRExperienceHelper.prototype.removeFloorMesh = function (floorMesh) {
  16699. if (!this._floorMeshesCollection) {
  16700. return;
  16701. }
  16702. var meshIndex = this._floorMeshesCollection.indexOf(floorMesh);
  16703. if (meshIndex !== -1) {
  16704. this._floorMeshesCollection.splice(meshIndex, 1);
  16705. }
  16706. };
  16707. /**
  16708. * Enables interactions and teleportation using the VR controllers and gaze.
  16709. * @param vrTeleportationOptions options to modify teleportation behavior.
  16710. */
  16711. VRExperienceHelper.prototype.enableTeleportation = function (vrTeleportationOptions) {
  16712. if (vrTeleportationOptions === void 0) { vrTeleportationOptions = {}; }
  16713. if (!this._teleportationInitialized) {
  16714. this._teleportationRequested = true;
  16715. this.enableInteractions();
  16716. if (vrTeleportationOptions.floorMeshName) {
  16717. this._floorMeshName = vrTeleportationOptions.floorMeshName;
  16718. }
  16719. if (vrTeleportationOptions.floorMeshes) {
  16720. this._floorMeshesCollection = vrTeleportationOptions.floorMeshes;
  16721. }
  16722. if (this._leftController != null) {
  16723. this._enableTeleportationOnController(this._leftController);
  16724. }
  16725. if (this._rightController != null) {
  16726. this._enableTeleportationOnController(this._rightController);
  16727. }
  16728. // Creates an image processing post process for the vignette not relying
  16729. // on the main scene configuration for image processing to reduce setup and spaces
  16730. // (gamma/linear) conflicts.
  16731. var imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__["ImageProcessingConfiguration"]();
  16732. imageProcessingConfiguration.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color4"](0, 0, 0, 0);
  16733. imageProcessingConfiguration.vignetteEnabled = true;
  16734. this._postProcessMove = new _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__["ImageProcessingPostProcess"]("postProcessMove", 1.0, this._webVRCamera, undefined, undefined, undefined, undefined, imageProcessingConfiguration);
  16735. this._webVRCamera.detachPostProcess(this._postProcessMove);
  16736. this._teleportationInitialized = true;
  16737. if (this._isDefaultTeleportationTarget) {
  16738. this._createTeleportationCircles();
  16739. this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor);
  16740. }
  16741. }
  16742. };
  16743. VRExperienceHelper.prototype._enableInteractionOnController = function (controller) {
  16744. var _this = this;
  16745. var controllerMesh = controller.webVRController.mesh;
  16746. if (controllerMesh) {
  16747. controller._interactionsEnabled = true;
  16748. if (this.isInVRMode && this._displayLaserPointer) {
  16749. controller._activatePointer();
  16750. }
  16751. if (this.webVROptions.laserToggle) {
  16752. controller.webVRController.onMainButtonStateChangedObservable.add(function (stateObject) {
  16753. // Enabling / disabling laserPointer
  16754. if (_this._displayLaserPointer && stateObject.value === 1) {
  16755. if (controller._activePointer) {
  16756. controller._deactivatePointer();
  16757. }
  16758. else {
  16759. controller._activatePointer();
  16760. }
  16761. if (_this.displayGaze) {
  16762. controller._gazeTracker.isVisible = controller._activePointer;
  16763. }
  16764. }
  16765. });
  16766. }
  16767. controller.webVRController.onTriggerStateChangedObservable.add(function (stateObject) {
  16768. var gazer = controller;
  16769. if (_this._noControllerIsActive) {
  16770. gazer = _this._cameraGazer;
  16771. }
  16772. if (!gazer._pointerDownOnMeshAsked) {
  16773. if (stateObject.value > _this._padSensibilityUp) {
  16774. gazer._selectionPointerDown();
  16775. }
  16776. }
  16777. else if (stateObject.value < _this._padSensibilityDown) {
  16778. gazer._selectionPointerUp();
  16779. }
  16780. });
  16781. }
  16782. };
  16783. VRExperienceHelper.prototype._checkTeleportWithRay = function (stateObject, gazer) {
  16784. // Dont teleport if another gaze already requested teleportation
  16785. if (this._teleportationRequestInitiated && !gazer._teleportationRequestInitiated) {
  16786. return;
  16787. }
  16788. if (!gazer._teleportationRequestInitiated) {
  16789. if (stateObject.y < -this._padSensibilityUp && gazer._dpadPressed) {
  16790. gazer._activatePointer();
  16791. gazer._teleportationRequestInitiated = true;
  16792. }
  16793. }
  16794. else {
  16795. // Listening to the proper controller values changes to confirm teleportation
  16796. if (Math.sqrt(stateObject.y * stateObject.y + stateObject.x * stateObject.x) < this._padSensibilityDown) {
  16797. if (this._teleportActive) {
  16798. this.teleportCamera(this._haloCenter);
  16799. }
  16800. gazer._teleportationRequestInitiated = false;
  16801. }
  16802. }
  16803. };
  16804. VRExperienceHelper.prototype._checkRotate = function (stateObject, gazer) {
  16805. // Only rotate when user is not currently selecting a teleportation location
  16806. if (gazer._teleportationRequestInitiated) {
  16807. return;
  16808. }
  16809. if (!gazer._rotationLeftAsked) {
  16810. if (stateObject.x < -this._padSensibilityUp && gazer._dpadPressed) {
  16811. gazer._rotationLeftAsked = true;
  16812. if (this._rotationAllowed) {
  16813. this._rotateCamera(false);
  16814. }
  16815. }
  16816. }
  16817. else {
  16818. if (stateObject.x > -this._padSensibilityDown) {
  16819. gazer._rotationLeftAsked = false;
  16820. }
  16821. }
  16822. if (!gazer._rotationRightAsked) {
  16823. if (stateObject.x > this._padSensibilityUp && gazer._dpadPressed) {
  16824. gazer._rotationRightAsked = true;
  16825. if (this._rotationAllowed) {
  16826. this._rotateCamera(true);
  16827. }
  16828. }
  16829. }
  16830. else {
  16831. if (stateObject.x < this._padSensibilityDown) {
  16832. gazer._rotationRightAsked = false;
  16833. }
  16834. }
  16835. };
  16836. VRExperienceHelper.prototype._checkTeleportBackwards = function (stateObject, gazer) {
  16837. // Only teleport backwards when user is not currently selecting a teleportation location
  16838. if (gazer._teleportationRequestInitiated) {
  16839. return;
  16840. }
  16841. // Teleport backwards
  16842. if (stateObject.y > this._padSensibilityUp && gazer._dpadPressed) {
  16843. if (!gazer._teleportationBackRequestInitiated) {
  16844. if (!this.currentVRCamera) {
  16845. return;
  16846. }
  16847. // Get rotation and position of the current camera
  16848. var rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix());
  16849. var position = this.currentVRCamera.position;
  16850. // If the camera has device position, use that instead
  16851. if (this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion) {
  16852. rotation = this.currentVRCamera.deviceRotationQuaternion;
  16853. position = this.currentVRCamera.devicePosition;
  16854. }
  16855. // Get matrix with only the y rotation of the device rotation
  16856. rotation.toEulerAnglesToRef(this._workingVector);
  16857. this._workingVector.z = 0;
  16858. this._workingVector.x = 0;
  16859. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion);
  16860. this._workingQuaternion.toRotationMatrix(this._workingMatrix);
  16861. // Rotate backwards ray by device rotation to cast at the ground behind the user
  16862. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
  16863. // Teleport if ray hit the ground and is not to far away eg. backwards off a cliff
  16864. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_15__["Ray"](position, this._workingVector);
  16865. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  16866. if (hit && hit.pickedPoint && hit.pickedMesh && this._isTeleportationFloor(hit.pickedMesh) && hit.distance < 5) {
  16867. this.teleportCamera(hit.pickedPoint);
  16868. }
  16869. gazer._teleportationBackRequestInitiated = true;
  16870. }
  16871. }
  16872. else {
  16873. gazer._teleportationBackRequestInitiated = false;
  16874. }
  16875. };
  16876. VRExperienceHelper.prototype._enableTeleportationOnController = function (controller) {
  16877. var _this = this;
  16878. var controllerMesh = controller.webVRController.mesh;
  16879. if (controllerMesh) {
  16880. if (!controller._interactionsEnabled) {
  16881. this._enableInteractionOnController(controller);
  16882. }
  16883. controller._interactionsEnabled = true;
  16884. controller._teleportationEnabled = true;
  16885. if (controller.webVRController.controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledControllerType"].VIVE) {
  16886. controller._dpadPressed = false;
  16887. controller.webVRController.onPadStateChangedObservable.add(function (stateObject) {
  16888. controller._dpadPressed = stateObject.pressed;
  16889. if (!controller._dpadPressed) {
  16890. controller._rotationLeftAsked = false;
  16891. controller._rotationRightAsked = false;
  16892. controller._teleportationBackRequestInitiated = false;
  16893. }
  16894. });
  16895. }
  16896. controller.webVRController.onPadValuesChangedObservable.add(function (stateObject) {
  16897. if (_this.teleportationEnabled) {
  16898. _this._checkTeleportBackwards(stateObject, controller);
  16899. _this._checkTeleportWithRay(stateObject, controller);
  16900. }
  16901. _this._checkRotate(stateObject, controller);
  16902. });
  16903. }
  16904. };
  16905. VRExperienceHelper.prototype._createTeleportationCircles = function () {
  16906. this._teleportationTarget = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateGround("teleportationTarget", 2, 2, 2, this._scene);
  16907. this._teleportationTarget.isPickable = false;
  16908. var length = 512;
  16909. var dynamicTexture = new _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__["DynamicTexture"]("DynamicTexture", length, this._scene, true);
  16910. dynamicTexture.hasAlpha = true;
  16911. var context = dynamicTexture.getContext();
  16912. var centerX = length / 2;
  16913. var centerY = length / 2;
  16914. var radius = 200;
  16915. context.beginPath();
  16916. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  16917. context.fillStyle = this._teleportationFillColor;
  16918. context.fill();
  16919. context.lineWidth = 10;
  16920. context.strokeStyle = this._teleportationBorderColor;
  16921. context.stroke();
  16922. context.closePath();
  16923. dynamicTexture.update();
  16924. var teleportationCircleMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("TextPlaneMaterial", this._scene);
  16925. teleportationCircleMaterial.diffuseTexture = dynamicTexture;
  16926. this._teleportationTarget.material = teleportationCircleMaterial;
  16927. var torus = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("torusTeleportation", 0.75, 0.1, 25, this._scene, false);
  16928. torus.isPickable = false;
  16929. torus.parent = this._teleportationTarget;
  16930. 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);
  16931. var keys = [];
  16932. keys.push({
  16933. frame: 0,
  16934. value: 0
  16935. });
  16936. keys.push({
  16937. frame: 30,
  16938. value: 0.4
  16939. });
  16940. keys.push({
  16941. frame: 60,
  16942. value: 0
  16943. });
  16944. animationInnerCircle.setKeys(keys);
  16945. var easingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["SineEase"]();
  16946. easingFunction.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  16947. animationInnerCircle.setEasingFunction(easingFunction);
  16948. torus.animations = [];
  16949. torus.animations.push(animationInnerCircle);
  16950. this._scene.beginAnimation(torus, 0, 60, true);
  16951. this._hideTeleportationTarget();
  16952. };
  16953. VRExperienceHelper.prototype._displayTeleportationTarget = function () {
  16954. this._teleportActive = true;
  16955. if (this._teleportationInitialized) {
  16956. this._teleportationTarget.isVisible = true;
  16957. if (this._isDefaultTeleportationTarget) {
  16958. this._teleportationTarget.getChildren()[0].isVisible = true;
  16959. }
  16960. }
  16961. };
  16962. VRExperienceHelper.prototype._hideTeleportationTarget = function () {
  16963. this._teleportActive = false;
  16964. if (this._teleportationInitialized) {
  16965. this._teleportationTarget.isVisible = false;
  16966. if (this._isDefaultTeleportationTarget) {
  16967. this._teleportationTarget.getChildren()[0].isVisible = false;
  16968. }
  16969. }
  16970. };
  16971. VRExperienceHelper.prototype._rotateCamera = function (right) {
  16972. var _this = this;
  16973. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  16974. return;
  16975. }
  16976. if (right) {
  16977. this._rotationAngle++;
  16978. }
  16979. else {
  16980. this._rotationAngle--;
  16981. }
  16982. this.currentVRCamera.animations = [];
  16983. var target = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].RotationY(Math.PI / 4 * this._rotationAngle));
  16984. 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);
  16985. var animationRotationKeys = [];
  16986. animationRotationKeys.push({
  16987. frame: 0,
  16988. value: this.currentVRCamera.rotationQuaternion
  16989. });
  16990. animationRotationKeys.push({
  16991. frame: 6,
  16992. value: target
  16993. });
  16994. animationRotation.setKeys(animationRotationKeys);
  16995. animationRotation.setEasingFunction(this._circleEase);
  16996. this.currentVRCamera.animations.push(animationRotation);
  16997. this._postProcessMove.animations = [];
  16998. 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);
  16999. var vignetteWeightKeys = [];
  17000. vignetteWeightKeys.push({
  17001. frame: 0,
  17002. value: 0
  17003. });
  17004. vignetteWeightKeys.push({
  17005. frame: 3,
  17006. value: 4
  17007. });
  17008. vignetteWeightKeys.push({
  17009. frame: 6,
  17010. value: 0
  17011. });
  17012. animationPP.setKeys(vignetteWeightKeys);
  17013. animationPP.setEasingFunction(this._circleEase);
  17014. this._postProcessMove.animations.push(animationPP);
  17015. 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);
  17016. var vignetteStretchKeys = [];
  17017. vignetteStretchKeys.push({
  17018. frame: 0,
  17019. value: 0
  17020. });
  17021. vignetteStretchKeys.push({
  17022. frame: 3,
  17023. value: 10
  17024. });
  17025. vignetteStretchKeys.push({
  17026. frame: 6,
  17027. value: 0
  17028. });
  17029. animationPP2.setKeys(vignetteStretchKeys);
  17030. animationPP2.setEasingFunction(this._circleEase);
  17031. this._postProcessMove.animations.push(animationPP2);
  17032. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17033. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17034. this._postProcessMove.samples = 4;
  17035. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17036. this._scene.beginAnimation(this._postProcessMove, 0, 6, false, 1, function () {
  17037. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17038. });
  17039. this._scene.beginAnimation(this.currentVRCamera, 0, 6, false, 1);
  17040. };
  17041. VRExperienceHelper.prototype._moveTeleportationSelectorTo = function (hit, gazer, ray) {
  17042. if (hit.pickedPoint) {
  17043. if (gazer._teleportationRequestInitiated) {
  17044. this._displayTeleportationTarget();
  17045. this._haloCenter.copyFrom(hit.pickedPoint);
  17046. this._teleportationTarget.position.copyFrom(hit.pickedPoint);
  17047. }
  17048. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(true, false), ray);
  17049. if (pickNormal) {
  17050. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17051. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17052. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, this._teleportationTarget.rotation);
  17053. }
  17054. this._teleportationTarget.position.y += 0.1;
  17055. }
  17056. };
  17057. /**
  17058. * Teleports the users feet to the desired location
  17059. * @param location The location where the user's feet should be placed
  17060. */
  17061. VRExperienceHelper.prototype.teleportCamera = function (location) {
  17062. var _this = this;
  17063. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17064. return;
  17065. }
  17066. // Teleport the hmd to where the user is looking by moving the anchor to where they are looking minus the
  17067. // offset of the headset from the anchor.
  17068. if (this.webVRCamera.leftCamera) {
  17069. this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition);
  17070. this._workingVector.subtractInPlace(this.webVRCamera.position);
  17071. location.subtractToRef(this._workingVector, this._workingVector);
  17072. }
  17073. else {
  17074. this._workingVector.copyFrom(location);
  17075. }
  17076. // Add height to account for user's height offset
  17077. if (this.isInVRMode) {
  17078. this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround() * this._webVRCamera.deviceScaleFactor;
  17079. }
  17080. else {
  17081. this._workingVector.y += this._defaultHeight;
  17082. }
  17083. this.onBeforeCameraTeleport.notifyObservers(this._workingVector);
  17084. // Create animation from the camera's position to the new location
  17085. this.currentVRCamera.animations = [];
  17086. 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);
  17087. var animationCameraTeleportationKeys = [{
  17088. frame: 0,
  17089. value: this.currentVRCamera.position
  17090. },
  17091. {
  17092. frame: 11,
  17093. value: this._workingVector
  17094. }
  17095. ];
  17096. animationCameraTeleportation.setKeys(animationCameraTeleportationKeys);
  17097. animationCameraTeleportation.setEasingFunction(this._circleEase);
  17098. this.currentVRCamera.animations.push(animationCameraTeleportation);
  17099. this._postProcessMove.animations = [];
  17100. 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);
  17101. var vignetteWeightKeys = [];
  17102. vignetteWeightKeys.push({
  17103. frame: 0,
  17104. value: 0
  17105. });
  17106. vignetteWeightKeys.push({
  17107. frame: 5,
  17108. value: 8
  17109. });
  17110. vignetteWeightKeys.push({
  17111. frame: 11,
  17112. value: 0
  17113. });
  17114. animationPP.setKeys(vignetteWeightKeys);
  17115. this._postProcessMove.animations.push(animationPP);
  17116. 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);
  17117. var vignetteStretchKeys = [];
  17118. vignetteStretchKeys.push({
  17119. frame: 0,
  17120. value: 0
  17121. });
  17122. vignetteStretchKeys.push({
  17123. frame: 5,
  17124. value: 10
  17125. });
  17126. vignetteStretchKeys.push({
  17127. frame: 11,
  17128. value: 0
  17129. });
  17130. animationPP2.setKeys(vignetteStretchKeys);
  17131. this._postProcessMove.animations.push(animationPP2);
  17132. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17133. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17134. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17135. this._scene.beginAnimation(this._postProcessMove, 0, 11, false, 1, function () {
  17136. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17137. });
  17138. this._scene.beginAnimation(this.currentVRCamera, 0, 11, false, 1, function () {
  17139. _this.onAfterCameraTeleport.notifyObservers(_this._workingVector);
  17140. });
  17141. this._hideTeleportationTarget();
  17142. };
  17143. VRExperienceHelper.prototype._convertNormalToDirectionOfRay = function (normal, ray) {
  17144. if (normal) {
  17145. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Dot(normal, ray.direction));
  17146. if (angle < Math.PI / 2) {
  17147. normal.scaleInPlace(-1);
  17148. }
  17149. }
  17150. return normal;
  17151. };
  17152. VRExperienceHelper.prototype._castRayAndSelectObject = function (gazer) {
  17153. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17154. return;
  17155. }
  17156. var ray = gazer._getForwardRay(this._rayLength);
  17157. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17158. if (hit) {
  17159. // Populate the contrllers mesh that can be used for drag/drop
  17160. if (gazer._laserPointer) {
  17161. hit.originMesh = gazer._laserPointer.parent;
  17162. }
  17163. this._scene.simulatePointerMove(hit, { pointerId: gazer._id });
  17164. }
  17165. gazer._currentHit = hit;
  17166. // Moving the gazeTracker on the mesh face targetted
  17167. if (hit && hit.pickedPoint) {
  17168. if (this._displayGaze) {
  17169. var multiplier = 1;
  17170. gazer._gazeTracker.isVisible = true;
  17171. if (gazer._isActionableMesh) {
  17172. multiplier = 3;
  17173. }
  17174. if (this.updateGazeTrackerScale) {
  17175. gazer._gazeTracker.scaling.x = hit.distance * multiplier;
  17176. gazer._gazeTracker.scaling.y = hit.distance * multiplier;
  17177. gazer._gazeTracker.scaling.z = hit.distance * multiplier;
  17178. }
  17179. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(), ray);
  17180. // To avoid z-fighting
  17181. var deltaFighting = 0.002;
  17182. if (pickNormal) {
  17183. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17184. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17185. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, gazer._gazeTracker.rotation);
  17186. }
  17187. gazer._gazeTracker.position.copyFrom(hit.pickedPoint);
  17188. if (gazer._gazeTracker.position.x < 0) {
  17189. gazer._gazeTracker.position.x += deltaFighting;
  17190. }
  17191. else {
  17192. gazer._gazeTracker.position.x -= deltaFighting;
  17193. }
  17194. if (gazer._gazeTracker.position.y < 0) {
  17195. gazer._gazeTracker.position.y += deltaFighting;
  17196. }
  17197. else {
  17198. gazer._gazeTracker.position.y -= deltaFighting;
  17199. }
  17200. if (gazer._gazeTracker.position.z < 0) {
  17201. gazer._gazeTracker.position.z += deltaFighting;
  17202. }
  17203. else {
  17204. gazer._gazeTracker.position.z -= deltaFighting;
  17205. }
  17206. }
  17207. // Changing the size of the laser pointer based on the distance from the targetted point
  17208. gazer._updatePointerDistance(hit.distance);
  17209. }
  17210. else {
  17211. gazer._updatePointerDistance();
  17212. gazer._gazeTracker.isVisible = false;
  17213. }
  17214. if (hit && hit.pickedMesh) {
  17215. // The object selected is the floor, we're in a teleportation scenario
  17216. if (this._teleportationInitialized && this._isTeleportationFloor(hit.pickedMesh) && hit.pickedPoint) {
  17217. // Moving the teleportation area to this targetted point
  17218. //Raise onSelectedMeshUnselected observable if ray collided floor mesh/meshes and a non floor mesh was previously selected
  17219. if (gazer._currentMeshSelected && !this._isTeleportationFloor(gazer._currentMeshSelected)) {
  17220. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17221. }
  17222. gazer._currentMeshSelected = null;
  17223. if (gazer._teleportationRequestInitiated) {
  17224. this._moveTeleportationSelectorTo(hit, gazer, ray);
  17225. }
  17226. return;
  17227. }
  17228. // If not, we're in a selection scenario
  17229. //this._teleportationAllowed = false;
  17230. if (hit.pickedMesh !== gazer._currentMeshSelected) {
  17231. if (this.meshSelectionPredicate(hit.pickedMesh)) {
  17232. this.onNewMeshPicked.notifyObservers(hit);
  17233. gazer._currentMeshSelected = hit.pickedMesh;
  17234. if (hit.pickedMesh.isPickable && hit.pickedMesh.actionManager) {
  17235. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0, 0, 1));
  17236. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.2, 0.2, 1));
  17237. gazer._isActionableMesh = true;
  17238. }
  17239. else {
  17240. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17241. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17242. gazer._isActionableMesh = false;
  17243. }
  17244. try {
  17245. this.onNewMeshSelected.notifyObservers(hit.pickedMesh);
  17246. }
  17247. catch (err) {
  17248. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onNewMeshSelected: " + err);
  17249. }
  17250. }
  17251. else {
  17252. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17253. gazer._currentMeshSelected = null;
  17254. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17255. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17256. }
  17257. }
  17258. }
  17259. else {
  17260. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17261. gazer._currentMeshSelected = null;
  17262. //this._teleportationAllowed = false;
  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. VRExperienceHelper.prototype._notifySelectedMeshUnselected = function (mesh) {
  17268. if (mesh) {
  17269. this.onSelectedMeshUnselected.notifyObservers(mesh);
  17270. }
  17271. };
  17272. /**
  17273. * Sets the color of the laser ray from the vr controllers.
  17274. * @param color new color for the ray.
  17275. */
  17276. VRExperienceHelper.prototype.changeLaserColor = function (color) {
  17277. if (this._leftController) {
  17278. this._leftController._setLaserPointerColor(color);
  17279. }
  17280. if (this._rightController) {
  17281. this._rightController._setLaserPointerColor(color);
  17282. }
  17283. };
  17284. /**
  17285. * Sets the color of the ray from the vr headsets gaze.
  17286. * @param color new color for the ray.
  17287. */
  17288. VRExperienceHelper.prototype.changeGazeColor = function (color) {
  17289. if (!this.updateGazeTrackerColor) {
  17290. return;
  17291. }
  17292. if (!this._cameraGazer._gazeTracker.material) {
  17293. return;
  17294. }
  17295. this._cameraGazer._gazeTracker.material.emissiveColor = color;
  17296. if (this._leftController) {
  17297. this._leftController._gazeTracker.material.emissiveColor = color;
  17298. }
  17299. if (this._rightController) {
  17300. this._rightController._gazeTracker.material.emissiveColor = color;
  17301. }
  17302. };
  17303. /**
  17304. * Exits VR and disposes of the vr experience helper
  17305. */
  17306. VRExperienceHelper.prototype.dispose = function () {
  17307. if (this.isInVRMode) {
  17308. this.exitVR();
  17309. }
  17310. if (this._postProcessMove) {
  17311. this._postProcessMove.dispose();
  17312. }
  17313. if (this._webVRCamera) {
  17314. this._webVRCamera.dispose();
  17315. }
  17316. if (this._vrDeviceOrientationCamera) {
  17317. this._vrDeviceOrientationCamera.dispose();
  17318. }
  17319. if (!this._useCustomVRButton && this._btnVR.parentNode) {
  17320. document.body.removeChild(this._btnVR);
  17321. }
  17322. if (this._deviceOrientationCamera && (this._scene.activeCamera != this._deviceOrientationCamera)) {
  17323. this._deviceOrientationCamera.dispose();
  17324. }
  17325. if (this._cameraGazer) {
  17326. this._cameraGazer.dispose();
  17327. }
  17328. if (this._leftController) {
  17329. this._leftController.dispose();
  17330. }
  17331. if (this._rightController) {
  17332. this._rightController.dispose();
  17333. }
  17334. if (this._teleportationTarget) {
  17335. this._teleportationTarget.dispose();
  17336. }
  17337. this._floorMeshesCollection = [];
  17338. document.removeEventListener("keydown", this._onKeyDown);
  17339. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17340. window.removeEventListener("resize", this._onResize);
  17341. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  17342. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  17343. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  17344. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  17345. document.onmsfullscreenchange = null;
  17346. this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged);
  17347. this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart);
  17348. this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete);
  17349. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17350. this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected);
  17351. this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected);
  17352. this._scene.unregisterBeforeRender(this.beforeRender);
  17353. };
  17354. /**
  17355. * Gets the name of the VRExperienceHelper class
  17356. * @returns "VRExperienceHelper"
  17357. */
  17358. VRExperienceHelper.prototype.getClassName = function () {
  17359. return "VRExperienceHelper";
  17360. };
  17361. return VRExperienceHelper;
  17362. }());
  17363. /***/ }),
  17364. /***/ "./Cameras/VR/webVRCamera.ts":
  17365. /*!***********************************!*\
  17366. !*** ./Cameras/VR/webVRCamera.ts ***!
  17367. \***********************************/
  17368. /*! exports provided: WebVRFreeCamera */
  17369. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17370. "use strict";
  17371. __webpack_require__.r(__webpack_exports__);
  17372. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return WebVRFreeCamera; });
  17373. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  17374. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  17375. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  17376. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  17377. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  17378. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  17379. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  17380. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../node */ "./node.ts");
  17381. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  17382. /* harmony import */ var _RigModes_webVRRigMode__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../RigModes/webVRRigMode */ "./Cameras/RigModes/webVRRigMode.ts");
  17383. // Side effect import to define the stereoscopic mode.
  17384. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRFreeCamera", function (name, scene) {
  17385. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17386. });
  17387. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRGamepadCamera", function (name, scene) {
  17388. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17389. });
  17390. /**
  17391. * This represents a WebVR camera.
  17392. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  17393. * @example http://doc.babylonjs.com/how_to/webvr_camera
  17394. */
  17395. var WebVRFreeCamera = /** @class */ (function (_super) {
  17396. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRFreeCamera, _super);
  17397. /**
  17398. * Instantiates a WebVRFreeCamera.
  17399. * @param name The name of the WebVRFreeCamera
  17400. * @param position The starting anchor position for the camera
  17401. * @param scene The scene the camera belongs to
  17402. * @param webVROptions a set of customizable options for the webVRCamera
  17403. */
  17404. function WebVRFreeCamera(name, position, scene, webVROptions) {
  17405. if (webVROptions === void 0) { webVROptions = {}; }
  17406. var _this = _super.call(this, name, position, scene) || this;
  17407. _this.webVROptions = webVROptions;
  17408. /**
  17409. * @hidden
  17410. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  17411. */
  17412. _this._vrDevice = null;
  17413. /**
  17414. * The rawPose of the vrDevice.
  17415. */
  17416. _this.rawPose = null;
  17417. _this._specsVersion = "1.1";
  17418. _this._attached = false;
  17419. _this._descendants = [];
  17420. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  17421. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17422. /** @hidden */
  17423. _this._deviceRoomRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17424. _this._standingMatrix = null;
  17425. /**
  17426. * Represents device position in babylon space.
  17427. */
  17428. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17429. /**
  17430. * Represents device rotation in babylon space.
  17431. */
  17432. _this.deviceRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17433. /**
  17434. * The scale of the device to be used when translating from device space to babylon space.
  17435. */
  17436. _this.deviceScaleFactor = 1;
  17437. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17438. _this._worldToDevice = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17439. /**
  17440. * References to the webVR controllers for the vrDevice.
  17441. */
  17442. _this.controllers = [];
  17443. /**
  17444. * Emits an event when a controller is attached.
  17445. */
  17446. _this.onControllersAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17447. /**
  17448. * Emits an event when a controller's mesh has been loaded;
  17449. */
  17450. _this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17451. /**
  17452. * Emits an event when the HMD's pose has been updated.
  17453. */
  17454. _this.onPoseUpdatedFromDeviceObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17455. _this._poseSet = false;
  17456. /**
  17457. * If the rig cameras be used as parent instead of this camera.
  17458. */
  17459. _this.rigParenting = true;
  17460. _this._defaultHeight = undefined;
  17461. _this._htmlElementAttached = null;
  17462. _this._detachIfAttached = function () {
  17463. var vrDisplay = _this.getEngine().getVRDevice();
  17464. if (vrDisplay && !vrDisplay.isPresenting && _this._htmlElementAttached) {
  17465. _this.detachControl(_this._htmlElementAttached);
  17466. }
  17467. };
  17468. _this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17469. _this._oneVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].One();
  17470. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17471. _this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  17472. _this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17473. if (webVROptions.defaultHeight) {
  17474. _this._defaultHeight = webVROptions.defaultHeight;
  17475. _this.position.y = _this._defaultHeight;
  17476. }
  17477. _this.minZ = 0.1;
  17478. //legacy support - the compensation boolean was removed.
  17479. if (arguments.length === 5) {
  17480. _this.webVROptions = arguments[4];
  17481. }
  17482. // default webVR options
  17483. if (_this.webVROptions.trackPosition == undefined) {
  17484. _this.webVROptions.trackPosition = true;
  17485. }
  17486. if (_this.webVROptions.controllerMeshes == undefined) {
  17487. _this.webVROptions.controllerMeshes = true;
  17488. }
  17489. if (_this.webVROptions.defaultLightingOnControllers == undefined) {
  17490. _this.webVROptions.defaultLightingOnControllers = true;
  17491. }
  17492. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]();
  17493. if (_this.webVROptions && _this.webVROptions.positionScale) {
  17494. _this.deviceScaleFactor = _this.webVROptions.positionScale;
  17495. }
  17496. //enable VR
  17497. var engine = _this.getEngine();
  17498. _this._onVREnabled = function (success) { if (success) {
  17499. _this.initControllers();
  17500. } };
  17501. engine.onVRRequestPresentComplete.add(_this._onVREnabled);
  17502. engine.initWebVR().add(function (event) {
  17503. if (!event.vrDisplay || _this._vrDevice === event.vrDisplay) {
  17504. return;
  17505. }
  17506. _this._vrDevice = event.vrDisplay;
  17507. //reset the rig parameters.
  17508. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].RIG_MODE_WEBVR, { parentCamera: _this, vrDisplay: _this._vrDevice, frameData: _this._frameData, specs: _this._specsVersion });
  17509. if (_this._attached) {
  17510. _this.getEngine().enableVR();
  17511. }
  17512. });
  17513. if (typeof (VRFrameData) !== "undefined") {
  17514. _this._frameData = new VRFrameData();
  17515. }
  17516. /**
  17517. * The idea behind the following lines:
  17518. * objects that have the camera as parent should actually have the rig cameras as a parent.
  17519. * BUT, each of those cameras has a different view matrix, which means that if we set the parent to the first rig camera,
  17520. * the second will not show it correctly.
  17521. *
  17522. * To solve this - each object that has the camera as parent will be added to a protected array.
  17523. * When the rig camera renders, it will take this array and set all of those to be its children.
  17524. * This way, the right camera will be used as a parent, and the mesh will be rendered correctly.
  17525. * Amazing!
  17526. */
  17527. scene.onBeforeCameraRenderObservable.add(function (camera) {
  17528. if (camera.parent === _this && _this.rigParenting) {
  17529. _this._descendants = _this.getDescendants(true, function (n) {
  17530. // don't take the cameras or the controllers!
  17531. var isController = _this.controllers.some(function (controller) { return controller._mesh === n; });
  17532. var isRigCamera = _this._rigCameras.indexOf(n) !== -1;
  17533. return !isController && !isRigCamera;
  17534. });
  17535. _this._descendants.forEach(function (node) {
  17536. node.parent = camera;
  17537. });
  17538. }
  17539. });
  17540. scene.onAfterCameraRenderObservable.add(function (camera) {
  17541. if (camera.parent === _this && _this.rigParenting) {
  17542. _this._descendants.forEach(function (node) {
  17543. node.parent = _this;
  17544. });
  17545. }
  17546. });
  17547. return _this;
  17548. }
  17549. /**
  17550. * Gets the device distance from the ground in meters.
  17551. * @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.
  17552. */
  17553. WebVRFreeCamera.prototype.deviceDistanceToRoomGround = function () {
  17554. if (this._standingMatrix) {
  17555. // Add standing matrix offset to get real offset from ground in room
  17556. this._standingMatrix.getTranslationToRef(this._workingVector);
  17557. return this._deviceRoomPosition.y + this._workingVector.y;
  17558. }
  17559. //If VRDisplay does not inform stage parameters and no default height is set we fallback to zero.
  17560. return this._defaultHeight || 0;
  17561. };
  17562. /**
  17563. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17564. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  17565. */
  17566. WebVRFreeCamera.prototype.useStandingMatrix = function (callback) {
  17567. var _this = this;
  17568. if (callback === void 0) { callback = function (bool) { }; }
  17569. // Use standing matrix if available
  17570. this.getEngine().initWebVRAsync().then(function (result) {
  17571. if (!result.vrDisplay || !result.vrDisplay.stageParameters || !result.vrDisplay.stageParameters.sittingToStandingTransform || !_this.webVROptions.trackPosition) {
  17572. callback(false);
  17573. }
  17574. else {
  17575. _this._standingMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  17576. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromFloat32ArrayToRefScaled(result.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, _this._standingMatrix);
  17577. if (!_this.getScene().useRightHandedSystem) {
  17578. if (_this._standingMatrix) {
  17579. _this._standingMatrix.toggleModelMatrixHandInPlace();
  17580. }
  17581. }
  17582. callback(true);
  17583. }
  17584. });
  17585. };
  17586. /**
  17587. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17588. * @returns A promise with a boolean set to if the standing matrix is supported.
  17589. */
  17590. WebVRFreeCamera.prototype.useStandingMatrixAsync = function () {
  17591. var _this = this;
  17592. return new Promise(function (res) {
  17593. _this.useStandingMatrix(function (supported) {
  17594. res(supported);
  17595. });
  17596. });
  17597. };
  17598. /**
  17599. * Disposes the camera
  17600. */
  17601. WebVRFreeCamera.prototype.dispose = function () {
  17602. this._detachIfAttached();
  17603. this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled);
  17604. if (this._updateCacheWhenTrackingDisabledObserver) {
  17605. this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver);
  17606. }
  17607. _super.prototype.dispose.call(this);
  17608. };
  17609. /**
  17610. * Gets a vrController by name.
  17611. * @param name The name of the controller to retreive
  17612. * @returns the controller matching the name specified or null if not found
  17613. */
  17614. WebVRFreeCamera.prototype.getControllerByName = function (name) {
  17615. for (var _i = 0, _a = this.controllers; _i < _a.length; _i++) {
  17616. var gp = _a[_i];
  17617. if (gp.hand === name) {
  17618. return gp;
  17619. }
  17620. }
  17621. return null;
  17622. };
  17623. Object.defineProperty(WebVRFreeCamera.prototype, "leftController", {
  17624. /**
  17625. * The controller corrisponding to the users left hand.
  17626. */
  17627. get: function () {
  17628. if (!this._leftController) {
  17629. this._leftController = this.getControllerByName("left");
  17630. }
  17631. return this._leftController;
  17632. },
  17633. enumerable: true,
  17634. configurable: true
  17635. });
  17636. Object.defineProperty(WebVRFreeCamera.prototype, "rightController", {
  17637. /**
  17638. * The controller corrisponding to the users right hand.
  17639. */
  17640. get: function () {
  17641. if (!this._rightController) {
  17642. this._rightController = this.getControllerByName("right");
  17643. }
  17644. return this._rightController;
  17645. },
  17646. enumerable: true,
  17647. configurable: true
  17648. });
  17649. /**
  17650. * Casts a ray forward from the vrCamera's gaze.
  17651. * @param length Length of the ray (default: 100)
  17652. * @returns the ray corrisponding to the gaze
  17653. */
  17654. WebVRFreeCamera.prototype.getForwardRay = function (length) {
  17655. if (length === void 0) { length = 100; }
  17656. if (this.leftCamera) {
  17657. // Use left eye to avoid computation to compute center on every call
  17658. return _super.prototype.getForwardRay.call(this, length, this.leftCamera.getWorldMatrix(), this.leftCamera.globalPosition); // Need the actual rendered camera
  17659. }
  17660. else {
  17661. return _super.prototype.getForwardRay.call(this, length);
  17662. }
  17663. };
  17664. /**
  17665. * @hidden
  17666. * Updates the camera based on device's frame data
  17667. */
  17668. WebVRFreeCamera.prototype._checkInputs = function () {
  17669. if (this._vrDevice && this._vrDevice.isPresenting) {
  17670. this._vrDevice.getFrameData(this._frameData);
  17671. this.updateFromDevice(this._frameData.pose);
  17672. }
  17673. _super.prototype._checkInputs.call(this);
  17674. };
  17675. /**
  17676. * Updates the poseControlled values based on the input device pose.
  17677. * @param poseData Pose coming from the device
  17678. */
  17679. WebVRFreeCamera.prototype.updateFromDevice = function (poseData) {
  17680. if (poseData && poseData.orientation) {
  17681. this.rawPose = poseData;
  17682. this._deviceRoomRotationQuaternion.copyFromFloats(poseData.orientation[0], poseData.orientation[1], -poseData.orientation[2], -poseData.orientation[3]);
  17683. if (this.getScene().useRightHandedSystem) {
  17684. this._deviceRoomRotationQuaternion.z *= -1;
  17685. this._deviceRoomRotationQuaternion.w *= -1;
  17686. }
  17687. if (this.webVROptions.trackPosition && this.rawPose.position) {
  17688. this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2]);
  17689. if (this.getScene().useRightHandedSystem) {
  17690. this._deviceRoomPosition.z *= -1;
  17691. }
  17692. }
  17693. this._poseSet = true;
  17694. }
  17695. };
  17696. /**
  17697. * WebVR's attach control will start broadcasting frames to the device.
  17698. * Note that in certain browsers (chrome for example) this function must be called
  17699. * within a user-interaction callback. Example:
  17700. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  17701. *
  17702. * @param element html element to attach the vrDevice to
  17703. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  17704. */
  17705. WebVRFreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  17706. _super.prototype.attachControl.call(this, element, noPreventDefault);
  17707. this._attached = true;
  17708. this._htmlElementAttached = element;
  17709. noPreventDefault = _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  17710. if (this._vrDevice) {
  17711. this.getEngine().enableVR();
  17712. }
  17713. window.addEventListener('vrdisplaypresentchange', this._detachIfAttached);
  17714. };
  17715. /**
  17716. * Detaches the camera from the html element and disables VR
  17717. *
  17718. * @param element html element to detach from
  17719. */
  17720. WebVRFreeCamera.prototype.detachControl = function (element) {
  17721. this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  17722. this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  17723. _super.prototype.detachControl.call(this, element);
  17724. this._attached = false;
  17725. this.getEngine().disableVR();
  17726. window.removeEventListener('vrdisplaypresentchange', this._detachIfAttached);
  17727. };
  17728. /**
  17729. * @returns the name of this class
  17730. */
  17731. WebVRFreeCamera.prototype.getClassName = function () {
  17732. return "WebVRFreeCamera";
  17733. };
  17734. /**
  17735. * Calls resetPose on the vrDisplay
  17736. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  17737. */
  17738. WebVRFreeCamera.prototype.resetToCurrentRotation = function () {
  17739. //uses the vrDisplay's "resetPose()".
  17740. //pitch and roll won't be affected.
  17741. this._vrDevice.resetPose();
  17742. };
  17743. /**
  17744. * @hidden
  17745. * Updates the rig cameras (left and right eye)
  17746. */
  17747. WebVRFreeCamera.prototype._updateRigCameras = function () {
  17748. var camLeft = this._rigCameras[0];
  17749. var camRight = this._rigCameras[1];
  17750. camLeft.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  17751. camRight.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  17752. camLeft.position.copyFrom(this._deviceRoomPosition);
  17753. camRight.position.copyFrom(this._deviceRoomPosition);
  17754. };
  17755. // Remove translation from 6dof headset if trackposition is set to false
  17756. WebVRFreeCamera.prototype._correctPositionIfNotTrackPosition = function (matrix, isViewMatrix) {
  17757. if (isViewMatrix === void 0) { isViewMatrix = false; }
  17758. if (this.rawPose && this.rawPose.position && !this.webVROptions.trackPosition) {
  17759. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2], this._tmpMatrix);
  17760. if (!isViewMatrix) {
  17761. this._tmpMatrix.invert();
  17762. }
  17763. this._tmpMatrix.multiplyToRef(matrix, matrix);
  17764. }
  17765. };
  17766. /**
  17767. * @hidden
  17768. * Updates the cached values of the camera
  17769. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  17770. */
  17771. WebVRFreeCamera.prototype._updateCache = function (ignoreParentClass) {
  17772. var _this = this;
  17773. if (!this.rotationQuaternion.equals(this._cache.rotationQuaternion) || !this.position.equals(this._cache.position)) {
  17774. // Update to ensure devicePosition is up to date with most recent _deviceRoomPosition
  17775. if (!this.updateCacheCalled) {
  17776. // make sure it is only called once per loop. this.update() might cause an infinite loop.
  17777. this.updateCacheCalled = true;
  17778. this.update();
  17779. }
  17780. // Set working vector to the device position in room space rotated by the new rotation
  17781. this.rotationQuaternion.toRotationMatrix(this._workingMatrix);
  17782. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector);
  17783. // Subtract this vector from the current device position in world to get the translation for the device world matrix
  17784. this.devicePosition.subtractToRef(this._workingVector, this._workingVector);
  17785. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld);
  17786. // Add translation from anchor position
  17787. this._deviceToWorld.getTranslationToRef(this._workingVector);
  17788. this._workingVector.addInPlace(this.position);
  17789. this._workingVector.subtractInPlace(this._cache.position);
  17790. this._deviceToWorld.setTranslation(this._workingVector);
  17791. // Set an inverted matrix to be used when updating the camera
  17792. this._deviceToWorld.invertToRef(this._worldToDevice);
  17793. // Update the gamepad to ensure the mesh is updated on the same frame as camera
  17794. this.controllers.forEach(function (controller) {
  17795. controller._deviceToWorld.copyFrom(_this._deviceToWorld);
  17796. _this._correctPositionIfNotTrackPosition(controller._deviceToWorld);
  17797. controller.update();
  17798. });
  17799. }
  17800. if (!ignoreParentClass) {
  17801. _super.prototype._updateCache.call(this);
  17802. }
  17803. this.updateCacheCalled = false;
  17804. };
  17805. /**
  17806. * @hidden
  17807. * Get current device position in babylon world
  17808. */
  17809. WebVRFreeCamera.prototype._computeDevicePosition = function () {
  17810. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition);
  17811. };
  17812. /**
  17813. * Updates the current device position and rotation in the babylon world
  17814. */
  17815. WebVRFreeCamera.prototype.update = function () {
  17816. this._computeDevicePosition();
  17817. // Get current device rotation in babylon world
  17818. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix);
  17819. this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix);
  17820. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  17821. if (this._poseSet) {
  17822. this.onPoseUpdatedFromDeviceObservable.notifyObservers(null);
  17823. }
  17824. _super.prototype.update.call(this);
  17825. };
  17826. /**
  17827. * @hidden
  17828. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  17829. * @returns an identity matrix
  17830. */
  17831. WebVRFreeCamera.prototype._getViewMatrix = function () {
  17832. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17833. };
  17834. /**
  17835. * This function is called by the two RIG cameras.
  17836. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  17837. * @hidden
  17838. */
  17839. WebVRFreeCamera.prototype._getWebVRViewMatrix = function () {
  17840. // Update the parent camera prior to using a child camera to avoid desynchronization
  17841. var parentCamera = this._cameraRigParams["parentCamera"];
  17842. parentCamera._updateCache();
  17843. //WebVR 1.1
  17844. var viewArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftViewMatrix : this._cameraRigParams["frameData"].rightViewMatrix;
  17845. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(viewArray, 0, this._webvrViewMatrix);
  17846. if (!this.getScene().useRightHandedSystem) {
  17847. this._webvrViewMatrix.toggleModelMatrixHandInPlace();
  17848. }
  17849. // update the camera rotation matrix
  17850. this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix);
  17851. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  17852. // Computing target and final matrix
  17853. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  17854. // should the view matrix be updated with scale and position offset?
  17855. if (parentCamera.deviceScaleFactor !== 1) {
  17856. this._webvrViewMatrix.invert();
  17857. // scale the position, if set
  17858. if (parentCamera.deviceScaleFactor) {
  17859. this._webvrViewMatrix.multiplyAtIndex(12, parentCamera.deviceScaleFactor);
  17860. this._webvrViewMatrix.multiplyAtIndex(13, parentCamera.deviceScaleFactor);
  17861. this._webvrViewMatrix.multiplyAtIndex(14, parentCamera.deviceScaleFactor);
  17862. }
  17863. this._webvrViewMatrix.invert();
  17864. }
  17865. // Remove translation from 6dof headset if trackposition is set to false
  17866. parentCamera._correctPositionIfNotTrackPosition(this._webvrViewMatrix, true);
  17867. parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
  17868. // Compute global position
  17869. this._workingMatrix = this._workingMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17870. this._webvrViewMatrix.invertToRef(this._workingMatrix);
  17871. this._workingMatrix.multiplyToRef(parentCamera.getWorldMatrix(), this._workingMatrix);
  17872. this._workingMatrix.getTranslationToRef(this._globalPosition);
  17873. this._markSyncedWithParent();
  17874. return this._webvrViewMatrix;
  17875. };
  17876. /** @hidden */
  17877. WebVRFreeCamera.prototype._getWebVRProjectionMatrix = function () {
  17878. var parentCamera = this.parent;
  17879. parentCamera._vrDevice.depthNear = parentCamera.minZ;
  17880. parentCamera._vrDevice.depthFar = parentCamera.maxZ;
  17881. var projectionArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftProjectionMatrix : this._cameraRigParams["frameData"].rightProjectionMatrix;
  17882. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(projectionArray, 0, this._projectionMatrix);
  17883. //babylon compatible matrix
  17884. if (!this.getScene().useRightHandedSystem) {
  17885. this._projectionMatrix.toggleProjectionMatrixHandInPlace();
  17886. }
  17887. return this._projectionMatrix;
  17888. };
  17889. /**
  17890. * Initializes the controllers and their meshes
  17891. */
  17892. WebVRFreeCamera.prototype.initControllers = function () {
  17893. var _this = this;
  17894. this.controllers = [];
  17895. var manager = this.getScene().gamepadManager;
  17896. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  17897. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  17898. var webVrController = gamepad;
  17899. if (webVrController.defaultModel) {
  17900. webVrController.defaultModel.setEnabled(false);
  17901. }
  17902. if (webVrController.hand === "right") {
  17903. _this._rightController = null;
  17904. }
  17905. if (webVrController.hand === "left") {
  17906. _this._leftController = null;
  17907. }
  17908. var controllerIndex = _this.controllers.indexOf(webVrController);
  17909. if (controllerIndex !== -1) {
  17910. _this.controllers.splice(controllerIndex, 1);
  17911. }
  17912. }
  17913. });
  17914. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  17915. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  17916. var webVrController_1 = gamepad;
  17917. if (!_this.webVROptions.trackPosition) {
  17918. webVrController_1._disableTrackPosition(new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](webVrController_1.hand == "left" ? -0.15 : 0.15, -0.5, 0.25));
  17919. // Cache must be updated before rendering controllers to avoid them being one frame behind
  17920. if (!_this._updateCacheWhenTrackingDisabledObserver) {
  17921. _this._updateCacheWhenTrackingDisabledObserver = _this._scene.onBeforeRenderObservable.add(function () {
  17922. _this._updateCache();
  17923. });
  17924. }
  17925. }
  17926. webVrController_1.deviceScaleFactor = _this.deviceScaleFactor;
  17927. webVrController_1._deviceToWorld.copyFrom(_this._deviceToWorld);
  17928. _this._correctPositionIfNotTrackPosition(webVrController_1._deviceToWorld);
  17929. if (_this.webVROptions.controllerMeshes) {
  17930. if (webVrController_1.defaultModel) {
  17931. webVrController_1.defaultModel.setEnabled(true);
  17932. }
  17933. else {
  17934. // Load the meshes
  17935. webVrController_1.initControllerMesh(_this.getScene(), function (loadedMesh) {
  17936. loadedMesh.scaling.scaleInPlace(_this.deviceScaleFactor);
  17937. _this.onControllerMeshLoadedObservable.notifyObservers(webVrController_1);
  17938. if (_this.webVROptions.defaultLightingOnControllers) {
  17939. if (!_this._lightOnControllers) {
  17940. _this._lightOnControllers = new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__["HemisphericLight"]("vrControllersLight", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 1, 0), _this.getScene());
  17941. }
  17942. var activateLightOnSubMeshes_1 = function (mesh, light) {
  17943. var children = mesh.getChildren();
  17944. if (children && children.length !== 0) {
  17945. children.forEach(function (mesh) {
  17946. light.includedOnlyMeshes.push(mesh);
  17947. activateLightOnSubMeshes_1(mesh, light);
  17948. });
  17949. }
  17950. };
  17951. _this._lightOnControllers.includedOnlyMeshes.push(loadedMesh);
  17952. activateLightOnSubMeshes_1(loadedMesh, _this._lightOnControllers);
  17953. }
  17954. });
  17955. }
  17956. }
  17957. webVrController_1.attachToPoseControlledCamera(_this);
  17958. // since this is async - sanity check. Is the controller already stored?
  17959. if (_this.controllers.indexOf(webVrController_1) === -1) {
  17960. //add to the controllers array
  17961. _this.controllers.push(webVrController_1);
  17962. // Forced to add some control code for Vive as it doesn't always fill properly the "hand" property
  17963. // Sometimes, both controllers are set correctly (left and right), sometimes none, sometimes only one of them...
  17964. // So we're overriding setting left & right manually to be sure
  17965. var firstViveWandDetected = false;
  17966. for (var i = 0; i < _this.controllers.length; i++) {
  17967. if (_this.controllers[i].controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__["PoseEnabledControllerType"].VIVE) {
  17968. if (!firstViveWandDetected) {
  17969. firstViveWandDetected = true;
  17970. _this.controllers[i].hand = "left";
  17971. }
  17972. else {
  17973. _this.controllers[i].hand = "right";
  17974. }
  17975. }
  17976. }
  17977. //did we find enough controllers? Great! let the developer know.
  17978. if (_this.controllers.length >= 2) {
  17979. _this.onControllersAttachedObservable.notifyObservers(_this.controllers);
  17980. }
  17981. }
  17982. }
  17983. });
  17984. };
  17985. return WebVRFreeCamera;
  17986. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  17987. /***/ }),
  17988. /***/ "./Cameras/XR/index.ts":
  17989. /*!*****************************!*\
  17990. !*** ./Cameras/XR/index.ts ***!
  17991. \*****************************/
  17992. /*! exports provided: WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  17993. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17994. "use strict";
  17995. __webpack_require__.r(__webpack_exports__);
  17996. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  17997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _webXRCamera__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  17998. /* harmony import */ var _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  17999. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIButton"]; });
  18000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIOptions"]; });
  18001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUI"]; });
  18002. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"]; });
  18004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRExperienceHelper"]; });
  18005. /* harmony import */ var _webXRInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRInput */ "./Cameras/XR/webXRInput.ts");
  18006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRController"]; });
  18007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRInput"]; });
  18008. /* harmony import */ var _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  18009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__["WebXRManagedOutputCanvas"]; });
  18010. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__["WebXRSessionManager"]; });
  18012. /***/ }),
  18013. /***/ "./Cameras/XR/webXRCamera.ts":
  18014. /*!***********************************!*\
  18015. !*** ./Cameras/XR/webXRCamera.ts ***!
  18016. \***********************************/
  18017. /*! exports provided: WebXRCamera */
  18018. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18019. "use strict";
  18020. __webpack_require__.r(__webpack_exports__);
  18021. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return WebXRCamera; });
  18022. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18023. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18024. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  18025. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  18026. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  18027. /**
  18028. * WebXR Camera which holds the views for the xrSession
  18029. * @see https://doc.babylonjs.com/how_to/webxr
  18030. */
  18031. var WebXRCamera = /** @class */ (function (_super) {
  18032. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebXRCamera, _super);
  18033. /**
  18034. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  18035. * @param name the name of the camera
  18036. * @param scene the scene to add the camera to
  18037. */
  18038. function WebXRCamera(name, scene) {
  18039. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), scene) || this;
  18040. // Initial camera configuration
  18041. _this.minZ = 0;
  18042. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18043. _this.cameraRigMode = _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_CUSTOM;
  18044. _this.updateUpVectorFromRotation = true;
  18045. _this._updateNumberOfRigCameras(1);
  18046. return _this;
  18047. }
  18048. WebXRCamera.prototype._updateNumberOfRigCameras = function (viewCount) {
  18049. if (viewCount === void 0) { viewCount = 1; }
  18050. while (this.rigCameras.length < viewCount) {
  18051. var newCamera = new _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]("view: " + this.rigCameras.length, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), this.getScene());
  18052. newCamera.minZ = 0;
  18053. newCamera.parent = this;
  18054. newCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18055. newCamera.updateUpVectorFromRotation = true;
  18056. this.rigCameras.push(newCamera);
  18057. }
  18058. while (this.rigCameras.length > viewCount) {
  18059. var removedCamera = this.rigCameras.pop();
  18060. if (removedCamera) {
  18061. removedCamera.dispose();
  18062. }
  18063. }
  18064. };
  18065. /** @hidden */
  18066. WebXRCamera.prototype._updateForDualEyeDebugging = function (pupilDistance) {
  18067. if (pupilDistance === void 0) { pupilDistance = 0.01; }
  18068. // Create initial camera rigs
  18069. this._updateNumberOfRigCameras(2);
  18070. this.rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  18071. this.rigCameras[0].position.x = -pupilDistance / 2;
  18072. this.rigCameras[0].outputRenderTarget = null;
  18073. this.rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  18074. this.rigCameras[1].position.x = pupilDistance / 2;
  18075. this.rigCameras[1].outputRenderTarget = null;
  18076. };
  18077. /**
  18078. * Updates the cameras position from the current pose information of the XR session
  18079. * @param xrSessionManager the session containing pose information
  18080. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  18081. */
  18082. WebXRCamera.prototype.updateFromXRSessionManager = function (xrSessionManager) {
  18083. var _this = this;
  18084. // Ensure all frame data is available
  18085. if (!xrSessionManager._currentXRFrame || !xrSessionManager._currentXRFrame.getDevicePose) {
  18086. return false;
  18087. }
  18088. var pose = xrSessionManager._currentXRFrame.getDevicePose(xrSessionManager._frameOfReference);
  18089. if (!pose || !pose.poseModelMatrix) {
  18090. return false;
  18091. }
  18092. // Update the parent cameras matrix
  18093. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.poseModelMatrix, 0, 1, WebXRCamera._TmpMatrix);
  18094. if (!this._scene.useRightHandedSystem) {
  18095. WebXRCamera._TmpMatrix.toggleModelMatrixHandInPlace();
  18096. }
  18097. WebXRCamera._TmpMatrix.getTranslationToRef(this.position);
  18098. WebXRCamera._TmpMatrix.getRotationMatrixToRef(WebXRCamera._TmpMatrix);
  18099. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(WebXRCamera._TmpMatrix, this.rotationQuaternion);
  18100. this.computeWorldMatrix();
  18101. // Update camera rigs
  18102. this._updateNumberOfRigCameras(xrSessionManager._currentXRFrame.views.length);
  18103. xrSessionManager._currentXRFrame.views.forEach(function (view, i) {
  18104. // Update view/projection matrix
  18105. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.getViewMatrix(view), 0, 1, _this.rigCameras[i]._computedViewMatrix);
  18106. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(view.projectionMatrix, 0, 1, _this.rigCameras[i]._projectionMatrix);
  18107. if (!_this._scene.useRightHandedSystem) {
  18108. _this.rigCameras[i]._computedViewMatrix.toggleModelMatrixHandInPlace();
  18109. _this.rigCameras[i]._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18110. }
  18111. // Update viewport
  18112. var viewport = xrSessionManager._xrSession.baseLayer.getViewport(view);
  18113. var width = xrSessionManager._xrSession.baseLayer.framebufferWidth;
  18114. var height = xrSessionManager._xrSession.baseLayer.framebufferHeight;
  18115. _this.rigCameras[i].viewport.width = viewport.width / width;
  18116. _this.rigCameras[i].viewport.height = viewport.height / height;
  18117. _this.rigCameras[i].viewport.x = viewport.x / width;
  18118. _this.rigCameras[i].viewport.y = viewport.y / height;
  18119. // Set cameras to render to the session's render target
  18120. _this.rigCameras[i].outputRenderTarget = xrSessionManager._sessionRenderTargetTexture;
  18121. });
  18122. return true;
  18123. };
  18124. WebXRCamera._TmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  18125. return WebXRCamera;
  18126. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"]));
  18127. /***/ }),
  18128. /***/ "./Cameras/XR/webXREnterExitUI.ts":
  18129. /*!****************************************!*\
  18130. !*** ./Cameras/XR/webXREnterExitUI.ts ***!
  18131. \****************************************/
  18132. /*! exports provided: WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI */
  18133. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18134. "use strict";
  18135. __webpack_require__.r(__webpack_exports__);
  18136. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return WebXREnterExitUIButton; });
  18137. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return WebXREnterExitUIOptions; });
  18138. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return WebXREnterExitUI; });
  18139. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18140. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18141. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18142. /**
  18143. * Button which can be used to enter a different mode of XR
  18144. */
  18145. var WebXREnterExitUIButton = /** @class */ (function () {
  18146. /**
  18147. * Creates a WebXREnterExitUIButton
  18148. * @param element button element
  18149. * @param initializationOptions XR initialization options for the button
  18150. */
  18151. function WebXREnterExitUIButton(
  18152. /** button element */
  18153. element,
  18154. /** XR initialization options for the button */
  18155. initializationOptions) {
  18156. this.element = element;
  18157. this.initializationOptions = initializationOptions;
  18158. }
  18159. /**
  18160. * Overwritable function which can be used to update the button's visuals when the state changes
  18161. * @param activeButton the current active button in the UI
  18162. */
  18163. WebXREnterExitUIButton.prototype.update = function (activeButton) {
  18164. };
  18165. return WebXREnterExitUIButton;
  18166. }());
  18167. /**
  18168. * Options to create the webXR UI
  18169. */
  18170. var WebXREnterExitUIOptions = /** @class */ (function () {
  18171. function WebXREnterExitUIOptions() {
  18172. }
  18173. return WebXREnterExitUIOptions;
  18174. }());
  18175. /**
  18176. * UI to allow the user to enter/exit XR mode
  18177. */
  18178. var WebXREnterExitUI = /** @class */ (function () {
  18179. function WebXREnterExitUI(scene, options) {
  18180. var _this = this;
  18181. this.scene = scene;
  18182. this._buttons = [];
  18183. this._activeButton = null;
  18184. /**
  18185. * Fired every time the active button is changed.
  18186. *
  18187. * When xr is entered via a button that launches xr that button will be the callback parameter
  18188. *
  18189. * When exiting xr the callback parameter will be null)
  18190. */
  18191. this.activeButtonChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18192. this._overlay = document.createElement("div");
  18193. this._overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;";
  18194. if (options.customButtons) {
  18195. this._buttons = options.customButtons;
  18196. }
  18197. else {
  18198. var hmdBtn = document.createElement("button");
  18199. 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;";
  18200. hmdBtn.innerText = "HMD";
  18201. this._buttons.push(new WebXREnterExitUIButton(hmdBtn, { immersive: true, outputContext: options.outputCanvasContext }));
  18202. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18203. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18204. this.element.innerText = activeButton === this ? "EXIT" : "HMD";
  18205. };
  18206. var windowBtn = document.createElement("button");
  18207. windowBtn.style.cssText = hmdBtn.style.cssText;
  18208. windowBtn.innerText = "Window";
  18209. this._buttons.push(new WebXREnterExitUIButton(windowBtn, { immersive: false, environmentIntegration: true, outputContext: options.outputCanvasContext }));
  18210. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18211. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18212. this.element.innerText = activeButton === this ? "EXIT" : "Window";
  18213. };
  18214. this._updateButtons(null);
  18215. }
  18216. var renderCanvas = scene.getEngine().getRenderingCanvas();
  18217. if (renderCanvas && renderCanvas.parentNode) {
  18218. renderCanvas.parentNode.appendChild(this._overlay);
  18219. scene.onDisposeObservable.addOnce(function () {
  18220. _this.dispose();
  18221. });
  18222. }
  18223. }
  18224. /**
  18225. * Creates UI to allow the user to enter/exit XR mode
  18226. * @param scene the scene to add the ui to
  18227. * @param helper the xr experience helper to enter/exit xr with
  18228. * @param options options to configure the UI
  18229. * @returns the created ui
  18230. */
  18231. WebXREnterExitUI.CreateAsync = function (scene, helper, options) {
  18232. var _this = this;
  18233. var ui = new WebXREnterExitUI(scene, options);
  18234. var supportedPromises = ui._buttons.map(function (btn) {
  18235. return helper.supportsSessionAsync(btn.initializationOptions);
  18236. });
  18237. helper.onStateChangedObservable.add(function (state) {
  18238. if (state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR) {
  18239. ui._updateButtons(null);
  18240. }
  18241. });
  18242. return Promise.all(supportedPromises).then(function (results) {
  18243. results.forEach(function (supported, i) {
  18244. if (supported) {
  18245. ui._overlay.appendChild(ui._buttons[i].element);
  18246. ui._buttons[i].element.onclick = function () { return tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"](_this, void 0, void 0, function () {
  18247. return tslib__WEBPACK_IMPORTED_MODULE_0__["__generator"](this, function (_a) {
  18248. switch (_a.label) {
  18249. case 0:
  18250. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].IN_XR)) return [3 /*break*/, 2];
  18251. ui._updateButtons(null);
  18252. return [4 /*yield*/, helper.exitXRAsync()];
  18253. case 1:
  18254. _a.sent();
  18255. return [2 /*return*/];
  18256. case 2:
  18257. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR)) return [3 /*break*/, 4];
  18258. ui._updateButtons(ui._buttons[i]);
  18259. return [4 /*yield*/, helper.enterXRAsync(ui._buttons[i].initializationOptions, "eye-level")];
  18260. case 3:
  18261. _a.sent();
  18262. _a.label = 4;
  18263. case 4: return [2 /*return*/];
  18264. }
  18265. });
  18266. }); };
  18267. }
  18268. });
  18269. return ui;
  18270. });
  18271. };
  18272. WebXREnterExitUI.prototype._updateButtons = function (activeButton) {
  18273. var _this = this;
  18274. this._activeButton = activeButton;
  18275. this._buttons.forEach(function (b) {
  18276. b.update(_this._activeButton);
  18277. });
  18278. this.activeButtonChangedObservable.notifyObservers(this._activeButton);
  18279. };
  18280. /**
  18281. * Disposes of the object
  18282. */
  18283. WebXREnterExitUI.prototype.dispose = function () {
  18284. var renderCanvas = this.scene.getEngine().getRenderingCanvas();
  18285. if (renderCanvas && renderCanvas.parentNode && renderCanvas.parentNode.contains(this._overlay)) {
  18286. renderCanvas.parentNode.removeChild(this._overlay);
  18287. }
  18288. this.activeButtonChangedObservable.clear();
  18289. };
  18290. return WebXREnterExitUI;
  18291. }());
  18292. /***/ }),
  18293. /***/ "./Cameras/XR/webXRExperienceHelper.ts":
  18294. /*!*********************************************!*\
  18295. !*** ./Cameras/XR/webXRExperienceHelper.ts ***!
  18296. \*********************************************/
  18297. /*! exports provided: WebXRState, WebXRExperienceHelper */
  18298. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18299. "use strict";
  18300. __webpack_require__.r(__webpack_exports__);
  18301. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return WebXRState; });
  18302. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return WebXRExperienceHelper; });
  18303. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18304. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18305. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18306. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18307. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18308. /**
  18309. * States of the webXR experience
  18310. */
  18311. var WebXRState;
  18312. (function (WebXRState) {
  18313. /**
  18314. * Transitioning to being in XR mode
  18315. */
  18316. WebXRState[WebXRState["ENTERING_XR"] = 0] = "ENTERING_XR";
  18317. /**
  18318. * Transitioning to non XR mode
  18319. */
  18320. WebXRState[WebXRState["EXITING_XR"] = 1] = "EXITING_XR";
  18321. /**
  18322. * In XR mode and presenting
  18323. */
  18324. WebXRState[WebXRState["IN_XR"] = 2] = "IN_XR";
  18325. /**
  18326. * Not entered XR mode
  18327. */
  18328. WebXRState[WebXRState["NOT_IN_XR"] = 3] = "NOT_IN_XR";
  18329. })(WebXRState || (WebXRState = {}));
  18330. /**
  18331. * Helper class used to enable XR
  18332. * @see https://doc.babylonjs.com/how_to/webxr
  18333. */
  18334. var WebXRExperienceHelper = /** @class */ (function () {
  18335. /**
  18336. * Creates a WebXRExperienceHelper
  18337. * @param scene The scene the helper should be created in
  18338. */
  18339. function WebXRExperienceHelper(scene) {
  18340. this.scene = scene;
  18341. /**
  18342. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  18343. */
  18344. this.state = WebXRState.NOT_IN_XR;
  18345. /**
  18346. * Fires when the state of the experience helper has changed
  18347. */
  18348. this.onStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  18349. this._nonVRCamera = null;
  18350. this._originalSceneAutoClear = true;
  18351. this._supported = false;
  18352. this.camera = new _webXRCamera__WEBPACK_IMPORTED_MODULE_4__["WebXRCamera"]("", scene);
  18353. this._sessionManager = new _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__["WebXRSessionManager"](scene);
  18354. this.container = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", scene);
  18355. this.camera.parent = this.container;
  18356. }
  18357. WebXRExperienceHelper.prototype._setState = function (val) {
  18358. this.state = val;
  18359. this.onStateChangedObservable.notifyObservers(this.state);
  18360. };
  18361. /**
  18362. * Creates the experience helper
  18363. * @param scene the scene to attach the experience helper to
  18364. * @returns a promise for the experience helper
  18365. */
  18366. WebXRExperienceHelper.CreateAsync = function (scene) {
  18367. var helper = new WebXRExperienceHelper(scene);
  18368. return helper._sessionManager.initializeAsync().then(function () {
  18369. helper._supported = true;
  18370. return helper;
  18371. }).catch(function () {
  18372. return helper;
  18373. });
  18374. };
  18375. /**
  18376. * Exits XR mode and returns the scene to its original state
  18377. * @returns promise that resolves after xr mode has exited
  18378. */
  18379. WebXRExperienceHelper.prototype.exitXRAsync = function () {
  18380. this._setState(WebXRState.EXITING_XR);
  18381. return this._sessionManager.exitXRAsync();
  18382. };
  18383. /**
  18384. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  18385. * @param sessionCreationOptions options for the XR session
  18386. * @param frameOfReference frame of reference of the XR session
  18387. * @returns promise that resolves after xr mode has entered
  18388. */
  18389. WebXRExperienceHelper.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReference) {
  18390. var _this = this;
  18391. if (!this._supported) {
  18392. throw "XR session not supported by this browser";
  18393. }
  18394. this._setState(WebXRState.ENTERING_XR);
  18395. return this._sessionManager.enterXRAsync(sessionCreationOptions, frameOfReference).then(function () {
  18396. // Cache pre xr scene settings
  18397. _this._originalSceneAutoClear = _this.scene.autoClear;
  18398. _this._nonVRCamera = _this.scene.activeCamera;
  18399. // Overwrite current scene settings
  18400. _this.scene.autoClear = false;
  18401. _this.scene.activeCamera = _this.camera;
  18402. _this._sessionManager.onXRFrameObservable.add(function () {
  18403. _this.camera.updateFromXRSessionManager(_this._sessionManager);
  18404. });
  18405. _this._sessionManager.onXRSessionEnded.addOnce(function () {
  18406. // Reset camera rigs output render target to ensure sessions render target is not drawn after it ends
  18407. _this.camera.rigCameras.forEach(function (c) {
  18408. c.outputRenderTarget = null;
  18409. });
  18410. // Restore scene settings
  18411. _this.scene.autoClear = _this._originalSceneAutoClear;
  18412. _this.scene.activeCamera = _this._nonVRCamera;
  18413. _this._sessionManager.onXRFrameObservable.clear();
  18414. _this._setState(WebXRState.NOT_IN_XR);
  18415. });
  18416. _this._setState(WebXRState.IN_XR);
  18417. });
  18418. };
  18419. /**
  18420. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  18421. * @param ray ray to cast into the environment
  18422. * @returns Promise which resolves with a collision point in the environment if it exists
  18423. */
  18424. WebXRExperienceHelper.prototype.environmentPointHitTestAsync = function (ray) {
  18425. return this._sessionManager.environmentPointHitTestAsync(ray);
  18426. };
  18427. /**
  18428. * Updates the global position of the camera by moving the camera's container
  18429. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  18430. * @param position The desired global position of the camera
  18431. */
  18432. WebXRExperienceHelper.prototype.setPositionOfCameraUsingContainer = function (position) {
  18433. this.camera.globalPosition.subtractToRef(position, WebXRExperienceHelper._TmpVector);
  18434. this.container.position.subtractInPlace(WebXRExperienceHelper._TmpVector);
  18435. };
  18436. /**
  18437. * Rotates the xr camera by rotating the camera's container around the camera's position
  18438. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  18439. * @param rotation the desired quaternion rotation to apply to the camera
  18440. */
  18441. WebXRExperienceHelper.prototype.rotateCameraByQuaternionUsingContainer = function (rotation) {
  18442. if (!this.container.rotationQuaternion) {
  18443. this.container.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromEulerVector(this.container.rotation);
  18444. }
  18445. this.container.rotationQuaternion.multiplyInPlace(rotation);
  18446. this.container.position.rotateByQuaternionAroundPointToRef(rotation, this.camera.globalPosition, this.container.position);
  18447. };
  18448. /**
  18449. * Checks if the creation options are supported by the xr session
  18450. * @param options creation options
  18451. * @returns true if supported
  18452. */
  18453. WebXRExperienceHelper.prototype.supportsSessionAsync = function (options) {
  18454. if (!this._supported) {
  18455. return Promise.resolve(false);
  18456. }
  18457. return this._sessionManager.supportsSessionAsync(options);
  18458. };
  18459. /**
  18460. * Disposes of the experience helper
  18461. */
  18462. WebXRExperienceHelper.prototype.dispose = function () {
  18463. this.camera.dispose();
  18464. this.container.dispose();
  18465. this.onStateChangedObservable.clear();
  18466. this._sessionManager.dispose();
  18467. };
  18468. WebXRExperienceHelper._TmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]();
  18469. return WebXRExperienceHelper;
  18470. }());
  18471. /***/ }),
  18472. /***/ "./Cameras/XR/webXRInput.ts":
  18473. /*!**********************************!*\
  18474. !*** ./Cameras/XR/webXRInput.ts ***!
  18475. \**********************************/
  18476. /*! exports provided: WebXRController, WebXRInput */
  18477. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18478. "use strict";
  18479. __webpack_require__.r(__webpack_exports__);
  18480. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return WebXRController; });
  18481. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return WebXRInput; });
  18482. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18483. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18484. /**
  18485. * Represents an XR input
  18486. */
  18487. var WebXRController = /** @class */ (function () {
  18488. /**
  18489. * Creates the controller
  18490. * @see https://doc.babylonjs.com/how_to/webxr
  18491. * @param scene the scene which the controller should be associated to
  18492. */
  18493. function WebXRController(scene) {
  18494. this.pointer = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerPointer", scene);
  18495. }
  18496. /**
  18497. * Disposes of the object
  18498. */
  18499. WebXRController.prototype.dispose = function () {
  18500. if (this.grip) {
  18501. this.grip.dispose();
  18502. }
  18503. this.pointer.dispose();
  18504. };
  18505. return WebXRController;
  18506. }());
  18507. /**
  18508. * XR input used to track XR inputs such as controllers/rays
  18509. */
  18510. var WebXRInput = /** @class */ (function () {
  18511. /**
  18512. * Initializes the WebXRInput
  18513. * @param helper experience helper which the input should be created for
  18514. */
  18515. function WebXRInput(helper) {
  18516. var _this = this;
  18517. this.helper = helper;
  18518. /**
  18519. * XR controllers being tracked
  18520. */
  18521. this.controllers = [];
  18522. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  18523. this._frameObserver = helper._sessionManager.onXRFrameObservable.add(function () {
  18524. if (!helper._sessionManager._currentXRFrame || !helper._sessionManager._currentXRFrame.getDevicePose) {
  18525. return;
  18526. }
  18527. var xrFrame = helper._sessionManager._currentXRFrame;
  18528. var inputSources = helper._sessionManager._xrSession.getInputSources();
  18529. inputSources.forEach(function (input, i) {
  18530. var inputPose = xrFrame.getInputPose(input, helper._sessionManager._frameOfReference);
  18531. if (inputPose) {
  18532. if (_this.controllers.length <= i) {
  18533. _this.controllers.push(new WebXRController(helper.container.getScene()));
  18534. }
  18535. var controller = _this.controllers[i];
  18536. // Manage the grip if it exists
  18537. if (inputPose.gripMatrix) {
  18538. if (!controller.grip) {
  18539. controller.grip = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerGrip", helper.container.getScene());
  18540. }
  18541. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.gripMatrix, 0, 1, _this._tmpMatrix);
  18542. if (!controller.grip.getScene().useRightHandedSystem) {
  18543. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  18544. }
  18545. if (!controller.grip.rotationQuaternion) {
  18546. controller.grip.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  18547. }
  18548. _this._tmpMatrix.decompose(controller.grip.scaling, controller.grip.rotationQuaternion, controller.grip.position);
  18549. }
  18550. // Manager pointer of controller
  18551. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.targetRay.transformMatrix, 0, 1, _this._tmpMatrix);
  18552. if (!controller.pointer.getScene().useRightHandedSystem) {
  18553. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  18554. }
  18555. if (!controller.pointer.rotationQuaternion) {
  18556. controller.pointer.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  18557. }
  18558. _this._tmpMatrix.decompose(controller.pointer.scaling, controller.pointer.rotationQuaternion, controller.pointer.position);
  18559. }
  18560. });
  18561. });
  18562. }
  18563. /**
  18564. * Disposes of the object
  18565. */
  18566. WebXRInput.prototype.dispose = function () {
  18567. this.controllers.forEach(function (c) {
  18568. c.dispose();
  18569. });
  18570. this.helper._sessionManager.onXRFrameObservable.remove(this._frameObserver);
  18571. };
  18572. return WebXRInput;
  18573. }());
  18574. /***/ }),
  18575. /***/ "./Cameras/XR/webXRManagedOutputCanvas.ts":
  18576. /*!************************************************!*\
  18577. !*** ./Cameras/XR/webXRManagedOutputCanvas.ts ***!
  18578. \************************************************/
  18579. /*! exports provided: WebXRManagedOutputCanvas */
  18580. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18581. "use strict";
  18582. __webpack_require__.r(__webpack_exports__);
  18583. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return WebXRManagedOutputCanvas; });
  18584. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18585. /**
  18586. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  18587. */
  18588. var WebXRManagedOutputCanvas = /** @class */ (function () {
  18589. /**
  18590. * Initializes the canvas to be added/removed upon entering/exiting xr
  18591. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  18592. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  18593. */
  18594. function WebXRManagedOutputCanvas(helper, canvas) {
  18595. var _this = this;
  18596. this._canvas = null;
  18597. /**
  18598. * xrpresent context of the canvas which can be used to display/mirror xr content
  18599. */
  18600. this.canvasContext = null;
  18601. if (!canvas) {
  18602. canvas = document.createElement('canvas');
  18603. canvas.style.cssText = "position:absolute; bottom:0px;right:0px;z-index:10;width:100%;height:100%;background-color: #000000;";
  18604. }
  18605. this._setManagedOutputCanvas(canvas);
  18606. helper.onStateChangedObservable.add(function (stateInfo) {
  18607. if (stateInfo == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].ENTERING_XR) {
  18608. // 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
  18609. _this._addCanvas();
  18610. }
  18611. else if (helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].NOT_IN_XR) {
  18612. _this._removeCanvas();
  18613. }
  18614. });
  18615. }
  18616. /**
  18617. * Disposes of the object
  18618. */
  18619. WebXRManagedOutputCanvas.prototype.dispose = function () {
  18620. this._removeCanvas();
  18621. this._setManagedOutputCanvas(null);
  18622. };
  18623. WebXRManagedOutputCanvas.prototype._setManagedOutputCanvas = function (canvas) {
  18624. this._removeCanvas();
  18625. if (!canvas) {
  18626. this._canvas = null;
  18627. this.canvasContext = null;
  18628. }
  18629. else {
  18630. this._canvas = canvas;
  18631. this.canvasContext = this._canvas.getContext('xrpresent');
  18632. }
  18633. };
  18634. WebXRManagedOutputCanvas.prototype._addCanvas = function () {
  18635. if (this._canvas) {
  18636. document.body.appendChild(this._canvas);
  18637. }
  18638. };
  18639. WebXRManagedOutputCanvas.prototype._removeCanvas = function () {
  18640. if (this._canvas && document.body.contains(this._canvas)) {
  18641. document.body.removeChild(this._canvas);
  18642. }
  18643. };
  18644. return WebXRManagedOutputCanvas;
  18645. }());
  18646. /***/ }),
  18647. /***/ "./Cameras/XR/webXRSessionManager.ts":
  18648. /*!*******************************************!*\
  18649. !*** ./Cameras/XR/webXRSessionManager.ts ***!
  18650. \*******************************************/
  18651. /*! exports provided: WebXRSessionManager */
  18652. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18653. "use strict";
  18654. __webpack_require__.r(__webpack_exports__);
  18655. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return WebXRSessionManager; });
  18656. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  18657. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18658. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18659. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  18660. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  18661. /**
  18662. * Manages an XRSession
  18663. * @see https://doc.babylonjs.com/how_to/webxr
  18664. */
  18665. var WebXRSessionManager = /** @class */ (function () {
  18666. /**
  18667. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  18668. * @param scene The scene which the session should be created for
  18669. */
  18670. function WebXRSessionManager(scene) {
  18671. this.scene = scene;
  18672. /**
  18673. * Fires every time a new xrFrame arrives which can be used to update the camera
  18674. */
  18675. this.onXRFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18676. /**
  18677. * Fires when the xr session is ended either by the device or manually done
  18678. */
  18679. this.onXRSessionEnded = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18680. /** @hidden */
  18681. this._sessionRenderTargetTexture = null;
  18682. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  18683. }
  18684. /**
  18685. * Initializes the manager
  18686. * After initialization enterXR can be called to start an XR session
  18687. * @returns Promise which resolves after it is initialized
  18688. */
  18689. WebXRSessionManager.prototype.initializeAsync = function () {
  18690. var _this = this;
  18691. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("The WebXR APIs are still under development and are subject to change in the future.");
  18692. // Check if the browser supports webXR
  18693. this._xrNavigator = navigator;
  18694. if (!this._xrNavigator.xr) {
  18695. return Promise.reject("webXR not supported by this browser");
  18696. }
  18697. // Request the webXR device
  18698. return this._xrNavigator.xr.requestDevice().then(function (device) {
  18699. _this._xrDevice = device;
  18700. return _this.scene.getEngine()._gl.setCompatibleXRDevice(_this._xrDevice);
  18701. });
  18702. };
  18703. /**
  18704. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  18705. * @param sessionCreationOptions xr options to create the session with
  18706. * @param frameOfReferenceType option to configure how the xr pose is expressed
  18707. * @returns Promise which resolves after it enters XR
  18708. */
  18709. WebXRSessionManager.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReferenceType) {
  18710. var _this = this;
  18711. // initialize session
  18712. return this._xrDevice.requestSession(sessionCreationOptions).then(function (session) {
  18713. _this._xrSession = session;
  18714. // handle when the session is ended (By calling session.end or device ends its own session eg. pressing home button on phone)
  18715. _this._xrSession.addEventListener("end", function () {
  18716. // Remove render target texture and notify frame obervers
  18717. _this._sessionRenderTargetTexture = null;
  18718. // Restore frame buffer to avoid clear on xr framebuffer after session end
  18719. _this.scene.getEngine().restoreDefaultFramebuffer();
  18720. // Need to restart render loop as after the session is ended the last request for new frame will never call callback
  18721. _this.scene.getEngine().customAnimationFrameRequester = null;
  18722. _this.onXRSessionEnded.notifyObservers(null);
  18723. _this.scene.getEngine()._renderLoop();
  18724. }, { once: true });
  18725. _this._xrSession.baseLayer = new XRWebGLLayer(_this._xrSession, _this.scene.getEngine()._gl);
  18726. return _this._xrSession.requestFrameOfReference(frameOfReferenceType);
  18727. }).then(function (frameOfRef) {
  18728. _this._frameOfReference = frameOfRef;
  18729. // Tell the engine's render loop to be driven by the xr session's refresh rate and provide xr pose information
  18730. _this.scene.getEngine().customAnimationFrameRequester = {
  18731. requestAnimationFrame: _this._xrSession.requestAnimationFrame.bind(_this._xrSession),
  18732. renderFunction: function (timestamp, xrFrame) {
  18733. // Store the XR frame in the manager to be consumed by the XR camera to update pose
  18734. _this._currentXRFrame = xrFrame;
  18735. _this.onXRFrameObservable.notifyObservers(null);
  18736. _this.scene.getEngine()._renderLoop();
  18737. }
  18738. };
  18739. // Create render target texture from xr's webgl render target
  18740. _this._sessionRenderTargetTexture = WebXRSessionManager._CreateRenderTargetTextureFromSession(_this._xrSession, _this.scene);
  18741. // Stop window's animation frame and trigger sessions animation frame
  18742. window.cancelAnimationFrame(_this.scene.getEngine()._frameHandler);
  18743. _this.scene.getEngine()._renderLoop();
  18744. });
  18745. };
  18746. /**
  18747. * Stops the xrSession and restores the renderloop
  18748. * @returns Promise which resolves after it exits XR
  18749. */
  18750. WebXRSessionManager.prototype.exitXRAsync = function () {
  18751. return this._xrSession.end();
  18752. };
  18753. /**
  18754. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  18755. * @param ray ray to cast into the environment
  18756. * @returns Promise which resolves with a collision point in the environment if it exists
  18757. */
  18758. WebXRSessionManager.prototype.environmentPointHitTestAsync = function (ray) {
  18759. var _this = this;
  18760. return new Promise(function (res) {
  18761. // Compute left handed inputs to request hit test
  18762. var origin = new Float32Array([ray.origin.x, ray.origin.y, ray.origin.z]);
  18763. var direction = new Float32Array([ray.direction.x, ray.direction.y, ray.direction.z]);
  18764. if (!_this.scene.useRightHandedSystem) {
  18765. origin[2] *= -1;
  18766. direction[2] *= -1;
  18767. }
  18768. // Fire hittest
  18769. _this._xrSession.requestHitTest(origin, direction, _this._frameOfReference)
  18770. .then(function (hits) {
  18771. if (hits.length > 0) {
  18772. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromFloat32ArrayToRefScaled(hits[0].hitMatrix, 0, 1.0, _this._tmpMatrix);
  18773. var hitPoint = _this._tmpMatrix.getTranslation();
  18774. if (!_this.scene.useRightHandedSystem) {
  18775. hitPoint.z *= -1;
  18776. }
  18777. res(hitPoint);
  18778. }
  18779. else {
  18780. res(null);
  18781. }
  18782. }).catch(function () {
  18783. res(null);
  18784. });
  18785. });
  18786. };
  18787. /**
  18788. * Checks if a session would be supported for the creation options specified
  18789. * @param options creation options to check if they are supported
  18790. * @returns true if supported
  18791. */
  18792. WebXRSessionManager.prototype.supportsSessionAsync = function (options) {
  18793. return this._xrDevice.supportsSession(options).then(function () {
  18794. return true;
  18795. }).catch(function () {
  18796. return false;
  18797. });
  18798. };
  18799. /**
  18800. * @hidden
  18801. * Converts the render layer of xrSession to a render target
  18802. * @param session session to create render target for
  18803. * @param scene scene the new render target should be created for
  18804. */
  18805. WebXRSessionManager._CreateRenderTargetTextureFromSession = function (session, scene) {
  18806. // Create internal texture
  18807. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"](scene.getEngine(), _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  18808. internalTexture.width = session.baseLayer.framebufferWidth;
  18809. internalTexture.height = session.baseLayer.framebufferHeight;
  18810. internalTexture._framebuffer = session.baseLayer.framebuffer;
  18811. // Create render target texture from the internal texture
  18812. 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);
  18813. renderTargetTexture._texture = internalTexture;
  18814. return renderTargetTexture;
  18815. };
  18816. /**
  18817. * Disposes of the session manager
  18818. */
  18819. WebXRSessionManager.prototype.dispose = function () {
  18820. this.onXRFrameObservable.clear();
  18821. this.onXRSessionEnded.clear();
  18822. };
  18823. return WebXRSessionManager;
  18824. }());
  18825. /***/ }),
  18826. /***/ "./Cameras/arcRotateCamera.ts":
  18827. /*!************************************!*\
  18828. !*** ./Cameras/arcRotateCamera.ts ***!
  18829. \************************************/
  18830. /*! exports provided: ArcRotateCamera */
  18831. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18832. "use strict";
  18833. __webpack_require__.r(__webpack_exports__);
  18834. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return ArcRotateCamera; });
  18835. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18836. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  18837. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  18838. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  18839. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  18840. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  18841. /* harmony import */ var _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Cameras/autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  18842. /* harmony import */ var _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Cameras/bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  18843. /* harmony import */ var _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Behaviors/Cameras/framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  18844. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  18845. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  18846. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  18847. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("ArcRotateCamera", function (name, scene) {
  18848. return function () { return new ArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  18849. });
  18850. /**
  18851. * This represents an orbital type of camera.
  18852. *
  18853. * 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.
  18854. * 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.
  18855. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  18856. */
  18857. var ArcRotateCamera = /** @class */ (function (_super) {
  18858. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCamera, _super);
  18859. /**
  18860. * Instantiates a new ArcRotateCamera in a given scene
  18861. * @param name Defines the name of the camera
  18862. * @param alpha Defines the camera rotation along the logitudinal axis
  18863. * @param beta Defines the camera rotation along the latitudinal axis
  18864. * @param radius Defines the camera distance from its target
  18865. * @param target Defines the camera target
  18866. * @param scene Defines the scene the camera belongs to
  18867. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18868. */
  18869. function ArcRotateCamera(name, alpha, beta, radius, target, scene, setActiveOnSceneIfNoneActive) {
  18870. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  18871. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene, setActiveOnSceneIfNoneActive) || this;
  18872. /**
  18873. * Current inertia value on the longitudinal axis.
  18874. * The bigger this number the longer it will take for the camera to stop.
  18875. */
  18876. _this.inertialAlphaOffset = 0;
  18877. /**
  18878. * Current inertia value on the latitudinal axis.
  18879. * The bigger this number the longer it will take for the camera to stop.
  18880. */
  18881. _this.inertialBetaOffset = 0;
  18882. /**
  18883. * Current inertia value on the radius axis.
  18884. * The bigger this number the longer it will take for the camera to stop.
  18885. */
  18886. _this.inertialRadiusOffset = 0;
  18887. /**
  18888. * Minimum allowed angle on the longitudinal axis.
  18889. * This can help limiting how the Camera is able to move in the scene.
  18890. */
  18891. _this.lowerAlphaLimit = null;
  18892. /**
  18893. * Maximum allowed angle on the longitudinal axis.
  18894. * This can help limiting how the Camera is able to move in the scene.
  18895. */
  18896. _this.upperAlphaLimit = null;
  18897. /**
  18898. * Minimum allowed angle on the latitudinal axis.
  18899. * This can help limiting how the Camera is able to move in the scene.
  18900. */
  18901. _this.lowerBetaLimit = 0.01;
  18902. /**
  18903. * Maximum allowed angle on the latitudinal axis.
  18904. * This can help limiting how the Camera is able to move in the scene.
  18905. */
  18906. _this.upperBetaLimit = Math.PI - 0.01;
  18907. /**
  18908. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  18909. * This can help limiting how the Camera is able to move in the scene.
  18910. */
  18911. _this.lowerRadiusLimit = null;
  18912. /**
  18913. * Maximum allowed distance of the camera to the target (The camera can not get further).
  18914. * This can help limiting how the Camera is able to move in the scene.
  18915. */
  18916. _this.upperRadiusLimit = null;
  18917. /**
  18918. * Defines the current inertia value used during panning of the camera along the X axis.
  18919. */
  18920. _this.inertialPanningX = 0;
  18921. /**
  18922. * Defines the current inertia value used during panning of the camera along the Y axis.
  18923. */
  18924. _this.inertialPanningY = 0;
  18925. /**
  18926. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  18927. * Basically if your fingers moves away from more than this distance you will be considered
  18928. * in pinch mode.
  18929. */
  18930. _this.pinchToPanMaxDistance = 20;
  18931. /**
  18932. * Defines the maximum distance the camera can pan.
  18933. * This could help keeping the cammera always in your scene.
  18934. */
  18935. _this.panningDistanceLimit = null;
  18936. /**
  18937. * Defines the target of the camera before paning.
  18938. */
  18939. _this.panningOriginTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18940. /**
  18941. * Defines the value of the inertia used during panning.
  18942. * 0 would mean stop inertia and one would mean no decelleration at all.
  18943. */
  18944. _this.panningInertia = 0.9;
  18945. //-- end properties for backward compatibility for inputs
  18946. /**
  18947. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  18948. */
  18949. _this.zoomOnFactor = 1;
  18950. /**
  18951. * Defines a screen offset for the camera position.
  18952. */
  18953. _this.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  18954. /**
  18955. * Allows the camera to be completely reversed.
  18956. * If false the camera can not arrive upside down.
  18957. */
  18958. _this.allowUpsideDown = true;
  18959. /**
  18960. * Define if double tap/click is used to restore the previously saved state of the camera.
  18961. */
  18962. _this.useInputToRestoreState = true;
  18963. /** @hidden */
  18964. _this._viewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  18965. /**
  18966. * Defines the allowed panning axis.
  18967. */
  18968. _this.panningAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 0);
  18969. /**
  18970. * Observable triggered when the mesh target has been changed on the camera.
  18971. */
  18972. _this.onMeshTargetChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  18973. /**
  18974. * Defines whether the camera should check collision with the objects oh the scene.
  18975. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  18976. */
  18977. _this.checkCollisions = false;
  18978. /**
  18979. * Defines the collision radius of the camera.
  18980. * This simulates a sphere around the camera.
  18981. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18982. */
  18983. _this.collisionRadius = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 0.5, 0.5);
  18984. _this._previousPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18985. _this._collisionVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18986. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18987. _this._computationVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18988. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  18989. if (collidedMesh === void 0) { collidedMesh = null; }
  18990. if (!collidedMesh) {
  18991. _this._previousPosition.copyFrom(_this.position);
  18992. }
  18993. else {
  18994. _this.setPosition(newPosition);
  18995. if (_this.onCollide) {
  18996. _this.onCollide(collidedMesh);
  18997. }
  18998. }
  18999. // Recompute because of constraints
  19000. var cosa = Math.cos(_this.alpha);
  19001. var sina = Math.sin(_this.alpha);
  19002. var cosb = Math.cos(_this.beta);
  19003. var sinb = Math.sin(_this.beta);
  19004. if (sinb === 0) {
  19005. sinb = 0.0001;
  19006. }
  19007. var target = _this._getTargetPosition();
  19008. _this._computationVector.copyFromFloats(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb);
  19009. target.addToRef(_this._computationVector, _this._newPosition);
  19010. _this.position.copyFrom(_this._newPosition);
  19011. var up = _this.upVector;
  19012. if (_this.allowUpsideDown && _this.beta < 0) {
  19013. up = up.clone();
  19014. up = up.negate();
  19015. }
  19016. _this._computeViewMatrix(_this.position, target, up);
  19017. _this._viewMatrix.addAtIndex(12, _this.targetScreenOffset.x);
  19018. _this._viewMatrix.addAtIndex(13, _this.targetScreenOffset.y);
  19019. _this._collisionTriggered = false;
  19020. };
  19021. _this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19022. if (target) {
  19023. _this.setTarget(target);
  19024. }
  19025. _this.alpha = alpha;
  19026. _this.beta = beta;
  19027. _this.radius = radius;
  19028. _this.getViewMatrix();
  19029. _this.inputs = new _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["ArcRotateCameraInputsManager"](_this);
  19030. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  19031. return _this;
  19032. }
  19033. Object.defineProperty(ArcRotateCamera.prototype, "target", {
  19034. /**
  19035. * Defines the target point of the camera.
  19036. * The camera looks towards it form the radius distance.
  19037. */
  19038. get: function () {
  19039. return this._target;
  19040. },
  19041. set: function (value) {
  19042. this.setTarget(value);
  19043. },
  19044. enumerable: true,
  19045. configurable: true
  19046. });
  19047. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityX", {
  19048. //-- begin properties for backward compatibility for inputs
  19049. /**
  19050. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  19051. */
  19052. get: function () {
  19053. var pointers = this.inputs.attached["pointers"];
  19054. if (pointers) {
  19055. return pointers.angularSensibilityX;
  19056. }
  19057. return 0;
  19058. },
  19059. set: function (value) {
  19060. var pointers = this.inputs.attached["pointers"];
  19061. if (pointers) {
  19062. pointers.angularSensibilityX = value;
  19063. }
  19064. },
  19065. enumerable: true,
  19066. configurable: true
  19067. });
  19068. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityY", {
  19069. /**
  19070. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  19071. */
  19072. get: function () {
  19073. var pointers = this.inputs.attached["pointers"];
  19074. if (pointers) {
  19075. return pointers.angularSensibilityY;
  19076. }
  19077. return 0;
  19078. },
  19079. set: function (value) {
  19080. var pointers = this.inputs.attached["pointers"];
  19081. if (pointers) {
  19082. pointers.angularSensibilityY = value;
  19083. }
  19084. },
  19085. enumerable: true,
  19086. configurable: true
  19087. });
  19088. Object.defineProperty(ArcRotateCamera.prototype, "pinchPrecision", {
  19089. /**
  19090. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  19091. */
  19092. get: function () {
  19093. var pointers = this.inputs.attached["pointers"];
  19094. if (pointers) {
  19095. return pointers.pinchPrecision;
  19096. }
  19097. return 0;
  19098. },
  19099. set: function (value) {
  19100. var pointers = this.inputs.attached["pointers"];
  19101. if (pointers) {
  19102. pointers.pinchPrecision = value;
  19103. }
  19104. },
  19105. enumerable: true,
  19106. configurable: true
  19107. });
  19108. Object.defineProperty(ArcRotateCamera.prototype, "pinchDeltaPercentage", {
  19109. /**
  19110. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  19111. * It will be used instead of pinchDeltaPrecision if different from 0.
  19112. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19113. */
  19114. get: function () {
  19115. var pointers = this.inputs.attached["pointers"];
  19116. if (pointers) {
  19117. return pointers.pinchDeltaPercentage;
  19118. }
  19119. return 0;
  19120. },
  19121. set: function (value) {
  19122. var pointers = this.inputs.attached["pointers"];
  19123. if (pointers) {
  19124. pointers.pinchDeltaPercentage = value;
  19125. }
  19126. },
  19127. enumerable: true,
  19128. configurable: true
  19129. });
  19130. Object.defineProperty(ArcRotateCamera.prototype, "panningSensibility", {
  19131. /**
  19132. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  19133. */
  19134. get: function () {
  19135. var pointers = this.inputs.attached["pointers"];
  19136. if (pointers) {
  19137. return pointers.panningSensibility;
  19138. }
  19139. return 0;
  19140. },
  19141. set: function (value) {
  19142. var pointers = this.inputs.attached["pointers"];
  19143. if (pointers) {
  19144. pointers.panningSensibility = value;
  19145. }
  19146. },
  19147. enumerable: true,
  19148. configurable: true
  19149. });
  19150. Object.defineProperty(ArcRotateCamera.prototype, "keysUp", {
  19151. /**
  19152. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  19153. */
  19154. get: function () {
  19155. var keyboard = this.inputs.attached["keyboard"];
  19156. if (keyboard) {
  19157. return keyboard.keysUp;
  19158. }
  19159. return [];
  19160. },
  19161. set: function (value) {
  19162. var keyboard = this.inputs.attached["keyboard"];
  19163. if (keyboard) {
  19164. keyboard.keysUp = value;
  19165. }
  19166. },
  19167. enumerable: true,
  19168. configurable: true
  19169. });
  19170. Object.defineProperty(ArcRotateCamera.prototype, "keysDown", {
  19171. /**
  19172. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  19173. */
  19174. get: function () {
  19175. var keyboard = this.inputs.attached["keyboard"];
  19176. if (keyboard) {
  19177. return keyboard.keysDown;
  19178. }
  19179. return [];
  19180. },
  19181. set: function (value) {
  19182. var keyboard = this.inputs.attached["keyboard"];
  19183. if (keyboard) {
  19184. keyboard.keysDown = value;
  19185. }
  19186. },
  19187. enumerable: true,
  19188. configurable: true
  19189. });
  19190. Object.defineProperty(ArcRotateCamera.prototype, "keysLeft", {
  19191. /**
  19192. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  19193. */
  19194. get: function () {
  19195. var keyboard = this.inputs.attached["keyboard"];
  19196. if (keyboard) {
  19197. return keyboard.keysLeft;
  19198. }
  19199. return [];
  19200. },
  19201. set: function (value) {
  19202. var keyboard = this.inputs.attached["keyboard"];
  19203. if (keyboard) {
  19204. keyboard.keysLeft = value;
  19205. }
  19206. },
  19207. enumerable: true,
  19208. configurable: true
  19209. });
  19210. Object.defineProperty(ArcRotateCamera.prototype, "keysRight", {
  19211. /**
  19212. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  19213. */
  19214. get: function () {
  19215. var keyboard = this.inputs.attached["keyboard"];
  19216. if (keyboard) {
  19217. return keyboard.keysRight;
  19218. }
  19219. return [];
  19220. },
  19221. set: function (value) {
  19222. var keyboard = this.inputs.attached["keyboard"];
  19223. if (keyboard) {
  19224. keyboard.keysRight = value;
  19225. }
  19226. },
  19227. enumerable: true,
  19228. configurable: true
  19229. });
  19230. Object.defineProperty(ArcRotateCamera.prototype, "wheelPrecision", {
  19231. /**
  19232. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  19233. */
  19234. get: function () {
  19235. var mousewheel = this.inputs.attached["mousewheel"];
  19236. if (mousewheel) {
  19237. return mousewheel.wheelPrecision;
  19238. }
  19239. return 0;
  19240. },
  19241. set: function (value) {
  19242. var mousewheel = this.inputs.attached["mousewheel"];
  19243. if (mousewheel) {
  19244. mousewheel.wheelPrecision = value;
  19245. }
  19246. },
  19247. enumerable: true,
  19248. configurable: true
  19249. });
  19250. Object.defineProperty(ArcRotateCamera.prototype, "wheelDeltaPercentage", {
  19251. /**
  19252. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  19253. * It will be used instead of pinchDeltaPrecision if different from 0.
  19254. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19255. */
  19256. get: function () {
  19257. var mousewheel = this.inputs.attached["mousewheel"];
  19258. if (mousewheel) {
  19259. return mousewheel.wheelDeltaPercentage;
  19260. }
  19261. return 0;
  19262. },
  19263. set: function (value) {
  19264. var mousewheel = this.inputs.attached["mousewheel"];
  19265. if (mousewheel) {
  19266. mousewheel.wheelDeltaPercentage = value;
  19267. }
  19268. },
  19269. enumerable: true,
  19270. configurable: true
  19271. });
  19272. Object.defineProperty(ArcRotateCamera.prototype, "bouncingBehavior", {
  19273. /**
  19274. * Gets the bouncing behavior of the camera if it has been enabled.
  19275. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19276. */
  19277. get: function () {
  19278. return this._bouncingBehavior;
  19279. },
  19280. enumerable: true,
  19281. configurable: true
  19282. });
  19283. Object.defineProperty(ArcRotateCamera.prototype, "useBouncingBehavior", {
  19284. /**
  19285. * Defines if the bouncing behavior of the camera is enabled on the camera.
  19286. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19287. */
  19288. get: function () {
  19289. return this._bouncingBehavior != null;
  19290. },
  19291. set: function (value) {
  19292. if (value === this.useBouncingBehavior) {
  19293. return;
  19294. }
  19295. if (value) {
  19296. this._bouncingBehavior = new _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__["BouncingBehavior"]();
  19297. this.addBehavior(this._bouncingBehavior);
  19298. }
  19299. else if (this._bouncingBehavior) {
  19300. this.removeBehavior(this._bouncingBehavior);
  19301. this._bouncingBehavior = null;
  19302. }
  19303. },
  19304. enumerable: true,
  19305. configurable: true
  19306. });
  19307. Object.defineProperty(ArcRotateCamera.prototype, "framingBehavior", {
  19308. /**
  19309. * Gets the framing behavior of the camera if it has been enabled.
  19310. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19311. */
  19312. get: function () {
  19313. return this._framingBehavior;
  19314. },
  19315. enumerable: true,
  19316. configurable: true
  19317. });
  19318. Object.defineProperty(ArcRotateCamera.prototype, "useFramingBehavior", {
  19319. /**
  19320. * Defines if the framing behavior of the camera is enabled on the camera.
  19321. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19322. */
  19323. get: function () {
  19324. return this._framingBehavior != null;
  19325. },
  19326. set: function (value) {
  19327. if (value === this.useFramingBehavior) {
  19328. return;
  19329. }
  19330. if (value) {
  19331. this._framingBehavior = new _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__["FramingBehavior"]();
  19332. this.addBehavior(this._framingBehavior);
  19333. }
  19334. else if (this._framingBehavior) {
  19335. this.removeBehavior(this._framingBehavior);
  19336. this._framingBehavior = null;
  19337. }
  19338. },
  19339. enumerable: true,
  19340. configurable: true
  19341. });
  19342. Object.defineProperty(ArcRotateCamera.prototype, "autoRotationBehavior", {
  19343. /**
  19344. * Gets the auto rotation behavior of the camera if it has been enabled.
  19345. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19346. */
  19347. get: function () {
  19348. return this._autoRotationBehavior;
  19349. },
  19350. enumerable: true,
  19351. configurable: true
  19352. });
  19353. Object.defineProperty(ArcRotateCamera.prototype, "useAutoRotationBehavior", {
  19354. /**
  19355. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  19356. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19357. */
  19358. get: function () {
  19359. return this._autoRotationBehavior != null;
  19360. },
  19361. set: function (value) {
  19362. if (value === this.useAutoRotationBehavior) {
  19363. return;
  19364. }
  19365. if (value) {
  19366. this._autoRotationBehavior = new _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__["AutoRotationBehavior"]();
  19367. this.addBehavior(this._autoRotationBehavior);
  19368. }
  19369. else if (this._autoRotationBehavior) {
  19370. this.removeBehavior(this._autoRotationBehavior);
  19371. this._autoRotationBehavior = null;
  19372. }
  19373. },
  19374. enumerable: true,
  19375. configurable: true
  19376. });
  19377. // Cache
  19378. /** @hidden */
  19379. ArcRotateCamera.prototype._initCache = function () {
  19380. _super.prototype._initCache.call(this);
  19381. this._cache._target = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  19382. this._cache.alpha = undefined;
  19383. this._cache.beta = undefined;
  19384. this._cache.radius = undefined;
  19385. this._cache.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  19386. };
  19387. /** @hidden */
  19388. ArcRotateCamera.prototype._updateCache = function (ignoreParentClass) {
  19389. if (!ignoreParentClass) {
  19390. _super.prototype._updateCache.call(this);
  19391. }
  19392. this._cache._target.copyFrom(this._getTargetPosition());
  19393. this._cache.alpha = this.alpha;
  19394. this._cache.beta = this.beta;
  19395. this._cache.radius = this.radius;
  19396. this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset);
  19397. };
  19398. ArcRotateCamera.prototype._getTargetPosition = function () {
  19399. if (this._targetHost && this._targetHost.getAbsolutePosition) {
  19400. var pos = this._targetHost.absolutePosition;
  19401. if (this._targetBoundingCenter) {
  19402. pos.addToRef(this._targetBoundingCenter, this._target);
  19403. }
  19404. else {
  19405. this._target.copyFrom(pos);
  19406. }
  19407. }
  19408. var lockedTargetPosition = this._getLockedTargetPosition();
  19409. if (lockedTargetPosition) {
  19410. return lockedTargetPosition;
  19411. }
  19412. return this._target;
  19413. };
  19414. /**
  19415. * Stores the current state of the camera (alpha, beta, radius and target)
  19416. * @returns the camera itself
  19417. */
  19418. ArcRotateCamera.prototype.storeState = function () {
  19419. this._storedAlpha = this.alpha;
  19420. this._storedBeta = this.beta;
  19421. this._storedRadius = this.radius;
  19422. this._storedTarget = this._getTargetPosition().clone();
  19423. return _super.prototype.storeState.call(this);
  19424. };
  19425. /**
  19426. * @hidden
  19427. * Restored camera state. You must call storeState() first
  19428. */
  19429. ArcRotateCamera.prototype._restoreStateValues = function () {
  19430. if (!_super.prototype._restoreStateValues.call(this)) {
  19431. return false;
  19432. }
  19433. this.alpha = this._storedAlpha;
  19434. this.beta = this._storedBeta;
  19435. this.radius = this._storedRadius;
  19436. this.setTarget(this._storedTarget.clone());
  19437. this.inertialAlphaOffset = 0;
  19438. this.inertialBetaOffset = 0;
  19439. this.inertialRadiusOffset = 0;
  19440. this.inertialPanningX = 0;
  19441. this.inertialPanningY = 0;
  19442. return true;
  19443. };
  19444. // Synchronized
  19445. /** @hidden */
  19446. ArcRotateCamera.prototype._isSynchronizedViewMatrix = function () {
  19447. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  19448. return false;
  19449. }
  19450. return this._cache._target.equals(this._getTargetPosition())
  19451. && this._cache.alpha === this.alpha
  19452. && this._cache.beta === this.beta
  19453. && this._cache.radius === this.radius
  19454. && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
  19455. };
  19456. /**
  19457. * Attached controls to the current camera.
  19458. * @param element Defines the element the controls should be listened from
  19459. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19460. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  19461. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  19462. */
  19463. ArcRotateCamera.prototype.attachControl = function (element, noPreventDefault, useCtrlForPanning, panningMouseButton) {
  19464. var _this = this;
  19465. if (useCtrlForPanning === void 0) { useCtrlForPanning = true; }
  19466. if (panningMouseButton === void 0) { panningMouseButton = 2; }
  19467. this._useCtrlForPanning = useCtrlForPanning;
  19468. this._panningMouseButton = panningMouseButton;
  19469. this.inputs.attachElement(element, noPreventDefault);
  19470. this._reset = function () {
  19471. _this.inertialAlphaOffset = 0;
  19472. _this.inertialBetaOffset = 0;
  19473. _this.inertialRadiusOffset = 0;
  19474. _this.inertialPanningX = 0;
  19475. _this.inertialPanningY = 0;
  19476. };
  19477. };
  19478. /**
  19479. * Detach the current controls from the camera.
  19480. * The camera will stop reacting to inputs.
  19481. * @param element Defines the element to stop listening the inputs from
  19482. */
  19483. ArcRotateCamera.prototype.detachControl = function (element) {
  19484. this.inputs.detachElement(element);
  19485. if (this._reset) {
  19486. this._reset();
  19487. }
  19488. };
  19489. /** @hidden */
  19490. ArcRotateCamera.prototype._checkInputs = function () {
  19491. //if (async) collision inspection was triggered, don't update the camera's position - until the collision callback was called.
  19492. if (this._collisionTriggered) {
  19493. return;
  19494. }
  19495. this.inputs.checkInputs();
  19496. // Inertia
  19497. if (this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
  19498. var inertialAlphaOffset = this.inertialAlphaOffset;
  19499. if (this.beta <= 0) {
  19500. inertialAlphaOffset *= -1;
  19501. }
  19502. if (this.getScene().useRightHandedSystem) {
  19503. inertialAlphaOffset *= -1;
  19504. }
  19505. if (this.parent && this.parent._getWorldMatrixDeterminant() < 0) {
  19506. inertialAlphaOffset *= -1;
  19507. }
  19508. this.alpha += inertialAlphaOffset;
  19509. this.beta += this.inertialBetaOffset;
  19510. this.radius -= this.inertialRadiusOffset;
  19511. this.inertialAlphaOffset *= this.inertia;
  19512. this.inertialBetaOffset *= this.inertia;
  19513. this.inertialRadiusOffset *= this.inertia;
  19514. if (Math.abs(this.inertialAlphaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19515. this.inertialAlphaOffset = 0;
  19516. }
  19517. if (Math.abs(this.inertialBetaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19518. this.inertialBetaOffset = 0;
  19519. }
  19520. if (Math.abs(this.inertialRadiusOffset) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19521. this.inertialRadiusOffset = 0;
  19522. }
  19523. }
  19524. // Panning inertia
  19525. if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
  19526. if (!this._localDirection) {
  19527. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19528. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19529. }
  19530. this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY);
  19531. this._localDirection.multiplyInPlace(this.panningAxis);
  19532. this._viewMatrix.invertToRef(this._cameraTransformMatrix);
  19533. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
  19534. //Eliminate y if map panning is enabled (panningAxis == 1,0,1)
  19535. if (!this.panningAxis.y) {
  19536. this._transformedDirection.y = 0;
  19537. }
  19538. if (!this._targetHost) {
  19539. if (this.panningDistanceLimit) {
  19540. this._transformedDirection.addInPlace(this._target);
  19541. var distanceSquared = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].DistanceSquared(this._transformedDirection, this.panningOriginTarget);
  19542. if (distanceSquared <= (this.panningDistanceLimit * this.panningDistanceLimit)) {
  19543. this._target.copyFrom(this._transformedDirection);
  19544. }
  19545. }
  19546. else {
  19547. this._target.addInPlace(this._transformedDirection);
  19548. }
  19549. }
  19550. this.inertialPanningX *= this.panningInertia;
  19551. this.inertialPanningY *= this.panningInertia;
  19552. if (Math.abs(this.inertialPanningX) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19553. this.inertialPanningX = 0;
  19554. }
  19555. if (Math.abs(this.inertialPanningY) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19556. this.inertialPanningY = 0;
  19557. }
  19558. }
  19559. // Limits
  19560. this._checkLimits();
  19561. _super.prototype._checkInputs.call(this);
  19562. };
  19563. ArcRotateCamera.prototype._checkLimits = function () {
  19564. if (this.lowerBetaLimit === null || this.lowerBetaLimit === undefined) {
  19565. if (this.allowUpsideDown && this.beta > Math.PI) {
  19566. this.beta = this.beta - (2 * Math.PI);
  19567. }
  19568. }
  19569. else {
  19570. if (this.beta < this.lowerBetaLimit) {
  19571. this.beta = this.lowerBetaLimit;
  19572. }
  19573. }
  19574. if (this.upperBetaLimit === null || this.upperBetaLimit === undefined) {
  19575. if (this.allowUpsideDown && this.beta < -Math.PI) {
  19576. this.beta = this.beta + (2 * Math.PI);
  19577. }
  19578. }
  19579. else {
  19580. if (this.beta > this.upperBetaLimit) {
  19581. this.beta = this.upperBetaLimit;
  19582. }
  19583. }
  19584. if (this.lowerAlphaLimit !== null && this.alpha < this.lowerAlphaLimit) {
  19585. this.alpha = this.lowerAlphaLimit;
  19586. }
  19587. if (this.upperAlphaLimit !== null && this.alpha > this.upperAlphaLimit) {
  19588. this.alpha = this.upperAlphaLimit;
  19589. }
  19590. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  19591. this.radius = this.lowerRadiusLimit;
  19592. this.inertialRadiusOffset = 0;
  19593. }
  19594. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  19595. this.radius = this.upperRadiusLimit;
  19596. this.inertialRadiusOffset = 0;
  19597. }
  19598. };
  19599. /**
  19600. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  19601. */
  19602. ArcRotateCamera.prototype.rebuildAnglesAndRadius = function () {
  19603. this.position.subtractToRef(this._getTargetPosition(), this._computationVector);
  19604. this.radius = this._computationVector.length();
  19605. if (this.radius === 0) {
  19606. this.radius = 0.0001; // Just to avoid division by zero
  19607. }
  19608. // Alpha
  19609. this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
  19610. if (this._computationVector.z < 0) {
  19611. this.alpha = 2 * Math.PI - this.alpha;
  19612. }
  19613. // Beta
  19614. this.beta = Math.acos(this._computationVector.y / this.radius);
  19615. this._checkLimits();
  19616. };
  19617. /**
  19618. * Use a position to define the current camera related information like aplha, beta and radius
  19619. * @param position Defines the position to set the camera at
  19620. */
  19621. ArcRotateCamera.prototype.setPosition = function (position) {
  19622. if (this.position.equals(position)) {
  19623. return;
  19624. }
  19625. this.position.copyFrom(position);
  19626. this.rebuildAnglesAndRadius();
  19627. };
  19628. /**
  19629. * Defines the target the camera should look at.
  19630. * This will automatically adapt alpha beta and radius to fit within the new target.
  19631. * @param target Defines the new target as a Vector or a mesh
  19632. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  19633. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  19634. */
  19635. ArcRotateCamera.prototype.setTarget = function (target, toBoundingCenter, allowSamePosition) {
  19636. if (toBoundingCenter === void 0) { toBoundingCenter = false; }
  19637. if (allowSamePosition === void 0) { allowSamePosition = false; }
  19638. if (target.getBoundingInfo) {
  19639. if (toBoundingCenter) {
  19640. this._targetBoundingCenter = target.getBoundingInfo().boundingBox.centerWorld.clone();
  19641. }
  19642. else {
  19643. this._targetBoundingCenter = null;
  19644. }
  19645. this._targetHost = target;
  19646. this._target = this._getTargetPosition();
  19647. this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
  19648. }
  19649. else {
  19650. var newTarget = target;
  19651. var currentTarget = this._getTargetPosition();
  19652. if (currentTarget && !allowSamePosition && currentTarget.equals(newTarget)) {
  19653. return;
  19654. }
  19655. this._targetHost = null;
  19656. this._target = newTarget;
  19657. this._targetBoundingCenter = null;
  19658. this.onMeshTargetChangedObservable.notifyObservers(null);
  19659. }
  19660. this.rebuildAnglesAndRadius();
  19661. };
  19662. /** @hidden */
  19663. ArcRotateCamera.prototype._getViewMatrix = function () {
  19664. // Compute
  19665. var cosa = Math.cos(this.alpha);
  19666. var sina = Math.sin(this.alpha);
  19667. var cosb = Math.cos(this.beta);
  19668. var sinb = Math.sin(this.beta);
  19669. if (sinb === 0) {
  19670. sinb = 0.0001;
  19671. }
  19672. var target = this._getTargetPosition();
  19673. this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
  19674. // Rotate according to up vector
  19675. if (this.upVector.x !== 0 || this.upVector.y !== 1.0 || this.upVector.z !== 0) {
  19676. if (!this._tempAxisVector) {
  19677. this._tempAxisVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  19678. this._tempAxisRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  19679. }
  19680. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), this.upVector, this._tempAxisVector);
  19681. this._tempAxisVector.normalize();
  19682. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].UpReadOnly, this.upVector));
  19683. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(this._tempAxisVector, angle, this._tempAxisRotationMatrix);
  19684. this._tempAxisVector.copyFrom(this._computationVector);
  19685. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._tempAxisVector, this._tempAxisRotationMatrix, this._computationVector);
  19686. }
  19687. target.addToRef(this._computationVector, this._newPosition);
  19688. if (this.getScene().collisionsEnabled && this.checkCollisions) {
  19689. var coordinator = this.getScene().collisionCoordinator;
  19690. if (!this._collider) {
  19691. this._collider = coordinator.createCollider();
  19692. }
  19693. this._collider._radius = this.collisionRadius;
  19694. this._newPosition.subtractToRef(this.position, this._collisionVelocity);
  19695. this._collisionTriggered = true;
  19696. coordinator.getNewPosition(this.position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  19697. }
  19698. else {
  19699. this.position.copyFrom(this._newPosition);
  19700. var up = this.upVector;
  19701. if (this.allowUpsideDown && sinb < 0) {
  19702. up = up.clone();
  19703. up = up.negate();
  19704. }
  19705. this._computeViewMatrix(this.position, target, up);
  19706. this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x);
  19707. this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y);
  19708. }
  19709. this._currentTarget = target;
  19710. return this._viewMatrix;
  19711. };
  19712. /**
  19713. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  19714. * @param meshes Defines the mesh to zoom on
  19715. * @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)
  19716. */
  19717. ArcRotateCamera.prototype.zoomOn = function (meshes, doNotUpdateMaxZ) {
  19718. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  19719. meshes = meshes || this.getScene().meshes;
  19720. var minMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  19721. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(minMaxVector.min, minMaxVector.max);
  19722. this.radius = distance * this.zoomOnFactor;
  19723. this.focusOn({ min: minMaxVector.min, max: minMaxVector.max, distance: distance }, doNotUpdateMaxZ);
  19724. };
  19725. /**
  19726. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  19727. * The target will be changed but the radius
  19728. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  19729. * @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)
  19730. */
  19731. ArcRotateCamera.prototype.focusOn = function (meshesOrMinMaxVectorAndDistance, doNotUpdateMaxZ) {
  19732. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  19733. var meshesOrMinMaxVector;
  19734. var distance;
  19735. if (meshesOrMinMaxVectorAndDistance.min === undefined) { // meshes
  19736. var meshes = meshesOrMinMaxVectorAndDistance || this.getScene().meshes;
  19737. meshesOrMinMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  19738. distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(meshesOrMinMaxVector.min, meshesOrMinMaxVector.max);
  19739. }
  19740. else { //minMaxVector and distance
  19741. var minMaxVectorAndDistance = meshesOrMinMaxVectorAndDistance;
  19742. meshesOrMinMaxVector = minMaxVectorAndDistance;
  19743. distance = minMaxVectorAndDistance.distance;
  19744. }
  19745. this._target = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].Center(meshesOrMinMaxVector);
  19746. if (!doNotUpdateMaxZ) {
  19747. this.maxZ = distance * 2;
  19748. }
  19749. };
  19750. /**
  19751. * @override
  19752. * Override Camera.createRigCamera
  19753. */
  19754. ArcRotateCamera.prototype.createRigCamera = function (name, cameraIndex) {
  19755. var alphaShift = 0;
  19756. switch (this.cameraRigMode) {
  19757. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  19758. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  19759. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  19760. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  19761. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? 1 : -1);
  19762. break;
  19763. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  19764. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? -1 : 1);
  19765. break;
  19766. }
  19767. var rigCam = new ArcRotateCamera(name, this.alpha + alphaShift, this.beta, this.radius, this._target, this.getScene());
  19768. rigCam._cameraRigParams = {};
  19769. return rigCam;
  19770. };
  19771. /**
  19772. * @hidden
  19773. * @override
  19774. * Override Camera._updateRigCameras
  19775. */
  19776. ArcRotateCamera.prototype._updateRigCameras = function () {
  19777. var camLeft = this._rigCameras[0];
  19778. var camRight = this._rigCameras[1];
  19779. camLeft.beta = camRight.beta = this.beta;
  19780. switch (this.cameraRigMode) {
  19781. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  19782. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  19783. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  19784. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  19785. camLeft.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  19786. camRight.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  19787. break;
  19788. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  19789. camLeft.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  19790. camRight.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  19791. break;
  19792. }
  19793. _super.prototype._updateRigCameras.call(this);
  19794. };
  19795. /**
  19796. * Destroy the camera and release the current resources hold by it.
  19797. */
  19798. ArcRotateCamera.prototype.dispose = function () {
  19799. this.inputs.clear();
  19800. _super.prototype.dispose.call(this);
  19801. };
  19802. /**
  19803. * Gets the current object class name.
  19804. * @return the class name
  19805. */
  19806. ArcRotateCamera.prototype.getClassName = function () {
  19807. return "ArcRotateCamera";
  19808. };
  19809. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19810. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19811. ], ArcRotateCamera.prototype, "alpha", void 0);
  19812. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19813. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19814. ], ArcRotateCamera.prototype, "beta", void 0);
  19815. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19816. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19817. ], ArcRotateCamera.prototype, "radius", void 0);
  19818. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19819. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("target")
  19820. ], ArcRotateCamera.prototype, "_target", void 0);
  19821. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19822. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19823. ], ArcRotateCamera.prototype, "inertialAlphaOffset", void 0);
  19824. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19826. ], ArcRotateCamera.prototype, "inertialBetaOffset", void 0);
  19827. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19828. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19829. ], ArcRotateCamera.prototype, "inertialRadiusOffset", void 0);
  19830. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19831. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19832. ], ArcRotateCamera.prototype, "lowerAlphaLimit", void 0);
  19833. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19834. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19835. ], ArcRotateCamera.prototype, "upperAlphaLimit", void 0);
  19836. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19837. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19838. ], ArcRotateCamera.prototype, "lowerBetaLimit", void 0);
  19839. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19840. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19841. ], ArcRotateCamera.prototype, "upperBetaLimit", void 0);
  19842. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19843. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19844. ], ArcRotateCamera.prototype, "lowerRadiusLimit", void 0);
  19845. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19846. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19847. ], ArcRotateCamera.prototype, "upperRadiusLimit", void 0);
  19848. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19849. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19850. ], ArcRotateCamera.prototype, "inertialPanningX", void 0);
  19851. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19852. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19853. ], ArcRotateCamera.prototype, "inertialPanningY", void 0);
  19854. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19855. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19856. ], ArcRotateCamera.prototype, "pinchToPanMaxDistance", void 0);
  19857. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19858. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19859. ], ArcRotateCamera.prototype, "panningDistanceLimit", void 0);
  19860. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19861. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  19862. ], ArcRotateCamera.prototype, "panningOriginTarget", void 0);
  19863. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19864. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19865. ], ArcRotateCamera.prototype, "panningInertia", void 0);
  19866. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19867. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19868. ], ArcRotateCamera.prototype, "zoomOnFactor", void 0);
  19869. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19870. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19871. ], ArcRotateCamera.prototype, "targetScreenOffset", void 0);
  19872. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19873. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19874. ], ArcRotateCamera.prototype, "allowUpsideDown", void 0);
  19875. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19876. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19877. ], ArcRotateCamera.prototype, "useInputToRestoreState", void 0);
  19878. return ArcRotateCamera;
  19879. }(_targetCamera__WEBPACK_IMPORTED_MODULE_10__["TargetCamera"]));
  19880. /***/ }),
  19881. /***/ "./Cameras/arcRotateCameraInputsManager.ts":
  19882. /*!*************************************************!*\
  19883. !*** ./Cameras/arcRotateCameraInputsManager.ts ***!
  19884. \*************************************************/
  19885. /*! exports provided: ArcRotateCameraInputsManager */
  19886. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19887. "use strict";
  19888. __webpack_require__.r(__webpack_exports__);
  19889. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return ArcRotateCameraInputsManager; });
  19890. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19891. /* harmony import */ var _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  19892. /* harmony import */ var _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  19893. /* harmony import */ var _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  19894. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  19895. /**
  19896. * Default Inputs manager for the ArcRotateCamera.
  19897. * It groups all the default supported inputs for ease of use.
  19898. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19899. */
  19900. var ArcRotateCameraInputsManager = /** @class */ (function (_super) {
  19901. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraInputsManager, _super);
  19902. /**
  19903. * Instantiates a new ArcRotateCameraInputsManager.
  19904. * @param camera Defines the camera the inputs belong to
  19905. */
  19906. function ArcRotateCameraInputsManager(camera) {
  19907. return _super.call(this, camera) || this;
  19908. }
  19909. /**
  19910. * Add mouse wheel input support to the input manager.
  19911. * @returns the current input manager
  19912. */
  19913. ArcRotateCameraInputsManager.prototype.addMouseWheel = function () {
  19914. this.add(new _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraMouseWheelInput"]());
  19915. return this;
  19916. };
  19917. /**
  19918. * Add pointers input support to the input manager.
  19919. * @returns the current input manager
  19920. */
  19921. ArcRotateCameraInputsManager.prototype.addPointers = function () {
  19922. this.add(new _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraPointersInput"]());
  19923. return this;
  19924. };
  19925. /**
  19926. * Add keyboard input support to the input manager.
  19927. * @returns the current input manager
  19928. */
  19929. ArcRotateCameraInputsManager.prototype.addKeyboard = function () {
  19930. this.add(new _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraKeyboardMoveInput"]());
  19931. return this;
  19932. };
  19933. return ArcRotateCameraInputsManager;
  19934. }(_Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__["CameraInputsManager"]));
  19935. /***/ }),
  19936. /***/ "./Cameras/camera.ts":
  19937. /*!***************************!*\
  19938. !*** ./Cameras/camera.ts ***!
  19939. \***************************/
  19940. /*! exports provided: Camera */
  19941. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19942. "use strict";
  19943. __webpack_require__.r(__webpack_exports__);
  19944. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return Camera; });
  19945. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19946. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  19947. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  19948. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  19949. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  19950. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  19951. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  19952. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  19953. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  19954. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  19955. /**
  19956. * This is the base class of all the camera used in the application.
  19957. * @see http://doc.babylonjs.com/features/cameras
  19958. */
  19959. var Camera = /** @class */ (function (_super) {
  19960. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Camera, _super);
  19961. /**
  19962. * Instantiates a new camera object.
  19963. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  19964. * @see http://doc.babylonjs.com/features/cameras
  19965. * @param name Defines the name of the camera in the scene
  19966. * @param position Defines the position of the camera
  19967. * @param scene Defines the scene the camera belongs too
  19968. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  19969. */
  19970. function Camera(name, position, scene, setActiveOnSceneIfNoneActive) {
  19971. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  19972. var _this = _super.call(this, name, scene) || this;
  19973. /**
  19974. * The vector the camera should consider as up.
  19975. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  19976. */
  19977. _this.upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Up();
  19978. /**
  19979. * Define the current limit on the left side for an orthographic camera
  19980. * In scene unit
  19981. */
  19982. _this.orthoLeft = null;
  19983. /**
  19984. * Define the current limit on the right side for an orthographic camera
  19985. * In scene unit
  19986. */
  19987. _this.orthoRight = null;
  19988. /**
  19989. * Define the current limit on the bottom side for an orthographic camera
  19990. * In scene unit
  19991. */
  19992. _this.orthoBottom = null;
  19993. /**
  19994. * Define the current limit on the top side for an orthographic camera
  19995. * In scene unit
  19996. */
  19997. _this.orthoTop = null;
  19998. /**
  19999. * Field Of View is set in Radians. (default is 0.8)
  20000. */
  20001. _this.fov = 0.8;
  20002. /**
  20003. * Define the minimum distance the camera can see from.
  20004. * This is important to note that the depth buffer are not infinite and the closer it starts
  20005. * the more your scene might encounter depth fighting issue.
  20006. */
  20007. _this.minZ = 1;
  20008. /**
  20009. * Define the maximum distance the camera can see to.
  20010. * This is important to note that the depth buffer are not infinite and the further it end
  20011. * the more your scene might encounter depth fighting issue.
  20012. */
  20013. _this.maxZ = 10000.0;
  20014. /**
  20015. * Define the default inertia of the camera.
  20016. * This helps giving a smooth feeling to the camera movement.
  20017. */
  20018. _this.inertia = 0.9;
  20019. /**
  20020. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  20021. */
  20022. _this.mode = Camera.PERSPECTIVE_CAMERA;
  20023. /**
  20024. * Define wether the camera is intermediate.
  20025. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  20026. */
  20027. _this.isIntermediate = false;
  20028. /**
  20029. * Define the viewport of the camera.
  20030. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  20031. */
  20032. _this.viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Viewport"](0, 0, 1.0, 1.0);
  20033. /**
  20034. * Restricts the camera to viewing objects with the same layerMask.
  20035. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  20036. */
  20037. _this.layerMask = 0x0FFFFFFF;
  20038. /**
  20039. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  20040. */
  20041. _this.fovMode = Camera.FOVMODE_VERTICAL_FIXED;
  20042. /**
  20043. * Rig mode of the camera.
  20044. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  20045. * This is normally controlled byt the camera themselves as internal use.
  20046. */
  20047. _this.cameraRigMode = Camera.RIG_MODE_NONE;
  20048. /**
  20049. * 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
  20050. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  20051. * else in the scene.
  20052. */
  20053. _this.customRenderTargets = new Array();
  20054. /**
  20055. * When set, the camera will render to this render target instead of the default canvas
  20056. */
  20057. _this.outputRenderTarget = null;
  20058. /**
  20059. * Observable triggered when the camera view matrix has changed.
  20060. */
  20061. _this.onViewMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20062. /**
  20063. * Observable triggered when the camera Projection matrix has changed.
  20064. */
  20065. _this.onProjectionMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20066. /**
  20067. * Observable triggered when the inputs have been processed.
  20068. */
  20069. _this.onAfterCheckInputsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20070. /**
  20071. * Observable triggered when reset has been called and applied to the camera.
  20072. */
  20073. _this.onRestoreStateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20074. /** @hidden */
  20075. _this._rigCameras = new Array();
  20076. _this._webvrViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20077. /** @hidden */
  20078. _this._skipRendering = false;
  20079. /** @hidden */
  20080. _this._projectionMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  20081. /** @hidden */
  20082. _this._postProcesses = new Array();
  20083. /** @hidden */
  20084. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](256);
  20085. _this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20086. /** hidden */
  20087. _this._computedViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20088. _this._doNotComputeProjectionMatrix = false;
  20089. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Zero();
  20090. _this._refreshFrustumPlanes = true;
  20091. /** @hidden */
  20092. _this._isCamera = true;
  20093. _this.getScene().addCamera(_this);
  20094. if (setActiveOnSceneIfNoneActive && !_this.getScene().activeCamera) {
  20095. _this.getScene().activeCamera = _this;
  20096. }
  20097. _this.position = position;
  20098. return _this;
  20099. }
  20100. /**
  20101. * Store current camera state (fov, position, etc..)
  20102. * @returns the camera
  20103. */
  20104. Camera.prototype.storeState = function () {
  20105. this._stateStored = true;
  20106. this._storedFov = this.fov;
  20107. return this;
  20108. };
  20109. /**
  20110. * Restores the camera state values if it has been stored. You must call storeState() first
  20111. */
  20112. Camera.prototype._restoreStateValues = function () {
  20113. if (!this._stateStored) {
  20114. return false;
  20115. }
  20116. this.fov = this._storedFov;
  20117. return true;
  20118. };
  20119. /**
  20120. * Restored camera state. You must call storeState() first.
  20121. * @returns true if restored and false otherwise
  20122. */
  20123. Camera.prototype.restoreState = function () {
  20124. if (this._restoreStateValues()) {
  20125. this.onRestoreStateObservable.notifyObservers(this);
  20126. return true;
  20127. }
  20128. return false;
  20129. };
  20130. /**
  20131. * Gets the class name of the camera.
  20132. * @returns the class name
  20133. */
  20134. Camera.prototype.getClassName = function () {
  20135. return "Camera";
  20136. };
  20137. /**
  20138. * Gets a string representation of the camera useful for debug purpose.
  20139. * @param fullDetails Defines that a more verboe level of logging is required
  20140. * @returns the string representation
  20141. */
  20142. Camera.prototype.toString = function (fullDetails) {
  20143. var ret = "Name: " + this.name;
  20144. ret += ", type: " + this.getClassName();
  20145. if (this.animations) {
  20146. for (var i = 0; i < this.animations.length; i++) {
  20147. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  20148. }
  20149. }
  20150. if (fullDetails) {
  20151. }
  20152. return ret;
  20153. };
  20154. Object.defineProperty(Camera.prototype, "globalPosition", {
  20155. /**
  20156. * Gets the current world space position of the camera.
  20157. */
  20158. get: function () {
  20159. return this._globalPosition;
  20160. },
  20161. enumerable: true,
  20162. configurable: true
  20163. });
  20164. /**
  20165. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  20166. * @returns the active meshe list
  20167. */
  20168. Camera.prototype.getActiveMeshes = function () {
  20169. return this._activeMeshes;
  20170. };
  20171. /**
  20172. * Check wether a mesh is part of the current active mesh list of the camera
  20173. * @param mesh Defines the mesh to check
  20174. * @returns true if active, false otherwise
  20175. */
  20176. Camera.prototype.isActiveMesh = function (mesh) {
  20177. return (this._activeMeshes.indexOf(mesh) !== -1);
  20178. };
  20179. /**
  20180. * Is this camera ready to be used/rendered
  20181. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  20182. * @return true if the camera is ready
  20183. */
  20184. Camera.prototype.isReady = function (completeCheck) {
  20185. if (completeCheck === void 0) { completeCheck = false; }
  20186. if (completeCheck) {
  20187. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  20188. var pp = _a[_i];
  20189. if (pp && !pp.isReady()) {
  20190. return false;
  20191. }
  20192. }
  20193. }
  20194. return _super.prototype.isReady.call(this, completeCheck);
  20195. };
  20196. /** @hidden */
  20197. Camera.prototype._initCache = function () {
  20198. _super.prototype._initCache.call(this);
  20199. this._cache.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20200. this._cache.upVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20201. this._cache.mode = undefined;
  20202. this._cache.minZ = undefined;
  20203. this._cache.maxZ = undefined;
  20204. this._cache.fov = undefined;
  20205. this._cache.fovMode = undefined;
  20206. this._cache.aspectRatio = undefined;
  20207. this._cache.orthoLeft = undefined;
  20208. this._cache.orthoRight = undefined;
  20209. this._cache.orthoBottom = undefined;
  20210. this._cache.orthoTop = undefined;
  20211. this._cache.renderWidth = undefined;
  20212. this._cache.renderHeight = undefined;
  20213. };
  20214. /** @hidden */
  20215. Camera.prototype._updateCache = function (ignoreParentClass) {
  20216. if (!ignoreParentClass) {
  20217. _super.prototype._updateCache.call(this);
  20218. }
  20219. this._cache.position.copyFrom(this.position);
  20220. this._cache.upVector.copyFrom(this.upVector);
  20221. };
  20222. /** @hidden */
  20223. Camera.prototype._isSynchronized = function () {
  20224. return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
  20225. };
  20226. /** @hidden */
  20227. Camera.prototype._isSynchronizedViewMatrix = function () {
  20228. if (!_super.prototype._isSynchronized.call(this)) {
  20229. return false;
  20230. }
  20231. return this._cache.position.equals(this.position)
  20232. && this._cache.upVector.equals(this.upVector)
  20233. && this.isSynchronizedWithParent();
  20234. };
  20235. /** @hidden */
  20236. Camera.prototype._isSynchronizedProjectionMatrix = function () {
  20237. var check = this._cache.mode === this.mode
  20238. && this._cache.minZ === this.minZ
  20239. && this._cache.maxZ === this.maxZ;
  20240. if (!check) {
  20241. return false;
  20242. }
  20243. var engine = this.getEngine();
  20244. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20245. check = this._cache.fov === this.fov
  20246. && this._cache.fovMode === this.fovMode
  20247. && this._cache.aspectRatio === engine.getAspectRatio(this);
  20248. }
  20249. else {
  20250. check = this._cache.orthoLeft === this.orthoLeft
  20251. && this._cache.orthoRight === this.orthoRight
  20252. && this._cache.orthoBottom === this.orthoBottom
  20253. && this._cache.orthoTop === this.orthoTop
  20254. && this._cache.renderWidth === engine.getRenderWidth()
  20255. && this._cache.renderHeight === engine.getRenderHeight();
  20256. }
  20257. return check;
  20258. };
  20259. /**
  20260. * Attach the input controls to a specific dom element to get the input from.
  20261. * @param element Defines the element the controls should be listened from
  20262. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20263. */
  20264. Camera.prototype.attachControl = function (element, noPreventDefault) {
  20265. };
  20266. /**
  20267. * Detach the current controls from the specified dom element.
  20268. * @param element Defines the element to stop listening the inputs from
  20269. */
  20270. Camera.prototype.detachControl = function (element) {
  20271. };
  20272. /**
  20273. * Update the camera state according to the different inputs gathered during the frame.
  20274. */
  20275. Camera.prototype.update = function () {
  20276. this._checkInputs();
  20277. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20278. this._updateRigCameras();
  20279. }
  20280. };
  20281. /** @hidden */
  20282. Camera.prototype._checkInputs = function () {
  20283. this.onAfterCheckInputsObservable.notifyObservers(this);
  20284. };
  20285. Object.defineProperty(Camera.prototype, "rigCameras", {
  20286. /** @hidden */
  20287. get: function () {
  20288. return this._rigCameras;
  20289. },
  20290. enumerable: true,
  20291. configurable: true
  20292. });
  20293. Object.defineProperty(Camera.prototype, "rigPostProcess", {
  20294. /**
  20295. * Gets the post process used by the rig cameras
  20296. */
  20297. get: function () {
  20298. return this._rigPostProcess;
  20299. },
  20300. enumerable: true,
  20301. configurable: true
  20302. });
  20303. /**
  20304. * Internal, gets the first post proces.
  20305. * @returns the first post process to be run on this camera.
  20306. */
  20307. Camera.prototype._getFirstPostProcess = function () {
  20308. for (var ppIndex = 0; ppIndex < this._postProcesses.length; ppIndex++) {
  20309. if (this._postProcesses[ppIndex] !== null) {
  20310. return this._postProcesses[ppIndex];
  20311. }
  20312. }
  20313. return null;
  20314. };
  20315. Camera.prototype._cascadePostProcessesToRigCams = function () {
  20316. // invalidate framebuffer
  20317. var firstPostProcess = this._getFirstPostProcess();
  20318. if (firstPostProcess) {
  20319. firstPostProcess.markTextureDirty();
  20320. }
  20321. // glue the rigPostProcess to the end of the user postprocesses & assign to each sub-camera
  20322. for (var i = 0, len = this._rigCameras.length; i < len; i++) {
  20323. var cam = this._rigCameras[i];
  20324. var rigPostProcess = cam._rigPostProcess;
  20325. // for VR rig, there does not have to be a post process
  20326. if (rigPostProcess) {
  20327. var isPass = rigPostProcess.getEffectName() === "pass";
  20328. if (isPass) {
  20329. // any rig which has a PassPostProcess for rig[0], cannot be isIntermediate when there are also user postProcesses
  20330. cam.isIntermediate = this._postProcesses.length === 0;
  20331. }
  20332. cam._postProcesses = this._postProcesses.slice(0).concat(rigPostProcess);
  20333. rigPostProcess.markTextureDirty();
  20334. }
  20335. else {
  20336. cam._postProcesses = this._postProcesses.slice(0);
  20337. }
  20338. }
  20339. };
  20340. /**
  20341. * Attach a post process to the camera.
  20342. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20343. * @param postProcess The post process to attach to the camera
  20344. * @param insertAt The position of the post process in case several of them are in use in the scene
  20345. * @returns the position the post process has been inserted at
  20346. */
  20347. Camera.prototype.attachPostProcess = function (postProcess, insertAt) {
  20348. if (insertAt === void 0) { insertAt = null; }
  20349. if (!postProcess.isReusable() && this._postProcesses.indexOf(postProcess) > -1) {
  20350. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("You're trying to reuse a post process not defined as reusable.");
  20351. return 0;
  20352. }
  20353. if (insertAt == null || insertAt < 0) {
  20354. this._postProcesses.push(postProcess);
  20355. }
  20356. else if (this._postProcesses[insertAt] === null) {
  20357. this._postProcesses[insertAt] = postProcess;
  20358. }
  20359. else {
  20360. this._postProcesses.splice(insertAt, 0, postProcess);
  20361. }
  20362. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20363. return this._postProcesses.indexOf(postProcess);
  20364. };
  20365. /**
  20366. * Detach a post process to the camera.
  20367. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20368. * @param postProcess The post process to detach from the camera
  20369. */
  20370. Camera.prototype.detachPostProcess = function (postProcess) {
  20371. var idx = this._postProcesses.indexOf(postProcess);
  20372. if (idx !== -1) {
  20373. this._postProcesses[idx] = null;
  20374. }
  20375. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20376. };
  20377. /**
  20378. * Gets the current world matrix of the camera
  20379. */
  20380. Camera.prototype.getWorldMatrix = function () {
  20381. if (this._isSynchronizedViewMatrix()) {
  20382. return this._worldMatrix;
  20383. }
  20384. // Getting the the view matrix will also compute the world matrix.
  20385. this.getViewMatrix();
  20386. return this._worldMatrix;
  20387. };
  20388. /** @hidden */
  20389. Camera.prototype._getViewMatrix = function () {
  20390. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20391. };
  20392. /**
  20393. * Gets the current view matrix of the camera.
  20394. * @param force forces the camera to recompute the matrix without looking at the cached state
  20395. * @returns the view matrix
  20396. */
  20397. Camera.prototype.getViewMatrix = function (force) {
  20398. if (!force && this._isSynchronizedViewMatrix()) {
  20399. return this._computedViewMatrix;
  20400. }
  20401. this.updateCache();
  20402. this._computedViewMatrix = this._getViewMatrix();
  20403. this._currentRenderId = this.getScene().getRenderId();
  20404. this._childRenderId = this._currentRenderId;
  20405. this._refreshFrustumPlanes = true;
  20406. if (this._cameraRigParams && this._cameraRigParams.vrPreViewMatrix) {
  20407. this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix, this._computedViewMatrix);
  20408. }
  20409. this.onViewMatrixChangedObservable.notifyObservers(this);
  20410. this._computedViewMatrix.invertToRef(this._worldMatrix);
  20411. return this._computedViewMatrix;
  20412. };
  20413. /**
  20414. * Freeze the projection matrix.
  20415. * It will prevent the cache check of the camera projection compute and can speed up perf
  20416. * if no parameter of the camera are meant to change
  20417. * @param projection Defines manually a projection if necessary
  20418. */
  20419. Camera.prototype.freezeProjectionMatrix = function (projection) {
  20420. this._doNotComputeProjectionMatrix = true;
  20421. if (projection !== undefined) {
  20422. this._projectionMatrix = projection;
  20423. }
  20424. };
  20425. /**
  20426. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  20427. */
  20428. Camera.prototype.unfreezeProjectionMatrix = function () {
  20429. this._doNotComputeProjectionMatrix = false;
  20430. };
  20431. /**
  20432. * Gets the current projection matrix of the camera.
  20433. * @param force forces the camera to recompute the matrix without looking at the cached state
  20434. * @returns the projection matrix
  20435. */
  20436. Camera.prototype.getProjectionMatrix = function (force) {
  20437. if (this._doNotComputeProjectionMatrix || (!force && this._isSynchronizedProjectionMatrix())) {
  20438. return this._projectionMatrix;
  20439. }
  20440. // Cache
  20441. this._cache.mode = this.mode;
  20442. this._cache.minZ = this.minZ;
  20443. this._cache.maxZ = this.maxZ;
  20444. // Matrix
  20445. this._refreshFrustumPlanes = true;
  20446. var engine = this.getEngine();
  20447. var scene = this.getScene();
  20448. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20449. this._cache.fov = this.fov;
  20450. this._cache.fovMode = this.fovMode;
  20451. this._cache.aspectRatio = engine.getAspectRatio(this);
  20452. if (this.minZ <= 0) {
  20453. this.minZ = 0.1;
  20454. }
  20455. if (scene.useRightHandedSystem) {
  20456. _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);
  20457. }
  20458. else {
  20459. _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);
  20460. }
  20461. }
  20462. else {
  20463. var halfWidth = engine.getRenderWidth() / 2.0;
  20464. var halfHeight = engine.getRenderHeight() / 2.0;
  20465. if (scene.useRightHandedSystem) {
  20466. _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);
  20467. }
  20468. else {
  20469. _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);
  20470. }
  20471. this._cache.orthoLeft = this.orthoLeft;
  20472. this._cache.orthoRight = this.orthoRight;
  20473. this._cache.orthoBottom = this.orthoBottom;
  20474. this._cache.orthoTop = this.orthoTop;
  20475. this._cache.renderWidth = engine.getRenderWidth();
  20476. this._cache.renderHeight = engine.getRenderHeight();
  20477. }
  20478. this.onProjectionMatrixChangedObservable.notifyObservers(this);
  20479. return this._projectionMatrix;
  20480. };
  20481. /**
  20482. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  20483. * @returns a Matrix
  20484. */
  20485. Camera.prototype.getTransformationMatrix = function () {
  20486. this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  20487. return this._transformMatrix;
  20488. };
  20489. Camera.prototype._updateFrustumPlanes = function () {
  20490. if (!this._refreshFrustumPlanes) {
  20491. return;
  20492. }
  20493. this.getTransformationMatrix();
  20494. if (!this._frustumPlanes) {
  20495. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanes(this._transformMatrix);
  20496. }
  20497. else {
  20498. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  20499. }
  20500. this._refreshFrustumPlanes = false;
  20501. };
  20502. /**
  20503. * Checks if a cullable object (mesh...) is in the camera frustum
  20504. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  20505. * @param target The object to check
  20506. * @returns true if the object is in frustum otherwise false
  20507. */
  20508. Camera.prototype.isInFrustum = function (target) {
  20509. this._updateFrustumPlanes();
  20510. return target.isInFrustum(this._frustumPlanes);
  20511. };
  20512. /**
  20513. * Checks if a cullable object (mesh...) is in the camera frustum
  20514. * Unlike isInFrustum this cheks the full bounding box
  20515. * @param target The object to check
  20516. * @returns true if the object is in frustum otherwise false
  20517. */
  20518. Camera.prototype.isCompletelyInFrustum = function (target) {
  20519. this._updateFrustumPlanes();
  20520. return target.isCompletelyInFrustum(this._frustumPlanes);
  20521. };
  20522. /**
  20523. * Gets a ray in the forward direction from the camera.
  20524. * @param length Defines the length of the ray to create
  20525. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  20526. * @param origin Defines the start point of the ray which defaults to the camera position
  20527. * @returns the forward ray
  20528. */
  20529. Camera.prototype.getForwardRay = function (length, transform, origin) {
  20530. if (length === void 0) { length = 100; }
  20531. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("Ray");
  20532. };
  20533. /**
  20534. * Releases resources associated with this node.
  20535. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20536. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20537. */
  20538. Camera.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  20539. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  20540. // Observables
  20541. this.onViewMatrixChangedObservable.clear();
  20542. this.onProjectionMatrixChangedObservable.clear();
  20543. this.onAfterCheckInputsObservable.clear();
  20544. this.onRestoreStateObservable.clear();
  20545. // Inputs
  20546. if (this.inputs) {
  20547. this.inputs.clear();
  20548. }
  20549. // Animations
  20550. this.getScene().stopAnimation(this);
  20551. // Remove from scene
  20552. this.getScene().removeCamera(this);
  20553. while (this._rigCameras.length > 0) {
  20554. var camera = this._rigCameras.pop();
  20555. if (camera) {
  20556. camera.dispose();
  20557. }
  20558. }
  20559. // Postprocesses
  20560. if (this._rigPostProcess) {
  20561. this._rigPostProcess.dispose(this);
  20562. this._rigPostProcess = null;
  20563. this._postProcesses = [];
  20564. }
  20565. else if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20566. this._rigPostProcess = null;
  20567. this._postProcesses = [];
  20568. }
  20569. else {
  20570. var i = this._postProcesses.length;
  20571. while (--i >= 0) {
  20572. var postProcess = this._postProcesses[i];
  20573. if (postProcess) {
  20574. postProcess.dispose(this);
  20575. }
  20576. }
  20577. }
  20578. // Render targets
  20579. var i = this.customRenderTargets.length;
  20580. while (--i >= 0) {
  20581. this.customRenderTargets[i].dispose();
  20582. }
  20583. this.customRenderTargets = [];
  20584. // Active Meshes
  20585. this._activeMeshes.dispose();
  20586. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  20587. };
  20588. Object.defineProperty(Camera.prototype, "leftCamera", {
  20589. /**
  20590. * Gets the left camera of a rig setup in case of Rigged Camera
  20591. */
  20592. get: function () {
  20593. if (this._rigCameras.length < 1) {
  20594. return null;
  20595. }
  20596. return this._rigCameras[0];
  20597. },
  20598. enumerable: true,
  20599. configurable: true
  20600. });
  20601. Object.defineProperty(Camera.prototype, "rightCamera", {
  20602. /**
  20603. * Gets the right camera of a rig setup in case of Rigged Camera
  20604. */
  20605. get: function () {
  20606. if (this._rigCameras.length < 2) {
  20607. return null;
  20608. }
  20609. return this._rigCameras[1];
  20610. },
  20611. enumerable: true,
  20612. configurable: true
  20613. });
  20614. /**
  20615. * Gets the left camera target of a rig setup in case of Rigged Camera
  20616. * @returns the target position
  20617. */
  20618. Camera.prototype.getLeftTarget = function () {
  20619. if (this._rigCameras.length < 1) {
  20620. return null;
  20621. }
  20622. return this._rigCameras[0].getTarget();
  20623. };
  20624. /**
  20625. * Gets the right camera target of a rig setup in case of Rigged Camera
  20626. * @returns the target position
  20627. */
  20628. Camera.prototype.getRightTarget = function () {
  20629. if (this._rigCameras.length < 2) {
  20630. return null;
  20631. }
  20632. return this._rigCameras[1].getTarget();
  20633. };
  20634. /**
  20635. * @hidden
  20636. */
  20637. Camera.prototype.setCameraRigMode = function (mode, rigParams) {
  20638. if (this.cameraRigMode === mode) {
  20639. return;
  20640. }
  20641. while (this._rigCameras.length > 0) {
  20642. var camera = this._rigCameras.pop();
  20643. if (camera) {
  20644. camera.dispose();
  20645. }
  20646. }
  20647. this.cameraRigMode = mode;
  20648. this._cameraRigParams = {};
  20649. //we have to implement stereo camera calcultating left and right viewpoints from interaxialDistance and target,
  20650. //not from a given angle as it is now, but until that complete code rewriting provisional stereoHalfAngle value is introduced
  20651. this._cameraRigParams.interaxialDistance = rigParams.interaxialDistance || 0.0637;
  20652. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(this._cameraRigParams.interaxialDistance / 0.0637);
  20653. // create the rig cameras, unless none
  20654. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20655. var leftCamera = this.createRigCamera(this.name + "_L", 0);
  20656. var rightCamera = this.createRigCamera(this.name + "_R", 1);
  20657. if (leftCamera && rightCamera) {
  20658. this._rigCameras.push(leftCamera);
  20659. this._rigCameras.push(rightCamera);
  20660. }
  20661. }
  20662. switch (this.cameraRigMode) {
  20663. case Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20664. Camera._setStereoscopicAnaglyphRigMode(this);
  20665. break;
  20666. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20667. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20668. case Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20669. Camera._setStereoscopicRigMode(this);
  20670. break;
  20671. case Camera.RIG_MODE_VR:
  20672. Camera._setVRRigMode(this, rigParams);
  20673. break;
  20674. case Camera.RIG_MODE_WEBVR:
  20675. Camera._setWebVRRigMode(this, rigParams);
  20676. break;
  20677. }
  20678. this._cascadePostProcessesToRigCams();
  20679. this.update();
  20680. };
  20681. /** @hidden */
  20682. Camera._setStereoscopicRigMode = function (camera) {
  20683. throw "Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode";
  20684. };
  20685. /** @hidden */
  20686. Camera._setStereoscopicAnaglyphRigMode = function (camera) {
  20687. throw "Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode";
  20688. };
  20689. /** @hidden */
  20690. Camera._setVRRigMode = function (camera, rigParams) {
  20691. throw "Import Cameras/RigModes/vrRigMode before using VR rig mode";
  20692. };
  20693. /** @hidden */
  20694. Camera._setWebVRRigMode = function (camera, rigParams) {
  20695. throw "Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode";
  20696. };
  20697. /** @hidden */
  20698. Camera.prototype._getVRProjectionMatrix = function () {
  20699. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix);
  20700. this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix);
  20701. return this._projectionMatrix;
  20702. };
  20703. Camera.prototype._updateCameraRotationMatrix = function () {
  20704. //Here for WebVR
  20705. };
  20706. Camera.prototype._updateWebVRCameraRotationMatrix = function () {
  20707. //Here for WebVR
  20708. };
  20709. /**
  20710. * This function MUST be overwritten by the different WebVR cameras available.
  20711. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  20712. * @hidden
  20713. */
  20714. Camera.prototype._getWebVRProjectionMatrix = function () {
  20715. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20716. };
  20717. /**
  20718. * This function MUST be overwritten by the different WebVR cameras available.
  20719. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  20720. * @hidden
  20721. */
  20722. Camera.prototype._getWebVRViewMatrix = function () {
  20723. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20724. };
  20725. /** @hidden */
  20726. Camera.prototype.setCameraRigParameter = function (name, value) {
  20727. if (!this._cameraRigParams) {
  20728. this._cameraRigParams = {};
  20729. }
  20730. this._cameraRigParams[name] = value;
  20731. //provisionnally:
  20732. if (name === "interaxialDistance") {
  20733. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(value / 0.0637);
  20734. }
  20735. };
  20736. /**
  20737. * needs to be overridden by children so sub has required properties to be copied
  20738. * @hidden
  20739. */
  20740. Camera.prototype.createRigCamera = function (name, cameraIndex) {
  20741. return null;
  20742. };
  20743. /**
  20744. * May need to be overridden by children
  20745. * @hidden
  20746. */
  20747. Camera.prototype._updateRigCameras = function () {
  20748. for (var i = 0; i < this._rigCameras.length; i++) {
  20749. this._rigCameras[i].minZ = this.minZ;
  20750. this._rigCameras[i].maxZ = this.maxZ;
  20751. this._rigCameras[i].fov = this.fov;
  20752. this._rigCameras[i].upVector.copyFrom(this.upVector);
  20753. }
  20754. // only update viewport when ANAGLYPH
  20755. if (this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH) {
  20756. this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport;
  20757. }
  20758. };
  20759. /** @hidden */
  20760. Camera.prototype._setupInputs = function () {
  20761. };
  20762. /**
  20763. * Serialiaze the camera setup to a json represention
  20764. * @returns the JSON representation
  20765. */
  20766. Camera.prototype.serialize = function () {
  20767. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  20768. // Type
  20769. serializationObject.type = this.getClassName();
  20770. // Parent
  20771. if (this.parent) {
  20772. serializationObject.parentId = this.parent.id;
  20773. }
  20774. if (this.inputs) {
  20775. this.inputs.serialize(serializationObject);
  20776. }
  20777. // Animations
  20778. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  20779. serializationObject.ranges = this.serializeAnimationRanges();
  20780. return serializationObject;
  20781. };
  20782. /**
  20783. * Clones the current camera.
  20784. * @param name The cloned camera name
  20785. * @returns the cloned camera
  20786. */
  20787. Camera.prototype.clone = function (name) {
  20788. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(Camera.GetConstructorFromName(this.getClassName(), name, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
  20789. };
  20790. /**
  20791. * Gets the direction of the camera relative to a given local axis.
  20792. * @param localAxis Defines the reference axis to provide a relative direction.
  20793. * @return the direction
  20794. */
  20795. Camera.prototype.getDirection = function (localAxis) {
  20796. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20797. this.getDirectionToRef(localAxis, result);
  20798. return result;
  20799. };
  20800. /**
  20801. * Gets the direction of the camera relative to a given local axis into a passed vector.
  20802. * @param localAxis Defines the reference axis to provide a relative direction.
  20803. * @param result Defines the vector to store the result in
  20804. */
  20805. Camera.prototype.getDirectionToRef = function (localAxis, result) {
  20806. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  20807. };
  20808. /**
  20809. * Gets a camera constructor for a given camera type
  20810. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  20811. * @param name The name of the camera the result will be able to instantiate
  20812. * @param scene The scene the result will construct the camera in
  20813. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  20814. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  20815. * @returns a factory method to construc the camera
  20816. */
  20817. Camera.GetConstructorFromName = function (type, name, scene, interaxial_distance, isStereoscopicSideBySide) {
  20818. if (interaxial_distance === void 0) { interaxial_distance = 0; }
  20819. if (isStereoscopicSideBySide === void 0) { isStereoscopicSideBySide = true; }
  20820. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_6__["Node"].Construct(type, name, scene, {
  20821. interaxial_distance: interaxial_distance,
  20822. isStereoscopicSideBySide: isStereoscopicSideBySide
  20823. });
  20824. if (constructorFunc) {
  20825. return constructorFunc;
  20826. }
  20827. // Default to universal camera
  20828. return function () { return Camera._createDefaultParsedCamera(name, scene); };
  20829. };
  20830. /**
  20831. * Compute the world matrix of the camera.
  20832. * @returns the camera workd matrix
  20833. */
  20834. Camera.prototype.computeWorldMatrix = function () {
  20835. return this.getWorldMatrix();
  20836. };
  20837. /**
  20838. * Parse a JSON and creates the camera from the parsed information
  20839. * @param parsedCamera The JSON to parse
  20840. * @param scene The scene to instantiate the camera in
  20841. * @returns the newly constructed camera
  20842. */
  20843. Camera.Parse = function (parsedCamera, scene) {
  20844. var type = parsedCamera.type;
  20845. var construct = Camera.GetConstructorFromName(type, parsedCamera.name, scene, parsedCamera.interaxial_distance, parsedCamera.isStereoscopicSideBySide);
  20846. var camera = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(construct, parsedCamera, scene);
  20847. // Parent
  20848. if (parsedCamera.parentId) {
  20849. camera._waitingParentId = parsedCamera.parentId;
  20850. }
  20851. //If camera has an input manager, let it parse inputs settings
  20852. if (camera.inputs) {
  20853. camera.inputs.parse(parsedCamera);
  20854. camera._setupInputs();
  20855. }
  20856. if (camera.setPosition) { // need to force position
  20857. camera.position.copyFromFloats(0, 0, 0);
  20858. camera.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.position));
  20859. }
  20860. // Target
  20861. if (parsedCamera.target) {
  20862. if (camera.setTarget) {
  20863. camera.setTarget(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.target));
  20864. }
  20865. }
  20866. // Apply 3d rig, when found
  20867. if (parsedCamera.cameraRigMode) {
  20868. var rigParams = (parsedCamera.interaxial_distance) ? { interaxialDistance: parsedCamera.interaxial_distance } : {};
  20869. camera.setCameraRigMode(parsedCamera.cameraRigMode, rigParams);
  20870. }
  20871. // Animations
  20872. if (parsedCamera.animations) {
  20873. for (var animationIndex = 0; animationIndex < parsedCamera.animations.length; animationIndex++) {
  20874. var parsedAnimation = parsedCamera.animations[animationIndex];
  20875. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON.Animation");
  20876. if (internalClass) {
  20877. camera.animations.push(internalClass.Parse(parsedAnimation));
  20878. }
  20879. }
  20880. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(camera, parsedCamera, scene);
  20881. }
  20882. if (parsedCamera.autoAnimate) {
  20883. scene.beginAnimation(camera, parsedCamera.autoAnimateFrom, parsedCamera.autoAnimateTo, parsedCamera.autoAnimateLoop, parsedCamera.autoAnimateSpeed || 1.0);
  20884. }
  20885. return camera;
  20886. };
  20887. /** @hidden */
  20888. Camera._createDefaultParsedCamera = function (name, scene) {
  20889. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("UniversalCamera");
  20890. };
  20891. /**
  20892. * This is the default projection mode used by the cameras.
  20893. * It helps recreating a feeling of perspective and better appreciate depth.
  20894. * This is the best way to simulate real life cameras.
  20895. */
  20896. Camera.PERSPECTIVE_CAMERA = 0;
  20897. /**
  20898. * This helps creating camera with an orthographic mode.
  20899. * 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.
  20900. */
  20901. Camera.ORTHOGRAPHIC_CAMERA = 1;
  20902. /**
  20903. * This is the default FOV mode for perspective cameras.
  20904. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  20905. */
  20906. Camera.FOVMODE_VERTICAL_FIXED = 0;
  20907. /**
  20908. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  20909. */
  20910. Camera.FOVMODE_HORIZONTAL_FIXED = 1;
  20911. /**
  20912. * This specifies ther is no need for a camera rig.
  20913. * Basically only one eye is rendered corresponding to the camera.
  20914. */
  20915. Camera.RIG_MODE_NONE = 0;
  20916. /**
  20917. * Simulates a camera Rig with one blue eye and one red eye.
  20918. * This can be use with 3d blue and red glasses.
  20919. */
  20920. Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10;
  20921. /**
  20922. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  20923. */
  20924. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11;
  20925. /**
  20926. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  20927. */
  20928. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12;
  20929. /**
  20930. * Defines that both eyes of the camera will be rendered over under each other.
  20931. */
  20932. Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13;
  20933. /**
  20934. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  20935. */
  20936. Camera.RIG_MODE_VR = 20;
  20937. /**
  20938. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  20939. */
  20940. Camera.RIG_MODE_WEBVR = 21;
  20941. /**
  20942. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  20943. */
  20944. Camera.RIG_MODE_CUSTOM = 22;
  20945. /**
  20946. * Defines if by default attaching controls should prevent the default javascript event to continue.
  20947. */
  20948. Camera.ForceAttachControlToAlwaysPreventDefault = false;
  20949. /**
  20950. * @hidden
  20951. * Might be removed once multiview will be a thing
  20952. */
  20953. Camera.UseAlternateWebVRRendering = false;
  20954. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20955. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20956. ], Camera.prototype, "position", void 0);
  20957. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20958. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20959. ], Camera.prototype, "upVector", void 0);
  20960. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20961. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20962. ], Camera.prototype, "orthoLeft", void 0);
  20963. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20964. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20965. ], Camera.prototype, "orthoRight", void 0);
  20966. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20967. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20968. ], Camera.prototype, "orthoBottom", void 0);
  20969. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20970. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20971. ], Camera.prototype, "orthoTop", void 0);
  20972. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20973. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20974. ], Camera.prototype, "fov", void 0);
  20975. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20976. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20977. ], Camera.prototype, "minZ", void 0);
  20978. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20979. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20980. ], Camera.prototype, "maxZ", void 0);
  20981. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20982. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20983. ], Camera.prototype, "inertia", void 0);
  20984. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20985. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20986. ], Camera.prototype, "mode", void 0);
  20987. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20988. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20989. ], Camera.prototype, "layerMask", void 0);
  20990. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20991. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20992. ], Camera.prototype, "fovMode", void 0);
  20993. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20994. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20995. ], Camera.prototype, "cameraRigMode", void 0);
  20996. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20997. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20998. ], Camera.prototype, "interaxialDistance", void 0);
  20999. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21000. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21001. ], Camera.prototype, "isStereoscopicSideBySide", void 0);
  21002. return Camera;
  21003. }(_node__WEBPACK_IMPORTED_MODULE_6__["Node"]));
  21004. /***/ }),
  21005. /***/ "./Cameras/cameraInputsManager.ts":
  21006. /*!****************************************!*\
  21007. !*** ./Cameras/cameraInputsManager.ts ***!
  21008. \****************************************/
  21009. /*! exports provided: CameraInputTypes, CameraInputsManager */
  21010. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21011. "use strict";
  21012. __webpack_require__.r(__webpack_exports__);
  21013. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return CameraInputTypes; });
  21014. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return CameraInputsManager; });
  21015. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  21016. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21017. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  21018. /**
  21019. * @ignore
  21020. * This is a list of all the different input types that are available in the application.
  21021. * Fo instance: ArcRotateCameraGamepadInput...
  21022. */
  21023. var CameraInputTypes = {};
  21024. /**
  21025. * This represents the input manager used within a camera.
  21026. * It helps dealing with all the different kind of input attached to a camera.
  21027. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21028. */
  21029. var CameraInputsManager = /** @class */ (function () {
  21030. /**
  21031. * Instantiate a new Camera Input Manager.
  21032. * @param camera Defines the camera the input manager blongs to
  21033. */
  21034. function CameraInputsManager(camera) {
  21035. this.attached = {};
  21036. this.camera = camera;
  21037. this.checkInputs = function () { };
  21038. }
  21039. /**
  21040. * Add an input method to a camera
  21041. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21042. * @param input camera input method
  21043. */
  21044. CameraInputsManager.prototype.add = function (input) {
  21045. var type = input.getSimpleName();
  21046. if (this.attached[type]) {
  21047. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("camera input of type " + type + " already exists on camera");
  21048. return;
  21049. }
  21050. this.attached[type] = input;
  21051. input.camera = this.camera;
  21052. //for checkInputs, we are dynamically creating a function
  21053. //the goal is to avoid the performance penalty of looping for inputs in the render loop
  21054. if (input.checkInputs) {
  21055. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21056. }
  21057. if (this.attachedElement) {
  21058. input.attachControl(this.attachedElement);
  21059. }
  21060. };
  21061. /**
  21062. * Remove a specific input method from a camera
  21063. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  21064. * @param inputToRemove camera input method
  21065. */
  21066. CameraInputsManager.prototype.remove = function (inputToRemove) {
  21067. for (var cam in this.attached) {
  21068. var input = this.attached[cam];
  21069. if (input === inputToRemove) {
  21070. input.detachControl(this.attachedElement);
  21071. input.camera = null;
  21072. delete this.attached[cam];
  21073. this.rebuildInputCheck();
  21074. }
  21075. }
  21076. };
  21077. /**
  21078. * Remove a specific input type from a camera
  21079. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  21080. * @param inputType the type of the input to remove
  21081. */
  21082. CameraInputsManager.prototype.removeByType = function (inputType) {
  21083. for (var cam in this.attached) {
  21084. var input = this.attached[cam];
  21085. if (input.getClassName() === inputType) {
  21086. input.detachControl(this.attachedElement);
  21087. input.camera = null;
  21088. delete this.attached[cam];
  21089. this.rebuildInputCheck();
  21090. }
  21091. }
  21092. };
  21093. CameraInputsManager.prototype._addCheckInputs = function (fn) {
  21094. var current = this.checkInputs;
  21095. return function () {
  21096. current();
  21097. fn();
  21098. };
  21099. };
  21100. /**
  21101. * Attach the input controls to the currently attached dom element to listen the events from.
  21102. * @param input Defines the input to attach
  21103. */
  21104. CameraInputsManager.prototype.attachInput = function (input) {
  21105. if (this.attachedElement) {
  21106. input.attachControl(this.attachedElement, this.noPreventDefault);
  21107. }
  21108. };
  21109. /**
  21110. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  21111. * @param element Defines the dom element to collect the events from
  21112. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21113. */
  21114. CameraInputsManager.prototype.attachElement = function (element, noPreventDefault) {
  21115. if (noPreventDefault === void 0) { noPreventDefault = false; }
  21116. if (this.attachedElement) {
  21117. return;
  21118. }
  21119. noPreventDefault = _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  21120. this.attachedElement = element;
  21121. this.noPreventDefault = noPreventDefault;
  21122. for (var cam in this.attached) {
  21123. this.attached[cam].attachControl(element, noPreventDefault);
  21124. }
  21125. };
  21126. /**
  21127. * Detach the current manager inputs controls from a specific dom element.
  21128. * @param element Defines the dom element to collect the events from
  21129. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  21130. */
  21131. CameraInputsManager.prototype.detachElement = function (element, disconnect) {
  21132. if (disconnect === void 0) { disconnect = false; }
  21133. if (this.attachedElement !== element) {
  21134. return;
  21135. }
  21136. for (var cam in this.attached) {
  21137. this.attached[cam].detachControl(element);
  21138. if (disconnect) {
  21139. this.attached[cam].camera = null;
  21140. }
  21141. }
  21142. this.attachedElement = null;
  21143. };
  21144. /**
  21145. * Rebuild the dynamic inputCheck function from the current list of
  21146. * defined inputs in the manager.
  21147. */
  21148. CameraInputsManager.prototype.rebuildInputCheck = function () {
  21149. this.checkInputs = function () { };
  21150. for (var cam in this.attached) {
  21151. var input = this.attached[cam];
  21152. if (input.checkInputs) {
  21153. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21154. }
  21155. }
  21156. };
  21157. /**
  21158. * Remove all attached input methods from a camera
  21159. */
  21160. CameraInputsManager.prototype.clear = function () {
  21161. if (this.attachedElement) {
  21162. this.detachElement(this.attachedElement, true);
  21163. }
  21164. this.attached = {};
  21165. this.attachedElement = null;
  21166. this.checkInputs = function () { };
  21167. };
  21168. /**
  21169. * Serialize the current input manager attached to a camera.
  21170. * This ensures than once parsed,
  21171. * the input associated to the camera will be identical to the current ones
  21172. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  21173. */
  21174. CameraInputsManager.prototype.serialize = function (serializedCamera) {
  21175. var inputs = {};
  21176. for (var cam in this.attached) {
  21177. var input = this.attached[cam];
  21178. var res = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(input);
  21179. inputs[input.getClassName()] = res;
  21180. }
  21181. serializedCamera.inputsmgr = inputs;
  21182. };
  21183. /**
  21184. * Parses an input manager serialized JSON to restore the previous list of inputs
  21185. * and states associated to a camera.
  21186. * @param parsedCamera Defines the JSON to parse
  21187. */
  21188. CameraInputsManager.prototype.parse = function (parsedCamera) {
  21189. var parsedInputs = parsedCamera.inputsmgr;
  21190. if (parsedInputs) {
  21191. this.clear();
  21192. for (var n in parsedInputs) {
  21193. var construct = CameraInputTypes[n];
  21194. if (construct) {
  21195. var parsedinput = parsedInputs[n];
  21196. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedinput, null);
  21197. this.add(input);
  21198. }
  21199. }
  21200. }
  21201. else {
  21202. //2016-03-08 this part is for managing backward compatibility
  21203. for (var n in this.attached) {
  21204. var construct = CameraInputTypes[this.attached[n].getClassName()];
  21205. if (construct) {
  21206. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedCamera, null);
  21207. this.remove(this.attached[n]);
  21208. this.add(input);
  21209. }
  21210. }
  21211. }
  21212. };
  21213. return CameraInputsManager;
  21214. }());
  21215. /***/ }),
  21216. /***/ "./Cameras/deviceOrientationCamera.ts":
  21217. /*!********************************************!*\
  21218. !*** ./Cameras/deviceOrientationCamera.ts ***!
  21219. \********************************************/
  21220. /*! exports provided: DeviceOrientationCamera */
  21221. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21222. "use strict";
  21223. __webpack_require__.r(__webpack_exports__);
  21224. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return DeviceOrientationCamera; });
  21225. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21226. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  21227. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21228. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  21229. /* harmony import */ var _Inputs_freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  21230. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("DeviceOrientationCamera", function (name, scene) {
  21231. return function () { return new DeviceOrientationCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  21232. });
  21233. // We're mainly based on the logic defined into the FreeCamera code
  21234. /**
  21235. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  21236. * being tilted forward or back and left or right.
  21237. */
  21238. var DeviceOrientationCamera = /** @class */ (function (_super) {
  21239. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DeviceOrientationCamera, _super);
  21240. /**
  21241. * Creates a new device orientation camera
  21242. * @param name The name of the camera
  21243. * @param position The start position camera
  21244. * @param scene The scene the camera belongs to
  21245. */
  21246. function DeviceOrientationCamera(name, position, scene) {
  21247. var _this = _super.call(this, name, position, scene) || this;
  21248. _this._quaternionCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21249. _this.inputs.addDeviceOrientation();
  21250. return _this;
  21251. }
  21252. /**
  21253. * Gets the current instance class name ("DeviceOrientationCamera").
  21254. * This helps avoiding instanceof at run time.
  21255. * @returns the class name
  21256. */
  21257. DeviceOrientationCamera.prototype.getClassName = function () {
  21258. return "DeviceOrientationCamera";
  21259. };
  21260. /**
  21261. * @hidden
  21262. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  21263. */
  21264. DeviceOrientationCamera.prototype._checkInputs = function () {
  21265. _super.prototype._checkInputs.call(this);
  21266. this._quaternionCache.copyFrom(this.rotationQuaternion);
  21267. if (this._initialQuaternion) {
  21268. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21269. }
  21270. };
  21271. /**
  21272. * Reset the camera to its default orientation on the specified axis only.
  21273. * @param axis The axis to reset
  21274. */
  21275. DeviceOrientationCamera.prototype.resetToCurrentRotation = function (axis) {
  21276. var _this = this;
  21277. if (axis === void 0) { axis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y; }
  21278. //can only work if this camera has a rotation quaternion already.
  21279. if (!this.rotationQuaternion) {
  21280. return;
  21281. }
  21282. if (!this._initialQuaternion) {
  21283. this._initialQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21284. }
  21285. this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion);
  21286. ['x', 'y', 'z'].forEach(function (axisName) {
  21287. if (!axis[axisName]) {
  21288. _this._initialQuaternion[axisName] = 0;
  21289. }
  21290. else {
  21291. _this._initialQuaternion[axisName] *= -1;
  21292. }
  21293. });
  21294. this._initialQuaternion.normalize();
  21295. //force rotation update
  21296. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21297. };
  21298. return DeviceOrientationCamera;
  21299. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  21300. /***/ }),
  21301. /***/ "./Cameras/flyCamera.ts":
  21302. /*!******************************!*\
  21303. !*** ./Cameras/flyCamera.ts ***!
  21304. \******************************/
  21305. /*! exports provided: FlyCamera */
  21306. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21307. "use strict";
  21308. __webpack_require__.r(__webpack_exports__);
  21309. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return FlyCamera; });
  21310. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21311. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21312. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21313. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  21314. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21315. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  21316. /**
  21317. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21318. * such as in a 3D Space Shooter or a Flight Simulator.
  21319. */
  21320. var FlyCamera = /** @class */ (function (_super) {
  21321. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCamera, _super);
  21322. /**
  21323. * Instantiates a FlyCamera.
  21324. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21325. * such as in a 3D Space Shooter or a Flight Simulator.
  21326. * @param name Define the name of the camera in the scene.
  21327. * @param position Define the starting position of the camera in the scene.
  21328. * @param scene Define the scene the camera belongs to.
  21329. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  21330. */
  21331. function FlyCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  21332. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  21333. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  21334. /**
  21335. * Define the collision ellipsoid of the camera.
  21336. * This is helpful for simulating a camera body, like a player's body.
  21337. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  21338. */
  21339. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  21340. /**
  21341. * Define an offset for the position of the ellipsoid around the camera.
  21342. * This can be helpful if the camera is attached away from the player's body center,
  21343. * such as at its head.
  21344. */
  21345. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  21346. /**
  21347. * Enable or disable collisions of the camera with the rest of the scene objects.
  21348. */
  21349. _this.checkCollisions = false;
  21350. /**
  21351. * Enable or disable gravity on the camera.
  21352. */
  21353. _this.applyGravity = false;
  21354. /**
  21355. * Define the current direction the camera is moving to.
  21356. */
  21357. _this.cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21358. /**
  21359. * Track Roll to maintain the wanted Rolling when looking around.
  21360. */
  21361. _this._trackRoll = 0;
  21362. /**
  21363. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  21364. */
  21365. _this.rollCorrect = 100;
  21366. /**
  21367. * Mimic a banked turn, Rolling the camera when Yawing.
  21368. * It's recommended to use rollCorrect = 10 for faster banking correction.
  21369. */
  21370. _this.bankedTurn = false;
  21371. /**
  21372. * Limit in radians for how much Roll banking will add. (Default: 90°)
  21373. */
  21374. _this.bankedTurnLimit = Math.PI / 2;
  21375. /**
  21376. * Value of 0 disables the banked Roll.
  21377. * Value of 1 is equal to the Yaw angle in radians.
  21378. */
  21379. _this.bankedTurnMultiplier = 1;
  21380. _this._needMoveForGravity = false;
  21381. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21382. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21383. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21384. // Collisions.
  21385. _this._collisionMask = -1;
  21386. /** @hidden */
  21387. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  21388. if (collidedMesh === void 0) { collidedMesh = null; }
  21389. var updatePosition = function (newPos) {
  21390. _this._newPosition.copyFrom(newPos);
  21391. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  21392. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  21393. _this.position.addInPlace(_this._diffPosition);
  21394. if (_this.onCollide && collidedMesh) {
  21395. _this.onCollide(collidedMesh);
  21396. }
  21397. }
  21398. };
  21399. updatePosition(newPosition);
  21400. };
  21401. _this.inputs = new _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FlyCameraInputsManager"](_this);
  21402. _this.inputs.addKeyboard().addMouse();
  21403. return _this;
  21404. }
  21405. Object.defineProperty(FlyCamera.prototype, "angularSensibility", {
  21406. /**
  21407. * Gets the input sensibility for mouse input.
  21408. * Higher values reduce sensitivity.
  21409. */
  21410. get: function () {
  21411. var mouse = this.inputs.attached["mouse"];
  21412. if (mouse) {
  21413. return mouse.angularSensibility;
  21414. }
  21415. return 0;
  21416. },
  21417. /**
  21418. * Sets the input sensibility for a mouse input.
  21419. * Higher values reduce sensitivity.
  21420. */
  21421. set: function (value) {
  21422. var mouse = this.inputs.attached["mouse"];
  21423. if (mouse) {
  21424. mouse.angularSensibility = value;
  21425. }
  21426. },
  21427. enumerable: true,
  21428. configurable: true
  21429. });
  21430. Object.defineProperty(FlyCamera.prototype, "keysForward", {
  21431. /**
  21432. * Get the keys for camera movement forward.
  21433. */
  21434. get: function () {
  21435. var keyboard = this.inputs.attached["keyboard"];
  21436. if (keyboard) {
  21437. return keyboard.keysForward;
  21438. }
  21439. return [];
  21440. },
  21441. /**
  21442. * Set the keys for camera movement forward.
  21443. */
  21444. set: function (value) {
  21445. var keyboard = this.inputs.attached["keyboard"];
  21446. if (keyboard) {
  21447. keyboard.keysForward = value;
  21448. }
  21449. },
  21450. enumerable: true,
  21451. configurable: true
  21452. });
  21453. Object.defineProperty(FlyCamera.prototype, "keysBackward", {
  21454. /**
  21455. * Get the keys for camera movement backward.
  21456. */
  21457. get: function () {
  21458. var keyboard = this.inputs.attached["keyboard"];
  21459. if (keyboard) {
  21460. return keyboard.keysBackward;
  21461. }
  21462. return [];
  21463. },
  21464. set: function (value) {
  21465. var keyboard = this.inputs.attached["keyboard"];
  21466. if (keyboard) {
  21467. keyboard.keysBackward = value;
  21468. }
  21469. },
  21470. enumerable: true,
  21471. configurable: true
  21472. });
  21473. Object.defineProperty(FlyCamera.prototype, "keysUp", {
  21474. /**
  21475. * Get the keys for camera movement up.
  21476. */
  21477. get: function () {
  21478. var keyboard = this.inputs.attached["keyboard"];
  21479. if (keyboard) {
  21480. return keyboard.keysUp;
  21481. }
  21482. return [];
  21483. },
  21484. /**
  21485. * Set the keys for camera movement up.
  21486. */
  21487. set: function (value) {
  21488. var keyboard = this.inputs.attached["keyboard"];
  21489. if (keyboard) {
  21490. keyboard.keysUp = value;
  21491. }
  21492. },
  21493. enumerable: true,
  21494. configurable: true
  21495. });
  21496. Object.defineProperty(FlyCamera.prototype, "keysDown", {
  21497. /**
  21498. * Get the keys for camera movement down.
  21499. */
  21500. get: function () {
  21501. var keyboard = this.inputs.attached["keyboard"];
  21502. if (keyboard) {
  21503. return keyboard.keysDown;
  21504. }
  21505. return [];
  21506. },
  21507. /**
  21508. * Set the keys for camera movement down.
  21509. */
  21510. set: function (value) {
  21511. var keyboard = this.inputs.attached["keyboard"];
  21512. if (keyboard) {
  21513. keyboard.keysDown = value;
  21514. }
  21515. },
  21516. enumerable: true,
  21517. configurable: true
  21518. });
  21519. Object.defineProperty(FlyCamera.prototype, "keysLeft", {
  21520. /**
  21521. * Get the keys for camera movement left.
  21522. */
  21523. get: function () {
  21524. var keyboard = this.inputs.attached["keyboard"];
  21525. if (keyboard) {
  21526. return keyboard.keysLeft;
  21527. }
  21528. return [];
  21529. },
  21530. /**
  21531. * Set the keys for camera movement left.
  21532. */
  21533. set: function (value) {
  21534. var keyboard = this.inputs.attached["keyboard"];
  21535. if (keyboard) {
  21536. keyboard.keysLeft = value;
  21537. }
  21538. },
  21539. enumerable: true,
  21540. configurable: true
  21541. });
  21542. Object.defineProperty(FlyCamera.prototype, "keysRight", {
  21543. /**
  21544. * Set the keys for camera movement right.
  21545. */
  21546. get: function () {
  21547. var keyboard = this.inputs.attached["keyboard"];
  21548. if (keyboard) {
  21549. return keyboard.keysRight;
  21550. }
  21551. return [];
  21552. },
  21553. /**
  21554. * Set the keys for camera movement right.
  21555. */
  21556. set: function (value) {
  21557. var keyboard = this.inputs.attached["keyboard"];
  21558. if (keyboard) {
  21559. keyboard.keysRight = value;
  21560. }
  21561. },
  21562. enumerable: true,
  21563. configurable: true
  21564. });
  21565. /**
  21566. * Attach a control to the HTML DOM element.
  21567. * @param element Defines the element that listens to the input events.
  21568. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  21569. */
  21570. FlyCamera.prototype.attachControl = function (element, noPreventDefault) {
  21571. this.inputs.attachElement(element, noPreventDefault);
  21572. };
  21573. /**
  21574. * Detach a control from the HTML DOM element.
  21575. * The camera will stop reacting to that input.
  21576. * @param element Defines the element that listens to the input events.
  21577. */
  21578. FlyCamera.prototype.detachControl = function (element) {
  21579. this.inputs.detachElement(element);
  21580. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  21581. };
  21582. Object.defineProperty(FlyCamera.prototype, "collisionMask", {
  21583. /**
  21584. * Get the mask that the camera ignores in collision events.
  21585. */
  21586. get: function () {
  21587. return this._collisionMask;
  21588. },
  21589. /**
  21590. * Set the mask that the camera ignores in collision events.
  21591. */
  21592. set: function (mask) {
  21593. this._collisionMask = !isNaN(mask) ? mask : -1;
  21594. },
  21595. enumerable: true,
  21596. configurable: true
  21597. });
  21598. /** @hidden */
  21599. FlyCamera.prototype._collideWithWorld = function (displacement) {
  21600. var globalPosition;
  21601. if (this.parent) {
  21602. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  21603. }
  21604. else {
  21605. globalPosition = this.position;
  21606. }
  21607. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  21608. this._oldPosition.addInPlace(this.ellipsoidOffset);
  21609. var coordinator = this.getScene().collisionCoordinator;
  21610. if (!this._collider) {
  21611. this._collider = coordinator.createCollider();
  21612. }
  21613. this._collider._radius = this.ellipsoid;
  21614. this._collider.collisionMask = this._collisionMask;
  21615. // No need for clone, as long as gravity is not on.
  21616. var actualDisplacement = displacement;
  21617. // Add gravity to direction to prevent dual-collision checking.
  21618. if (this.applyGravity) {
  21619. // This prevents mending with cameraDirection, a global variable of the fly camera class.
  21620. actualDisplacement = displacement.add(this.getScene().gravity);
  21621. }
  21622. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  21623. };
  21624. /** @hidden */
  21625. FlyCamera.prototype._checkInputs = function () {
  21626. if (!this._localDirection) {
  21627. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21628. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21629. }
  21630. this.inputs.checkInputs();
  21631. _super.prototype._checkInputs.call(this);
  21632. };
  21633. /** @hidden */
  21634. FlyCamera.prototype._decideIfNeedsToMove = function () {
  21635. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  21636. };
  21637. /** @hidden */
  21638. FlyCamera.prototype._updatePosition = function () {
  21639. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  21640. this._collideWithWorld(this.cameraDirection);
  21641. }
  21642. else {
  21643. _super.prototype._updatePosition.call(this);
  21644. }
  21645. };
  21646. /**
  21647. * Restore the Roll to its target value at the rate specified.
  21648. * @param rate - Higher means slower restoring.
  21649. * @hidden
  21650. */
  21651. FlyCamera.prototype.restoreRoll = function (rate) {
  21652. var limit = this._trackRoll; // Target Roll.
  21653. var z = this.rotation.z; // Current Roll.
  21654. var delta = limit - z; // Difference in Roll.
  21655. var minRad = 0.001; // Tenth of a radian is a barely noticable difference.
  21656. // If the difference is noticable, restore the Roll.
  21657. if (Math.abs(delta) >= minRad) {
  21658. // Change Z rotation towards the target Roll.
  21659. this.rotation.z += delta / rate;
  21660. // Match when near enough.
  21661. if (Math.abs(limit - this.rotation.z) <= minRad) {
  21662. this.rotation.z = limit;
  21663. }
  21664. }
  21665. };
  21666. /**
  21667. * Destroy the camera and release the current resources held by it.
  21668. */
  21669. FlyCamera.prototype.dispose = function () {
  21670. this.inputs.clear();
  21671. _super.prototype.dispose.call(this);
  21672. };
  21673. /**
  21674. * Get the current object class name.
  21675. * @returns the class name.
  21676. */
  21677. FlyCamera.prototype.getClassName = function () {
  21678. return "FlyCamera";
  21679. };
  21680. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21681. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21682. ], FlyCamera.prototype, "ellipsoid", void 0);
  21683. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21684. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21685. ], FlyCamera.prototype, "ellipsoidOffset", void 0);
  21686. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21687. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21688. ], FlyCamera.prototype, "checkCollisions", void 0);
  21689. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21690. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21691. ], FlyCamera.prototype, "applyGravity", void 0);
  21692. return FlyCamera;
  21693. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  21694. /***/ }),
  21695. /***/ "./Cameras/flyCameraInputsManager.ts":
  21696. /*!*******************************************!*\
  21697. !*** ./Cameras/flyCameraInputsManager.ts ***!
  21698. \*******************************************/
  21699. /*! exports provided: FlyCameraInputsManager */
  21700. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21701. "use strict";
  21702. __webpack_require__.r(__webpack_exports__);
  21703. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return FlyCameraInputsManager; });
  21704. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21705. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  21706. /* harmony import */ var _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  21707. /* harmony import */ var _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  21708. /**
  21709. * Default Inputs manager for the FlyCamera.
  21710. * It groups all the default supported inputs for ease of use.
  21711. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21712. */
  21713. var FlyCameraInputsManager = /** @class */ (function (_super) {
  21714. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCameraInputsManager, _super);
  21715. /**
  21716. * Instantiates a new FlyCameraInputsManager.
  21717. * @param camera Defines the camera the inputs belong to.
  21718. */
  21719. function FlyCameraInputsManager(camera) {
  21720. return _super.call(this, camera) || this;
  21721. }
  21722. /**
  21723. * Add keyboard input support to the input manager.
  21724. * @returns the new FlyCameraKeyboardMoveInput().
  21725. */
  21726. FlyCameraInputsManager.prototype.addKeyboard = function () {
  21727. this.add(new _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__["FlyCameraKeyboardInput"]());
  21728. return this;
  21729. };
  21730. /**
  21731. * Add mouse input support to the input manager.
  21732. * @param touchEnabled Enable touch screen support.
  21733. * @returns the new FlyCameraMouseInput().
  21734. */
  21735. FlyCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  21736. if (touchEnabled === void 0) { touchEnabled = true; }
  21737. this.add(new _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__["FlyCameraMouseInput"](touchEnabled));
  21738. return this;
  21739. };
  21740. return FlyCameraInputsManager;
  21741. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  21742. /***/ }),
  21743. /***/ "./Cameras/followCamera.ts":
  21744. /*!*********************************!*\
  21745. !*** ./Cameras/followCamera.ts ***!
  21746. \*********************************/
  21747. /*! exports provided: FollowCamera, ArcFollowCamera */
  21748. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21749. "use strict";
  21750. __webpack_require__.r(__webpack_exports__);
  21751. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return FollowCamera; });
  21752. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return ArcFollowCamera; });
  21753. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21754. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21755. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  21756. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21757. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21758. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../node */ "./node.ts");
  21759. /* harmony import */ var _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./followCameraInputsManager */ "./Cameras/followCameraInputsManager.ts");
  21760. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("FollowCamera", function (name, scene) {
  21761. return function () { return new FollowCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  21762. });
  21763. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("ArcFollowCamera", function (name, scene) {
  21764. return function () { return new ArcFollowCamera(name, 0, 0, 1.0, null, scene); };
  21765. });
  21766. /**
  21767. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  21768. * an arc rotate version arcFollowCamera are available.
  21769. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21770. */
  21771. var FollowCamera = /** @class */ (function (_super) {
  21772. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCamera, _super);
  21773. /**
  21774. * Instantiates the follow camera.
  21775. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21776. * @param name Define the name of the camera in the scene
  21777. * @param position Define the position of the camera
  21778. * @param scene Define the scene the camera belong to
  21779. * @param lockedTarget Define the target of the camera
  21780. */
  21781. function FollowCamera(name, position, scene, lockedTarget) {
  21782. if (lockedTarget === void 0) { lockedTarget = null; }
  21783. var _this = _super.call(this, name, position, scene) || this;
  21784. /**
  21785. * Distance the follow camera should follow an object at
  21786. */
  21787. _this.radius = 12;
  21788. /**
  21789. * Minimum allowed distance of the camera to the axis of rotation
  21790. * (The camera can not get closer).
  21791. * This can help limiting how the Camera is able to move in the scene.
  21792. */
  21793. _this.lowerRadiusLimit = null;
  21794. /**
  21795. * Maximum allowed distance of the camera to the axis of rotation
  21796. * (The camera can not get further).
  21797. * This can help limiting how the Camera is able to move in the scene.
  21798. */
  21799. _this.upperRadiusLimit = null;
  21800. /**
  21801. * Define a rotation offset between the camera and the object it follows
  21802. */
  21803. _this.rotationOffset = 0;
  21804. /**
  21805. * Minimum allowed angle to camera position relative to target object.
  21806. * This can help limiting how the Camera is able to move in the scene.
  21807. */
  21808. _this.lowerRotationOffsetLimit = null;
  21809. /**
  21810. * Maximum allowed angle to camera position relative to target object.
  21811. * This can help limiting how the Camera is able to move in the scene.
  21812. */
  21813. _this.upperRotationOffsetLimit = null;
  21814. /**
  21815. * Define a height offset between the camera and the object it follows.
  21816. * It can help following an object from the top (like a car chaing a plane)
  21817. */
  21818. _this.heightOffset = 4;
  21819. /**
  21820. * Minimum allowed height of camera position relative to target object.
  21821. * This can help limiting how the Camera is able to move in the scene.
  21822. */
  21823. _this.lowerHeightOffsetLimit = null;
  21824. /**
  21825. * Maximum allowed height of camera position relative to target object.
  21826. * This can help limiting how the Camera is able to move in the scene.
  21827. */
  21828. _this.upperHeightOffsetLimit = null;
  21829. /**
  21830. * Define how fast the camera can accelerate to follow it s target.
  21831. */
  21832. _this.cameraAcceleration = 0.05;
  21833. /**
  21834. * Define the speed limit of the camera following an object.
  21835. */
  21836. _this.maxCameraSpeed = 20;
  21837. _this.lockedTarget = lockedTarget;
  21838. _this.inputs = new _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__["FollowCameraInputsManager"](_this);
  21839. _this.inputs.addKeyboard().addMouseWheel();
  21840. return _this;
  21841. // Uncomment the following line when the relevant handlers have been implemented.
  21842. // this.inputs.addKeyboard().addMouseWheel().addPointers().addVRDeviceOrientation();
  21843. }
  21844. FollowCamera.prototype._follow = function (cameraTarget) {
  21845. if (!cameraTarget) {
  21846. return;
  21847. }
  21848. var yRotation;
  21849. if (cameraTarget.rotationQuaternion) {
  21850. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  21851. cameraTarget.rotationQuaternion.toRotationMatrix(rotMatrix);
  21852. yRotation = Math.atan2(rotMatrix.m[8], rotMatrix.m[10]);
  21853. }
  21854. else {
  21855. yRotation = cameraTarget.rotation.y;
  21856. }
  21857. var radians = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this.rotationOffset) + yRotation;
  21858. var targetPosition = cameraTarget.getAbsolutePosition();
  21859. var targetX = targetPosition.x + Math.sin(radians) * this.radius;
  21860. var targetZ = targetPosition.z + Math.cos(radians) * this.radius;
  21861. var dx = targetX - this.position.x;
  21862. var dy = (targetPosition.y + this.heightOffset) - this.position.y;
  21863. var dz = (targetZ) - this.position.z;
  21864. var vx = dx * this.cameraAcceleration * 2; //this is set to .05
  21865. var vy = dy * this.cameraAcceleration;
  21866. var vz = dz * this.cameraAcceleration * 2;
  21867. if (vx > this.maxCameraSpeed || vx < -this.maxCameraSpeed) {
  21868. vx = vx < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21869. }
  21870. if (vy > this.maxCameraSpeed || vy < -this.maxCameraSpeed) {
  21871. vy = vy < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21872. }
  21873. if (vz > this.maxCameraSpeed || vz < -this.maxCameraSpeed) {
  21874. vz = vz < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21875. }
  21876. this.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](this.position.x + vx, this.position.y + vy, this.position.z + vz);
  21877. this.setTarget(targetPosition);
  21878. };
  21879. /**
  21880. * Attached controls to the current camera.
  21881. * @param element Defines the element the controls should be listened from
  21882. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21883. */
  21884. FollowCamera.prototype.attachControl = function (element, noPreventDefault) {
  21885. this.inputs.attachElement(element, noPreventDefault);
  21886. this._reset = function () {
  21887. };
  21888. };
  21889. /**
  21890. * Detach the current controls from the camera.
  21891. * The camera will stop reacting to inputs.
  21892. * @param element Defines the element to stop listening the inputs from
  21893. */
  21894. FollowCamera.prototype.detachControl = function (element) {
  21895. this.inputs.detachElement(element);
  21896. if (this._reset) {
  21897. this._reset();
  21898. }
  21899. };
  21900. /** @hidden */
  21901. FollowCamera.prototype._checkInputs = function () {
  21902. this.inputs.checkInputs();
  21903. this._checkLimits();
  21904. _super.prototype._checkInputs.call(this);
  21905. if (this.lockedTarget) {
  21906. this._follow(this.lockedTarget);
  21907. }
  21908. };
  21909. FollowCamera.prototype._checkLimits = function () {
  21910. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  21911. this.radius = this.lowerRadiusLimit;
  21912. }
  21913. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  21914. this.radius = this.upperRadiusLimit;
  21915. }
  21916. if (this.lowerHeightOffsetLimit !== null &&
  21917. this.heightOffset < this.lowerHeightOffsetLimit) {
  21918. this.heightOffset = this.lowerHeightOffsetLimit;
  21919. }
  21920. if (this.upperHeightOffsetLimit !== null &&
  21921. this.heightOffset > this.upperHeightOffsetLimit) {
  21922. this.heightOffset = this.upperHeightOffsetLimit;
  21923. }
  21924. if (this.lowerRotationOffsetLimit !== null &&
  21925. this.rotationOffset < this.lowerRotationOffsetLimit) {
  21926. this.rotationOffset = this.lowerRotationOffsetLimit;
  21927. }
  21928. if (this.upperRotationOffsetLimit !== null &&
  21929. this.rotationOffset > this.upperRotationOffsetLimit) {
  21930. this.rotationOffset = this.upperRotationOffsetLimit;
  21931. }
  21932. };
  21933. /**
  21934. * Gets the camera class name.
  21935. * @returns the class name
  21936. */
  21937. FollowCamera.prototype.getClassName = function () {
  21938. return "FollowCamera";
  21939. };
  21940. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21941. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21942. ], FollowCamera.prototype, "radius", void 0);
  21943. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21944. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21945. ], FollowCamera.prototype, "lowerRadiusLimit", void 0);
  21946. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21947. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21948. ], FollowCamera.prototype, "upperRadiusLimit", void 0);
  21949. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21950. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21951. ], FollowCamera.prototype, "rotationOffset", void 0);
  21952. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21953. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21954. ], FollowCamera.prototype, "lowerRotationOffsetLimit", void 0);
  21955. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21956. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21957. ], FollowCamera.prototype, "upperRotationOffsetLimit", void 0);
  21958. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21959. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21960. ], FollowCamera.prototype, "heightOffset", void 0);
  21961. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21962. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21963. ], FollowCamera.prototype, "lowerHeightOffsetLimit", void 0);
  21964. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21965. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21966. ], FollowCamera.prototype, "upperHeightOffsetLimit", void 0);
  21967. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21968. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21969. ], FollowCamera.prototype, "cameraAcceleration", void 0);
  21970. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21971. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21972. ], FollowCamera.prototype, "maxCameraSpeed", void 0);
  21973. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21974. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  21975. ], FollowCamera.prototype, "lockedTarget", void 0);
  21976. return FollowCamera;
  21977. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  21978. /**
  21979. * Arc Rotate version of the follow camera.
  21980. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  21981. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21982. */
  21983. var ArcFollowCamera = /** @class */ (function (_super) {
  21984. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcFollowCamera, _super);
  21985. /**
  21986. * Instantiates a new ArcFollowCamera
  21987. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21988. * @param name Define the name of the camera
  21989. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  21990. * @param beta Define the rotation angle of the camera around the elevation axis
  21991. * @param radius Define the radius of the camera from its target point
  21992. * @param target Define the target of the camera
  21993. * @param scene Define the scene the camera belongs to
  21994. */
  21995. function ArcFollowCamera(name,
  21996. /** The longitudinal angle of the camera */
  21997. alpha,
  21998. /** The latitudinal angle of the camera */
  21999. beta,
  22000. /** The radius of the camera from its target */
  22001. radius,
  22002. /** Define the camera target (the messh it should follow) */
  22003. target, scene) {
  22004. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene) || this;
  22005. _this.alpha = alpha;
  22006. _this.beta = beta;
  22007. _this.radius = radius;
  22008. _this.target = target;
  22009. _this._cartesianCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  22010. _this._follow();
  22011. return _this;
  22012. }
  22013. ArcFollowCamera.prototype._follow = function () {
  22014. if (!this.target) {
  22015. return;
  22016. }
  22017. this._cartesianCoordinates.x = this.radius * Math.cos(this.alpha) * Math.cos(this.beta);
  22018. this._cartesianCoordinates.y = this.radius * Math.sin(this.beta);
  22019. this._cartesianCoordinates.z = this.radius * Math.sin(this.alpha) * Math.cos(this.beta);
  22020. var targetPosition = this.target.getAbsolutePosition();
  22021. this.position = targetPosition.add(this._cartesianCoordinates);
  22022. this.setTarget(targetPosition);
  22023. };
  22024. /** @hidden */
  22025. ArcFollowCamera.prototype._checkInputs = function () {
  22026. _super.prototype._checkInputs.call(this);
  22027. this._follow();
  22028. };
  22029. /**
  22030. * Returns the class name of the object.
  22031. * It is mostly used internally for serialization purposes.
  22032. */
  22033. ArcFollowCamera.prototype.getClassName = function () {
  22034. return "ArcFollowCamera";
  22035. };
  22036. return ArcFollowCamera;
  22037. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  22038. /***/ }),
  22039. /***/ "./Cameras/followCameraInputsManager.ts":
  22040. /*!**********************************************!*\
  22041. !*** ./Cameras/followCameraInputsManager.ts ***!
  22042. \**********************************************/
  22043. /*! exports provided: FollowCameraInputsManager */
  22044. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22045. "use strict";
  22046. __webpack_require__.r(__webpack_exports__);
  22047. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraInputsManager", function() { return FollowCameraInputsManager; });
  22048. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22049. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22050. /* harmony import */ var _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Inputs/followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  22051. /* harmony import */ var _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Inputs/followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  22052. /**
  22053. * Default Inputs manager for the FollowCamera.
  22054. * It groups all the default supported inputs for ease of use.
  22055. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22056. */
  22057. var FollowCameraInputsManager = /** @class */ (function (_super) {
  22058. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraInputsManager, _super);
  22059. /**
  22060. * Instantiates a new FollowCameraInputsManager.
  22061. * @param camera Defines the camera the inputs belong to
  22062. */
  22063. function FollowCameraInputsManager(camera) {
  22064. return _super.call(this, camera) || this;
  22065. }
  22066. /**
  22067. * Add keyboard input support to the input manager.
  22068. * @returns the current input manager
  22069. */
  22070. FollowCameraInputsManager.prototype.addKeyboard = function () {
  22071. this.add(new _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FollowCameraKeyboardMoveInput"]());
  22072. return this;
  22073. };
  22074. /**
  22075. * Add mouse wheel input support to the input manager.
  22076. * @returns the current input manager
  22077. */
  22078. FollowCameraInputsManager.prototype.addMouseWheel = function () {
  22079. this.add(new _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["FollowCameraMouseWheelInput"]());
  22080. return this;
  22081. };
  22082. /**
  22083. * Add pointers input support to the input manager.
  22084. * @returns the current input manager
  22085. */
  22086. FollowCameraInputsManager.prototype.addPointers = function () {
  22087. console.warn("Pointer support not yet implemented for FollowCamera.");
  22088. return this;
  22089. };
  22090. /**
  22091. * Add orientation input support to the input manager.
  22092. * @returns the current input manager
  22093. */
  22094. FollowCameraInputsManager.prototype.addVRDeviceOrientation = function () {
  22095. console.warn("DeviceOrientation support not yet implemented for FollowCamera.");
  22096. return this;
  22097. };
  22098. return FollowCameraInputsManager;
  22099. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22100. /***/ }),
  22101. /***/ "./Cameras/freeCamera.ts":
  22102. /*!*******************************!*\
  22103. !*** ./Cameras/freeCamera.ts ***!
  22104. \*******************************/
  22105. /*! exports provided: FreeCamera */
  22106. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22107. "use strict";
  22108. __webpack_require__.r(__webpack_exports__);
  22109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return FreeCamera; });
  22110. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22111. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22112. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22113. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  22114. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22115. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  22116. /**
  22117. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22118. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  22119. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22120. */
  22121. var FreeCamera = /** @class */ (function (_super) {
  22122. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCamera, _super);
  22123. /**
  22124. * Instantiates a Free Camera.
  22125. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22126. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  22127. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22128. * @param name Define the name of the camera in the scene
  22129. * @param position Define the start position of the camera in the scene
  22130. * @param scene Define the scene the camera belongs to
  22131. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  22132. */
  22133. function FreeCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22134. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22135. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22136. /**
  22137. * Define the collision ellipsoid of the camera.
  22138. * This is helpful to simulate a camera body like the player body around the camera
  22139. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  22140. */
  22141. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.5, 1, 0.5);
  22142. /**
  22143. * Define an offset for the position of the ellipsoid around the camera.
  22144. * This can be helpful to determine the center of the body near the gravity center of the body
  22145. * instead of its head.
  22146. */
  22147. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22148. /**
  22149. * Enable or disable collisions of the camera with the rest of the scene objects.
  22150. */
  22151. _this.checkCollisions = false;
  22152. /**
  22153. * Enable or disable gravity on the camera.
  22154. */
  22155. _this.applyGravity = false;
  22156. _this._needMoveForGravity = false;
  22157. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22158. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22159. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22160. // Collisions
  22161. _this._collisionMask = -1;
  22162. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  22163. if (collidedMesh === void 0) { collidedMesh = null; }
  22164. var updatePosition = function (newPos) {
  22165. _this._newPosition.copyFrom(newPos);
  22166. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  22167. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  22168. _this.position.addInPlace(_this._diffPosition);
  22169. if (_this.onCollide && collidedMesh) {
  22170. _this.onCollide(collidedMesh);
  22171. }
  22172. }
  22173. };
  22174. updatePosition(newPosition);
  22175. };
  22176. _this.inputs = new _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"](_this);
  22177. _this.inputs.addKeyboard().addMouse();
  22178. return _this;
  22179. }
  22180. Object.defineProperty(FreeCamera.prototype, "angularSensibility", {
  22181. /**
  22182. * Gets the input sensibility for a mouse input. (default is 2000.0)
  22183. * Higher values reduce sensitivity.
  22184. */
  22185. get: function () {
  22186. var mouse = this.inputs.attached["mouse"];
  22187. if (mouse) {
  22188. return mouse.angularSensibility;
  22189. }
  22190. return 0;
  22191. },
  22192. /**
  22193. * Sets the input sensibility for a mouse input. (default is 2000.0)
  22194. * Higher values reduce sensitivity.
  22195. */
  22196. set: function (value) {
  22197. var mouse = this.inputs.attached["mouse"];
  22198. if (mouse) {
  22199. mouse.angularSensibility = value;
  22200. }
  22201. },
  22202. enumerable: true,
  22203. configurable: true
  22204. });
  22205. Object.defineProperty(FreeCamera.prototype, "keysUp", {
  22206. /**
  22207. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  22208. */
  22209. get: function () {
  22210. var keyboard = this.inputs.attached["keyboard"];
  22211. if (keyboard) {
  22212. return keyboard.keysUp;
  22213. }
  22214. return [];
  22215. },
  22216. set: function (value) {
  22217. var keyboard = this.inputs.attached["keyboard"];
  22218. if (keyboard) {
  22219. keyboard.keysUp = value;
  22220. }
  22221. },
  22222. enumerable: true,
  22223. configurable: true
  22224. });
  22225. Object.defineProperty(FreeCamera.prototype, "keysDown", {
  22226. /**
  22227. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  22228. */
  22229. get: function () {
  22230. var keyboard = this.inputs.attached["keyboard"];
  22231. if (keyboard) {
  22232. return keyboard.keysDown;
  22233. }
  22234. return [];
  22235. },
  22236. set: function (value) {
  22237. var keyboard = this.inputs.attached["keyboard"];
  22238. if (keyboard) {
  22239. keyboard.keysDown = value;
  22240. }
  22241. },
  22242. enumerable: true,
  22243. configurable: true
  22244. });
  22245. Object.defineProperty(FreeCamera.prototype, "keysLeft", {
  22246. /**
  22247. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  22248. */
  22249. get: function () {
  22250. var keyboard = this.inputs.attached["keyboard"];
  22251. if (keyboard) {
  22252. return keyboard.keysLeft;
  22253. }
  22254. return [];
  22255. },
  22256. set: function (value) {
  22257. var keyboard = this.inputs.attached["keyboard"];
  22258. if (keyboard) {
  22259. keyboard.keysLeft = value;
  22260. }
  22261. },
  22262. enumerable: true,
  22263. configurable: true
  22264. });
  22265. Object.defineProperty(FreeCamera.prototype, "keysRight", {
  22266. /**
  22267. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  22268. */
  22269. get: function () {
  22270. var keyboard = this.inputs.attached["keyboard"];
  22271. if (keyboard) {
  22272. return keyboard.keysRight;
  22273. }
  22274. return [];
  22275. },
  22276. set: function (value) {
  22277. var keyboard = this.inputs.attached["keyboard"];
  22278. if (keyboard) {
  22279. keyboard.keysRight = value;
  22280. }
  22281. },
  22282. enumerable: true,
  22283. configurable: true
  22284. });
  22285. /**
  22286. * Attached controls to the current camera.
  22287. * @param element Defines the element the controls should be listened from
  22288. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  22289. */
  22290. FreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  22291. this.inputs.attachElement(element, noPreventDefault);
  22292. };
  22293. /**
  22294. * Detach the current controls from the camera.
  22295. * The camera will stop reacting to inputs.
  22296. * @param element Defines the element to stop listening the inputs from
  22297. */
  22298. FreeCamera.prototype.detachControl = function (element) {
  22299. this.inputs.detachElement(element);
  22300. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22301. this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](0, 0);
  22302. };
  22303. Object.defineProperty(FreeCamera.prototype, "collisionMask", {
  22304. /**
  22305. * Define a collision mask to limit the list of object the camera can collide with
  22306. */
  22307. get: function () {
  22308. return this._collisionMask;
  22309. },
  22310. set: function (mask) {
  22311. this._collisionMask = !isNaN(mask) ? mask : -1;
  22312. },
  22313. enumerable: true,
  22314. configurable: true
  22315. });
  22316. /** @hidden */
  22317. FreeCamera.prototype._collideWithWorld = function (displacement) {
  22318. var globalPosition;
  22319. if (this.parent) {
  22320. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  22321. }
  22322. else {
  22323. globalPosition = this.position;
  22324. }
  22325. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  22326. this._oldPosition.addInPlace(this.ellipsoidOffset);
  22327. var coordinator = this.getScene().collisionCoordinator;
  22328. if (!this._collider) {
  22329. this._collider = coordinator.createCollider();
  22330. }
  22331. this._collider._radius = this.ellipsoid;
  22332. this._collider.collisionMask = this._collisionMask;
  22333. //no need for clone, as long as gravity is not on.
  22334. var actualDisplacement = displacement;
  22335. //add gravity to the direction to prevent the dual-collision checking
  22336. if (this.applyGravity) {
  22337. //this prevents mending with cameraDirection, a global variable of the free camera class.
  22338. actualDisplacement = displacement.add(this.getScene().gravity);
  22339. }
  22340. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  22341. };
  22342. /** @hidden */
  22343. FreeCamera.prototype._checkInputs = function () {
  22344. if (!this._localDirection) {
  22345. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22346. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22347. }
  22348. this.inputs.checkInputs();
  22349. _super.prototype._checkInputs.call(this);
  22350. };
  22351. /** @hidden */
  22352. FreeCamera.prototype._decideIfNeedsToMove = function () {
  22353. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22354. };
  22355. /** @hidden */
  22356. FreeCamera.prototype._updatePosition = function () {
  22357. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  22358. this._collideWithWorld(this.cameraDirection);
  22359. }
  22360. else {
  22361. _super.prototype._updatePosition.call(this);
  22362. }
  22363. };
  22364. /**
  22365. * Destroy the camera and release the current resources hold by it.
  22366. */
  22367. FreeCamera.prototype.dispose = function () {
  22368. this.inputs.clear();
  22369. _super.prototype.dispose.call(this);
  22370. };
  22371. /**
  22372. * Gets the current object class name.
  22373. * @return the class name
  22374. */
  22375. FreeCamera.prototype.getClassName = function () {
  22376. return "FreeCamera";
  22377. };
  22378. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22379. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22380. ], FreeCamera.prototype, "ellipsoid", void 0);
  22381. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22382. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22383. ], FreeCamera.prototype, "ellipsoidOffset", void 0);
  22384. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22385. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22386. ], FreeCamera.prototype, "checkCollisions", void 0);
  22387. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22388. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22389. ], FreeCamera.prototype, "applyGravity", void 0);
  22390. return FreeCamera;
  22391. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  22392. /***/ }),
  22393. /***/ "./Cameras/freeCameraInputsManager.ts":
  22394. /*!********************************************!*\
  22395. !*** ./Cameras/freeCameraInputsManager.ts ***!
  22396. \********************************************/
  22397. /*! exports provided: FreeCameraInputsManager */
  22398. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22399. "use strict";
  22400. __webpack_require__.r(__webpack_exports__);
  22401. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return FreeCameraInputsManager; });
  22402. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22403. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22404. /* harmony import */ var _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  22405. /* harmony import */ var _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  22406. /* harmony import */ var _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  22407. /**
  22408. * Default Inputs manager for the FreeCamera.
  22409. * It groups all the default supported inputs for ease of use.
  22410. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22411. */
  22412. var FreeCameraInputsManager = /** @class */ (function (_super) {
  22413. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCameraInputsManager, _super);
  22414. /**
  22415. * Instantiates a new FreeCameraInputsManager.
  22416. * @param camera Defines the camera the inputs belong to
  22417. */
  22418. function FreeCameraInputsManager(camera) {
  22419. return _super.call(this, camera) || this;
  22420. }
  22421. /**
  22422. * Add keyboard input support to the input manager.
  22423. * @returns the current input manager
  22424. */
  22425. FreeCameraInputsManager.prototype.addKeyboard = function () {
  22426. this.add(new _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FreeCameraKeyboardMoveInput"]());
  22427. return this;
  22428. };
  22429. /**
  22430. * Add mouse input support to the input manager.
  22431. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  22432. * @returns the current input manager
  22433. */
  22434. FreeCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  22435. if (touchEnabled === void 0) { touchEnabled = true; }
  22436. this.add(new _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__["FreeCameraMouseInput"](touchEnabled));
  22437. return this;
  22438. };
  22439. /**
  22440. * Add touch input support to the input manager.
  22441. * @returns the current input manager
  22442. */
  22443. FreeCameraInputsManager.prototype.addTouch = function () {
  22444. this.add(new _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraTouchInput"]());
  22445. return this;
  22446. };
  22447. return FreeCameraInputsManager;
  22448. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22449. /***/ }),
  22450. /***/ "./Cameras/gamepadCamera.ts":
  22451. /*!**********************************!*\
  22452. !*** ./Cameras/gamepadCamera.ts ***!
  22453. \**********************************/
  22454. /*! exports provided: GamepadCamera */
  22455. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22456. "use strict";
  22457. __webpack_require__.r(__webpack_exports__);
  22458. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return GamepadCamera; });
  22459. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22460. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  22461. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22462. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  22463. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("GamepadCamera", function (name, scene) {
  22464. return function () { return new GamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  22465. });
  22466. /**
  22467. * This represents a FPS type of camera. This is only here for back compat purpose.
  22468. * Please use the UniversalCamera instead as both are identical.
  22469. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22470. */
  22471. var GamepadCamera = /** @class */ (function (_super) {
  22472. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GamepadCamera, _super);
  22473. /**
  22474. * Instantiates a new Gamepad Camera
  22475. * This represents a FPS type of camera. This is only here for back compat purpose.
  22476. * Please use the UniversalCamera instead as both are identical.
  22477. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22478. * @param name Define the name of the camera in the scene
  22479. * @param position Define the start position of the camera in the scene
  22480. * @param scene Define the scene the camera belongs to
  22481. */
  22482. function GamepadCamera(name, position, scene) {
  22483. return _super.call(this, name, position, scene) || this;
  22484. }
  22485. /**
  22486. * Gets the current object class name.
  22487. * @return the class name
  22488. */
  22489. GamepadCamera.prototype.getClassName = function () {
  22490. return "GamepadCamera";
  22491. };
  22492. return GamepadCamera;
  22493. }(_universalCamera__WEBPACK_IMPORTED_MODULE_1__["UniversalCamera"]));
  22494. /***/ }),
  22495. /***/ "./Cameras/index.ts":
  22496. /*!**************************!*\
  22497. !*** ./Cameras/index.ts ***!
  22498. \**************************/
  22499. /*! 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 */
  22500. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22501. "use strict";
  22502. __webpack_require__.r(__webpack_exports__);
  22503. /* harmony import */ var _Inputs_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Inputs/index */ "./Cameras/Inputs/index.ts");
  22504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  22505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  22506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  22507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  22508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  22509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  22510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  22511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  22512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  22513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  22514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  22515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  22516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  22517. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]; });
  22519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]; });
  22520. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  22521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]; });
  22522. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]; });
  22524. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  22525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _freeCamera__WEBPACK_IMPORTED_MODULE_4__["FreeCamera"]; });
  22526. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  22527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"]; });
  22528. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  22529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _touchCamera__WEBPACK_IMPORTED_MODULE_6__["TouchCamera"]; });
  22530. /* harmony import */ var _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  22531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  22532. /* harmony import */ var _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  22533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__["ArcRotateCameraInputsManager"]; });
  22534. /* harmony import */ var _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  22535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__["DeviceOrientationCamera"]; });
  22536. /* harmony import */ var _flyCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./flyCamera */ "./Cameras/flyCamera.ts");
  22537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _flyCamera__WEBPACK_IMPORTED_MODULE_10__["FlyCamera"]; });
  22538. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  22539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["FlyCameraInputsManager"]; });
  22540. /* harmony import */ var _followCamera__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./followCamera */ "./Cameras/followCamera.ts");
  22541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["FollowCamera"]; });
  22542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["ArcFollowCamera"]; });
  22543. /* harmony import */ var _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./gamepadCamera */ "./Cameras/gamepadCamera.ts");
  22544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__["GamepadCamera"]; });
  22545. /* harmony import */ var _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Stereoscopic/index */ "./Cameras/Stereoscopic/index.ts");
  22546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphArcRotateCamera"]; });
  22547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphFreeCamera"]; });
  22548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphGamepadCamera"]; });
  22549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphUniversalCamera"]; });
  22550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicArcRotateCamera"]; });
  22551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicFreeCamera"]; });
  22552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicGamepadCamera"]; });
  22553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicUniversalCamera"]; });
  22554. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  22555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _universalCamera__WEBPACK_IMPORTED_MODULE_15__["UniversalCamera"]; });
  22556. /* harmony import */ var _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./virtualJoysticksCamera */ "./Cameras/virtualJoysticksCamera.ts");
  22557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__["VirtualJoysticksCamera"]; });
  22558. /* harmony import */ var _VR_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./VR/index */ "./Cameras/VR/index.ts");
  22559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRCameraMetrics"]; });
  22560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationArcRotateCamera"]; });
  22561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationFreeCamera"]; });
  22562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationGamepadCamera"]; });
  22563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRExperienceHelper"]; });
  22564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["WebVRFreeCamera"]; });
  22565. /* harmony import */ var _XR_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./XR/index */ "./Cameras/XR/index.ts");
  22566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRCamera"]; });
  22567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIButton"]; });
  22568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIOptions"]; });
  22569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUI"]; });
  22570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRState"]; });
  22571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRExperienceHelper"]; });
  22572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRController"]; });
  22573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRInput"]; });
  22574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRManagedOutputCanvas"]; });
  22575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRSessionManager"]; });
  22576. /***/ }),
  22577. /***/ "./Cameras/targetCamera.ts":
  22578. /*!*********************************!*\
  22579. !*** ./Cameras/targetCamera.ts ***!
  22580. \*********************************/
  22581. /*! exports provided: TargetCamera */
  22582. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22583. "use strict";
  22584. __webpack_require__.r(__webpack_exports__);
  22585. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return TargetCamera; });
  22586. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22587. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22588. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  22589. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22590. /**
  22591. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  22592. * This is the base of the follow, arc rotate cameras and Free camera
  22593. * @see http://doc.babylonjs.com/features/cameras
  22594. */
  22595. var TargetCamera = /** @class */ (function (_super) {
  22596. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TargetCamera, _super);
  22597. /**
  22598. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  22599. * This is the base of the follow, arc rotate cameras and Free camera
  22600. * @see http://doc.babylonjs.com/features/cameras
  22601. * @param name Defines the name of the camera in the scene
  22602. * @param position Defines the start position of the camera in the scene
  22603. * @param scene Defines the scene the camera belongs to
  22604. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  22605. */
  22606. function TargetCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22607. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22608. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22609. /**
  22610. * Define the current direction the camera is moving to
  22611. */
  22612. _this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  22613. /**
  22614. * Define the current rotation the camera is rotating to
  22615. */
  22616. _this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  22617. /**
  22618. * When set, the up vector of the camera will be updated by the rotation of the camera
  22619. */
  22620. _this.updateUpVectorFromRotation = false;
  22621. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22622. /**
  22623. * Define the current rotation of the camera
  22624. */
  22625. _this.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  22626. /**
  22627. * Define the current speed of the camera
  22628. */
  22629. _this.speed = 2.0;
  22630. /**
  22631. * Add cconstraint to the camera to prevent it to move freely in all directions and
  22632. * around all axis.
  22633. */
  22634. _this.noRotationConstraint = false;
  22635. /**
  22636. * Define the current target of the camera as an object or a position.
  22637. */
  22638. _this.lockedTarget = null;
  22639. /** @hidden */
  22640. _this._currentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22641. /** @hidden */
  22642. _this._initialFocalDistance = 1;
  22643. /** @hidden */
  22644. _this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22645. /** @hidden */
  22646. _this._camMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22647. /** @hidden */
  22648. _this._cameraTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22649. /** @hidden */
  22650. _this._cameraRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22651. /** @hidden */
  22652. _this._referencePoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  22653. /** @hidden */
  22654. _this._transformedReferencePoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22655. _this._globalCurrentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22656. _this._globalCurrentUpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22657. _this._defaultUp = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up();
  22658. _this._cachedRotationZ = 0;
  22659. _this._cachedQuaternionRotationZ = 0;
  22660. return _this;
  22661. }
  22662. /**
  22663. * Gets the position in front of the camera at a given distance.
  22664. * @param distance The distance from the camera we want the position to be
  22665. * @returns the position
  22666. */
  22667. TargetCamera.prototype.getFrontPosition = function (distance) {
  22668. this.getWorldMatrix();
  22669. var direction = this.getTarget().subtract(this.position);
  22670. direction.normalize();
  22671. direction.scaleInPlace(distance);
  22672. return this.globalPosition.add(direction);
  22673. };
  22674. /** @hidden */
  22675. TargetCamera.prototype._getLockedTargetPosition = function () {
  22676. if (!this.lockedTarget) {
  22677. return null;
  22678. }
  22679. if (this.lockedTarget.absolutePosition) {
  22680. this.lockedTarget.computeWorldMatrix();
  22681. }
  22682. return this.lockedTarget.absolutePosition || this.lockedTarget;
  22683. };
  22684. /**
  22685. * Store current camera state of the camera (fov, position, rotation, etc..)
  22686. * @returns the camera
  22687. */
  22688. TargetCamera.prototype.storeState = function () {
  22689. this._storedPosition = this.position.clone();
  22690. this._storedRotation = this.rotation.clone();
  22691. if (this.rotationQuaternion) {
  22692. this._storedRotationQuaternion = this.rotationQuaternion.clone();
  22693. }
  22694. return _super.prototype.storeState.call(this);
  22695. };
  22696. /**
  22697. * Restored camera state. You must call storeState() first
  22698. * @returns whether it was successful or not
  22699. * @hidden
  22700. */
  22701. TargetCamera.prototype._restoreStateValues = function () {
  22702. if (!_super.prototype._restoreStateValues.call(this)) {
  22703. return false;
  22704. }
  22705. this.position = this._storedPosition.clone();
  22706. this.rotation = this._storedRotation.clone();
  22707. if (this.rotationQuaternion) {
  22708. this.rotationQuaternion = this._storedRotationQuaternion.clone();
  22709. }
  22710. this.cameraDirection.copyFromFloats(0, 0, 0);
  22711. this.cameraRotation.copyFromFloats(0, 0);
  22712. return true;
  22713. };
  22714. /** @hidden */
  22715. TargetCamera.prototype._initCache = function () {
  22716. _super.prototype._initCache.call(this);
  22717. this._cache.lockedTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22718. this._cache.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22719. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22720. };
  22721. /** @hidden */
  22722. TargetCamera.prototype._updateCache = function (ignoreParentClass) {
  22723. if (!ignoreParentClass) {
  22724. _super.prototype._updateCache.call(this);
  22725. }
  22726. var lockedTargetPosition = this._getLockedTargetPosition();
  22727. if (!lockedTargetPosition) {
  22728. this._cache.lockedTarget = null;
  22729. }
  22730. else {
  22731. if (!this._cache.lockedTarget) {
  22732. this._cache.lockedTarget = lockedTargetPosition.clone();
  22733. }
  22734. else {
  22735. this._cache.lockedTarget.copyFrom(lockedTargetPosition);
  22736. }
  22737. }
  22738. this._cache.rotation.copyFrom(this.rotation);
  22739. if (this.rotationQuaternion) {
  22740. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22741. }
  22742. };
  22743. // Synchronized
  22744. /** @hidden */
  22745. TargetCamera.prototype._isSynchronizedViewMatrix = function () {
  22746. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  22747. return false;
  22748. }
  22749. var lockedTargetPosition = this._getLockedTargetPosition();
  22750. return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(lockedTargetPosition) : !lockedTargetPosition)
  22751. && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation));
  22752. };
  22753. // Methods
  22754. /** @hidden */
  22755. TargetCamera.prototype._computeLocalCameraSpeed = function () {
  22756. var engine = this.getEngine();
  22757. return this.speed * Math.sqrt((engine.getDeltaTime() / (engine.getFps() * 100.0)));
  22758. };
  22759. // Target
  22760. /** @hidden */
  22761. TargetCamera.prototype.setTarget = function (target) {
  22762. this.upVector.normalize();
  22763. this._initialFocalDistance = target.subtract(this.position).length();
  22764. if (this.position.z === target.z) {
  22765. this.position.z += _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  22766. }
  22767. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this.position, target, this._defaultUp, this._camMatrix);
  22768. this._camMatrix.invert();
  22769. this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
  22770. var vDir = target.subtract(this.position);
  22771. if (vDir.x >= 0.0) {
  22772. this.rotation.y = (-Math.atan(vDir.z / vDir.x) + Math.PI / 2.0);
  22773. }
  22774. else {
  22775. this.rotation.y = (-Math.atan(vDir.z / vDir.x) - Math.PI / 2.0);
  22776. }
  22777. this.rotation.z = 0;
  22778. if (isNaN(this.rotation.x)) {
  22779. this.rotation.x = 0;
  22780. }
  22781. if (isNaN(this.rotation.y)) {
  22782. this.rotation.y = 0;
  22783. }
  22784. if (isNaN(this.rotation.z)) {
  22785. this.rotation.z = 0;
  22786. }
  22787. if (this.rotationQuaternion) {
  22788. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  22789. }
  22790. };
  22791. /**
  22792. * Return the current target position of the camera. This value is expressed in local space.
  22793. * @returns the target position
  22794. */
  22795. TargetCamera.prototype.getTarget = function () {
  22796. return this._currentTarget;
  22797. };
  22798. /** @hidden */
  22799. TargetCamera.prototype._decideIfNeedsToMove = function () {
  22800. return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22801. };
  22802. /** @hidden */
  22803. TargetCamera.prototype._updatePosition = function () {
  22804. if (this.parent) {
  22805. this.parent.getWorldMatrix().invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  22806. _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]);
  22807. this.position.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  22808. return;
  22809. }
  22810. this.position.addInPlace(this.cameraDirection);
  22811. };
  22812. /** @hidden */
  22813. TargetCamera.prototype._checkInputs = function () {
  22814. var needToMove = this._decideIfNeedsToMove();
  22815. var needToRotate = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
  22816. // Move
  22817. if (needToMove) {
  22818. this._updatePosition();
  22819. }
  22820. // Rotate
  22821. if (needToRotate) {
  22822. this.rotation.x += this.cameraRotation.x;
  22823. this.rotation.y += this.cameraRotation.y;
  22824. //rotate, if quaternion is set and rotation was used
  22825. if (this.rotationQuaternion) {
  22826. var len = this.rotation.lengthSquared();
  22827. if (len) {
  22828. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  22829. }
  22830. }
  22831. if (!this.noRotationConstraint) {
  22832. var limit = (Math.PI / 2) * 0.95;
  22833. if (this.rotation.x > limit) {
  22834. this.rotation.x = limit;
  22835. }
  22836. if (this.rotation.x < -limit) {
  22837. this.rotation.x = -limit;
  22838. }
  22839. }
  22840. }
  22841. // Inertia
  22842. if (needToMove) {
  22843. if (Math.abs(this.cameraDirection.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22844. this.cameraDirection.x = 0;
  22845. }
  22846. if (Math.abs(this.cameraDirection.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22847. this.cameraDirection.y = 0;
  22848. }
  22849. if (Math.abs(this.cameraDirection.z) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22850. this.cameraDirection.z = 0;
  22851. }
  22852. this.cameraDirection.scaleInPlace(this.inertia);
  22853. }
  22854. if (needToRotate) {
  22855. if (Math.abs(this.cameraRotation.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22856. this.cameraRotation.x = 0;
  22857. }
  22858. if (Math.abs(this.cameraRotation.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22859. this.cameraRotation.y = 0;
  22860. }
  22861. this.cameraRotation.scaleInPlace(this.inertia);
  22862. }
  22863. _super.prototype._checkInputs.call(this);
  22864. };
  22865. TargetCamera.prototype._updateCameraRotationMatrix = function () {
  22866. if (this.rotationQuaternion) {
  22867. this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix);
  22868. }
  22869. else {
  22870. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
  22871. }
  22872. };
  22873. /**
  22874. * 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)
  22875. * @returns the current camera
  22876. */
  22877. TargetCamera.prototype._rotateUpVectorWithCameraRotationMatrix = function () {
  22878. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector);
  22879. return this;
  22880. };
  22881. /** @hidden */
  22882. TargetCamera.prototype._getViewMatrix = function () {
  22883. if (this.lockedTarget) {
  22884. this.setTarget(this._getLockedTargetPosition());
  22885. }
  22886. // Compute
  22887. this._updateCameraRotationMatrix();
  22888. // Apply the changed rotation to the upVector
  22889. if (this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z) {
  22890. this._rotateUpVectorWithCameraRotationMatrix();
  22891. this._cachedQuaternionRotationZ = this.rotationQuaternion.z;
  22892. }
  22893. else if (this._cachedRotationZ != this.rotation.z) {
  22894. this._rotateUpVectorWithCameraRotationMatrix();
  22895. this._cachedRotationZ = this.rotation.z;
  22896. }
  22897. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  22898. // Computing target and final matrix
  22899. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  22900. if (this.updateUpVectorFromRotation) {
  22901. if (this.rotationQuaternion) {
  22902. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector);
  22903. }
  22904. else {
  22905. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, this._tmpQuaternion);
  22906. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector);
  22907. }
  22908. }
  22909. this._computeViewMatrix(this.position, this._currentTarget, this.upVector);
  22910. return this._viewMatrix;
  22911. };
  22912. TargetCamera.prototype._computeViewMatrix = function (position, target, up) {
  22913. if (this.parent) {
  22914. var parentWorldMatrix = this.parent.getWorldMatrix();
  22915. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(position, parentWorldMatrix, this._globalPosition);
  22916. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(target, parentWorldMatrix, this._globalCurrentTarget);
  22917. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(up, parentWorldMatrix, this._globalCurrentUpVector);
  22918. this._markSyncedWithParent();
  22919. }
  22920. else {
  22921. this._globalPosition.copyFrom(position);
  22922. this._globalCurrentTarget.copyFrom(target);
  22923. this._globalCurrentUpVector.copyFrom(up);
  22924. }
  22925. if (this.getScene().useRightHandedSystem) {
  22926. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtRHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  22927. }
  22928. else {
  22929. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  22930. }
  22931. };
  22932. /**
  22933. * @hidden
  22934. */
  22935. TargetCamera.prototype.createRigCamera = function (name, cameraIndex) {
  22936. if (this.cameraRigMode !== _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_NONE) {
  22937. var rigCamera = new TargetCamera(name, this.position.clone(), this.getScene());
  22938. if (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR || this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_WEBVR) {
  22939. if (!this.rotationQuaternion) {
  22940. this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22941. }
  22942. rigCamera._cameraRigParams = {};
  22943. rigCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22944. }
  22945. return rigCamera;
  22946. }
  22947. return null;
  22948. };
  22949. /**
  22950. * @hidden
  22951. */
  22952. TargetCamera.prototype._updateRigCameras = function () {
  22953. var camLeft = this._rigCameras[0];
  22954. var camRight = this._rigCameras[1];
  22955. this.computeWorldMatrix();
  22956. switch (this.cameraRigMode) {
  22957. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  22958. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  22959. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  22960. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  22961. //provisionnaly using _cameraRigParams.stereoHalfAngle instead of calculations based on _cameraRigParams.interaxialDistance:
  22962. var leftSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? 1 : -1;
  22963. var rightSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? -1 : 1;
  22964. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * leftSign, camLeft);
  22965. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * rightSign, camRight);
  22966. break;
  22967. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR:
  22968. if (camLeft.rotationQuaternion) {
  22969. camLeft.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22970. camRight.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22971. }
  22972. else {
  22973. camLeft.rotation.copyFrom(this.rotation);
  22974. camRight.rotation.copyFrom(this.rotation);
  22975. }
  22976. camLeft.position.copyFrom(this.position);
  22977. camRight.position.copyFrom(this.position);
  22978. break;
  22979. }
  22980. _super.prototype._updateRigCameras.call(this);
  22981. };
  22982. TargetCamera.prototype._getRigCamPositionAndTarget = function (halfSpace, rigCamera) {
  22983. var target = this.getTarget();
  22984. target.subtractToRef(this.position, TargetCamera._TargetFocalPoint);
  22985. TargetCamera._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
  22986. var newFocalTarget = TargetCamera._TargetFocalPoint.addInPlace(this.position);
  22987. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-newFocalTarget.x, -newFocalTarget.y, -newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  22988. TargetCamera._TargetTransformMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(halfSpace), TargetCamera._RigCamTransformMatrix);
  22989. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(newFocalTarget.x, newFocalTarget.y, newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  22990. TargetCamera._RigCamTransformMatrix.multiplyToRef(TargetCamera._TargetTransformMatrix, TargetCamera._RigCamTransformMatrix);
  22991. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, TargetCamera._RigCamTransformMatrix, rigCamera.position);
  22992. rigCamera.setTarget(newFocalTarget);
  22993. };
  22994. /**
  22995. * Gets the current object class name.
  22996. * @return the class name
  22997. */
  22998. TargetCamera.prototype.getClassName = function () {
  22999. return "TargetCamera";
  23000. };
  23001. TargetCamera._RigCamTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23002. TargetCamera._TargetTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23003. TargetCamera._TargetFocalPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  23004. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23005. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23006. ], TargetCamera.prototype, "rotation", void 0);
  23007. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23008. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23009. ], TargetCamera.prototype, "speed", void 0);
  23010. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23011. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  23012. ], TargetCamera.prototype, "lockedTarget", void 0);
  23013. return TargetCamera;
  23014. }(_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]));
  23015. /***/ }),
  23016. /***/ "./Cameras/touchCamera.ts":
  23017. /*!********************************!*\
  23018. !*** ./Cameras/touchCamera.ts ***!
  23019. \********************************/
  23020. /*! exports provided: TouchCamera */
  23021. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23022. "use strict";
  23023. __webpack_require__.r(__webpack_exports__);
  23024. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return TouchCamera; });
  23025. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23026. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23027. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23028. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23029. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("TouchCamera", function (name, scene) {
  23030. return function () { return new TouchCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23031. });
  23032. /**
  23033. * This represents a FPS type of camera controlled by touch.
  23034. * This is like a universal camera minus the Gamepad controls.
  23035. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23036. */
  23037. var TouchCamera = /** @class */ (function (_super) {
  23038. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TouchCamera, _super);
  23039. /**
  23040. * Instantiates a new touch camera.
  23041. * This represents a FPS type of camera controlled by touch.
  23042. * This is like a universal camera minus the Gamepad controls.
  23043. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23044. * @param name Define the name of the camera in the scene
  23045. * @param position Define the start position of the camera in the scene
  23046. * @param scene Define the scene the camera belongs to
  23047. */
  23048. function TouchCamera(name, position, scene) {
  23049. var _this = _super.call(this, name, position, scene) || this;
  23050. _this.inputs.addTouch();
  23051. _this._setupInputs();
  23052. return _this;
  23053. }
  23054. Object.defineProperty(TouchCamera.prototype, "touchAngularSensibility", {
  23055. /**
  23056. * Defines the touch sensibility for rotation.
  23057. * The higher the faster.
  23058. */
  23059. get: function () {
  23060. var touch = this.inputs.attached["touch"];
  23061. if (touch) {
  23062. return touch.touchAngularSensibility;
  23063. }
  23064. return 0;
  23065. },
  23066. set: function (value) {
  23067. var touch = this.inputs.attached["touch"];
  23068. if (touch) {
  23069. touch.touchAngularSensibility = value;
  23070. }
  23071. },
  23072. enumerable: true,
  23073. configurable: true
  23074. });
  23075. Object.defineProperty(TouchCamera.prototype, "touchMoveSensibility", {
  23076. /**
  23077. * Defines the touch sensibility for move.
  23078. * The higher the faster.
  23079. */
  23080. get: function () {
  23081. var touch = this.inputs.attached["touch"];
  23082. if (touch) {
  23083. return touch.touchMoveSensibility;
  23084. }
  23085. return 0;
  23086. },
  23087. set: function (value) {
  23088. var touch = this.inputs.attached["touch"];
  23089. if (touch) {
  23090. touch.touchMoveSensibility = value;
  23091. }
  23092. },
  23093. enumerable: true,
  23094. configurable: true
  23095. });
  23096. /**
  23097. * Gets the current object class name.
  23098. * @return the class name
  23099. */
  23100. TouchCamera.prototype.getClassName = function () {
  23101. return "TouchCamera";
  23102. };
  23103. /** @hidden */
  23104. TouchCamera.prototype._setupInputs = function () {
  23105. var mouse = this.inputs.attached["mouse"];
  23106. if (mouse) {
  23107. mouse.touchEnabled = false;
  23108. }
  23109. };
  23110. return TouchCamera;
  23111. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23112. /***/ }),
  23113. /***/ "./Cameras/universalCamera.ts":
  23114. /*!************************************!*\
  23115. !*** ./Cameras/universalCamera.ts ***!
  23116. \************************************/
  23117. /*! exports provided: UniversalCamera */
  23118. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23119. "use strict";
  23120. __webpack_require__.r(__webpack_exports__);
  23121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return UniversalCamera; });
  23122. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23123. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  23124. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../node */ "./node.ts");
  23125. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23126. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23127. _node__WEBPACK_IMPORTED_MODULE_2__["Node"].AddNodeConstructor("FreeCamera", function (name, scene) {
  23128. // Forcing to use the Universal camera
  23129. return function () { return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  23130. });
  23131. /**
  23132. * 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,
  23133. * which still works and will still be found in many Playgrounds.
  23134. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23135. */
  23136. var UniversalCamera = /** @class */ (function (_super) {
  23137. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](UniversalCamera, _super);
  23138. /**
  23139. * 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,
  23140. * which still works and will still be found in many Playgrounds.
  23141. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23142. * @param name Define the name of the camera in the scene
  23143. * @param position Define the start position of the camera in the scene
  23144. * @param scene Define the scene the camera belongs to
  23145. */
  23146. function UniversalCamera(name, position, scene) {
  23147. var _this = _super.call(this, name, position, scene) || this;
  23148. _this.inputs.addGamepad();
  23149. return _this;
  23150. }
  23151. Object.defineProperty(UniversalCamera.prototype, "gamepadAngularSensibility", {
  23152. /**
  23153. * Defines the gamepad rotation sensiblity.
  23154. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  23155. */
  23156. get: function () {
  23157. var gamepad = this.inputs.attached["gamepad"];
  23158. if (gamepad) {
  23159. return gamepad.gamepadAngularSensibility;
  23160. }
  23161. return 0;
  23162. },
  23163. set: function (value) {
  23164. var gamepad = this.inputs.attached["gamepad"];
  23165. if (gamepad) {
  23166. gamepad.gamepadAngularSensibility = value;
  23167. }
  23168. },
  23169. enumerable: true,
  23170. configurable: true
  23171. });
  23172. Object.defineProperty(UniversalCamera.prototype, "gamepadMoveSensibility", {
  23173. /**
  23174. * Defines the gamepad move sensiblity.
  23175. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  23176. */
  23177. get: function () {
  23178. var gamepad = this.inputs.attached["gamepad"];
  23179. if (gamepad) {
  23180. return gamepad.gamepadMoveSensibility;
  23181. }
  23182. return 0;
  23183. },
  23184. set: function (value) {
  23185. var gamepad = this.inputs.attached["gamepad"];
  23186. if (gamepad) {
  23187. gamepad.gamepadMoveSensibility = value;
  23188. }
  23189. },
  23190. enumerable: true,
  23191. configurable: true
  23192. });
  23193. /**
  23194. * Gets the current object class name.
  23195. * @return the class name
  23196. */
  23197. UniversalCamera.prototype.getClassName = function () {
  23198. return "UniversalCamera";
  23199. };
  23200. return UniversalCamera;
  23201. }(_touchCamera__WEBPACK_IMPORTED_MODULE_1__["TouchCamera"]));
  23202. _camera__WEBPACK_IMPORTED_MODULE_4__["Camera"]._createDefaultParsedCamera = function (name, scene) {
  23203. return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene);
  23204. };
  23205. /***/ }),
  23206. /***/ "./Cameras/virtualJoysticksCamera.ts":
  23207. /*!*******************************************!*\
  23208. !*** ./Cameras/virtualJoysticksCamera.ts ***!
  23209. \*******************************************/
  23210. /*! exports provided: VirtualJoysticksCamera */
  23211. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23212. "use strict";
  23213. __webpack_require__.r(__webpack_exports__);
  23214. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return VirtualJoysticksCamera; });
  23215. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23216. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23217. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23218. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23219. /* harmony import */ var _Inputs_freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  23220. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("VirtualJoysticksCamera", function (name, scene) {
  23221. return function () { return new VirtualJoysticksCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23222. });
  23223. /**
  23224. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  23225. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23226. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23227. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23228. */
  23229. var VirtualJoysticksCamera = /** @class */ (function (_super) {
  23230. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualJoysticksCamera, _super);
  23231. /**
  23232. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  23233. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23234. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23235. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23236. * @param name Define the name of the camera in the scene
  23237. * @param position Define the start position of the camera in the scene
  23238. * @param scene Define the scene the camera belongs to
  23239. */
  23240. function VirtualJoysticksCamera(name, position, scene) {
  23241. var _this = _super.call(this, name, position, scene) || this;
  23242. _this.inputs.addVirtualJoystick();
  23243. return _this;
  23244. }
  23245. /**
  23246. * Gets the current object class name.
  23247. * @return the class name
  23248. */
  23249. VirtualJoysticksCamera.prototype.getClassName = function () {
  23250. return "VirtualJoysticksCamera";
  23251. };
  23252. return VirtualJoysticksCamera;
  23253. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23254. /***/ }),
  23255. /***/ "./Collisions/collider.ts":
  23256. /*!********************************!*\
  23257. !*** ./Collisions/collider.ts ***!
  23258. \********************************/
  23259. /*! exports provided: Collider */
  23260. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23261. "use strict";
  23262. __webpack_require__.r(__webpack_exports__);
  23263. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return Collider; });
  23264. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23265. var intersectBoxAASphere = function (boxMin, boxMax, sphereCenter, sphereRadius) {
  23266. if (boxMin.x > sphereCenter.x + sphereRadius) {
  23267. return false;
  23268. }
  23269. if (sphereCenter.x - sphereRadius > boxMax.x) {
  23270. return false;
  23271. }
  23272. if (boxMin.y > sphereCenter.y + sphereRadius) {
  23273. return false;
  23274. }
  23275. if (sphereCenter.y - sphereRadius > boxMax.y) {
  23276. return false;
  23277. }
  23278. if (boxMin.z > sphereCenter.z + sphereRadius) {
  23279. return false;
  23280. }
  23281. if (sphereCenter.z - sphereRadius > boxMax.z) {
  23282. return false;
  23283. }
  23284. return true;
  23285. };
  23286. var getLowestRoot = (function () {
  23287. var result = { root: 0, found: false };
  23288. return function (a, b, c, maxR) {
  23289. result.root = 0;
  23290. result.found = false;
  23291. var determinant = b * b - 4.0 * a * c;
  23292. if (determinant < 0) {
  23293. return result;
  23294. }
  23295. var sqrtD = Math.sqrt(determinant);
  23296. var r1 = (-b - sqrtD) / (2.0 * a);
  23297. var r2 = (-b + sqrtD) / (2.0 * a);
  23298. if (r1 > r2) {
  23299. var temp = r2;
  23300. r2 = r1;
  23301. r1 = temp;
  23302. }
  23303. if (r1 > 0 && r1 < maxR) {
  23304. result.root = r1;
  23305. result.found = true;
  23306. return result;
  23307. }
  23308. if (r2 > 0 && r2 < maxR) {
  23309. result.root = r2;
  23310. result.found = true;
  23311. return result;
  23312. }
  23313. return result;
  23314. };
  23315. })();
  23316. /** @hidden */
  23317. var Collider = /** @class */ (function () {
  23318. function Collider() {
  23319. this._collisionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23320. this._planeIntersectionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23321. this._tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23322. this._tempVector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23323. this._tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23324. this._tempVector4 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23325. this._edge = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23326. this._baseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23327. this._destinationPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23328. this._slidePlaneNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23329. this._displacementVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23330. /** @hidden */
  23331. this._radius = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  23332. /** @hidden */
  23333. this._retry = 0;
  23334. /** @hidden */
  23335. this._basePointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23336. this._velocityWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23337. this._normalizedVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23338. this._collisionMask = -1;
  23339. }
  23340. Object.defineProperty(Collider.prototype, "collisionMask", {
  23341. get: function () {
  23342. return this._collisionMask;
  23343. },
  23344. set: function (mask) {
  23345. this._collisionMask = !isNaN(mask) ? mask : -1;
  23346. },
  23347. enumerable: true,
  23348. configurable: true
  23349. });
  23350. Object.defineProperty(Collider.prototype, "slidePlaneNormal", {
  23351. /**
  23352. * Gets the plane normal used to compute the sliding response (in local space)
  23353. */
  23354. get: function () {
  23355. return this._slidePlaneNormal;
  23356. },
  23357. enumerable: true,
  23358. configurable: true
  23359. });
  23360. // Methods
  23361. /** @hidden */
  23362. Collider.prototype._initialize = function (source, dir, e) {
  23363. this._velocity = dir;
  23364. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].NormalizeToRef(dir, this._normalizedVelocity);
  23365. this._basePoint = source;
  23366. source.multiplyToRef(this._radius, this._basePointWorld);
  23367. dir.multiplyToRef(this._radius, this._velocityWorld);
  23368. this._velocityWorldLength = this._velocityWorld.length();
  23369. this._epsilon = e;
  23370. this.collisionFound = false;
  23371. };
  23372. /** @hidden */
  23373. Collider.prototype._checkPointInTriangle = function (point, pa, pb, pc, n) {
  23374. pa.subtractToRef(point, this._tempVector);
  23375. pb.subtractToRef(point, this._tempVector2);
  23376. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
  23377. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23378. if (d < 0) {
  23379. return false;
  23380. }
  23381. pc.subtractToRef(point, this._tempVector3);
  23382. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4);
  23383. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23384. if (d < 0) {
  23385. return false;
  23386. }
  23387. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector3, this._tempVector, this._tempVector4);
  23388. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23389. return d >= 0;
  23390. };
  23391. /** @hidden */
  23392. Collider.prototype._canDoCollision = function (sphereCenter, sphereRadius, vecMin, vecMax) {
  23393. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._basePointWorld, sphereCenter);
  23394. var max = Math.max(this._radius.x, this._radius.y, this._radius.z);
  23395. if (distance > this._velocityWorldLength + max + sphereRadius) {
  23396. return false;
  23397. }
  23398. if (!intersectBoxAASphere(vecMin, vecMax, this._basePointWorld, this._velocityWorldLength + max)) {
  23399. return false;
  23400. }
  23401. return true;
  23402. };
  23403. /** @hidden */
  23404. Collider.prototype._testTriangle = function (faceIndex, trianglePlaneArray, p1, p2, p3, hasMaterial) {
  23405. var t0;
  23406. var embeddedInPlane = false;
  23407. //defensive programming, actually not needed.
  23408. if (!trianglePlaneArray) {
  23409. trianglePlaneArray = [];
  23410. }
  23411. if (!trianglePlaneArray[faceIndex]) {
  23412. trianglePlaneArray[faceIndex] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"](0, 0, 0, 0);
  23413. trianglePlaneArray[faceIndex].copyFromPoints(p1, p2, p3);
  23414. }
  23415. var trianglePlane = trianglePlaneArray[faceIndex];
  23416. if ((!hasMaterial) && !trianglePlane.isFrontFacingTo(this._normalizedVelocity, 0)) {
  23417. return;
  23418. }
  23419. var signedDistToTrianglePlane = trianglePlane.signedDistanceTo(this._basePoint);
  23420. var normalDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(trianglePlane.normal, this._velocity);
  23421. if (normalDotVelocity == 0) {
  23422. if (Math.abs(signedDistToTrianglePlane) >= 1.0) {
  23423. return;
  23424. }
  23425. embeddedInPlane = true;
  23426. t0 = 0;
  23427. }
  23428. else {
  23429. t0 = (-1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  23430. var t1 = (1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  23431. if (t0 > t1) {
  23432. var temp = t1;
  23433. t1 = t0;
  23434. t0 = temp;
  23435. }
  23436. if (t0 > 1.0 || t1 < 0.0) {
  23437. return;
  23438. }
  23439. if (t0 < 0) {
  23440. t0 = 0;
  23441. }
  23442. if (t0 > 1.0) {
  23443. t0 = 1.0;
  23444. }
  23445. }
  23446. this._collisionPoint.copyFromFloats(0, 0, 0);
  23447. var found = false;
  23448. var t = 1.0;
  23449. if (!embeddedInPlane) {
  23450. this._basePoint.subtractToRef(trianglePlane.normal, this._planeIntersectionPoint);
  23451. this._velocity.scaleToRef(t0, this._tempVector);
  23452. this._planeIntersectionPoint.addInPlace(this._tempVector);
  23453. if (this._checkPointInTriangle(this._planeIntersectionPoint, p1, p2, p3, trianglePlane.normal)) {
  23454. found = true;
  23455. t = t0;
  23456. this._collisionPoint.copyFrom(this._planeIntersectionPoint);
  23457. }
  23458. }
  23459. if (!found) {
  23460. var velocitySquaredLength = this._velocity.lengthSquared();
  23461. var a = velocitySquaredLength;
  23462. this._basePoint.subtractToRef(p1, this._tempVector);
  23463. var b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23464. var c = this._tempVector.lengthSquared() - 1.0;
  23465. var lowestRoot = getLowestRoot(a, b, c, t);
  23466. if (lowestRoot.found) {
  23467. t = lowestRoot.root;
  23468. found = true;
  23469. this._collisionPoint.copyFrom(p1);
  23470. }
  23471. this._basePoint.subtractToRef(p2, this._tempVector);
  23472. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23473. c = this._tempVector.lengthSquared() - 1.0;
  23474. lowestRoot = getLowestRoot(a, b, c, t);
  23475. if (lowestRoot.found) {
  23476. t = lowestRoot.root;
  23477. found = true;
  23478. this._collisionPoint.copyFrom(p2);
  23479. }
  23480. this._basePoint.subtractToRef(p3, 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(p3);
  23488. }
  23489. p2.subtractToRef(p1, this._edge);
  23490. p1.subtractToRef(this._basePoint, this._baseToVertex);
  23491. var edgeSquaredLength = this._edge.lengthSquared();
  23492. var edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23493. var edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  23494. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  23495. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  23496. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  23497. lowestRoot = getLowestRoot(a, b, c, t);
  23498. if (lowestRoot.found) {
  23499. var f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  23500. if (f >= 0.0 && f <= 1.0) {
  23501. t = lowestRoot.root;
  23502. found = true;
  23503. this._edge.scaleInPlace(f);
  23504. p1.addToRef(this._edge, this._collisionPoint);
  23505. }
  23506. }
  23507. p3.subtractToRef(p2, this._edge);
  23508. p2.subtractToRef(this._basePoint, this._baseToVertex);
  23509. edgeSquaredLength = this._edge.lengthSquared();
  23510. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23511. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  23512. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  23513. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  23514. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  23515. lowestRoot = getLowestRoot(a, b, c, t);
  23516. if (lowestRoot.found) {
  23517. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  23518. if (f >= 0.0 && f <= 1.0) {
  23519. t = lowestRoot.root;
  23520. found = true;
  23521. this._edge.scaleInPlace(f);
  23522. p2.addToRef(this._edge, this._collisionPoint);
  23523. }
  23524. }
  23525. p1.subtractToRef(p3, this._edge);
  23526. p3.subtractToRef(this._basePoint, this._baseToVertex);
  23527. edgeSquaredLength = this._edge.lengthSquared();
  23528. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23529. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  23530. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  23531. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  23532. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  23533. lowestRoot = getLowestRoot(a, b, c, t);
  23534. if (lowestRoot.found) {
  23535. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  23536. if (f >= 0.0 && f <= 1.0) {
  23537. t = lowestRoot.root;
  23538. found = true;
  23539. this._edge.scaleInPlace(f);
  23540. p3.addToRef(this._edge, this._collisionPoint);
  23541. }
  23542. }
  23543. }
  23544. if (found) {
  23545. var distToCollision = t * this._velocity.length();
  23546. if (!this.collisionFound || distToCollision < this._nearestDistance) {
  23547. if (!this.intersectionPoint) {
  23548. this.intersectionPoint = this._collisionPoint.clone();
  23549. }
  23550. else {
  23551. this.intersectionPoint.copyFrom(this._collisionPoint);
  23552. }
  23553. this._nearestDistance = distToCollision;
  23554. this.collisionFound = true;
  23555. }
  23556. }
  23557. };
  23558. /** @hidden */
  23559. Collider.prototype._collide = function (trianglePlaneArray, pts, indices, indexStart, indexEnd, decal, hasMaterial) {
  23560. for (var i = indexStart; i < indexEnd; i += 3) {
  23561. var p1 = pts[indices[i] - decal];
  23562. var p2 = pts[indices[i + 1] - decal];
  23563. var p3 = pts[indices[i + 2] - decal];
  23564. this._testTriangle(i, trianglePlaneArray, p3, p2, p1, hasMaterial);
  23565. }
  23566. };
  23567. /** @hidden */
  23568. Collider.prototype._getResponse = function (pos, vel) {
  23569. pos.addToRef(vel, this._destinationPoint);
  23570. vel.scaleInPlace((this._nearestDistance / vel.length()));
  23571. this._basePoint.addToRef(vel, pos);
  23572. pos.subtractToRef(this.intersectionPoint, this._slidePlaneNormal);
  23573. this._slidePlaneNormal.normalize();
  23574. this._slidePlaneNormal.scaleToRef(this._epsilon, this._displacementVector);
  23575. pos.addInPlace(this._displacementVector);
  23576. this.intersectionPoint.addInPlace(this._displacementVector);
  23577. this._slidePlaneNormal.scaleInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"].SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint));
  23578. this._destinationPoint.subtractInPlace(this._slidePlaneNormal);
  23579. this._destinationPoint.subtractToRef(this.intersectionPoint, vel);
  23580. };
  23581. return Collider;
  23582. }());
  23583. /***/ }),
  23584. /***/ "./Collisions/collisionCoordinator.ts":
  23585. /*!********************************************!*\
  23586. !*** ./Collisions/collisionCoordinator.ts ***!
  23587. \********************************************/
  23588. /*! exports provided: DefaultCollisionCoordinator */
  23589. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23590. "use strict";
  23591. __webpack_require__.r(__webpack_exports__);
  23592. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return DefaultCollisionCoordinator; });
  23593. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  23594. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23595. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  23596. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  23597. /** @hidden */
  23598. var DefaultCollisionCoordinator = /** @class */ (function () {
  23599. function DefaultCollisionCoordinator() {
  23600. this._scaledPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23601. this._scaledVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23602. this._finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23603. }
  23604. DefaultCollisionCoordinator.prototype.getNewPosition = function (position, displacement, collider, maximumRetry, excludedMesh, onNewPosition, collisionIndex) {
  23605. position.divideToRef(collider._radius, this._scaledPosition);
  23606. displacement.divideToRef(collider._radius, this._scaledVelocity);
  23607. collider.collidedMesh = null;
  23608. collider._retry = 0;
  23609. collider._initialVelocity = this._scaledVelocity;
  23610. collider._initialPosition = this._scaledPosition;
  23611. this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, this._finalPosition, excludedMesh);
  23612. this._finalPosition.multiplyInPlace(collider._radius);
  23613. //run the callback
  23614. onNewPosition(collisionIndex, this._finalPosition, collider.collidedMesh);
  23615. };
  23616. DefaultCollisionCoordinator.prototype.createCollider = function () {
  23617. return new _collider__WEBPACK_IMPORTED_MODULE_3__["Collider"]();
  23618. };
  23619. DefaultCollisionCoordinator.prototype.init = function (scene) {
  23620. this._scene = scene;
  23621. };
  23622. DefaultCollisionCoordinator.prototype._collideWithWorld = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
  23623. if (excludedMesh === void 0) { excludedMesh = null; }
  23624. var closeDistance = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].CollisionsEpsilon * 10.0;
  23625. if (collider._retry >= maximumRetry) {
  23626. finalPosition.copyFrom(position);
  23627. return;
  23628. }
  23629. // Check if this is a mesh else camera or -1
  23630. var collisionMask = (excludedMesh ? excludedMesh.collisionMask : collider.collisionMask);
  23631. collider._initialize(position, velocity, closeDistance);
  23632. // Check all meshes
  23633. for (var index = 0; index < this._scene.meshes.length; index++) {
  23634. var mesh = this._scene.meshes[index];
  23635. if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh && ((collisionMask & mesh.collisionGroup) !== 0)) {
  23636. mesh._checkCollision(collider);
  23637. }
  23638. }
  23639. if (!collider.collisionFound) {
  23640. position.addToRef(velocity, finalPosition);
  23641. return;
  23642. }
  23643. if (velocity.x !== 0 || velocity.y !== 0 || velocity.z !== 0) {
  23644. collider._getResponse(position, velocity);
  23645. }
  23646. if (velocity.length() <= closeDistance) {
  23647. finalPosition.copyFrom(position);
  23648. return;
  23649. }
  23650. collider._retry++;
  23651. this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh);
  23652. };
  23653. return DefaultCollisionCoordinator;
  23654. }());
  23655. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].CollisionCoordinatorFactory = function () {
  23656. return new DefaultCollisionCoordinator();
  23657. };
  23658. /***/ }),
  23659. /***/ "./Collisions/index.ts":
  23660. /*!*****************************!*\
  23661. !*** ./Collisions/index.ts ***!
  23662. \*****************************/
  23663. /*! exports provided: Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo */
  23664. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23665. "use strict";
  23666. __webpack_require__.r(__webpack_exports__);
  23667. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  23668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _collider__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  23669. /* harmony import */ var _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./collisionCoordinator */ "./Collisions/collisionCoordinator.ts");
  23670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__["DefaultCollisionCoordinator"]; });
  23671. /* harmony import */ var _pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pickingInfo */ "./Collisions/pickingInfo.ts");
  23672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]; });
  23673. /* harmony import */ var _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./intersectionInfo */ "./Collisions/intersectionInfo.ts");
  23674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"]; });
  23675. /***/ }),
  23676. /***/ "./Collisions/intersectionInfo.ts":
  23677. /*!****************************************!*\
  23678. !*** ./Collisions/intersectionInfo.ts ***!
  23679. \****************************************/
  23680. /*! exports provided: IntersectionInfo */
  23681. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23682. "use strict";
  23683. __webpack_require__.r(__webpack_exports__);
  23684. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return IntersectionInfo; });
  23685. /**
  23686. * @hidden
  23687. */
  23688. var IntersectionInfo = /** @class */ (function () {
  23689. function IntersectionInfo(bu, bv, distance) {
  23690. this.bu = bu;
  23691. this.bv = bv;
  23692. this.distance = distance;
  23693. this.faceId = 0;
  23694. this.subMeshId = 0;
  23695. }
  23696. return IntersectionInfo;
  23697. }());
  23698. /***/ }),
  23699. /***/ "./Collisions/pickingInfo.ts":
  23700. /*!***********************************!*\
  23701. !*** ./Collisions/pickingInfo.ts ***!
  23702. \***********************************/
  23703. /*! exports provided: PickingInfo */
  23704. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23705. "use strict";
  23706. __webpack_require__.r(__webpack_exports__);
  23707. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return PickingInfo; });
  23708. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23709. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  23710. /**
  23711. * Information about the result of picking within a scene
  23712. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  23713. */
  23714. var PickingInfo = /** @class */ (function () {
  23715. function PickingInfo() {
  23716. /** @hidden */
  23717. this._pickingUnavailable = false;
  23718. /**
  23719. * If the pick collided with an object
  23720. */
  23721. this.hit = false;
  23722. /**
  23723. * Distance away where the pick collided
  23724. */
  23725. this.distance = 0;
  23726. /**
  23727. * The location of pick collision
  23728. */
  23729. this.pickedPoint = null;
  23730. /**
  23731. * The mesh corresponding the the pick collision
  23732. */
  23733. this.pickedMesh = null;
  23734. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  23735. this.bu = 0;
  23736. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  23737. this.bv = 0;
  23738. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23739. this.faceId = -1;
  23740. /** Id of the the submesh that was picked */
  23741. this.subMeshId = 0;
  23742. /** If a sprite was picked, this will be the sprite the pick collided with */
  23743. this.pickedSprite = null;
  23744. /**
  23745. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  23746. */
  23747. this.originMesh = null;
  23748. /**
  23749. * The ray that was used to perform the picking.
  23750. */
  23751. this.ray = null;
  23752. }
  23753. /**
  23754. * Gets the normal correspodning to the face the pick collided with
  23755. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  23756. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  23757. * @returns The normal correspodning to the face the pick collided with
  23758. */
  23759. PickingInfo.prototype.getNormal = function (useWorldCoordinates, useVerticesNormals) {
  23760. if (useWorldCoordinates === void 0) { useWorldCoordinates = false; }
  23761. if (useVerticesNormals === void 0) { useVerticesNormals = true; }
  23762. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  23763. return null;
  23764. }
  23765. var indices = this.pickedMesh.getIndices();
  23766. if (!indices) {
  23767. return null;
  23768. }
  23769. var result;
  23770. if (useVerticesNormals) {
  23771. var normals = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  23772. var normal0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3] * 3);
  23773. var normal1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 1] * 3);
  23774. var normal2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 2] * 3);
  23775. normal0 = normal0.scale(this.bu);
  23776. normal1 = normal1.scale(this.bv);
  23777. normal2 = normal2.scale(1.0 - this.bu - this.bv);
  23778. 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);
  23779. }
  23780. else {
  23781. var positions = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  23782. var vertex1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3] * 3);
  23783. var vertex2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 1] * 3);
  23784. var vertex3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 2] * 3);
  23785. var p1p2 = vertex1.subtract(vertex2);
  23786. var p3p2 = vertex3.subtract(vertex2);
  23787. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(p1p2, p3p2);
  23788. }
  23789. if (useWorldCoordinates) {
  23790. var wm = this.pickedMesh.getWorldMatrix();
  23791. if (this.pickedMesh.nonUniformScaling) {
  23792. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0].copyFrom(wm);
  23793. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  23794. wm.setTranslationFromFloats(0, 0, 0);
  23795. wm.invert();
  23796. wm.transposeToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1]);
  23797. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  23798. }
  23799. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result, wm);
  23800. }
  23801. result.normalize();
  23802. return result;
  23803. };
  23804. /**
  23805. * Gets the texture coordinates of where the pick occured
  23806. * @returns the vector containing the coordnates of the texture
  23807. */
  23808. PickingInfo.prototype.getTextureCoordinates = function () {
  23809. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  23810. return null;
  23811. }
  23812. var indices = this.pickedMesh.getIndices();
  23813. if (!indices) {
  23814. return null;
  23815. }
  23816. var uvs = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  23817. if (!uvs) {
  23818. return null;
  23819. }
  23820. var uv0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3] * 2);
  23821. var uv1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 1] * 2);
  23822. var uv2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 2] * 2);
  23823. uv0 = uv0.scale(1.0 - this.bu - this.bv);
  23824. uv1 = uv1.scale(this.bu);
  23825. uv2 = uv2.scale(this.bv);
  23826. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);
  23827. };
  23828. return PickingInfo;
  23829. }());
  23830. /***/ }),
  23831. /***/ "./Culling/Octrees/index.ts":
  23832. /*!**********************************!*\
  23833. !*** ./Culling/Octrees/index.ts ***!
  23834. \**********************************/
  23835. /*! exports provided: Octree, OctreeBlock, OctreeSceneComponent */
  23836. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23837. "use strict";
  23838. __webpack_require__.r(__webpack_exports__);
  23839. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  23840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _octree__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  23841. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  23842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]; });
  23843. /* harmony import */ var _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./octreeSceneComponent */ "./Culling/Octrees/octreeSceneComponent.ts");
  23844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__["OctreeSceneComponent"]; });
  23845. /***/ }),
  23846. /***/ "./Culling/Octrees/octree.ts":
  23847. /*!***********************************!*\
  23848. !*** ./Culling/Octrees/octree.ts ***!
  23849. \***********************************/
  23850. /*! exports provided: Octree */
  23851. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23852. "use strict";
  23853. __webpack_require__.r(__webpack_exports__);
  23854. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return Octree; });
  23855. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  23856. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  23857. /**
  23858. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  23859. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23860. */
  23861. var Octree = /** @class */ (function () {
  23862. /**
  23863. * Creates a octree
  23864. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23865. * @param creationFunc function to be used to instatiate the octree
  23866. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  23867. * @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.)
  23868. */
  23869. function Octree(creationFunc, maxBlockCapacity,
  23870. /** 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.) */
  23871. maxDepth) {
  23872. if (maxDepth === void 0) { maxDepth = 2; }
  23873. this.maxDepth = maxDepth;
  23874. /**
  23875. * Content stored in the octree
  23876. */
  23877. this.dynamicContent = new Array();
  23878. this._maxBlockCapacity = maxBlockCapacity || 64;
  23879. this._selectionContent = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"](1024);
  23880. this._creationFunc = creationFunc;
  23881. }
  23882. // Methods
  23883. /**
  23884. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  23885. * @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);
  23886. * @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);
  23887. * @param entries meshes to be added to the octree blocks
  23888. */
  23889. Octree.prototype.update = function (worldMin, worldMax, entries) {
  23890. _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]._CreateBlocks(worldMin, worldMax, entries, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc);
  23891. };
  23892. /**
  23893. * Adds a mesh to the octree
  23894. * @param entry Mesh to add to the octree
  23895. */
  23896. Octree.prototype.addMesh = function (entry) {
  23897. for (var index = 0; index < this.blocks.length; index++) {
  23898. var block = this.blocks[index];
  23899. block.addEntry(entry);
  23900. }
  23901. };
  23902. /**
  23903. * Remove an element from the octree
  23904. * @param entry defines the element to remove
  23905. */
  23906. Octree.prototype.removeMesh = function (entry) {
  23907. for (var index = 0; index < this.blocks.length; index++) {
  23908. var block = this.blocks[index];
  23909. block.removeEntry(entry);
  23910. }
  23911. };
  23912. /**
  23913. * Selects an array of meshes within the frustum
  23914. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  23915. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  23916. * @returns array of meshes within the frustum
  23917. */
  23918. Octree.prototype.select = function (frustumPlanes, allowDuplicate) {
  23919. this._selectionContent.reset();
  23920. for (var index = 0; index < this.blocks.length; index++) {
  23921. var block = this.blocks[index];
  23922. block.select(frustumPlanes, this._selectionContent, allowDuplicate);
  23923. }
  23924. if (allowDuplicate) {
  23925. this._selectionContent.concat(this.dynamicContent);
  23926. }
  23927. else {
  23928. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23929. }
  23930. return this._selectionContent;
  23931. };
  23932. /**
  23933. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  23934. * @param sphereCenter defines the bounding sphere center
  23935. * @param sphereRadius defines the bounding sphere radius
  23936. * @param allowDuplicate defines if the selection array can contains duplicated entries
  23937. * @returns an array of objects that intersect the sphere
  23938. */
  23939. Octree.prototype.intersects = function (sphereCenter, sphereRadius, allowDuplicate) {
  23940. this._selectionContent.reset();
  23941. for (var index = 0; index < this.blocks.length; index++) {
  23942. var block = this.blocks[index];
  23943. block.intersects(sphereCenter, sphereRadius, this._selectionContent, allowDuplicate);
  23944. }
  23945. if (allowDuplicate) {
  23946. this._selectionContent.concat(this.dynamicContent);
  23947. }
  23948. else {
  23949. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23950. }
  23951. return this._selectionContent;
  23952. };
  23953. /**
  23954. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  23955. * @param ray defines the ray to test with
  23956. * @returns array of intersected objects
  23957. */
  23958. Octree.prototype.intersectsRay = function (ray) {
  23959. this._selectionContent.reset();
  23960. for (var index = 0; index < this.blocks.length; index++) {
  23961. var block = this.blocks[index];
  23962. block.intersectsRay(ray, this._selectionContent);
  23963. }
  23964. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23965. return this._selectionContent;
  23966. };
  23967. /**
  23968. * Adds a mesh into the octree block if it intersects the block
  23969. */
  23970. Octree.CreationFuncForMeshes = function (entry, block) {
  23971. var boundingInfo = entry.getBoundingInfo();
  23972. if (!entry.isBlocked && boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  23973. block.entries.push(entry);
  23974. }
  23975. };
  23976. /**
  23977. * Adds a submesh into the octree block if it intersects the block
  23978. */
  23979. Octree.CreationFuncForSubMeshes = function (entry, block) {
  23980. var boundingInfo = entry.getBoundingInfo();
  23981. if (boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  23982. block.entries.push(entry);
  23983. }
  23984. };
  23985. return Octree;
  23986. }());
  23987. /***/ }),
  23988. /***/ "./Culling/Octrees/octreeBlock.ts":
  23989. /*!****************************************!*\
  23990. !*** ./Culling/Octrees/octreeBlock.ts ***!
  23991. \****************************************/
  23992. /*! exports provided: OctreeBlock */
  23993. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23994. "use strict";
  23995. __webpack_require__.r(__webpack_exports__);
  23996. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return OctreeBlock; });
  23997. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  23998. /* harmony import */ var _Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Culling/boundingBox */ "./Culling/boundingBox.ts");
  23999. /**
  24000. * Class used to store a cell in an octree
  24001. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24002. */
  24003. var OctreeBlock = /** @class */ (function () {
  24004. /**
  24005. * Creates a new block
  24006. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  24007. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  24008. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24009. * @param depth defines the current depth of this block in the octree
  24010. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  24011. * @param creationFunc defines a callback to call when an element is added to the block
  24012. */
  24013. function OctreeBlock(minPoint, maxPoint, capacity, depth, maxDepth, creationFunc) {
  24014. /**
  24015. * Gets the content of the current block
  24016. */
  24017. this.entries = new Array();
  24018. this._boundingVectors = new Array();
  24019. this._capacity = capacity;
  24020. this._depth = depth;
  24021. this._maxDepth = maxDepth;
  24022. this._creationFunc = creationFunc;
  24023. this._minPoint = minPoint;
  24024. this._maxPoint = maxPoint;
  24025. this._boundingVectors.push(minPoint.clone());
  24026. this._boundingVectors.push(maxPoint.clone());
  24027. this._boundingVectors.push(minPoint.clone());
  24028. this._boundingVectors[2].x = maxPoint.x;
  24029. this._boundingVectors.push(minPoint.clone());
  24030. this._boundingVectors[3].y = maxPoint.y;
  24031. this._boundingVectors.push(minPoint.clone());
  24032. this._boundingVectors[4].z = maxPoint.z;
  24033. this._boundingVectors.push(maxPoint.clone());
  24034. this._boundingVectors[5].z = minPoint.z;
  24035. this._boundingVectors.push(maxPoint.clone());
  24036. this._boundingVectors[6].x = minPoint.x;
  24037. this._boundingVectors.push(maxPoint.clone());
  24038. this._boundingVectors[7].y = minPoint.y;
  24039. }
  24040. Object.defineProperty(OctreeBlock.prototype, "capacity", {
  24041. // Property
  24042. /**
  24043. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24044. */
  24045. get: function () {
  24046. return this._capacity;
  24047. },
  24048. enumerable: true,
  24049. configurable: true
  24050. });
  24051. Object.defineProperty(OctreeBlock.prototype, "minPoint", {
  24052. /**
  24053. * Gets the minimum vector (in world space) of the block's bounding box
  24054. */
  24055. get: function () {
  24056. return this._minPoint;
  24057. },
  24058. enumerable: true,
  24059. configurable: true
  24060. });
  24061. Object.defineProperty(OctreeBlock.prototype, "maxPoint", {
  24062. /**
  24063. * Gets the maximum vector (in world space) of the block's bounding box
  24064. */
  24065. get: function () {
  24066. return this._maxPoint;
  24067. },
  24068. enumerable: true,
  24069. configurable: true
  24070. });
  24071. // Methods
  24072. /**
  24073. * Add a new element to this block
  24074. * @param entry defines the element to add
  24075. */
  24076. OctreeBlock.prototype.addEntry = function (entry) {
  24077. if (this.blocks) {
  24078. for (var index = 0; index < this.blocks.length; index++) {
  24079. var block = this.blocks[index];
  24080. block.addEntry(entry);
  24081. }
  24082. return;
  24083. }
  24084. this._creationFunc(entry, this);
  24085. if (this.entries.length > this.capacity && this._depth < this._maxDepth) {
  24086. this.createInnerBlocks();
  24087. }
  24088. };
  24089. /**
  24090. * Remove an element from this block
  24091. * @param entry defines the element to remove
  24092. */
  24093. OctreeBlock.prototype.removeEntry = function (entry) {
  24094. if (this.blocks) {
  24095. for (var index = 0; index < this.blocks.length; index++) {
  24096. var block = this.blocks[index];
  24097. block.removeEntry(entry);
  24098. }
  24099. return;
  24100. }
  24101. var entryIndex = this.entries.indexOf(entry);
  24102. if (entryIndex > -1) {
  24103. this.entries.splice(entryIndex, 1);
  24104. }
  24105. };
  24106. /**
  24107. * Add an array of elements to this block
  24108. * @param entries defines the array of elements to add
  24109. */
  24110. OctreeBlock.prototype.addEntries = function (entries) {
  24111. for (var index = 0; index < entries.length; index++) {
  24112. var mesh = entries[index];
  24113. this.addEntry(mesh);
  24114. }
  24115. };
  24116. /**
  24117. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  24118. * @param frustumPlanes defines the frustum planes to test
  24119. * @param selection defines the array to store current content if selection is positive
  24120. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24121. */
  24122. OctreeBlock.prototype.select = function (frustumPlanes, selection, allowDuplicate) {
  24123. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IsInFrustum(this._boundingVectors, frustumPlanes)) {
  24124. if (this.blocks) {
  24125. for (var index = 0; index < this.blocks.length; index++) {
  24126. var block = this.blocks[index];
  24127. block.select(frustumPlanes, selection, allowDuplicate);
  24128. }
  24129. return;
  24130. }
  24131. if (allowDuplicate) {
  24132. selection.concat(this.entries);
  24133. }
  24134. else {
  24135. selection.concatWithNoDuplicate(this.entries);
  24136. }
  24137. }
  24138. };
  24139. /**
  24140. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  24141. * @param sphereCenter defines the bounding sphere center
  24142. * @param sphereRadius defines the bounding sphere radius
  24143. * @param selection defines the array to store current content if selection is positive
  24144. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24145. */
  24146. OctreeBlock.prototype.intersects = function (sphereCenter, sphereRadius, selection, allowDuplicate) {
  24147. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IntersectsSphere(this._minPoint, this._maxPoint, sphereCenter, sphereRadius)) {
  24148. if (this.blocks) {
  24149. for (var index = 0; index < this.blocks.length; index++) {
  24150. var block = this.blocks[index];
  24151. block.intersects(sphereCenter, sphereRadius, selection, allowDuplicate);
  24152. }
  24153. return;
  24154. }
  24155. if (allowDuplicate) {
  24156. selection.concat(this.entries);
  24157. }
  24158. else {
  24159. selection.concatWithNoDuplicate(this.entries);
  24160. }
  24161. }
  24162. };
  24163. /**
  24164. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  24165. * @param ray defines the ray to test with
  24166. * @param selection defines the array to store current content if selection is positive
  24167. */
  24168. OctreeBlock.prototype.intersectsRay = function (ray, selection) {
  24169. if (ray.intersectsBoxMinMax(this._minPoint, this._maxPoint)) {
  24170. if (this.blocks) {
  24171. for (var index = 0; index < this.blocks.length; index++) {
  24172. var block = this.blocks[index];
  24173. block.intersectsRay(ray, selection);
  24174. }
  24175. return;
  24176. }
  24177. selection.concatWithNoDuplicate(this.entries);
  24178. }
  24179. };
  24180. /**
  24181. * Subdivide the content into child blocks (this block will then be empty)
  24182. */
  24183. OctreeBlock.prototype.createInnerBlocks = function () {
  24184. OctreeBlock._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc);
  24185. };
  24186. /**
  24187. * @hidden
  24188. */
  24189. OctreeBlock._CreateBlocks = function (worldMin, worldMax, entries, maxBlockCapacity, currentDepth, maxDepth, target, creationFunc) {
  24190. target.blocks = new Array();
  24191. 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);
  24192. // Segmenting space
  24193. for (var x = 0; x < 2; x++) {
  24194. for (var y = 0; y < 2; y++) {
  24195. for (var z = 0; z < 2; z++) {
  24196. var localMin = worldMin.add(blockSize.multiplyByFloats(x, y, z));
  24197. var localMax = worldMin.add(blockSize.multiplyByFloats(x + 1, y + 1, z + 1));
  24198. var block = new OctreeBlock(localMin, localMax, maxBlockCapacity, currentDepth + 1, maxDepth, creationFunc);
  24199. block.addEntries(entries);
  24200. target.blocks.push(block);
  24201. }
  24202. }
  24203. }
  24204. };
  24205. return OctreeBlock;
  24206. }());
  24207. /***/ }),
  24208. /***/ "./Culling/Octrees/octreeSceneComponent.ts":
  24209. /*!*************************************************!*\
  24210. !*** ./Culling/Octrees/octreeSceneComponent.ts ***!
  24211. \*************************************************/
  24212. /*! exports provided: OctreeSceneComponent */
  24213. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24214. "use strict";
  24215. __webpack_require__.r(__webpack_exports__);
  24216. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return OctreeSceneComponent; });
  24217. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  24218. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  24219. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  24220. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  24221. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  24222. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  24223. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.createOrUpdateSelectionOctree = function (maxCapacity, maxDepth) {
  24224. if (maxCapacity === void 0) { maxCapacity = 64; }
  24225. if (maxDepth === void 0) { maxDepth = 2; }
  24226. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24227. if (!component) {
  24228. component = new OctreeSceneComponent(this);
  24229. this._addComponent(component);
  24230. }
  24231. if (!this._selectionOctree) {
  24232. this._selectionOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForMeshes, maxCapacity, maxDepth);
  24233. }
  24234. var worldExtends = this.getWorldExtends();
  24235. // Update octree
  24236. this._selectionOctree.update(worldExtends.min, worldExtends.max, this.meshes);
  24237. return this._selectionOctree;
  24238. };
  24239. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "selectionOctree", {
  24240. get: function () {
  24241. return this._selectionOctree;
  24242. },
  24243. enumerable: true,
  24244. configurable: true
  24245. });
  24246. /**
  24247. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  24248. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  24249. * @param maxCapacity defines the maximum size of each block (64 by default)
  24250. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  24251. * @returns the new octree
  24252. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  24253. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24254. */
  24255. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.createOrUpdateSubmeshesOctree = function (maxCapacity, maxDepth) {
  24256. if (maxCapacity === void 0) { maxCapacity = 64; }
  24257. if (maxDepth === void 0) { maxDepth = 2; }
  24258. var scene = this.getScene();
  24259. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24260. if (!component) {
  24261. component = new OctreeSceneComponent(scene);
  24262. scene._addComponent(component);
  24263. }
  24264. if (!this._submeshesOctree) {
  24265. this._submeshesOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForSubMeshes, maxCapacity, maxDepth);
  24266. }
  24267. this.computeWorldMatrix(true);
  24268. var boundingInfo = this.getBoundingInfo();
  24269. // Update octree
  24270. var bbox = boundingInfo.boundingBox;
  24271. this._submeshesOctree.update(bbox.minimumWorld, bbox.maximumWorld, this.subMeshes);
  24272. return this._submeshesOctree;
  24273. };
  24274. /**
  24275. * Defines the octree scene component responsible to manage any octrees
  24276. * in a given scene.
  24277. */
  24278. var OctreeSceneComponent = /** @class */ (function () {
  24279. /**
  24280. * Creates a new instance of the component for the given scene
  24281. * @param scene Defines the scene to register the component in
  24282. */
  24283. function OctreeSceneComponent(scene) {
  24284. /**
  24285. * The component name helpfull to identify the component in the list of scene components.
  24286. */
  24287. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE;
  24288. /**
  24289. * Indicates if the meshes have been checked to make sure they are isEnabled()
  24290. */
  24291. this.checksIsEnabled = true;
  24292. 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));
  24293. this.scene = scene;
  24294. this.scene.getActiveMeshCandidates = this.getActiveMeshCandidates.bind(this);
  24295. this.scene.getActiveSubMeshCandidates = this.getActiveSubMeshCandidates.bind(this);
  24296. this.scene.getCollidingSubMeshCandidates = this.getCollidingSubMeshCandidates.bind(this);
  24297. this.scene.getIntersectingSubMeshCandidates = this.getIntersectingSubMeshCandidates.bind(this);
  24298. }
  24299. /**
  24300. * Registers the component in a given scene
  24301. */
  24302. OctreeSceneComponent.prototype.register = function () {
  24303. var _this = this;
  24304. this.scene.onMeshRemovedObservable.add(function (mesh) {
  24305. var sceneOctree = _this.scene.selectionOctree;
  24306. if (sceneOctree !== undefined && sceneOctree !== null) {
  24307. var index = sceneOctree.dynamicContent.indexOf(mesh);
  24308. if (index !== -1) {
  24309. sceneOctree.dynamicContent.splice(index, 1);
  24310. }
  24311. }
  24312. });
  24313. this.scene.onMeshImportedObservable.add(function (mesh) {
  24314. var sceneOctree = _this.scene.selectionOctree;
  24315. if (sceneOctree !== undefined && sceneOctree !== null) {
  24316. sceneOctree.addMesh(mesh);
  24317. }
  24318. });
  24319. };
  24320. /**
  24321. * Return the list of active meshes
  24322. * @returns the list of active meshes
  24323. */
  24324. OctreeSceneComponent.prototype.getActiveMeshCandidates = function () {
  24325. if (this.scene._selectionOctree) {
  24326. var selection = this.scene._selectionOctree.select(this.scene.frustumPlanes);
  24327. return selection;
  24328. }
  24329. return this.scene._getDefaultMeshCandidates();
  24330. };
  24331. /**
  24332. * Return the list of active sub meshes
  24333. * @param mesh The mesh to get the candidates sub meshes from
  24334. * @returns the list of active sub meshes
  24335. */
  24336. OctreeSceneComponent.prototype.getActiveSubMeshCandidates = function (mesh) {
  24337. if (mesh._submeshesOctree && mesh.useOctreeForRenderingSelection) {
  24338. var intersections = mesh._submeshesOctree.select(this.scene.frustumPlanes);
  24339. return intersections;
  24340. }
  24341. return this.scene._getDefaultSubMeshCandidates(mesh);
  24342. };
  24343. /**
  24344. * Return the list of sub meshes intersecting with a given local ray
  24345. * @param mesh defines the mesh to find the submesh for
  24346. * @param localRay defines the ray in local space
  24347. * @returns the list of intersecting sub meshes
  24348. */
  24349. OctreeSceneComponent.prototype.getIntersectingSubMeshCandidates = function (mesh, localRay) {
  24350. if (mesh._submeshesOctree && mesh.useOctreeForPicking) {
  24351. _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"].TransformToRef(localRay, mesh.getWorldMatrix(), this._tempRay);
  24352. var intersections = mesh._submeshesOctree.intersectsRay(this._tempRay);
  24353. return intersections;
  24354. }
  24355. return this.scene._getDefaultSubMeshCandidates(mesh);
  24356. };
  24357. /**
  24358. * Return the list of sub meshes colliding with a collider
  24359. * @param mesh defines the mesh to find the submesh for
  24360. * @param collider defines the collider to evaluate the collision against
  24361. * @returns the list of colliding sub meshes
  24362. */
  24363. OctreeSceneComponent.prototype.getCollidingSubMeshCandidates = function (mesh, collider) {
  24364. if (mesh._submeshesOctree && mesh.useOctreeForCollisions) {
  24365. var radius = collider._velocityWorldLength + Math.max(collider._radius.x, collider._radius.y, collider._radius.z);
  24366. var intersections = mesh._submeshesOctree.intersects(collider._basePointWorld, radius);
  24367. return intersections;
  24368. }
  24369. return this.scene._getDefaultSubMeshCandidates(mesh);
  24370. };
  24371. /**
  24372. * Rebuilds the elements related to this component in case of
  24373. * context lost for instance.
  24374. */
  24375. OctreeSceneComponent.prototype.rebuild = function () {
  24376. // Nothing to do here.
  24377. };
  24378. /**
  24379. * Disposes the component and the associated ressources.
  24380. */
  24381. OctreeSceneComponent.prototype.dispose = function () {
  24382. // Nothing to do here.
  24383. };
  24384. return OctreeSceneComponent;
  24385. }());
  24386. /***/ }),
  24387. /***/ "./Culling/boundingBox.ts":
  24388. /*!********************************!*\
  24389. !*** ./Culling/boundingBox.ts ***!
  24390. \********************************/
  24391. /*! exports provided: BoundingBox */
  24392. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24393. "use strict";
  24394. __webpack_require__.r(__webpack_exports__);
  24395. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return BoundingBox; });
  24396. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24397. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24398. /**
  24399. * Class used to store bounding box information
  24400. */
  24401. var BoundingBox = /** @class */ (function () {
  24402. /**
  24403. * Creates a new bounding box
  24404. * @param min defines the minimum vector (in local space)
  24405. * @param max defines the maximum vector (in local space)
  24406. * @param worldMatrix defines the new world matrix
  24407. */
  24408. function BoundingBox(min, max, worldMatrix) {
  24409. /**
  24410. * Gets the 8 vectors representing the bounding box in local space
  24411. */
  24412. this.vectors = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24413. /**
  24414. * Gets the center of the bounding box in local space
  24415. */
  24416. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24417. /**
  24418. * Gets the center of the bounding box in world space
  24419. */
  24420. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24421. /**
  24422. * Gets the extend size in local space
  24423. */
  24424. this.extendSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24425. /**
  24426. * Gets the extend size in world space
  24427. */
  24428. this.extendSizeWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24429. /**
  24430. * Gets the OBB (object bounding box) directions
  24431. */
  24432. this.directions = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24433. /**
  24434. * Gets the 8 vectors representing the bounding box in world space
  24435. */
  24436. this.vectorsWorld = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24437. /**
  24438. * Gets the minimum vector in world space
  24439. */
  24440. this.minimumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24441. /**
  24442. * Gets the maximum vector in world space
  24443. */
  24444. this.maximumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24445. /**
  24446. * Gets the minimum vector in local space
  24447. */
  24448. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24449. /**
  24450. * Gets the maximum vector in local space
  24451. */
  24452. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24453. this.reConstruct(min, max, worldMatrix);
  24454. }
  24455. // Methods
  24456. /**
  24457. * Recreates the entire bounding box from scratch as if we call the constructor in place
  24458. * @param min defines the new minimum vector (in local space)
  24459. * @param max defines the new maximum vector (in local space)
  24460. * @param worldMatrix defines the new world matrix
  24461. */
  24462. BoundingBox.prototype.reConstruct = function (min, max, worldMatrix) {
  24463. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  24464. var vectors = this.vectors;
  24465. this.minimum.copyFromFloats(minX, minY, minZ);
  24466. this.maximum.copyFromFloats(maxX, maxY, maxZ);
  24467. vectors[0].copyFromFloats(minX, minY, minZ);
  24468. vectors[1].copyFromFloats(maxX, maxY, maxZ);
  24469. vectors[2].copyFromFloats(maxX, minY, minZ);
  24470. vectors[3].copyFromFloats(minX, maxY, minZ);
  24471. vectors[4].copyFromFloats(minX, minY, maxZ);
  24472. vectors[5].copyFromFloats(maxX, maxY, minZ);
  24473. vectors[6].copyFromFloats(minX, maxY, maxZ);
  24474. vectors[7].copyFromFloats(maxX, minY, maxZ);
  24475. // OBB
  24476. max.addToRef(min, this.center).scaleInPlace(0.5);
  24477. max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);
  24478. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  24479. };
  24480. /**
  24481. * Scale the current bounding box by applying a scale factor
  24482. * @param factor defines the scale factor to apply
  24483. * @returns the current bounding box
  24484. */
  24485. BoundingBox.prototype.scale = function (factor) {
  24486. var tmpVectors = BoundingBox.TmpVector3;
  24487. var diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);
  24488. var len = diff.length();
  24489. diff.normalizeFromLength(len);
  24490. var distance = len * factor;
  24491. var newRadius = diff.scaleInPlace(distance * 0.5);
  24492. var min = this.center.subtractToRef(newRadius, tmpVectors[1]);
  24493. var max = this.center.addToRef(newRadius, tmpVectors[2]);
  24494. this.reConstruct(min, max, this._worldMatrix);
  24495. return this;
  24496. };
  24497. /**
  24498. * Gets the world matrix of the bounding box
  24499. * @returns a matrix
  24500. */
  24501. BoundingBox.prototype.getWorldMatrix = function () {
  24502. return this._worldMatrix;
  24503. };
  24504. /** @hidden */
  24505. BoundingBox.prototype._update = function (world) {
  24506. var minWorld = this.minimumWorld;
  24507. var maxWorld = this.maximumWorld;
  24508. var directions = this.directions;
  24509. var vectorsWorld = this.vectorsWorld;
  24510. var vectors = this.vectors;
  24511. if (!world.isIdentity()) {
  24512. minWorld.setAll(Number.MAX_VALUE);
  24513. maxWorld.setAll(-Number.MAX_VALUE);
  24514. for (var index = 0; index < 8; ++index) {
  24515. var v = vectorsWorld[index];
  24516. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vectors[index], world, v);
  24517. minWorld.minimizeInPlace(v);
  24518. maxWorld.maximizeInPlace(v);
  24519. }
  24520. // Extend
  24521. maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);
  24522. maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);
  24523. }
  24524. else {
  24525. minWorld.copyFrom(this.minimum);
  24526. maxWorld.copyFrom(this.maximum);
  24527. for (var index = 0; index < 8; ++index) {
  24528. vectorsWorld[index].copyFrom(vectors[index]);
  24529. }
  24530. // Extend
  24531. this.extendSizeWorld.copyFrom(this.extendSize);
  24532. this.centerWorld.copyFrom(this.center);
  24533. }
  24534. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 0, directions[0]);
  24535. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 4, directions[1]);
  24536. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 8, directions[2]);
  24537. this._worldMatrix = world;
  24538. };
  24539. /**
  24540. * Tests if the bounding box is intersecting the frustum planes
  24541. * @param frustumPlanes defines the frustum planes to test
  24542. * @returns true if there is an intersection
  24543. */
  24544. BoundingBox.prototype.isInFrustum = function (frustumPlanes) {
  24545. return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);
  24546. };
  24547. /**
  24548. * Tests if the bounding box is entirely inside the frustum planes
  24549. * @param frustumPlanes defines the frustum planes to test
  24550. * @returns true if there is an inclusion
  24551. */
  24552. BoundingBox.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  24553. return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);
  24554. };
  24555. /**
  24556. * Tests if a point is inside the bounding box
  24557. * @param point defines the point to test
  24558. * @returns true if the point is inside the bounding box
  24559. */
  24560. BoundingBox.prototype.intersectsPoint = function (point) {
  24561. var min = this.minimumWorld;
  24562. var max = this.maximumWorld;
  24563. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  24564. var pointX = point.x, pointY = point.y, pointZ = point.z;
  24565. var delta = -_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"];
  24566. if (maxX - pointX < delta || delta > pointX - minX) {
  24567. return false;
  24568. }
  24569. if (maxY - pointY < delta || delta > pointY - minY) {
  24570. return false;
  24571. }
  24572. if (maxZ - pointZ < delta || delta > pointZ - minZ) {
  24573. return false;
  24574. }
  24575. return true;
  24576. };
  24577. /**
  24578. * Tests if the bounding box intersects with a bounding sphere
  24579. * @param sphere defines the sphere to test
  24580. * @returns true if there is an intersection
  24581. */
  24582. BoundingBox.prototype.intersectsSphere = function (sphere) {
  24583. return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);
  24584. };
  24585. /**
  24586. * Tests if the bounding box intersects with a box defined by a min and max vectors
  24587. * @param min defines the min vector to use
  24588. * @param max defines the max vector to use
  24589. * @returns true if there is an intersection
  24590. */
  24591. BoundingBox.prototype.intersectsMinMax = function (min, max) {
  24592. var myMin = this.minimumWorld;
  24593. var myMax = this.maximumWorld;
  24594. var myMinX = myMin.x, myMinY = myMin.y, myMinZ = myMin.z, myMaxX = myMax.x, myMaxY = myMax.y, myMaxZ = myMax.z;
  24595. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  24596. if (myMaxX < minX || myMinX > maxX) {
  24597. return false;
  24598. }
  24599. if (myMaxY < minY || myMinY > maxY) {
  24600. return false;
  24601. }
  24602. if (myMaxZ < minZ || myMinZ > maxZ) {
  24603. return false;
  24604. }
  24605. return true;
  24606. };
  24607. // Statics
  24608. /**
  24609. * Tests if two bounding boxes are intersections
  24610. * @param box0 defines the first box to test
  24611. * @param box1 defines the second box to test
  24612. * @returns true if there is an intersection
  24613. */
  24614. BoundingBox.Intersects = function (box0, box1) {
  24615. return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);
  24616. };
  24617. /**
  24618. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  24619. * @param minPoint defines the minimum vector of the bounding box
  24620. * @param maxPoint defines the maximum vector of the bounding box
  24621. * @param sphereCenter defines the sphere center
  24622. * @param sphereRadius defines the sphere radius
  24623. * @returns true if there is an intersection
  24624. */
  24625. BoundingBox.IntersectsSphere = function (minPoint, maxPoint, sphereCenter, sphereRadius) {
  24626. var vector = BoundingBox.TmpVector3[0];
  24627. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ClampToRef(sphereCenter, minPoint, maxPoint, vector);
  24628. var num = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphereCenter, vector);
  24629. return (num <= (sphereRadius * sphereRadius));
  24630. };
  24631. /**
  24632. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  24633. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  24634. * @param frustumPlanes defines the frustum planes to test
  24635. * @return true if there is an inclusion
  24636. */
  24637. BoundingBox.IsCompletelyInFrustum = function (boundingVectors, frustumPlanes) {
  24638. for (var p = 0; p < 6; ++p) {
  24639. var frustumPlane = frustumPlanes[p];
  24640. for (var i = 0; i < 8; ++i) {
  24641. if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {
  24642. return false;
  24643. }
  24644. }
  24645. }
  24646. return true;
  24647. };
  24648. /**
  24649. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  24650. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  24651. * @param frustumPlanes defines the frustum planes to test
  24652. * @return true if there is an intersection
  24653. */
  24654. BoundingBox.IsInFrustum = function (boundingVectors, frustumPlanes) {
  24655. for (var p = 0; p < 6; ++p) {
  24656. var canReturnFalse = true;
  24657. var frustumPlane = frustumPlanes[p];
  24658. for (var i = 0; i < 8; ++i) {
  24659. if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {
  24660. canReturnFalse = false;
  24661. break;
  24662. }
  24663. }
  24664. if (canReturnFalse) {
  24665. return false;
  24666. }
  24667. }
  24668. return true;
  24669. };
  24670. BoundingBox.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24671. return BoundingBox;
  24672. }());
  24673. /***/ }),
  24674. /***/ "./Culling/boundingInfo.ts":
  24675. /*!*********************************!*\
  24676. !*** ./Culling/boundingInfo.ts ***!
  24677. \*********************************/
  24678. /*! exports provided: BoundingInfo */
  24679. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24680. "use strict";
  24681. __webpack_require__.r(__webpack_exports__);
  24682. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return BoundingInfo; });
  24683. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24684. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24685. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  24686. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  24687. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  24688. var _result0 = { min: 0, max: 0 };
  24689. var _result1 = { min: 0, max: 0 };
  24690. var computeBoxExtents = function (axis, box, result) {
  24691. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.centerWorld, axis);
  24692. var r0 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[0], axis)) * box.extendSize.x;
  24693. var r1 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[1], axis)) * box.extendSize.y;
  24694. var r2 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[2], axis)) * box.extendSize.z;
  24695. var r = r0 + r1 + r2;
  24696. result.min = p - r;
  24697. result.max = p + r;
  24698. };
  24699. var axisOverlap = function (axis, box0, box1) {
  24700. computeBoxExtents(axis, box0, _result0);
  24701. computeBoxExtents(axis, box1, _result1);
  24702. return !(_result0.min > _result1.max || _result1.min > _result0.max);
  24703. };
  24704. /**
  24705. * Info for a bounding data of a mesh
  24706. */
  24707. var BoundingInfo = /** @class */ (function () {
  24708. /**
  24709. * Constructs bounding info
  24710. * @param minimum min vector of the bounding box/sphere
  24711. * @param maximum max vector of the bounding box/sphere
  24712. * @param worldMatrix defines the new world matrix
  24713. */
  24714. function BoundingInfo(minimum, maximum, worldMatrix) {
  24715. this._isLocked = false;
  24716. this.boundingBox = new _boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"](minimum, maximum, worldMatrix);
  24717. this.boundingSphere = new _boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"](minimum, maximum, worldMatrix);
  24718. }
  24719. /**
  24720. * Recreates the entire bounding info from scratch as if we call the constructor in place
  24721. * @param min defines the new minimum vector (in local space)
  24722. * @param max defines the new maximum vector (in local space)
  24723. * @param worldMatrix defines the new world matrix
  24724. */
  24725. BoundingInfo.prototype.reConstruct = function (min, max, worldMatrix) {
  24726. this.boundingBox.reConstruct(min, max, worldMatrix);
  24727. this.boundingSphere.reConstruct(min, max, worldMatrix);
  24728. };
  24729. Object.defineProperty(BoundingInfo.prototype, "minimum", {
  24730. /**
  24731. * min vector of the bounding box/sphere
  24732. */
  24733. get: function () {
  24734. return this.boundingBox.minimum;
  24735. },
  24736. enumerable: true,
  24737. configurable: true
  24738. });
  24739. Object.defineProperty(BoundingInfo.prototype, "maximum", {
  24740. /**
  24741. * max vector of the bounding box/sphere
  24742. */
  24743. get: function () {
  24744. return this.boundingBox.maximum;
  24745. },
  24746. enumerable: true,
  24747. configurable: true
  24748. });
  24749. Object.defineProperty(BoundingInfo.prototype, "isLocked", {
  24750. /**
  24751. * If the info is locked and won't be updated to avoid perf overhead
  24752. */
  24753. get: function () {
  24754. return this._isLocked;
  24755. },
  24756. set: function (value) {
  24757. this._isLocked = value;
  24758. },
  24759. enumerable: true,
  24760. configurable: true
  24761. });
  24762. // Methods
  24763. /**
  24764. * Updates the bounding sphere and box
  24765. * @param world world matrix to be used to update
  24766. */
  24767. BoundingInfo.prototype.update = function (world) {
  24768. if (this._isLocked) {
  24769. return;
  24770. }
  24771. this.boundingBox._update(world);
  24772. this.boundingSphere._update(world);
  24773. };
  24774. /**
  24775. * Recreate the bounding info to be centered around a specific point given a specific extend.
  24776. * @param center New center of the bounding info
  24777. * @param extend New extend of the bounding info
  24778. * @returns the current bounding info
  24779. */
  24780. BoundingInfo.prototype.centerOn = function (center, extend) {
  24781. var minimum = BoundingInfo.TmpVector3[0].copyFrom(center).subtractInPlace(extend);
  24782. var maximum = BoundingInfo.TmpVector3[1].copyFrom(center).addInPlace(extend);
  24783. this.boundingBox.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  24784. this.boundingSphere.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  24785. return this;
  24786. };
  24787. /**
  24788. * Scale the current bounding info by applying a scale factor
  24789. * @param factor defines the scale factor to apply
  24790. * @returns the current bounding info
  24791. */
  24792. BoundingInfo.prototype.scale = function (factor) {
  24793. this.boundingBox.scale(factor);
  24794. this.boundingSphere.scale(factor);
  24795. return this;
  24796. };
  24797. /**
  24798. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  24799. * @param frustumPlanes defines the frustum to test
  24800. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  24801. * @returns true if the bounding info is in the frustum planes
  24802. */
  24803. BoundingInfo.prototype.isInFrustum = function (frustumPlanes, strategy) {
  24804. if (strategy === void 0) { strategy = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD; }
  24805. 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);
  24806. if (inclusionTest) {
  24807. if (this.boundingSphere.isCenterInFrustum(frustumPlanes)) {
  24808. return true;
  24809. }
  24810. }
  24811. if (!this.boundingSphere.isInFrustum(frustumPlanes)) {
  24812. return false;
  24813. }
  24814. 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);
  24815. if (bSphereOnlyTest) {
  24816. return true;
  24817. }
  24818. return this.boundingBox.isInFrustum(frustumPlanes);
  24819. };
  24820. Object.defineProperty(BoundingInfo.prototype, "diagonalLength", {
  24821. /**
  24822. * Gets the world distance between the min and max points of the bounding box
  24823. */
  24824. get: function () {
  24825. var boundingBox = this.boundingBox;
  24826. var diag = boundingBox.maximumWorld.subtractToRef(boundingBox.minimumWorld, BoundingInfo.TmpVector3[0]);
  24827. return diag.length();
  24828. },
  24829. enumerable: true,
  24830. configurable: true
  24831. });
  24832. /**
  24833. * Checks if a cullable object (mesh...) is in the camera frustum
  24834. * Unlike isInFrustum this cheks the full bounding box
  24835. * @param frustumPlanes Camera near/planes
  24836. * @returns true if the object is in frustum otherwise false
  24837. */
  24838. BoundingInfo.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  24839. return this.boundingBox.isCompletelyInFrustum(frustumPlanes);
  24840. };
  24841. /** @hidden */
  24842. BoundingInfo.prototype._checkCollision = function (collider) {
  24843. return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);
  24844. };
  24845. /**
  24846. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  24847. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24848. * @param point the point to check intersection with
  24849. * @returns if the point intersects
  24850. */
  24851. BoundingInfo.prototype.intersectsPoint = function (point) {
  24852. if (!this.boundingSphere.centerWorld) {
  24853. return false;
  24854. }
  24855. if (!this.boundingSphere.intersectsPoint(point)) {
  24856. return false;
  24857. }
  24858. if (!this.boundingBox.intersectsPoint(point)) {
  24859. return false;
  24860. }
  24861. return true;
  24862. };
  24863. /**
  24864. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  24865. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24866. * @param boundingInfo the bounding info to check intersection with
  24867. * @param precise if the intersection should be done using OBB
  24868. * @returns if the bounding info intersects
  24869. */
  24870. BoundingInfo.prototype.intersects = function (boundingInfo, precise) {
  24871. if (!_boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"].Intersects(this.boundingSphere, boundingInfo.boundingSphere)) {
  24872. return false;
  24873. }
  24874. if (!_boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"].Intersects(this.boundingBox, boundingInfo.boundingBox)) {
  24875. return false;
  24876. }
  24877. if (!precise) {
  24878. return true;
  24879. }
  24880. var box0 = this.boundingBox;
  24881. var box1 = boundingInfo.boundingBox;
  24882. if (!axisOverlap(box0.directions[0], box0, box1)) {
  24883. return false;
  24884. }
  24885. if (!axisOverlap(box0.directions[1], box0, box1)) {
  24886. return false;
  24887. }
  24888. if (!axisOverlap(box0.directions[2], box0, box1)) {
  24889. return false;
  24890. }
  24891. if (!axisOverlap(box1.directions[0], box0, box1)) {
  24892. return false;
  24893. }
  24894. if (!axisOverlap(box1.directions[1], box0, box1)) {
  24895. return false;
  24896. }
  24897. if (!axisOverlap(box1.directions[2], box0, box1)) {
  24898. return false;
  24899. }
  24900. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[0]), box0, box1)) {
  24901. return false;
  24902. }
  24903. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[1]), box0, box1)) {
  24904. return false;
  24905. }
  24906. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[2]), box0, box1)) {
  24907. return false;
  24908. }
  24909. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[0]), box0, box1)) {
  24910. return false;
  24911. }
  24912. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[1]), box0, box1)) {
  24913. return false;
  24914. }
  24915. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[2]), box0, box1)) {
  24916. return false;
  24917. }
  24918. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[0]), box0, box1)) {
  24919. return false;
  24920. }
  24921. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[1]), box0, box1)) {
  24922. return false;
  24923. }
  24924. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[2]), box0, box1)) {
  24925. return false;
  24926. }
  24927. return true;
  24928. };
  24929. BoundingInfo.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24930. return BoundingInfo;
  24931. }());
  24932. /***/ }),
  24933. /***/ "./Culling/boundingSphere.ts":
  24934. /*!***********************************!*\
  24935. !*** ./Culling/boundingSphere.ts ***!
  24936. \***********************************/
  24937. /*! exports provided: BoundingSphere */
  24938. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24939. "use strict";
  24940. __webpack_require__.r(__webpack_exports__);
  24941. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return BoundingSphere; });
  24942. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24943. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24944. /**
  24945. * Class used to store bounding sphere information
  24946. */
  24947. var BoundingSphere = /** @class */ (function () {
  24948. /**
  24949. * Creates a new bounding sphere
  24950. * @param min defines the minimum vector (in local space)
  24951. * @param max defines the maximum vector (in local space)
  24952. * @param worldMatrix defines the new world matrix
  24953. */
  24954. function BoundingSphere(min, max, worldMatrix) {
  24955. /**
  24956. * Gets the center of the bounding sphere in local space
  24957. */
  24958. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24959. /**
  24960. * Gets the center of the bounding sphere in world space
  24961. */
  24962. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24963. /**
  24964. * Gets the minimum vector in local space
  24965. */
  24966. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24967. /**
  24968. * Gets the maximum vector in local space
  24969. */
  24970. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24971. this.reConstruct(min, max, worldMatrix);
  24972. }
  24973. /**
  24974. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  24975. * @param min defines the new minimum vector (in local space)
  24976. * @param max defines the new maximum vector (in local space)
  24977. * @param worldMatrix defines the new world matrix
  24978. */
  24979. BoundingSphere.prototype.reConstruct = function (min, max, worldMatrix) {
  24980. this.minimum.copyFrom(min);
  24981. this.maximum.copyFrom(max);
  24982. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(min, max);
  24983. max.addToRef(min, this.center).scaleInPlace(0.5);
  24984. this.radius = distance * 0.5;
  24985. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  24986. };
  24987. /**
  24988. * Scale the current bounding sphere by applying a scale factor
  24989. * @param factor defines the scale factor to apply
  24990. * @returns the current bounding box
  24991. */
  24992. BoundingSphere.prototype.scale = function (factor) {
  24993. var newRadius = this.radius * factor;
  24994. var tmpVectors = BoundingSphere.TmpVector3;
  24995. var tempRadiusVector = tmpVectors[0].setAll(newRadius);
  24996. var min = this.center.subtractToRef(tempRadiusVector, tmpVectors[1]);
  24997. var max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);
  24998. this.reConstruct(min, max, this._worldMatrix);
  24999. return this;
  25000. };
  25001. /**
  25002. * Gets the world matrix of the bounding box
  25003. * @returns a matrix
  25004. */
  25005. BoundingSphere.prototype.getWorldMatrix = function () {
  25006. return this._worldMatrix;
  25007. };
  25008. // Methods
  25009. /** @hidden */
  25010. BoundingSphere.prototype._update = function (worldMatrix) {
  25011. if (!worldMatrix.isIdentity()) {
  25012. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(this.center, worldMatrix, this.centerWorld);
  25013. var tempVector = BoundingSphere.TmpVector3[0];
  25014. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, worldMatrix, tempVector);
  25015. this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;
  25016. }
  25017. else {
  25018. this.centerWorld.copyFrom(this.center);
  25019. this.radiusWorld = this.radius;
  25020. }
  25021. };
  25022. /**
  25023. * Tests if the bounding sphere is intersecting the frustum planes
  25024. * @param frustumPlanes defines the frustum planes to test
  25025. * @returns true if there is an intersection
  25026. */
  25027. BoundingSphere.prototype.isInFrustum = function (frustumPlanes) {
  25028. var center = this.centerWorld;
  25029. var radius = this.radiusWorld;
  25030. for (var i = 0; i < 6; i++) {
  25031. if (frustumPlanes[i].dotCoordinate(center) <= -radius) {
  25032. return false;
  25033. }
  25034. }
  25035. return true;
  25036. };
  25037. /**
  25038. * Tests if the bounding sphere center is in between the frustum planes.
  25039. * Used for optimistic fast inclusion.
  25040. * @param frustumPlanes defines the frustum planes to test
  25041. * @returns true if the sphere center is in between the frustum planes
  25042. */
  25043. BoundingSphere.prototype.isCenterInFrustum = function (frustumPlanes) {
  25044. var center = this.centerWorld;
  25045. for (var i = 0; i < 6; i++) {
  25046. if (frustumPlanes[i].dotCoordinate(center) < 0) {
  25047. return false;
  25048. }
  25049. }
  25050. return true;
  25051. };
  25052. /**
  25053. * Tests if a point is inside the bounding sphere
  25054. * @param point defines the point to test
  25055. * @returns true if the point is inside the bounding sphere
  25056. */
  25057. BoundingSphere.prototype.intersectsPoint = function (point) {
  25058. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(this.centerWorld, point);
  25059. if (this.radiusWorld * this.radiusWorld < squareDistance) {
  25060. return false;
  25061. }
  25062. return true;
  25063. };
  25064. // Statics
  25065. /**
  25066. * Checks if two sphere intersct
  25067. * @param sphere0 sphere 0
  25068. * @param sphere1 sphere 1
  25069. * @returns true if the speres intersect
  25070. */
  25071. BoundingSphere.Intersects = function (sphere0, sphere1) {
  25072. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphere0.centerWorld, sphere1.centerWorld);
  25073. var radiusSum = sphere0.radiusWorld + sphere1.radiusWorld;
  25074. if (radiusSum * radiusSum < squareDistance) {
  25075. return false;
  25076. }
  25077. return true;
  25078. };
  25079. BoundingSphere.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25080. return BoundingSphere;
  25081. }());
  25082. /***/ }),
  25083. /***/ "./Culling/index.ts":
  25084. /*!**************************!*\
  25085. !*** ./Culling/index.ts ***!
  25086. \**************************/
  25087. /*! exports provided: BoundingBox, BoundingInfo, BoundingSphere, Ray, Octree, OctreeBlock, OctreeSceneComponent */
  25088. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25089. "use strict";
  25090. __webpack_require__.r(__webpack_exports__);
  25091. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  25092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _boundingBox__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  25093. /* harmony import */ var _boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boundingInfo */ "./Culling/boundingInfo.ts");
  25094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"]; });
  25095. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  25096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"]; });
  25097. /* harmony import */ var _Octrees_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Octrees/index */ "./Culling/Octrees/index.ts");
  25098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["Octree"]; });
  25099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeBlock"]; });
  25100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeSceneComponent"]; });
  25101. /* harmony import */ var _ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ray */ "./Culling/ray.ts");
  25102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _ray__WEBPACK_IMPORTED_MODULE_4__["Ray"]; });
  25103. /***/ }),
  25104. /***/ "./Culling/ray.ts":
  25105. /*!************************!*\
  25106. !*** ./Culling/ray.ts ***!
  25107. \************************/
  25108. /*! exports provided: Ray */
  25109. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25110. "use strict";
  25111. __webpack_require__.r(__webpack_exports__);
  25112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return Ray; });
  25113. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25114. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25115. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  25116. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  25117. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  25118. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  25119. /**
  25120. * Class representing a ray with position and direction
  25121. */
  25122. var Ray = /** @class */ (function () {
  25123. /**
  25124. * Creates a new ray
  25125. * @param origin origin point
  25126. * @param direction direction
  25127. * @param length length of the ray
  25128. */
  25129. function Ray(
  25130. /** origin point */
  25131. origin,
  25132. /** direction */
  25133. direction,
  25134. /** length of the ray */
  25135. length) {
  25136. if (length === void 0) { length = Number.MAX_VALUE; }
  25137. this.origin = origin;
  25138. this.direction = direction;
  25139. this.length = length;
  25140. }
  25141. // Methods
  25142. /**
  25143. * Checks if the ray intersects a box
  25144. * @param minimum bound of the box
  25145. * @param maximum bound of the box
  25146. * @param intersectionTreshold extra extend to be added to the box in all direction
  25147. * @returns if the box was hit
  25148. */
  25149. Ray.prototype.intersectsBoxMinMax = function (minimum, maximum, intersectionTreshold) {
  25150. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25151. var newMinimum = Ray.TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);
  25152. var newMaximum = Ray.TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);
  25153. var d = 0.0;
  25154. var maxValue = Number.MAX_VALUE;
  25155. var inv;
  25156. var min;
  25157. var max;
  25158. var temp;
  25159. if (Math.abs(this.direction.x) < 0.0000001) {
  25160. if (this.origin.x < newMinimum.x || this.origin.x > newMaximum.x) {
  25161. return false;
  25162. }
  25163. }
  25164. else {
  25165. inv = 1.0 / this.direction.x;
  25166. min = (newMinimum.x - this.origin.x) * inv;
  25167. max = (newMaximum.x - this.origin.x) * inv;
  25168. if (max === -Infinity) {
  25169. max = Infinity;
  25170. }
  25171. if (min > max) {
  25172. temp = min;
  25173. min = max;
  25174. max = temp;
  25175. }
  25176. d = Math.max(min, d);
  25177. maxValue = Math.min(max, maxValue);
  25178. if (d > maxValue) {
  25179. return false;
  25180. }
  25181. }
  25182. if (Math.abs(this.direction.y) < 0.0000001) {
  25183. if (this.origin.y < newMinimum.y || this.origin.y > newMaximum.y) {
  25184. return false;
  25185. }
  25186. }
  25187. else {
  25188. inv = 1.0 / this.direction.y;
  25189. min = (newMinimum.y - this.origin.y) * inv;
  25190. max = (newMaximum.y - this.origin.y) * inv;
  25191. if (max === -Infinity) {
  25192. max = Infinity;
  25193. }
  25194. if (min > max) {
  25195. temp = min;
  25196. min = max;
  25197. max = temp;
  25198. }
  25199. d = Math.max(min, d);
  25200. maxValue = Math.min(max, maxValue);
  25201. if (d > maxValue) {
  25202. return false;
  25203. }
  25204. }
  25205. if (Math.abs(this.direction.z) < 0.0000001) {
  25206. if (this.origin.z < newMinimum.z || this.origin.z > newMaximum.z) {
  25207. return false;
  25208. }
  25209. }
  25210. else {
  25211. inv = 1.0 / this.direction.z;
  25212. min = (newMinimum.z - this.origin.z) * inv;
  25213. max = (newMaximum.z - this.origin.z) * inv;
  25214. if (max === -Infinity) {
  25215. max = Infinity;
  25216. }
  25217. if (min > max) {
  25218. temp = min;
  25219. min = max;
  25220. max = temp;
  25221. }
  25222. d = Math.max(min, d);
  25223. maxValue = Math.min(max, maxValue);
  25224. if (d > maxValue) {
  25225. return false;
  25226. }
  25227. }
  25228. return true;
  25229. };
  25230. /**
  25231. * Checks if the ray intersects a box
  25232. * @param box the bounding box to check
  25233. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  25234. * @returns if the box was hit
  25235. */
  25236. Ray.prototype.intersectsBox = function (box, intersectionTreshold) {
  25237. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25238. return this.intersectsBoxMinMax(box.minimum, box.maximum, intersectionTreshold);
  25239. };
  25240. /**
  25241. * If the ray hits a sphere
  25242. * @param sphere the bounding sphere to check
  25243. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  25244. * @returns true if it hits the sphere
  25245. */
  25246. Ray.prototype.intersectsSphere = function (sphere, intersectionTreshold) {
  25247. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25248. var x = sphere.center.x - this.origin.x;
  25249. var y = sphere.center.y - this.origin.y;
  25250. var z = sphere.center.z - this.origin.z;
  25251. var pyth = (x * x) + (y * y) + (z * z);
  25252. var radius = sphere.radius + intersectionTreshold;
  25253. var rr = radius * radius;
  25254. if (pyth <= rr) {
  25255. return true;
  25256. }
  25257. var dot = (x * this.direction.x) + (y * this.direction.y) + (z * this.direction.z);
  25258. if (dot < 0.0) {
  25259. return false;
  25260. }
  25261. var temp = pyth - (dot * dot);
  25262. return temp <= rr;
  25263. };
  25264. /**
  25265. * If the ray hits a triange
  25266. * @param vertex0 triangle vertex
  25267. * @param vertex1 triangle vertex
  25268. * @param vertex2 triangle vertex
  25269. * @returns intersection information if hit
  25270. */
  25271. Ray.prototype.intersectsTriangle = function (vertex0, vertex1, vertex2) {
  25272. var edge1 = Ray.TmpVector3[0];
  25273. var edge2 = Ray.TmpVector3[1];
  25274. var pvec = Ray.TmpVector3[2];
  25275. var tvec = Ray.TmpVector3[3];
  25276. var qvec = Ray.TmpVector3[4];
  25277. vertex1.subtractToRef(vertex0, edge1);
  25278. vertex2.subtractToRef(vertex0, edge2);
  25279. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(this.direction, edge2, pvec);
  25280. var det = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge1, pvec);
  25281. if (det === 0) {
  25282. return null;
  25283. }
  25284. var invdet = 1 / det;
  25285. this.origin.subtractToRef(vertex0, tvec);
  25286. var bu = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(tvec, pvec) * invdet;
  25287. if (bu < 0 || bu > 1.0) {
  25288. return null;
  25289. }
  25290. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(tvec, edge1, qvec);
  25291. var bv = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this.direction, qvec) * invdet;
  25292. if (bv < 0 || bu + bv > 1.0) {
  25293. return null;
  25294. }
  25295. //check if the distance is longer than the predefined length.
  25296. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge2, qvec) * invdet;
  25297. if (distance > this.length) {
  25298. return null;
  25299. }
  25300. return new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](bu, bv, distance);
  25301. };
  25302. /**
  25303. * Checks if ray intersects a plane
  25304. * @param plane the plane to check
  25305. * @returns the distance away it was hit
  25306. */
  25307. Ray.prototype.intersectsPlane = function (plane) {
  25308. var distance;
  25309. var result1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.direction);
  25310. if (Math.abs(result1) < 9.99999997475243E-07) {
  25311. return null;
  25312. }
  25313. else {
  25314. var result2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.origin);
  25315. distance = (-plane.d - result2) / result1;
  25316. if (distance < 0.0) {
  25317. if (distance < -9.99999997475243E-07) {
  25318. return null;
  25319. }
  25320. else {
  25321. return 0;
  25322. }
  25323. }
  25324. return distance;
  25325. }
  25326. };
  25327. /**
  25328. * Checks if ray intersects a mesh
  25329. * @param mesh the mesh to check
  25330. * @param fastCheck if only the bounding box should checked
  25331. * @returns picking info of the intersecton
  25332. */
  25333. Ray.prototype.intersectsMesh = function (mesh, fastCheck) {
  25334. var tm = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  25335. mesh.getWorldMatrix().invertToRef(tm);
  25336. if (this._tmpRay) {
  25337. Ray.TransformToRef(this, tm, this._tmpRay);
  25338. }
  25339. else {
  25340. this._tmpRay = Ray.Transform(this, tm);
  25341. }
  25342. return mesh.intersects(this._tmpRay, fastCheck);
  25343. };
  25344. /**
  25345. * Checks if ray intersects a mesh
  25346. * @param meshes the meshes to check
  25347. * @param fastCheck if only the bounding box should checked
  25348. * @param results array to store result in
  25349. * @returns Array of picking infos
  25350. */
  25351. Ray.prototype.intersectsMeshes = function (meshes, fastCheck, results) {
  25352. if (results) {
  25353. results.length = 0;
  25354. }
  25355. else {
  25356. results = [];
  25357. }
  25358. for (var i = 0; i < meshes.length; i++) {
  25359. var pickInfo = this.intersectsMesh(meshes[i], fastCheck);
  25360. if (pickInfo.hit) {
  25361. results.push(pickInfo);
  25362. }
  25363. }
  25364. results.sort(this._comparePickingInfo);
  25365. return results;
  25366. };
  25367. Ray.prototype._comparePickingInfo = function (pickingInfoA, pickingInfoB) {
  25368. if (pickingInfoA.distance < pickingInfoB.distance) {
  25369. return -1;
  25370. }
  25371. else if (pickingInfoA.distance > pickingInfoB.distance) {
  25372. return 1;
  25373. }
  25374. else {
  25375. return 0;
  25376. }
  25377. };
  25378. /**
  25379. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  25380. * @param sega the first point of the segment to test the intersection against
  25381. * @param segb the second point of the segment to test the intersection against
  25382. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  25383. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  25384. */
  25385. Ray.prototype.intersectionSegment = function (sega, segb, threshold) {
  25386. var o = this.origin;
  25387. var u = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  25388. var rsegb = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  25389. var v = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  25390. var w = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  25391. segb.subtractToRef(sega, u);
  25392. this.direction.scaleToRef(Ray.rayl, v);
  25393. o.addToRef(v, rsegb);
  25394. sega.subtractToRef(o, w);
  25395. var a = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, u); // always >= 0
  25396. var b = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, v);
  25397. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, v); // always >= 0
  25398. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, w);
  25399. var e = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, w);
  25400. var D = a * c - b * b; // always >= 0
  25401. var sc, sN, sD = D; // sc = sN / sD, default sD = D >= 0
  25402. var tc, tN, tD = D; // tc = tN / tD, default tD = D >= 0
  25403. // compute the line parameters of the two closest points
  25404. if (D < Ray.smallnum) { // the lines are almost parallel
  25405. sN = 0.0; // force using point P0 on segment S1
  25406. sD = 1.0; // to prevent possible division by 0.0 later
  25407. tN = e;
  25408. tD = c;
  25409. }
  25410. else { // get the closest points on the infinite lines
  25411. sN = (b * e - c * d);
  25412. tN = (a * e - b * d);
  25413. if (sN < 0.0) { // sc < 0 => the s=0 edge is visible
  25414. sN = 0.0;
  25415. tN = e;
  25416. tD = c;
  25417. }
  25418. else if (sN > sD) { // sc > 1 => the s=1 edge is visible
  25419. sN = sD;
  25420. tN = e + b;
  25421. tD = c;
  25422. }
  25423. }
  25424. if (tN < 0.0) { // tc < 0 => the t=0 edge is visible
  25425. tN = 0.0;
  25426. // recompute sc for this edge
  25427. if (-d < 0.0) {
  25428. sN = 0.0;
  25429. }
  25430. else if (-d > a) {
  25431. sN = sD;
  25432. }
  25433. else {
  25434. sN = -d;
  25435. sD = a;
  25436. }
  25437. }
  25438. else if (tN > tD) { // tc > 1 => the t=1 edge is visible
  25439. tN = tD;
  25440. // recompute sc for this edge
  25441. if ((-d + b) < 0.0) {
  25442. sN = 0;
  25443. }
  25444. else if ((-d + b) > a) {
  25445. sN = sD;
  25446. }
  25447. else {
  25448. sN = (-d + b);
  25449. sD = a;
  25450. }
  25451. }
  25452. // finally do the division to get sc and tc
  25453. sc = (Math.abs(sN) < Ray.smallnum ? 0.0 : sN / sD);
  25454. tc = (Math.abs(tN) < Ray.smallnum ? 0.0 : tN / tD);
  25455. // get the difference of the two closest points
  25456. var qtc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  25457. v.scaleToRef(tc, qtc);
  25458. var qsc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  25459. u.scaleToRef(sc, qsc);
  25460. qsc.addInPlace(w);
  25461. var dP = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  25462. qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)
  25463. var isIntersected = (tc > 0) && (tc <= this.length) && (dP.lengthSquared() < (threshold * threshold)); // return intersection result
  25464. if (isIntersected) {
  25465. return qsc.length();
  25466. }
  25467. return -1;
  25468. };
  25469. /**
  25470. * Update the ray from viewport position
  25471. * @param x position
  25472. * @param y y position
  25473. * @param viewportWidth viewport width
  25474. * @param viewportHeight viewport height
  25475. * @param world world matrix
  25476. * @param view view matrix
  25477. * @param projection projection matrix
  25478. * @returns this ray updated
  25479. */
  25480. Ray.prototype.update = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  25481. this.unprojectRayToRef(x, y, viewportWidth, viewportHeight, world, view, projection);
  25482. return this;
  25483. };
  25484. // Statics
  25485. /**
  25486. * Creates a ray with origin and direction of 0,0,0
  25487. * @returns the new ray
  25488. */
  25489. Ray.Zero = function () {
  25490. return new Ray(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero());
  25491. };
  25492. /**
  25493. * Creates a new ray from screen space and viewport
  25494. * @param x position
  25495. * @param y y position
  25496. * @param viewportWidth viewport width
  25497. * @param viewportHeight viewport height
  25498. * @param world world matrix
  25499. * @param view view matrix
  25500. * @param projection projection matrix
  25501. * @returns new ray
  25502. */
  25503. Ray.CreateNew = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  25504. var result = Ray.Zero();
  25505. return result.update(x, y, viewportWidth, viewportHeight, world, view, projection);
  25506. };
  25507. /**
  25508. * 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
  25509. * transformed to the given world matrix.
  25510. * @param origin The origin point
  25511. * @param end The end point
  25512. * @param world a matrix to transform the ray to. Default is the identity matrix.
  25513. * @returns the new ray
  25514. */
  25515. Ray.CreateNewFromTo = function (origin, end, world) {
  25516. if (world === void 0) { world = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly; }
  25517. var direction = end.subtract(origin);
  25518. var length = Math.sqrt((direction.x * direction.x) + (direction.y * direction.y) + (direction.z * direction.z));
  25519. direction.normalize();
  25520. return Ray.Transform(new Ray(origin, direction, length), world);
  25521. };
  25522. /**
  25523. * Transforms a ray by a matrix
  25524. * @param ray ray to transform
  25525. * @param matrix matrix to apply
  25526. * @returns the resulting new ray
  25527. */
  25528. Ray.Transform = function (ray, matrix) {
  25529. 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));
  25530. Ray.TransformToRef(ray, matrix, result);
  25531. return result;
  25532. };
  25533. /**
  25534. * Transforms a ray by a matrix
  25535. * @param ray ray to transform
  25536. * @param matrix matrix to apply
  25537. * @param result ray to store result in
  25538. */
  25539. Ray.TransformToRef = function (ray, matrix, result) {
  25540. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(ray.origin, matrix, result.origin);
  25541. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(ray.direction, matrix, result.direction);
  25542. result.length = ray.length;
  25543. var dir = result.direction;
  25544. var len = dir.length();
  25545. if (!(len === 0 || len === 1)) {
  25546. var num = 1.0 / len;
  25547. dir.x *= num;
  25548. dir.y *= num;
  25549. dir.z *= num;
  25550. result.length *= len;
  25551. }
  25552. };
  25553. /**
  25554. * Unproject a ray from screen space to object space
  25555. * @param sourceX defines the screen space x coordinate to use
  25556. * @param sourceY defines the screen space y coordinate to use
  25557. * @param viewportWidth defines the current width of the viewport
  25558. * @param viewportHeight defines the current height of the viewport
  25559. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  25560. * @param view defines the view matrix to use
  25561. * @param projection defines the projection matrix to use
  25562. */
  25563. Ray.prototype.unprojectRayToRef = function (sourceX, sourceY, viewportWidth, viewportHeight, world, view, projection) {
  25564. var matrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  25565. world.multiplyToRef(view, matrix);
  25566. matrix.multiplyToRef(projection, matrix);
  25567. matrix.invert();
  25568. var nearScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  25569. nearScreenSource.x = sourceX / viewportWidth * 2 - 1;
  25570. nearScreenSource.y = -(sourceY / viewportHeight * 2 - 1);
  25571. nearScreenSource.z = -1.0;
  25572. var farScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0);
  25573. var nearVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  25574. var farVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  25575. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(nearScreenSource, matrix, nearVec3);
  25576. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(farScreenSource, matrix, farVec3);
  25577. this.origin.copyFrom(nearVec3);
  25578. farVec3.subtractToRef(nearVec3, this.direction);
  25579. this.direction.normalize();
  25580. };
  25581. Ray.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25582. Ray.smallnum = 0.00000001;
  25583. Ray.rayl = 10e8;
  25584. return Ray;
  25585. }());
  25586. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  25587. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  25588. var result = Ray.Zero();
  25589. this.createPickingRayToRef(x, y, world, result, camera, cameraViewSpace);
  25590. return result;
  25591. };
  25592. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  25593. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  25594. var engine = this.getEngine();
  25595. if (!camera) {
  25596. if (!this.activeCamera) {
  25597. throw new Error("Active camera not set");
  25598. }
  25599. camera = this.activeCamera;
  25600. }
  25601. var cameraViewport = camera.viewport;
  25602. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  25603. // Moving coordinates to local viewport world
  25604. x = x / engine.getHardwareScalingLevel() - viewport.x;
  25605. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  25606. 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());
  25607. return this;
  25608. };
  25609. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  25610. var result = Ray.Zero();
  25611. this.createPickingRayInCameraSpaceToRef(x, y, result, camera);
  25612. return result;
  25613. };
  25614. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  25615. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  25616. return this;
  25617. }
  25618. var engine = this.getEngine();
  25619. if (!camera) {
  25620. if (!this.activeCamera) {
  25621. throw new Error("Active camera not set");
  25622. }
  25623. camera = this.activeCamera;
  25624. }
  25625. var cameraViewport = camera.viewport;
  25626. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  25627. var identity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  25628. // Moving coordinates to local viewport world
  25629. x = x / engine.getHardwareScalingLevel() - viewport.x;
  25630. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  25631. result.update(x, y, viewport.width, viewport.height, identity, identity, camera.getProjectionMatrix());
  25632. return this;
  25633. };
  25634. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalPick = function (rayFunction, predicate, fastCheck) {
  25635. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  25636. return null;
  25637. }
  25638. var pickingInfo = null;
  25639. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  25640. var mesh = this.meshes[meshIndex];
  25641. if (predicate) {
  25642. if (!predicate(mesh)) {
  25643. continue;
  25644. }
  25645. }
  25646. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  25647. continue;
  25648. }
  25649. var world = mesh.getWorldMatrix();
  25650. var ray = rayFunction(world);
  25651. var result = mesh.intersects(ray, fastCheck);
  25652. if (!result || !result.hit) {
  25653. continue;
  25654. }
  25655. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  25656. continue;
  25657. }
  25658. pickingInfo = result;
  25659. if (fastCheck) {
  25660. break;
  25661. }
  25662. }
  25663. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]();
  25664. };
  25665. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalMultiPick = function (rayFunction, predicate) {
  25666. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  25667. return null;
  25668. }
  25669. var pickingInfos = new Array();
  25670. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  25671. var mesh = this.meshes[meshIndex];
  25672. if (predicate) {
  25673. if (!predicate(mesh)) {
  25674. continue;
  25675. }
  25676. }
  25677. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  25678. continue;
  25679. }
  25680. var world = mesh.getWorldMatrix();
  25681. var ray = rayFunction(world);
  25682. var result = mesh.intersects(ray, false);
  25683. if (!result || !result.hit) {
  25684. continue;
  25685. }
  25686. pickingInfos.push(result);
  25687. }
  25688. return pickingInfos;
  25689. };
  25690. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pick = function (x, y, predicate, fastCheck, camera) {
  25691. var _this = this;
  25692. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  25693. return null;
  25694. }
  25695. var result = this._internalPick(function (world) {
  25696. if (!_this._tempPickingRay) {
  25697. _this._tempPickingRay = Ray.Zero();
  25698. }
  25699. _this.createPickingRayToRef(x, y, world, _this._tempPickingRay, camera || null);
  25700. return _this._tempPickingRay;
  25701. }, predicate, fastCheck);
  25702. if (result) {
  25703. result.ray = this.createPickingRay(x, y, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), camera || null);
  25704. }
  25705. return result;
  25706. };
  25707. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pickWithRay = function (ray, predicate, fastCheck) {
  25708. var _this = this;
  25709. var result = this._internalPick(function (world) {
  25710. if (!_this._pickWithRayInverseMatrix) {
  25711. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  25712. }
  25713. world.invertToRef(_this._pickWithRayInverseMatrix);
  25714. if (!_this._cachedRayForTransform) {
  25715. _this._cachedRayForTransform = Ray.Zero();
  25716. }
  25717. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  25718. return _this._cachedRayForTransform;
  25719. }, predicate, fastCheck);
  25720. if (result) {
  25721. result.ray = ray;
  25722. }
  25723. return result;
  25724. };
  25725. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPick = function (x, y, predicate, camera) {
  25726. var _this = this;
  25727. return this._internalMultiPick(function (world) { return _this.createPickingRay(x, y, world, camera || null); }, predicate);
  25728. };
  25729. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPickWithRay = function (ray, predicate) {
  25730. var _this = this;
  25731. return this._internalMultiPick(function (world) {
  25732. if (!_this._pickWithRayInverseMatrix) {
  25733. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  25734. }
  25735. world.invertToRef(_this._pickWithRayInverseMatrix);
  25736. if (!_this._cachedRayForTransform) {
  25737. _this._cachedRayForTransform = Ray.Zero();
  25738. }
  25739. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  25740. return _this._cachedRayForTransform;
  25741. }, predicate);
  25742. };
  25743. _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].prototype.getForwardRay = function (length, transform, origin) {
  25744. if (length === void 0) { length = 100; }
  25745. if (!transform) {
  25746. transform = this.getWorldMatrix();
  25747. }
  25748. if (!origin) {
  25749. origin = this.position;
  25750. }
  25751. 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);
  25752. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(forward, transform);
  25753. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Normalize(forwardWorld);
  25754. return new Ray(origin, direction, length);
  25755. };
  25756. /***/ }),
  25757. /***/ "./Debug/axesViewer.ts":
  25758. /*!*****************************!*\
  25759. !*** ./Debug/axesViewer.ts ***!
  25760. \*****************************/
  25761. /*! exports provided: AxesViewer */
  25762. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25763. "use strict";
  25764. __webpack_require__.r(__webpack_exports__);
  25765. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return AxesViewer; });
  25766. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25767. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  25768. /* harmony import */ var _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gizmos/axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  25769. /**
  25770. * The Axes viewer will show 3 axes in a specific point in space
  25771. */
  25772. var AxesViewer = /** @class */ (function () {
  25773. /**
  25774. * Creates a new AxesViewer
  25775. * @param scene defines the hosting scene
  25776. * @param scaleLines defines a number used to scale line length (1 by default)
  25777. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  25778. * @param xAxis defines the node hierarchy used to render the x-axis
  25779. * @param yAxis defines the node hierarchy used to render the y-axis
  25780. * @param zAxis defines the node hierarchy used to render the z-axis
  25781. */
  25782. function AxesViewer(scene, scaleLines, renderingGroupId, xAxis, yAxis, zAxis) {
  25783. if (scaleLines === void 0) { scaleLines = 1; }
  25784. if (renderingGroupId === void 0) { renderingGroupId = 2; }
  25785. this._scaleLinesFactor = 4;
  25786. this._instanced = false;
  25787. /**
  25788. * Gets or sets a number used to scale line length
  25789. */
  25790. this.scaleLines = 1;
  25791. this.scaleLines = scaleLines;
  25792. if (!xAxis) {
  25793. var redColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  25794. redColoredMaterial.disableLighting = true;
  25795. redColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Red().scale(0.5);
  25796. xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, redColoredMaterial);
  25797. }
  25798. if (!yAxis) {
  25799. var greenColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  25800. greenColoredMaterial.disableLighting = true;
  25801. greenColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Green().scale(0.5);
  25802. yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, greenColoredMaterial);
  25803. }
  25804. if (!zAxis) {
  25805. var blueColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  25806. blueColoredMaterial.disableLighting = true;
  25807. blueColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Blue().scale(0.5);
  25808. zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, blueColoredMaterial);
  25809. }
  25810. this._xAxis = xAxis;
  25811. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25812. this._yAxis = yAxis;
  25813. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25814. this._zAxis = zAxis;
  25815. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25816. if (renderingGroupId != null) {
  25817. AxesViewer._SetRenderingGroupId(this._xAxis, renderingGroupId);
  25818. AxesViewer._SetRenderingGroupId(this._yAxis, renderingGroupId);
  25819. AxesViewer._SetRenderingGroupId(this._zAxis, renderingGroupId);
  25820. }
  25821. this.scene = scene;
  25822. 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());
  25823. }
  25824. Object.defineProperty(AxesViewer.prototype, "xAxis", {
  25825. /** Gets the node hierarchy used to render x-axis */
  25826. get: function () {
  25827. return this._xAxis;
  25828. },
  25829. enumerable: true,
  25830. configurable: true
  25831. });
  25832. Object.defineProperty(AxesViewer.prototype, "yAxis", {
  25833. /** Gets the node hierarchy used to render y-axis */
  25834. get: function () {
  25835. return this._yAxis;
  25836. },
  25837. enumerable: true,
  25838. configurable: true
  25839. });
  25840. Object.defineProperty(AxesViewer.prototype, "zAxis", {
  25841. /** Gets the node hierarchy used to render z-axis */
  25842. get: function () {
  25843. return this._zAxis;
  25844. },
  25845. enumerable: true,
  25846. configurable: true
  25847. });
  25848. /**
  25849. * Force the viewer to update
  25850. * @param position defines the position of the viewer
  25851. * @param xaxis defines the x axis of the viewer
  25852. * @param yaxis defines the y axis of the viewer
  25853. * @param zaxis defines the z axis of the viewer
  25854. */
  25855. AxesViewer.prototype.update = function (position, xaxis, yaxis, zaxis) {
  25856. this._xAxis.position.copyFrom(position);
  25857. this._xAxis.setDirection(xaxis);
  25858. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25859. this._yAxis.position.copyFrom(position);
  25860. this._yAxis.setDirection(yaxis);
  25861. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25862. this._zAxis.position.copyFrom(position);
  25863. this._zAxis.setDirection(zaxis);
  25864. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25865. };
  25866. /**
  25867. * Creates an instance of this axes viewer.
  25868. * @returns a new axes viewer with instanced meshes
  25869. */
  25870. AxesViewer.prototype.createInstance = function () {
  25871. var xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._xAxis);
  25872. var yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._yAxis);
  25873. var zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._zAxis);
  25874. var axesViewer = new AxesViewer(this.scene, this.scaleLines, null, xAxis, yAxis, zAxis);
  25875. axesViewer._instanced = true;
  25876. return axesViewer;
  25877. };
  25878. /** Releases resources */
  25879. AxesViewer.prototype.dispose = function () {
  25880. if (this._xAxis) {
  25881. this._xAxis.dispose(false, !this._instanced);
  25882. delete this._xAxis;
  25883. }
  25884. if (this._yAxis) {
  25885. this._yAxis.dispose(false, !this._instanced);
  25886. delete this._yAxis;
  25887. }
  25888. if (this._zAxis) {
  25889. this._zAxis.dispose(false, !this._instanced);
  25890. delete this._zAxis;
  25891. }
  25892. delete this.scene;
  25893. };
  25894. AxesViewer._SetRenderingGroupId = function (node, id) {
  25895. node.getChildMeshes().forEach(function (mesh) {
  25896. mesh.renderingGroupId = id;
  25897. });
  25898. };
  25899. return AxesViewer;
  25900. }());
  25901. /***/ }),
  25902. /***/ "./Debug/boneAxesViewer.ts":
  25903. /*!*********************************!*\
  25904. !*** ./Debug/boneAxesViewer.ts ***!
  25905. \*********************************/
  25906. /*! exports provided: BoneAxesViewer */
  25907. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25908. "use strict";
  25909. __webpack_require__.r(__webpack_exports__);
  25910. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return BoneAxesViewer; });
  25911. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  25912. /* harmony import */ var _Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/axesViewer */ "./Debug/axesViewer.ts");
  25913. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25914. /**
  25915. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  25916. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  25917. */
  25918. var BoneAxesViewer = /** @class */ (function (_super) {
  25919. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoneAxesViewer, _super);
  25920. /**
  25921. * Creates a new BoneAxesViewer
  25922. * @param scene defines the hosting scene
  25923. * @param bone defines the target bone
  25924. * @param mesh defines the target mesh
  25925. * @param scaleLines defines a scaling factor for line length (1 by default)
  25926. */
  25927. function BoneAxesViewer(scene, bone, mesh, scaleLines) {
  25928. if (scaleLines === void 0) { scaleLines = 1; }
  25929. var _this = _super.call(this, scene, scaleLines) || this;
  25930. /** Gets current position */
  25931. _this.pos = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25932. /** Gets direction of X axis */
  25933. _this.xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25934. /** Gets direction of Y axis */
  25935. _this.yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25936. /** Gets direction of Z axis */
  25937. _this.zaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25938. _this.mesh = mesh;
  25939. _this.bone = bone;
  25940. return _this;
  25941. }
  25942. /**
  25943. * Force the viewer to update
  25944. */
  25945. BoneAxesViewer.prototype.update = function () {
  25946. if (!this.mesh || !this.bone) {
  25947. return;
  25948. }
  25949. var bone = this.bone;
  25950. bone.getAbsolutePositionToRef(this.mesh, this.pos);
  25951. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].X, this.mesh, this.xaxis);
  25952. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y, this.mesh, this.yaxis);
  25953. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Z, this.mesh, this.zaxis);
  25954. _super.prototype.update.call(this, this.pos, this.xaxis, this.yaxis, this.zaxis);
  25955. };
  25956. /** Releases resources */
  25957. BoneAxesViewer.prototype.dispose = function () {
  25958. if (this.mesh) {
  25959. this.mesh = null;
  25960. this.bone = null;
  25961. _super.prototype.dispose.call(this);
  25962. }
  25963. };
  25964. return BoneAxesViewer;
  25965. }(_Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"]));
  25966. /***/ }),
  25967. /***/ "./Debug/debugLayer.ts":
  25968. /*!*****************************!*\
  25969. !*** ./Debug/debugLayer.ts ***!
  25970. \*****************************/
  25971. /*! exports provided: DebugLayer */
  25972. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25973. "use strict";
  25974. __webpack_require__.r(__webpack_exports__);
  25975. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return DebugLayer; });
  25976. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  25977. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  25978. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  25979. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  25980. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype, "debugLayer", {
  25981. get: function () {
  25982. if (!this._debugLayer) {
  25983. this._debugLayer = new DebugLayer(this);
  25984. }
  25985. return this._debugLayer;
  25986. },
  25987. enumerable: true,
  25988. configurable: true
  25989. });
  25990. /**
  25991. * The debug layer (aka Inspector) is the go to tool in order to better understand
  25992. * what is happening in your scene
  25993. * @see http://doc.babylonjs.com/features/playground_debuglayer
  25994. */
  25995. var DebugLayer = /** @class */ (function () {
  25996. /**
  25997. * Instantiates a new debug layer.
  25998. * The debug layer (aka Inspector) is the go to tool in order to better understand
  25999. * what is happening in your scene
  26000. * @see http://doc.babylonjs.com/features/playground_debuglayer
  26001. * @param scene Defines the scene to inspect
  26002. */
  26003. function DebugLayer(scene) {
  26004. var _this = this;
  26005. this.BJSINSPECTOR = this._getGlobalInspector();
  26006. /**
  26007. * Observable triggered when a property is changed through the inspector.
  26008. */
  26009. this.onPropertyChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  26010. this._scene = scene;
  26011. this._scene.onDisposeObservable.add(function () {
  26012. // Debug layer
  26013. if (_this._scene._debugLayer) {
  26014. _this._scene._debugLayer.hide();
  26015. }
  26016. });
  26017. }
  26018. /** Creates the inspector window. */
  26019. DebugLayer.prototype._createInspector = function (config) {
  26020. if (this.isVisible()) {
  26021. return;
  26022. }
  26023. var userOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ overlay: false, showExplorer: true, showInspector: true, embedMode: false, handleResize: true, enablePopup: true }, config);
  26024. this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector();
  26025. this.BJSINSPECTOR.Inspector.Show(this._scene, userOptions);
  26026. };
  26027. /** Get the inspector from bundle or global */
  26028. DebugLayer.prototype._getGlobalInspector = function () {
  26029. // UMD Global name detection from Webpack Bundle UMD Name.
  26030. if (typeof INSPECTOR !== 'undefined') {
  26031. return INSPECTOR;
  26032. }
  26033. // In case of module let s check the global emitted from the Inspector entry point.
  26034. if (typeof BABYLON !== 'undefined' && typeof BABYLON.Inspector !== 'undefined') {
  26035. return BABYLON;
  26036. }
  26037. return undefined;
  26038. };
  26039. /**
  26040. * Get if the inspector is visible or not.
  26041. * @returns true if visible otherwise, false
  26042. */
  26043. DebugLayer.prototype.isVisible = function () {
  26044. return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible;
  26045. };
  26046. /**
  26047. * Hide the inspector and close its window.
  26048. */
  26049. DebugLayer.prototype.hide = function () {
  26050. if (this.BJSINSPECTOR) {
  26051. this.BJSINSPECTOR.Inspector.Hide();
  26052. }
  26053. };
  26054. /**
  26055. * Launch the debugLayer.
  26056. * @param config Define the configuration of the inspector
  26057. */
  26058. DebugLayer.prototype.show = function (config) {
  26059. if (typeof this.BJSINSPECTOR == 'undefined') {
  26060. // Load inspector and add it to the DOM
  26061. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadScript(DebugLayer.InspectorURL, this._createInspector.bind(this, config));
  26062. }
  26063. else {
  26064. // Otherwise creates the inspector
  26065. this._createInspector(config);
  26066. }
  26067. };
  26068. /**
  26069. * Define the url to get the inspector script from.
  26070. * By default it uses the babylonjs CDN.
  26071. * @ignoreNaming
  26072. */
  26073. DebugLayer.InspectorURL = 'https://preview.babylonjs.com/inspector/babylon.inspector.bundle.js';
  26074. return DebugLayer;
  26075. }());
  26076. /***/ }),
  26077. /***/ "./Debug/index.ts":
  26078. /*!************************!*\
  26079. !*** ./Debug/index.ts ***!
  26080. \************************/
  26081. /*! exports provided: AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer */
  26082. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26083. "use strict";
  26084. __webpack_require__.r(__webpack_exports__);
  26085. /* harmony import */ var _axesViewer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axesViewer */ "./Debug/axesViewer.ts");
  26086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _axesViewer__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  26087. /* harmony import */ var _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneAxesViewer */ "./Debug/boneAxesViewer.ts");
  26088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"]; });
  26089. /* harmony import */ var _debugLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./debugLayer */ "./Debug/debugLayer.ts");
  26090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _debugLayer__WEBPACK_IMPORTED_MODULE_2__["DebugLayer"]; });
  26091. /* harmony import */ var _physicsViewer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsViewer */ "./Debug/physicsViewer.ts");
  26092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _physicsViewer__WEBPACK_IMPORTED_MODULE_3__["PhysicsViewer"]; });
  26093. /* harmony import */ var _rayHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rayHelper */ "./Debug/rayHelper.ts");
  26094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _rayHelper__WEBPACK_IMPORTED_MODULE_4__["RayHelper"]; });
  26095. /* harmony import */ var _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./skeletonViewer */ "./Debug/skeletonViewer.ts");
  26096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__["SkeletonViewer"]; });
  26097. /***/ }),
  26098. /***/ "./Debug/physicsViewer.ts":
  26099. /*!********************************!*\
  26100. !*** ./Debug/physicsViewer.ts ***!
  26101. \********************************/
  26102. /*! exports provided: PhysicsViewer */
  26103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26104. "use strict";
  26105. __webpack_require__.r(__webpack_exports__);
  26106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return PhysicsViewer; });
  26107. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  26108. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  26109. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26110. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  26111. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  26112. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  26113. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  26114. /**
  26115. * Used to show the physics impostor around the specific mesh
  26116. */
  26117. var PhysicsViewer = /** @class */ (function () {
  26118. /**
  26119. * Creates a new PhysicsViewer
  26120. * @param scene defines the hosting scene
  26121. */
  26122. function PhysicsViewer(scene) {
  26123. /** @hidden */
  26124. this._impostors = [];
  26125. /** @hidden */
  26126. this._meshes = [];
  26127. /** @hidden */
  26128. this._numMeshes = 0;
  26129. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  26130. var physicEngine = this._scene.getPhysicsEngine();
  26131. if (physicEngine) {
  26132. this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();
  26133. }
  26134. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"](this._scene, false);
  26135. this._utilityLayer.pickUtilitySceneFirst = false;
  26136. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  26137. }
  26138. /** @hidden */
  26139. PhysicsViewer.prototype._updateDebugMeshes = function () {
  26140. var plugin = this._physicsEnginePlugin;
  26141. for (var i = 0; i < this._numMeshes; i++) {
  26142. var impostor = this._impostors[i];
  26143. if (!impostor) {
  26144. continue;
  26145. }
  26146. if (impostor.isDisposed) {
  26147. this.hideImpostor(this._impostors[i--]);
  26148. }
  26149. else {
  26150. var mesh = this._meshes[i];
  26151. if (mesh && plugin) {
  26152. plugin.syncMeshWithImpostor(mesh, impostor);
  26153. }
  26154. }
  26155. }
  26156. };
  26157. /**
  26158. * Renders a specified physic impostor
  26159. * @param impostor defines the impostor to render
  26160. * @returns the new debug mesh used to render the impostor
  26161. */
  26162. PhysicsViewer.prototype.showImpostor = function (impostor) {
  26163. if (!this._scene) {
  26164. return null;
  26165. }
  26166. for (var i = 0; i < this._numMeshes; i++) {
  26167. if (this._impostors[i] == impostor) {
  26168. return null;
  26169. }
  26170. }
  26171. var debugMesh = this._getDebugMesh(impostor);
  26172. if (debugMesh) {
  26173. this._impostors[this._numMeshes] = impostor;
  26174. this._meshes[this._numMeshes] = debugMesh;
  26175. if (this._numMeshes === 0) {
  26176. this._renderFunction = this._updateDebugMeshes.bind(this);
  26177. this._scene.registerBeforeRender(this._renderFunction);
  26178. }
  26179. this._numMeshes++;
  26180. }
  26181. return debugMesh;
  26182. };
  26183. /**
  26184. * Hides a specified physic impostor
  26185. * @param impostor defines the impostor to hide
  26186. */
  26187. PhysicsViewer.prototype.hideImpostor = function (impostor) {
  26188. if (!impostor || !this._scene || !this._utilityLayer) {
  26189. return;
  26190. }
  26191. var removed = false;
  26192. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  26193. for (var i = 0; i < this._numMeshes; i++) {
  26194. if (this._impostors[i] == impostor) {
  26195. var mesh = this._meshes[i];
  26196. if (!mesh) {
  26197. continue;
  26198. }
  26199. utilityLayerScene.removeMesh(mesh);
  26200. mesh.dispose();
  26201. this._numMeshes--;
  26202. if (this._numMeshes > 0) {
  26203. this._meshes[i] = this._meshes[this._numMeshes];
  26204. this._impostors[i] = this._impostors[this._numMeshes];
  26205. this._meshes[this._numMeshes] = null;
  26206. this._impostors[this._numMeshes] = null;
  26207. }
  26208. else {
  26209. this._meshes[0] = null;
  26210. this._impostors[0] = null;
  26211. }
  26212. removed = true;
  26213. break;
  26214. }
  26215. }
  26216. if (removed && this._numMeshes === 0) {
  26217. this._scene.unregisterBeforeRender(this._renderFunction);
  26218. }
  26219. };
  26220. PhysicsViewer.prototype._getDebugMaterial = function (scene) {
  26221. if (!this._debugMaterial) {
  26222. this._debugMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_4__["StandardMaterial"]('', scene);
  26223. this._debugMaterial.wireframe = true;
  26224. this._debugMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  26225. this._debugMaterial.disableLighting = true;
  26226. }
  26227. return this._debugMaterial;
  26228. };
  26229. PhysicsViewer.prototype._getDebugBoxMesh = function (scene) {
  26230. if (!this._debugBoxMesh) {
  26231. this._debugBoxMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"].CreateBox('physicsBodyBoxViewMesh', { size: 1 }, scene);
  26232. this._debugBoxMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  26233. this._debugBoxMesh.material = this._getDebugMaterial(scene);
  26234. }
  26235. return this._debugBoxMesh.createInstance('physicsBodyBoxViewInstance');
  26236. };
  26237. PhysicsViewer.prototype._getDebugSphereMesh = function (scene) {
  26238. if (!this._debugSphereMesh) {
  26239. this._debugSphereMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere('physicsBodySphereViewMesh', { diameter: 1 }, scene);
  26240. this._debugSphereMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  26241. this._debugSphereMesh.material = this._getDebugMaterial(scene);
  26242. }
  26243. return this._debugSphereMesh.createInstance('physicsBodyBoxViewInstance');
  26244. };
  26245. PhysicsViewer.prototype._getDebugMesh = function (impostor) {
  26246. if (!this._utilityLayer) {
  26247. return null;
  26248. }
  26249. var mesh = null;
  26250. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  26251. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__["PhysicsImpostor"].BoxImpostor) {
  26252. mesh = this._getDebugBoxMesh(utilityLayerScene);
  26253. impostor.getBoxSizeToRef(mesh.scaling);
  26254. }
  26255. else if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__["PhysicsImpostor"].SphereImpostor) {
  26256. mesh = this._getDebugSphereMesh(utilityLayerScene);
  26257. var radius = impostor.getRadius();
  26258. mesh.scaling.x = radius * 2;
  26259. mesh.scaling.y = radius * 2;
  26260. mesh.scaling.z = radius * 2;
  26261. }
  26262. return mesh;
  26263. };
  26264. /** Releases all resources */
  26265. PhysicsViewer.prototype.dispose = function () {
  26266. for (var i = 0; i < this._numMeshes; i++) {
  26267. this.hideImpostor(this._impostors[i]);
  26268. }
  26269. if (this._debugBoxMesh) {
  26270. this._debugBoxMesh.dispose();
  26271. }
  26272. if (this._debugSphereMesh) {
  26273. this._debugSphereMesh.dispose();
  26274. }
  26275. if (this._debugMaterial) {
  26276. this._debugMaterial.dispose();
  26277. }
  26278. this._impostors.length = 0;
  26279. this._scene = null;
  26280. this._physicsEnginePlugin = null;
  26281. if (this._utilityLayer) {
  26282. this._utilityLayer.dispose();
  26283. this._utilityLayer = null;
  26284. }
  26285. };
  26286. return PhysicsViewer;
  26287. }());
  26288. /***/ }),
  26289. /***/ "./Debug/rayHelper.ts":
  26290. /*!****************************!*\
  26291. !*** ./Debug/rayHelper.ts ***!
  26292. \****************************/
  26293. /*! exports provided: RayHelper */
  26294. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26295. "use strict";
  26296. __webpack_require__.r(__webpack_exports__);
  26297. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return RayHelper; });
  26298. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26299. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  26300. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  26301. /**
  26302. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  26303. * in order to better appreciate the issue one might have.
  26304. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  26305. */
  26306. var RayHelper = /** @class */ (function () {
  26307. /**
  26308. * Instantiate a new ray helper.
  26309. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  26310. * in order to better appreciate the issue one might have.
  26311. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  26312. * @param ray Defines the ray we are currently tryin to visualize
  26313. */
  26314. function RayHelper(ray) {
  26315. this.ray = ray;
  26316. }
  26317. /**
  26318. * Helper function to create a colored helper in a scene in one line.
  26319. * @param ray Defines the ray we are currently tryin to visualize
  26320. * @param scene Defines the scene the ray is used in
  26321. * @param color Defines the color we want to see the ray in
  26322. * @returns The newly created ray helper.
  26323. */
  26324. RayHelper.CreateAndShow = function (ray, scene, color) {
  26325. var helper = new RayHelper(ray);
  26326. helper.show(scene, color);
  26327. return helper;
  26328. };
  26329. /**
  26330. * Shows the ray we are willing to debug.
  26331. * @param scene Defines the scene the ray needs to be rendered in
  26332. * @param color Defines the color the ray needs to be rendered in
  26333. */
  26334. RayHelper.prototype.show = function (scene, color) {
  26335. if (!this._renderFunction && this.ray) {
  26336. var ray = this.ray;
  26337. this._renderFunction = this._render.bind(this);
  26338. this._scene = scene;
  26339. this._renderPoints = [ray.origin, ray.origin.add(ray.direction.scale(ray.length))];
  26340. this._renderLine = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, scene, true);
  26341. if (this._renderFunction) {
  26342. this._scene.registerBeforeRender(this._renderFunction);
  26343. }
  26344. }
  26345. if (color && this._renderLine) {
  26346. this._renderLine.color.copyFrom(color);
  26347. }
  26348. };
  26349. /**
  26350. * Hides the ray we are debugging.
  26351. */
  26352. RayHelper.prototype.hide = function () {
  26353. if (this._renderFunction && this._scene) {
  26354. this._scene.unregisterBeforeRender(this._renderFunction);
  26355. this._scene = null;
  26356. this._renderFunction = null;
  26357. if (this._renderLine) {
  26358. this._renderLine.dispose();
  26359. this._renderLine = null;
  26360. }
  26361. this._renderPoints = [];
  26362. }
  26363. };
  26364. RayHelper.prototype._render = function () {
  26365. var ray = this.ray;
  26366. if (!ray) {
  26367. return;
  26368. }
  26369. var point = this._renderPoints[1];
  26370. var len = Math.min(ray.length, 1000000);
  26371. point.copyFrom(ray.direction);
  26372. point.scaleInPlace(len);
  26373. point.addInPlace(ray.origin);
  26374. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, this._scene, true, this._renderLine);
  26375. };
  26376. /**
  26377. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  26378. * @param mesh Defines the mesh we want the helper attached to
  26379. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  26380. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  26381. * @param length Defines the length of the ray
  26382. */
  26383. RayHelper.prototype.attachToMesh = function (mesh, meshSpaceDirection, meshSpaceOrigin, length) {
  26384. this._attachedToMesh = mesh;
  26385. var ray = this.ray;
  26386. if (!ray) {
  26387. return;
  26388. }
  26389. if (!ray.direction) {
  26390. ray.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26391. }
  26392. if (!ray.origin) {
  26393. ray.origin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26394. }
  26395. if (length) {
  26396. ray.length = length;
  26397. }
  26398. if (!meshSpaceOrigin) {
  26399. meshSpaceOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26400. }
  26401. if (!meshSpaceDirection) {
  26402. // -1 so that this will work with Mesh.lookAt
  26403. meshSpaceDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1);
  26404. }
  26405. if (!this._meshSpaceDirection) {
  26406. this._meshSpaceDirection = meshSpaceDirection.clone();
  26407. this._meshSpaceOrigin = meshSpaceOrigin.clone();
  26408. }
  26409. else {
  26410. this._meshSpaceDirection.copyFrom(meshSpaceDirection);
  26411. this._meshSpaceOrigin.copyFrom(meshSpaceOrigin);
  26412. }
  26413. if (!this._updateToMeshFunction) {
  26414. this._updateToMeshFunction = this._updateToMesh.bind(this);
  26415. this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction);
  26416. }
  26417. this._updateToMesh();
  26418. };
  26419. /**
  26420. * Detach the ray helper from the mesh it has previously been attached to.
  26421. */
  26422. RayHelper.prototype.detachFromMesh = function () {
  26423. if (this._attachedToMesh) {
  26424. if (this._updateToMeshFunction) {
  26425. this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction);
  26426. }
  26427. this._attachedToMesh = null;
  26428. this._updateToMeshFunction = null;
  26429. }
  26430. };
  26431. RayHelper.prototype._updateToMesh = function () {
  26432. var ray = this.ray;
  26433. if (!this._attachedToMesh || !ray) {
  26434. return;
  26435. }
  26436. if (this._attachedToMesh._isDisposed) {
  26437. this.detachFromMesh();
  26438. return;
  26439. }
  26440. this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection, ray.direction);
  26441. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._meshSpaceOrigin, this._attachedToMesh.getWorldMatrix(), ray.origin);
  26442. };
  26443. /**
  26444. * Dispose the helper and release its associated resources.
  26445. */
  26446. RayHelper.prototype.dispose = function () {
  26447. this.hide();
  26448. this.detachFromMesh();
  26449. this.ray = null;
  26450. };
  26451. return RayHelper;
  26452. }());
  26453. /***/ }),
  26454. /***/ "./Debug/skeletonViewer.ts":
  26455. /*!*********************************!*\
  26456. !*** ./Debug/skeletonViewer.ts ***!
  26457. \*********************************/
  26458. /*! exports provided: SkeletonViewer */
  26459. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26460. "use strict";
  26461. __webpack_require__.r(__webpack_exports__);
  26462. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return SkeletonViewer; });
  26463. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26464. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  26465. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  26466. /**
  26467. * Class used to render a debug view of a given skeleton
  26468. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  26469. */
  26470. var SkeletonViewer = /** @class */ (function () {
  26471. /**
  26472. * Creates a new SkeletonViewer
  26473. * @param skeleton defines the skeleton to render
  26474. * @param mesh defines the mesh attached to the skeleton
  26475. * @param scene defines the hosting scene
  26476. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  26477. * @param renderingGroupId defines the rendering group id to use with the viewer
  26478. */
  26479. function SkeletonViewer(
  26480. /** defines the skeleton to render */
  26481. skeleton,
  26482. /** defines the mesh attached to the skeleton */
  26483. mesh, scene,
  26484. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  26485. autoUpdateBonesMatrices,
  26486. /** defines the rendering group id to use with the viewer */
  26487. renderingGroupId) {
  26488. if (autoUpdateBonesMatrices === void 0) { autoUpdateBonesMatrices = true; }
  26489. if (renderingGroupId === void 0) { renderingGroupId = 1; }
  26490. this.skeleton = skeleton;
  26491. this.mesh = mesh;
  26492. this.autoUpdateBonesMatrices = autoUpdateBonesMatrices;
  26493. this.renderingGroupId = renderingGroupId;
  26494. /** Gets or sets the color used to render the skeleton */
  26495. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
  26496. this._debugLines = new Array();
  26497. this._isEnabled = false;
  26498. this._scene = scene;
  26499. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"](this._scene, false);
  26500. this._utilityLayer.pickUtilitySceneFirst = false;
  26501. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  26502. this.update();
  26503. this._renderFunction = this.update.bind(this);
  26504. }
  26505. Object.defineProperty(SkeletonViewer.prototype, "debugMesh", {
  26506. /**
  26507. * Returns the mesh used to render the bones
  26508. */
  26509. get: function () {
  26510. return this._debugMesh;
  26511. },
  26512. enumerable: true,
  26513. configurable: true
  26514. });
  26515. Object.defineProperty(SkeletonViewer.prototype, "isEnabled", {
  26516. get: function () {
  26517. return this._isEnabled;
  26518. },
  26519. /** Gets or sets a boolean indicating if the viewer is enabled */
  26520. set: function (value) {
  26521. if (this._isEnabled === value) {
  26522. return;
  26523. }
  26524. this._isEnabled = value;
  26525. if (value) {
  26526. this._scene.registerBeforeRender(this._renderFunction);
  26527. }
  26528. else {
  26529. this._scene.unregisterBeforeRender(this._renderFunction);
  26530. }
  26531. },
  26532. enumerable: true,
  26533. configurable: true
  26534. });
  26535. SkeletonViewer.prototype._getBonePosition = function (position, bone, meshMat, x, y, z) {
  26536. if (x === void 0) { x = 0; }
  26537. if (y === void 0) { y = 0; }
  26538. if (z === void 0) { z = 0; }
  26539. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  26540. var parentBone = bone.getParent();
  26541. tmat.copyFrom(bone.getLocalMatrix());
  26542. if (x !== 0 || y !== 0 || z !== 0) {
  26543. var tmat2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  26544. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(tmat2);
  26545. tmat2.setTranslationFromFloats(x, y, z);
  26546. tmat2.multiplyToRef(tmat, tmat);
  26547. }
  26548. if (parentBone) {
  26549. tmat.multiplyToRef(parentBone.getAbsoluteTransform(), tmat);
  26550. }
  26551. tmat.multiplyToRef(meshMat, tmat);
  26552. position.x = tmat.m[12];
  26553. position.y = tmat.m[13];
  26554. position.z = tmat.m[14];
  26555. };
  26556. SkeletonViewer.prototype._getLinesForBonesWithLength = function (bones, meshMat) {
  26557. var len = bones.length;
  26558. var meshPos = this.mesh.position;
  26559. for (var i = 0; i < len; i++) {
  26560. var bone = bones[i];
  26561. var points = this._debugLines[i];
  26562. if (!points) {
  26563. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  26564. this._debugLines[i] = points;
  26565. }
  26566. this._getBonePosition(points[0], bone, meshMat);
  26567. this._getBonePosition(points[1], bone, meshMat, 0, bone.length, 0);
  26568. points[0].subtractInPlace(meshPos);
  26569. points[1].subtractInPlace(meshPos);
  26570. }
  26571. };
  26572. SkeletonViewer.prototype._getLinesForBonesNoLength = function (bones, meshMat) {
  26573. var len = bones.length;
  26574. var boneNum = 0;
  26575. var meshPos = this.mesh.position;
  26576. for (var i = len - 1; i >= 0; i--) {
  26577. var childBone = bones[i];
  26578. var parentBone = childBone.getParent();
  26579. if (!parentBone) {
  26580. continue;
  26581. }
  26582. var points = this._debugLines[boneNum];
  26583. if (!points) {
  26584. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  26585. this._debugLines[boneNum] = points;
  26586. }
  26587. childBone.getAbsolutePositionToRef(this.mesh, points[0]);
  26588. parentBone.getAbsolutePositionToRef(this.mesh, points[1]);
  26589. points[0].subtractInPlace(meshPos);
  26590. points[1].subtractInPlace(meshPos);
  26591. boneNum++;
  26592. }
  26593. };
  26594. /** Update the viewer to sync with current skeleton state */
  26595. SkeletonViewer.prototype.update = function () {
  26596. if (!this._utilityLayer) {
  26597. return;
  26598. }
  26599. if (this.autoUpdateBonesMatrices) {
  26600. this.skeleton.computeAbsoluteTransforms();
  26601. }
  26602. if (this.skeleton.bones[0].length === undefined) {
  26603. this._getLinesForBonesNoLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  26604. }
  26605. else {
  26606. this._getLinesForBonesWithLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  26607. }
  26608. var targetScene = this._utilityLayer.utilityLayerScene;
  26609. if (!this._debugMesh) {
  26610. this._debugMesh = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: null }, targetScene);
  26611. this._debugMesh.renderingGroupId = this.renderingGroupId;
  26612. }
  26613. else {
  26614. _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: this._debugMesh }, targetScene);
  26615. }
  26616. this._debugMesh.position.copyFrom(this.mesh.position);
  26617. this._debugMesh.color = this.color;
  26618. };
  26619. /** Release associated resources */
  26620. SkeletonViewer.prototype.dispose = function () {
  26621. this.isEnabled = false;
  26622. if (this._debugMesh) {
  26623. this.isEnabled = false;
  26624. this._debugMesh.dispose();
  26625. this._debugMesh = null;
  26626. }
  26627. if (this._utilityLayer) {
  26628. this._utilityLayer.dispose();
  26629. this._utilityLayer = null;
  26630. }
  26631. };
  26632. return SkeletonViewer;
  26633. }());
  26634. /***/ }),
  26635. /***/ "./Engines/Extensions/engine.occlusionQuery.ts":
  26636. /*!*****************************************************!*\
  26637. !*** ./Engines/Extensions/engine.occlusionQuery.ts ***!
  26638. \*****************************************************/
  26639. /*! exports provided: _OcclusionDataStorage */
  26640. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26641. "use strict";
  26642. __webpack_require__.r(__webpack_exports__);
  26643. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _OcclusionDataStorage; });
  26644. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  26645. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  26646. /* harmony import */ var _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Instrumentation/timeToken */ "./Instrumentation/timeToken.ts");
  26647. /** @hidden */
  26648. var _OcclusionDataStorage = /** @class */ (function () {
  26649. function _OcclusionDataStorage() {
  26650. /** @hidden */
  26651. this.occlusionInternalRetryCounter = 0;
  26652. /** @hidden */
  26653. this.isOcclusionQueryInProgress = false;
  26654. /** @hidden */
  26655. this.isOccluded = false;
  26656. /** @hidden */
  26657. this.occlusionRetryCount = -1;
  26658. /** @hidden */
  26659. this.occlusionType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE;
  26660. /** @hidden */
  26661. this.occlusionQueryAlgorithmType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE;
  26662. }
  26663. return _OcclusionDataStorage;
  26664. }());
  26665. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createQuery = function () {
  26666. return this._gl.createQuery();
  26667. };
  26668. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteQuery = function (query) {
  26669. this._gl.deleteQuery(query);
  26670. return this;
  26671. };
  26672. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.isQueryResultAvailable = function (query) {
  26673. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT_AVAILABLE);
  26674. };
  26675. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.getQueryResult = function (query) {
  26676. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT);
  26677. };
  26678. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginOcclusionQuery = function (algorithmType, query) {
  26679. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  26680. this._gl.beginQuery(glAlgorithm, query);
  26681. return this;
  26682. };
  26683. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endOcclusionQuery = function (algorithmType) {
  26684. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  26685. this._gl.endQuery(glAlgorithm);
  26686. return this;
  26687. };
  26688. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._createTimeQuery = function () {
  26689. var timerQuery = this.getCaps().timerQuery;
  26690. if (timerQuery.createQueryEXT) {
  26691. return timerQuery.createQueryEXT();
  26692. }
  26693. return this.createQuery();
  26694. };
  26695. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._deleteTimeQuery = function (query) {
  26696. var timerQuery = this.getCaps().timerQuery;
  26697. if (timerQuery.deleteQueryEXT) {
  26698. timerQuery.deleteQueryEXT(query);
  26699. return;
  26700. }
  26701. this.deleteQuery(query);
  26702. };
  26703. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryResult = function (query) {
  26704. var timerQuery = this.getCaps().timerQuery;
  26705. if (timerQuery.getQueryObjectEXT) {
  26706. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_EXT);
  26707. }
  26708. return this.getQueryResult(query);
  26709. };
  26710. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryAvailability = function (query) {
  26711. var timerQuery = this.getCaps().timerQuery;
  26712. if (timerQuery.getQueryObjectEXT) {
  26713. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_AVAILABLE_EXT);
  26714. }
  26715. return this.isQueryResultAvailable(query);
  26716. };
  26717. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.startTimeQuery = function () {
  26718. var caps = this.getCaps();
  26719. var timerQuery = caps.timerQuery;
  26720. if (!timerQuery) {
  26721. return null;
  26722. }
  26723. var token = new _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]();
  26724. this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  26725. if (caps.canUseTimestampForTimerQuery) {
  26726. token._startTimeQuery = this._createTimeQuery();
  26727. timerQuery.queryCounterEXT(token._startTimeQuery, timerQuery.TIMESTAMP_EXT);
  26728. }
  26729. else {
  26730. if (this._currentNonTimestampToken) {
  26731. return this._currentNonTimestampToken;
  26732. }
  26733. token._timeElapsedQuery = this._createTimeQuery();
  26734. if (timerQuery.beginQueryEXT) {
  26735. timerQuery.beginQueryEXT(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  26736. }
  26737. else {
  26738. this._gl.beginQuery(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  26739. }
  26740. this._currentNonTimestampToken = token;
  26741. }
  26742. return token;
  26743. };
  26744. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTimeQuery = function (token) {
  26745. var caps = this.getCaps();
  26746. var timerQuery = caps.timerQuery;
  26747. if (!timerQuery || !token) {
  26748. return -1;
  26749. }
  26750. if (caps.canUseTimestampForTimerQuery) {
  26751. if (!token._startTimeQuery) {
  26752. return -1;
  26753. }
  26754. if (!token._endTimeQuery) {
  26755. token._endTimeQuery = this._createTimeQuery();
  26756. timerQuery.queryCounterEXT(token._endTimeQuery, timerQuery.TIMESTAMP_EXT);
  26757. }
  26758. }
  26759. else if (!token._timeElapsedQueryEnded) {
  26760. if (!token._timeElapsedQuery) {
  26761. return -1;
  26762. }
  26763. if (timerQuery.endQueryEXT) {
  26764. timerQuery.endQueryEXT(timerQuery.TIME_ELAPSED_EXT);
  26765. }
  26766. else {
  26767. this._gl.endQuery(timerQuery.TIME_ELAPSED_EXT);
  26768. }
  26769. token._timeElapsedQueryEnded = true;
  26770. }
  26771. var disjoint = this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  26772. var available = false;
  26773. if (token._endTimeQuery) {
  26774. available = this._getTimeQueryAvailability(token._endTimeQuery);
  26775. }
  26776. else if (token._timeElapsedQuery) {
  26777. available = this._getTimeQueryAvailability(token._timeElapsedQuery);
  26778. }
  26779. if (available && !disjoint) {
  26780. var result = 0;
  26781. if (caps.canUseTimestampForTimerQuery) {
  26782. if (!token._startTimeQuery || !token._endTimeQuery) {
  26783. return -1;
  26784. }
  26785. var timeStart = this._getTimeQueryResult(token._startTimeQuery);
  26786. var timeEnd = this._getTimeQueryResult(token._endTimeQuery);
  26787. result = timeEnd - timeStart;
  26788. this._deleteTimeQuery(token._startTimeQuery);
  26789. this._deleteTimeQuery(token._endTimeQuery);
  26790. token._startTimeQuery = null;
  26791. token._endTimeQuery = null;
  26792. }
  26793. else {
  26794. if (!token._timeElapsedQuery) {
  26795. return -1;
  26796. }
  26797. result = this._getTimeQueryResult(token._timeElapsedQuery);
  26798. this._deleteTimeQuery(token._timeElapsedQuery);
  26799. token._timeElapsedQuery = null;
  26800. token._timeElapsedQueryEnded = false;
  26801. this._currentNonTimestampToken = null;
  26802. }
  26803. return result;
  26804. }
  26805. return -1;
  26806. };
  26807. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getGlAlgorithmType = function (algorithmType) {
  26808. return algorithmType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED;
  26809. };
  26810. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOcclusionQueryInProgress", {
  26811. get: function () {
  26812. return this._occlusionDataStorage.isOcclusionQueryInProgress;
  26813. },
  26814. enumerable: false,
  26815. configurable: true
  26816. });
  26817. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "_occlusionDataStorage", {
  26818. get: function () {
  26819. if (!this.__occlusionDataStorage) {
  26820. this.__occlusionDataStorage = new _OcclusionDataStorage();
  26821. }
  26822. return this.__occlusionDataStorage;
  26823. },
  26824. enumerable: false,
  26825. configurable: true
  26826. });
  26827. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOccluded", {
  26828. get: function () {
  26829. return this._occlusionDataStorage.isOccluded;
  26830. },
  26831. set: function (value) {
  26832. this._occlusionDataStorage.isOccluded = value;
  26833. },
  26834. enumerable: true,
  26835. configurable: true
  26836. });
  26837. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionQueryAlgorithmType", {
  26838. get: function () {
  26839. return this._occlusionDataStorage.occlusionQueryAlgorithmType;
  26840. },
  26841. set: function (value) {
  26842. this._occlusionDataStorage.occlusionQueryAlgorithmType = value;
  26843. },
  26844. enumerable: true,
  26845. configurable: true
  26846. });
  26847. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionType", {
  26848. get: function () {
  26849. return this._occlusionDataStorage.occlusionType;
  26850. },
  26851. set: function (value) {
  26852. this._occlusionDataStorage.occlusionType = value;
  26853. },
  26854. enumerable: true,
  26855. configurable: true
  26856. });
  26857. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionRetryCount", {
  26858. get: function () {
  26859. return this._occlusionDataStorage.occlusionRetryCount;
  26860. },
  26861. set: function (value) {
  26862. this._occlusionDataStorage.occlusionRetryCount = value;
  26863. },
  26864. enumerable: true,
  26865. configurable: true
  26866. });
  26867. // We also need to update AbstractMesh as there is a portion of the code there
  26868. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype._checkOcclusionQuery = function () {
  26869. var dataStorage = this._occlusionDataStorage;
  26870. if (dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE) {
  26871. dataStorage.isOccluded = false;
  26872. return false;
  26873. }
  26874. var engine = this.getEngine();
  26875. if (engine.webGLVersion < 2) {
  26876. dataStorage.isOccluded = false;
  26877. return false;
  26878. }
  26879. if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
  26880. dataStorage.isOccluded = false;
  26881. return false;
  26882. }
  26883. if (this.isOcclusionQueryInProgress && this._occlusionQuery) {
  26884. var isOcclusionQueryAvailable = engine.isQueryResultAvailable(this._occlusionQuery);
  26885. if (isOcclusionQueryAvailable) {
  26886. var occlusionQueryResult = engine.getQueryResult(this._occlusionQuery);
  26887. dataStorage.isOcclusionQueryInProgress = false;
  26888. dataStorage.occlusionInternalRetryCounter = 0;
  26889. dataStorage.isOccluded = occlusionQueryResult === 1 ? false : true;
  26890. }
  26891. else {
  26892. dataStorage.occlusionInternalRetryCounter++;
  26893. if (dataStorage.occlusionRetryCount !== -1 && dataStorage.occlusionInternalRetryCounter > dataStorage.occlusionRetryCount) {
  26894. dataStorage.isOcclusionQueryInProgress = false;
  26895. dataStorage.occlusionInternalRetryCounter = 0;
  26896. // if optimistic set isOccluded to false regardless of the status of isOccluded. (Render in the current render loop)
  26897. // if strict continue the last state of the object.
  26898. dataStorage.isOccluded = dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_OPTIMISTIC ? false : dataStorage.isOccluded;
  26899. }
  26900. else {
  26901. return false;
  26902. }
  26903. }
  26904. }
  26905. var scene = this.getScene();
  26906. if (scene.getBoundingBoxRenderer) {
  26907. var occlusionBoundingBoxRenderer = scene.getBoundingBoxRenderer();
  26908. if (!this._occlusionQuery) {
  26909. this._occlusionQuery = engine.createQuery();
  26910. }
  26911. engine.beginOcclusionQuery(dataStorage.occlusionQueryAlgorithmType, this._occlusionQuery);
  26912. occlusionBoundingBoxRenderer.renderOcclusionBoundingBox(this);
  26913. engine.endOcclusionQuery(dataStorage.occlusionQueryAlgorithmType);
  26914. this._occlusionDataStorage.isOcclusionQueryInProgress = true;
  26915. }
  26916. return dataStorage.isOccluded;
  26917. };
  26918. /***/ }),
  26919. /***/ "./Engines/Extensions/engine.transformFeedback.ts":
  26920. /*!********************************************************!*\
  26921. !*** ./Engines/Extensions/engine.transformFeedback.ts ***!
  26922. \********************************************************/
  26923. /*! exports provided: _forceTransformFeedbackToBundle */
  26924. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26925. "use strict";
  26926. __webpack_require__.r(__webpack_exports__);
  26927. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _forceTransformFeedbackToBundle; });
  26928. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  26929. /** @hidden */
  26930. var _forceTransformFeedbackToBundle = true;
  26931. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createTransformFeedback = function () {
  26932. return this._gl.createTransformFeedback();
  26933. };
  26934. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteTransformFeedback = function (value) {
  26935. this._gl.deleteTransformFeedback(value);
  26936. };
  26937. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedback = function (value) {
  26938. this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, value);
  26939. };
  26940. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginTransformFeedback = function (usePoints) {
  26941. if (usePoints === void 0) { usePoints = true; }
  26942. this._gl.beginTransformFeedback(usePoints ? this._gl.POINTS : this._gl.TRIANGLES);
  26943. };
  26944. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTransformFeedback = function () {
  26945. this._gl.endTransformFeedback();
  26946. };
  26947. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.setTranformFeedbackVaryings = function (program, value) {
  26948. this._gl.transformFeedbackVaryings(program, value, this._gl.INTERLEAVED_ATTRIBS);
  26949. };
  26950. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedbackBuffer = function (value) {
  26951. this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, value);
  26952. };
  26953. /***/ }),
  26954. /***/ "./Engines/Extensions/index.ts":
  26955. /*!*************************************!*\
  26956. !*** ./Engines/Extensions/index.ts ***!
  26957. \*************************************/
  26958. /*! exports provided: _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  26959. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26960. "use strict";
  26961. __webpack_require__.r(__webpack_exports__);
  26962. /* harmony import */ var _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.occlusionQuery */ "./Engines/Extensions/engine.occlusionQuery.ts");
  26963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  26964. /* harmony import */ var _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.transformFeedback */ "./Engines/Extensions/engine.transformFeedback.ts");
  26965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__["_forceTransformFeedbackToBundle"]; });
  26966. /***/ }),
  26967. /***/ "./Engines/constants.ts":
  26968. /*!******************************!*\
  26969. !*** ./Engines/constants.ts ***!
  26970. \******************************/
  26971. /*! exports provided: Constants */
  26972. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26973. "use strict";
  26974. __webpack_require__.r(__webpack_exports__);
  26975. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return Constants; });
  26976. /** Defines the cross module used constants to avoid circular dependncies */
  26977. var Constants = /** @class */ (function () {
  26978. function Constants() {
  26979. }
  26980. /** Defines that alpha blending is disabled */
  26981. Constants.ALPHA_DISABLE = 0;
  26982. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26983. Constants.ALPHA_ADD = 1;
  26984. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26985. Constants.ALPHA_COMBINE = 2;
  26986. /** Defines that alpha blending to DEST - SRC * DEST */
  26987. Constants.ALPHA_SUBTRACT = 3;
  26988. /** Defines that alpha blending to SRC * DEST */
  26989. Constants.ALPHA_MULTIPLY = 4;
  26990. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26991. Constants.ALPHA_MAXIMIZED = 5;
  26992. /** Defines that alpha blending to SRC + DEST */
  26993. Constants.ALPHA_ONEONE = 6;
  26994. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26995. Constants.ALPHA_PREMULTIPLIED = 7;
  26996. /**
  26997. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26998. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26999. */
  27000. Constants.ALPHA_PREMULTIPLIED_PORTERDUFF = 8;
  27001. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27002. Constants.ALPHA_INTERPOLATE = 9;
  27003. /**
  27004. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27005. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27006. */
  27007. Constants.ALPHA_SCREENMODE = 10;
  27008. /** Defines that the ressource is not delayed*/
  27009. Constants.DELAYLOADSTATE_NONE = 0;
  27010. /** Defines that the ressource was successfully delay loaded */
  27011. Constants.DELAYLOADSTATE_LOADED = 1;
  27012. /** Defines that the ressource is currently delay loading */
  27013. Constants.DELAYLOADSTATE_LOADING = 2;
  27014. /** Defines that the ressource is delayed and has not started loading */
  27015. Constants.DELAYLOADSTATE_NOTLOADED = 4;
  27016. // Depht or Stencil test Constants.
  27017. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27018. Constants.NEVER = 0x0200;
  27019. /** 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 */
  27020. Constants.ALWAYS = 0x0207;
  27021. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27022. Constants.LESS = 0x0201;
  27023. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27024. Constants.EQUAL = 0x0202;
  27025. /** 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 */
  27026. Constants.LEQUAL = 0x0203;
  27027. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27028. Constants.GREATER = 0x0204;
  27029. /** 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 */
  27030. Constants.GEQUAL = 0x0206;
  27031. /** 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 */
  27032. Constants.NOTEQUAL = 0x0205;
  27033. // Stencil Actions Constants.
  27034. /** Passed to stencilOperation to specify that stencil value must be kept */
  27035. Constants.KEEP = 0x1E00;
  27036. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27037. Constants.REPLACE = 0x1E01;
  27038. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27039. Constants.INCR = 0x1E02;
  27040. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27041. Constants.DECR = 0x1E03;
  27042. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27043. Constants.INVERT = 0x150A;
  27044. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27045. Constants.INCR_WRAP = 0x8507;
  27046. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27047. Constants.DECR_WRAP = 0x8508;
  27048. /** Texture is not repeating outside of 0..1 UVs */
  27049. Constants.TEXTURE_CLAMP_ADDRESSMODE = 0;
  27050. /** Texture is repeating outside of 0..1 UVs */
  27051. Constants.TEXTURE_WRAP_ADDRESSMODE = 1;
  27052. /** Texture is repeating and mirrored */
  27053. Constants.TEXTURE_MIRROR_ADDRESSMODE = 2;
  27054. /** ALPHA */
  27055. Constants.TEXTUREFORMAT_ALPHA = 0;
  27056. /** LUMINANCE */
  27057. Constants.TEXTUREFORMAT_LUMINANCE = 1;
  27058. /** LUMINANCE_ALPHA */
  27059. Constants.TEXTUREFORMAT_LUMINANCE_ALPHA = 2;
  27060. /** RGB */
  27061. Constants.TEXTUREFORMAT_RGB = 4;
  27062. /** RGBA */
  27063. Constants.TEXTUREFORMAT_RGBA = 5;
  27064. /** RED */
  27065. Constants.TEXTUREFORMAT_RED = 6;
  27066. /** RED (2nd reference) */
  27067. Constants.TEXTUREFORMAT_R = 6;
  27068. /** RG */
  27069. Constants.TEXTUREFORMAT_RG = 7;
  27070. /** RED_INTEGER */
  27071. Constants.TEXTUREFORMAT_RED_INTEGER = 8;
  27072. /** RED_INTEGER (2nd reference) */
  27073. Constants.TEXTUREFORMAT_R_INTEGER = 8;
  27074. /** RG_INTEGER */
  27075. Constants.TEXTUREFORMAT_RG_INTEGER = 9;
  27076. /** RGB_INTEGER */
  27077. Constants.TEXTUREFORMAT_RGB_INTEGER = 10;
  27078. /** RGBA_INTEGER */
  27079. Constants.TEXTUREFORMAT_RGBA_INTEGER = 11;
  27080. /** UNSIGNED_BYTE */
  27081. Constants.TEXTURETYPE_UNSIGNED_BYTE = 0;
  27082. /** UNSIGNED_BYTE (2nd reference) */
  27083. Constants.TEXTURETYPE_UNSIGNED_INT = 0;
  27084. /** FLOAT */
  27085. Constants.TEXTURETYPE_FLOAT = 1;
  27086. /** HALF_FLOAT */
  27087. Constants.TEXTURETYPE_HALF_FLOAT = 2;
  27088. /** BYTE */
  27089. Constants.TEXTURETYPE_BYTE = 3;
  27090. /** SHORT */
  27091. Constants.TEXTURETYPE_SHORT = 4;
  27092. /** UNSIGNED_SHORT */
  27093. Constants.TEXTURETYPE_UNSIGNED_SHORT = 5;
  27094. /** INT */
  27095. Constants.TEXTURETYPE_INT = 6;
  27096. /** UNSIGNED_INT */
  27097. Constants.TEXTURETYPE_UNSIGNED_INTEGER = 7;
  27098. /** UNSIGNED_SHORT_4_4_4_4 */
  27099. Constants.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8;
  27100. /** UNSIGNED_SHORT_5_5_5_1 */
  27101. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9;
  27102. /** UNSIGNED_SHORT_5_6_5 */
  27103. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10;
  27104. /** UNSIGNED_INT_2_10_10_10_REV */
  27105. Constants.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11;
  27106. /** UNSIGNED_INT_24_8 */
  27107. Constants.TEXTURETYPE_UNSIGNED_INT_24_8 = 12;
  27108. /** UNSIGNED_INT_10F_11F_11F_REV */
  27109. Constants.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13;
  27110. /** UNSIGNED_INT_5_9_9_9_REV */
  27111. Constants.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14;
  27112. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27113. Constants.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15;
  27114. /** nearest is mag = nearest and min = nearest and mip = linear */
  27115. Constants.TEXTURE_NEAREST_SAMPLINGMODE = 1;
  27116. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27117. Constants.TEXTURE_BILINEAR_SAMPLINGMODE = 2;
  27118. /** Trilinear is mag = linear and min = linear and mip = linear */
  27119. Constants.TEXTURE_TRILINEAR_SAMPLINGMODE = 3;
  27120. /** nearest is mag = nearest and min = nearest and mip = linear */
  27121. Constants.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 1;
  27122. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27123. Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 2;
  27124. /** Trilinear is mag = linear and min = linear and mip = linear */
  27125. Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3;
  27126. /** mag = nearest and min = nearest and mip = nearest */
  27127. Constants.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4;
  27128. /** mag = nearest and min = linear and mip = nearest */
  27129. Constants.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5;
  27130. /** mag = nearest and min = linear and mip = linear */
  27131. Constants.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6;
  27132. /** mag = nearest and min = linear and mip = none */
  27133. Constants.TEXTURE_NEAREST_LINEAR = 7;
  27134. /** mag = nearest and min = nearest and mip = none */
  27135. Constants.TEXTURE_NEAREST_NEAREST = 8;
  27136. /** mag = linear and min = nearest and mip = nearest */
  27137. Constants.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9;
  27138. /** mag = linear and min = nearest and mip = linear */
  27139. Constants.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10;
  27140. /** mag = linear and min = linear and mip = none */
  27141. Constants.TEXTURE_LINEAR_LINEAR = 11;
  27142. /** mag = linear and min = nearest and mip = none */
  27143. Constants.TEXTURE_LINEAR_NEAREST = 12;
  27144. /** Explicit coordinates mode */
  27145. Constants.TEXTURE_EXPLICIT_MODE = 0;
  27146. /** Spherical coordinates mode */
  27147. Constants.TEXTURE_SPHERICAL_MODE = 1;
  27148. /** Planar coordinates mode */
  27149. Constants.TEXTURE_PLANAR_MODE = 2;
  27150. /** Cubic coordinates mode */
  27151. Constants.TEXTURE_CUBIC_MODE = 3;
  27152. /** Projection coordinates mode */
  27153. Constants.TEXTURE_PROJECTION_MODE = 4;
  27154. /** Skybox coordinates mode */
  27155. Constants.TEXTURE_SKYBOX_MODE = 5;
  27156. /** Inverse Cubic coordinates mode */
  27157. Constants.TEXTURE_INVCUBIC_MODE = 6;
  27158. /** Equirectangular coordinates mode */
  27159. Constants.TEXTURE_EQUIRECTANGULAR_MODE = 7;
  27160. /** Equirectangular Fixed coordinates mode */
  27161. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8;
  27162. /** Equirectangular Fixed Mirrored coordinates mode */
  27163. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9;
  27164. // Texture rescaling mode
  27165. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27166. Constants.SCALEMODE_FLOOR = 1;
  27167. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27168. Constants.SCALEMODE_NEAREST = 2;
  27169. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27170. Constants.SCALEMODE_CEILING = 3;
  27171. /**
  27172. * The dirty texture flag value
  27173. */
  27174. Constants.MATERIAL_TextureDirtyFlag = 1;
  27175. /**
  27176. * The dirty light flag value
  27177. */
  27178. Constants.MATERIAL_LightDirtyFlag = 2;
  27179. /**
  27180. * The dirty fresnel flag value
  27181. */
  27182. Constants.MATERIAL_FresnelDirtyFlag = 4;
  27183. /**
  27184. * The dirty attribute flag value
  27185. */
  27186. Constants.MATERIAL_AttributesDirtyFlag = 8;
  27187. /**
  27188. * The dirty misc flag value
  27189. */
  27190. Constants.MATERIAL_MiscDirtyFlag = 16;
  27191. /**
  27192. * The all dirty flag value
  27193. */
  27194. Constants.MATERIAL_AllDirtyFlag = 31;
  27195. /**
  27196. * Returns the triangle fill mode
  27197. */
  27198. Constants.MATERIAL_TriangleFillMode = 0;
  27199. /**
  27200. * Returns the wireframe mode
  27201. */
  27202. Constants.MATERIAL_WireFrameFillMode = 1;
  27203. /**
  27204. * Returns the point fill mode
  27205. */
  27206. Constants.MATERIAL_PointFillMode = 2;
  27207. /**
  27208. * Returns the point list draw mode
  27209. */
  27210. Constants.MATERIAL_PointListDrawMode = 3;
  27211. /**
  27212. * Returns the line list draw mode
  27213. */
  27214. Constants.MATERIAL_LineListDrawMode = 4;
  27215. /**
  27216. * Returns the line loop draw mode
  27217. */
  27218. Constants.MATERIAL_LineLoopDrawMode = 5;
  27219. /**
  27220. * Returns the line strip draw mode
  27221. */
  27222. Constants.MATERIAL_LineStripDrawMode = 6;
  27223. /**
  27224. * Returns the triangle strip draw mode
  27225. */
  27226. Constants.MATERIAL_TriangleStripDrawMode = 7;
  27227. /**
  27228. * Returns the triangle fan draw mode
  27229. */
  27230. Constants.MATERIAL_TriangleFanDrawMode = 8;
  27231. /**
  27232. * Stores the clock-wise side orientation
  27233. */
  27234. Constants.MATERIAL_ClockWiseSideOrientation = 0;
  27235. /**
  27236. * Stores the counter clock-wise side orientation
  27237. */
  27238. Constants.MATERIAL_CounterClockWiseSideOrientation = 1;
  27239. /**
  27240. * Nothing
  27241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27242. */
  27243. Constants.ACTION_NothingTrigger = 0;
  27244. /**
  27245. * On pick
  27246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27247. */
  27248. Constants.ACTION_OnPickTrigger = 1;
  27249. /**
  27250. * On left pick
  27251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27252. */
  27253. Constants.ACTION_OnLeftPickTrigger = 2;
  27254. /**
  27255. * On right pick
  27256. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27257. */
  27258. Constants.ACTION_OnRightPickTrigger = 3;
  27259. /**
  27260. * On center pick
  27261. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27262. */
  27263. Constants.ACTION_OnCenterPickTrigger = 4;
  27264. /**
  27265. * On pick down
  27266. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27267. */
  27268. Constants.ACTION_OnPickDownTrigger = 5;
  27269. /**
  27270. * On double pick
  27271. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27272. */
  27273. Constants.ACTION_OnDoublePickTrigger = 6;
  27274. /**
  27275. * On pick up
  27276. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27277. */
  27278. Constants.ACTION_OnPickUpTrigger = 7;
  27279. /**
  27280. * On pick out.
  27281. * This trigger will only be raised if you also declared a OnPickDown
  27282. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27283. */
  27284. Constants.ACTION_OnPickOutTrigger = 16;
  27285. /**
  27286. * On long press
  27287. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27288. */
  27289. Constants.ACTION_OnLongPressTrigger = 8;
  27290. /**
  27291. * On pointer over
  27292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27293. */
  27294. Constants.ACTION_OnPointerOverTrigger = 9;
  27295. /**
  27296. * On pointer out
  27297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27298. */
  27299. Constants.ACTION_OnPointerOutTrigger = 10;
  27300. /**
  27301. * On every frame
  27302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27303. */
  27304. Constants.ACTION_OnEveryFrameTrigger = 11;
  27305. /**
  27306. * On intersection enter
  27307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27308. */
  27309. Constants.ACTION_OnIntersectionEnterTrigger = 12;
  27310. /**
  27311. * On intersection exit
  27312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27313. */
  27314. Constants.ACTION_OnIntersectionExitTrigger = 13;
  27315. /**
  27316. * On key down
  27317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27318. */
  27319. Constants.ACTION_OnKeyDownTrigger = 14;
  27320. /**
  27321. * On key up
  27322. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27323. */
  27324. Constants.ACTION_OnKeyUpTrigger = 15;
  27325. /**
  27326. * Billboard mode will only apply to Y axis
  27327. */
  27328. Constants.PARTICLES_BILLBOARDMODE_Y = 2;
  27329. /**
  27330. * Billboard mode will apply to all axes
  27331. */
  27332. Constants.PARTICLES_BILLBOARDMODE_ALL = 7;
  27333. /**
  27334. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  27335. */
  27336. Constants.PARTICLES_BILLBOARDMODE_STRETCHED = 8;
  27337. /**
  27338. * Gets or sets base Assets URL
  27339. */
  27340. Constants.PARTICLES_BaseAssetsUrl = "https://assets.babylonjs.com/particles";
  27341. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27342. * Test order :
  27343. * Is the bounding sphere outside the frustum ?
  27344. * If not, are the bounding box vertices outside the frustum ?
  27345. * It not, then the cullable object is in the frustum.
  27346. */
  27347. Constants.MESHES_CULLINGSTRATEGY_STANDARD = 0;
  27348. /** Culling strategy : Bounding Sphere Only.
  27349. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27350. * It's also less accurate than the standard because some not visible objects can still be selected.
  27351. * Test : is the bounding sphere outside the frustum ?
  27352. * If not, then the cullable object is in the frustum.
  27353. */
  27354. Constants.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1;
  27355. /** Culling strategy : Optimistic Inclusion.
  27356. * This in an inclusion test first, then the standard exclusion test.
  27357. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27358. * 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.
  27359. * Anyway, it's as accurate as the standard strategy.
  27360. * Test :
  27361. * Is the cullable object bounding sphere center in the frustum ?
  27362. * If not, apply the default culling strategy.
  27363. */
  27364. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2;
  27365. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27366. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27367. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27368. * 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.
  27369. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27370. * Test :
  27371. * Is the cullable object bounding sphere center in the frustum ?
  27372. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27373. */
  27374. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3;
  27375. /**
  27376. * No logging while loading
  27377. */
  27378. Constants.SCENELOADER_NO_LOGGING = 0;
  27379. /**
  27380. * Minimal logging while loading
  27381. */
  27382. Constants.SCENELOADER_MINIMAL_LOGGING = 1;
  27383. /**
  27384. * Summary logging while loading
  27385. */
  27386. Constants.SCENELOADER_SUMMARY_LOGGING = 2;
  27387. /**
  27388. * Detailled logging while loading
  27389. */
  27390. Constants.SCENELOADER_DETAILED_LOGGING = 3;
  27391. return Constants;
  27392. }());
  27393. /***/ }),
  27394. /***/ "./Engines/engine.ts":
  27395. /*!***************************!*\
  27396. !*** ./Engines/engine.ts ***!
  27397. \***************************/
  27398. /*! exports provided: InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine */
  27399. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27400. "use strict";
  27401. __webpack_require__.r(__webpack_exports__);
  27402. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return InstancingAttributeInfo; });
  27403. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return DepthTextureCreationOptions; });
  27404. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return EngineCapabilities; });
  27405. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return Engine; });
  27406. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  27407. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  27408. /* harmony import */ var _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/performanceMonitor */ "./Misc/performanceMonitor.ts");
  27409. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  27410. /* harmony import */ var _Misc_promise__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/promise */ "./Misc/promise.ts");
  27411. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  27412. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  27413. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  27414. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  27415. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  27416. /* harmony import */ var _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  27417. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  27418. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../States/index */ "./States/index.ts");
  27419. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  27420. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  27421. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  27422. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  27423. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  27424. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  27425. /**
  27426. * Keeps track of all the buffer info used in engine.
  27427. */
  27428. var BufferPointer = /** @class */ (function () {
  27429. function BufferPointer() {
  27430. }
  27431. return BufferPointer;
  27432. }());
  27433. /**
  27434. * Interface for attribute information associated with buffer instanciation
  27435. */
  27436. var InstancingAttributeInfo = /** @class */ (function () {
  27437. function InstancingAttributeInfo() {
  27438. }
  27439. return InstancingAttributeInfo;
  27440. }());
  27441. /**
  27442. * Define options used to create a depth texture
  27443. */
  27444. var DepthTextureCreationOptions = /** @class */ (function () {
  27445. function DepthTextureCreationOptions() {
  27446. }
  27447. return DepthTextureCreationOptions;
  27448. }());
  27449. /**
  27450. * Class used to describe the capabilities of the engine relatively to the current browser
  27451. */
  27452. var EngineCapabilities = /** @class */ (function () {
  27453. function EngineCapabilities() {
  27454. }
  27455. return EngineCapabilities;
  27456. }());
  27457. /**
  27458. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27459. */
  27460. var Engine = /** @class */ (function () {
  27461. /**
  27462. * Creates a new engine
  27463. * @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
  27464. * @param antialias defines enable antialiasing (default: false)
  27465. * @param options defines further options to be sent to the getContext() function
  27466. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27467. */
  27468. function Engine(canvasOrContext, antialias, options, adaptToDeviceRatio) {
  27469. if (adaptToDeviceRatio === void 0) { adaptToDeviceRatio = false; }
  27470. var _this = this;
  27471. // Public members
  27472. /**
  27473. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27474. */
  27475. this.forcePOTTextures = false;
  27476. /**
  27477. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27478. */
  27479. this.isFullscreen = false;
  27480. /**
  27481. * Gets a boolean indicating if the pointer is currently locked
  27482. */
  27483. this.isPointerLock = false;
  27484. /**
  27485. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27486. */
  27487. this.cullBackFaces = true;
  27488. /**
  27489. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27490. */
  27491. this.renderEvenInBackground = true;
  27492. /**
  27493. * Gets or sets a boolean indicating that cache can be kept between frames
  27494. */
  27495. this.preventCacheWipeBetweenFrames = false;
  27496. /**
  27497. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27498. **/
  27499. this.enableOfflineSupport = false;
  27500. /**
  27501. * 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)
  27502. **/
  27503. this.disableManifestCheck = false;
  27504. /**
  27505. * Gets the list of created scenes
  27506. */
  27507. this.scenes = new Array();
  27508. /**
  27509. * Event raised when a new scene is created
  27510. */
  27511. this.onNewSceneAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27512. /**
  27513. * Gets the list of created postprocesses
  27514. */
  27515. this.postProcesses = new Array();
  27516. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27517. this.validateShaderPrograms = false;
  27518. // Observables
  27519. /**
  27520. * Observable event triggered each time the rendering canvas is resized
  27521. */
  27522. this.onResizeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27523. /**
  27524. * Observable event triggered each time the canvas loses focus
  27525. */
  27526. this.onCanvasBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27527. /**
  27528. * Observable event triggered each time the canvas gains focus
  27529. */
  27530. this.onCanvasFocusObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27531. /**
  27532. * Observable event triggered each time the canvas receives pointerout event
  27533. */
  27534. this.onCanvasPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27535. /**
  27536. * Observable event triggered before each texture is initialized
  27537. */
  27538. this.onBeforeTextureInitObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27539. //WebVR
  27540. this._vrDisplay = undefined;
  27541. this._vrSupported = false;
  27542. this._vrExclusivePointerMode = false;
  27543. // Uniform buffers list
  27544. /**
  27545. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27546. */
  27547. this.disableUniformBuffers = false;
  27548. /** @hidden */
  27549. this._uniformBuffers = new Array();
  27550. // Observables
  27551. /**
  27552. * Observable raised when the engine begins a new frame
  27553. */
  27554. this.onBeginFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27555. /**
  27556. * If set, will be used to request the next animation frame for the render loop
  27557. */
  27558. this.customAnimationFrameRequester = null;
  27559. /**
  27560. * Observable raised when the engine ends the current frame
  27561. */
  27562. this.onEndFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27563. /**
  27564. * Observable raised when the engine is about to compile a shader
  27565. */
  27566. this.onBeforeShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27567. /**
  27568. * Observable raised when the engine has jsut compiled a shader
  27569. */
  27570. this.onAfterShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27571. this._windowIsBackground = false;
  27572. this._webGLVersion = 1.0;
  27573. /** @hidden */
  27574. this._badOS = false;
  27575. /** @hidden */
  27576. this._badDesktopOS = false;
  27577. /**
  27578. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27579. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27580. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27581. */
  27582. this.disableTextureBindingOptimization = false;
  27583. /**
  27584. * Observable signaled when VR display mode changes
  27585. */
  27586. this.onVRDisplayChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27587. /**
  27588. * Observable signaled when VR request present is complete
  27589. */
  27590. this.onVRRequestPresentComplete = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27591. /**
  27592. * Observable signaled when VR request present starts
  27593. */
  27594. this.onVRRequestPresentStart = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27595. this._colorWrite = true;
  27596. /** @hidden */
  27597. this._drawCalls = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  27598. /** @hidden */
  27599. this._textureCollisions = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  27600. this._renderingQueueLaunched = false;
  27601. this._activeRenderLoops = new Array();
  27602. // Deterministic lockstepMaxSteps
  27603. this._deterministicLockstep = false;
  27604. this._lockstepMaxSteps = 4;
  27605. // Lost context
  27606. /**
  27607. * Observable signaled when a context lost event is raised
  27608. */
  27609. this.onContextLostObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27610. /**
  27611. * Observable signaled when a context restored event is raised
  27612. */
  27613. this.onContextRestoredObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27614. this._contextWasLost = false;
  27615. this._doNotHandleContextLost = false;
  27616. // FPS
  27617. this._performanceMonitor = new _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__["PerformanceMonitor"]();
  27618. this._fps = 60;
  27619. this._deltaTime = 0;
  27620. /**
  27621. * Turn this value on if you want to pause FPS computation when in background
  27622. */
  27623. this.disablePerformanceMonitorInBackground = false;
  27624. // States
  27625. /** @hidden */
  27626. this._depthCullingState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_DepthCullingState"]();
  27627. /** @hidden */
  27628. this._stencilState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_StencilState"]();
  27629. /** @hidden */
  27630. this._alphaState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_AlphaState"]();
  27631. /** @hidden */
  27632. this._alphaMode = Engine.ALPHA_DISABLE;
  27633. // Cache
  27634. this._internalTexturesCache = new Array();
  27635. /** @hidden */
  27636. this._activeChannel = 0;
  27637. this._currentTextureChannel = -1;
  27638. /** @hidden */
  27639. this._boundTexturesCache = {};
  27640. this._compiledEffects = {};
  27641. this._vertexAttribArraysEnabled = [];
  27642. this._uintIndicesCurrentlySet = false;
  27643. this._currentBoundBuffer = new Array();
  27644. /** @hidden */
  27645. this._currentFramebuffer = null;
  27646. this._currentBufferPointers = new Array();
  27647. this._currentInstanceLocations = new Array();
  27648. this._currentInstanceBuffers = new Array();
  27649. this._firstBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  27650. this._lastBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  27651. this._vaoRecordInProgress = false;
  27652. this._mustWipeVertexAttributes = false;
  27653. this._nextFreeTextureSlots = new Array();
  27654. this._maxSimultaneousTextures = 0;
  27655. this._activeRequests = new Array();
  27656. // Hardware supported Compressed Textures
  27657. this._texturesSupported = new Array();
  27658. /**
  27659. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27660. */
  27661. this.premultipliedAlpha = true;
  27662. this._viewportCached = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](0, 0, 0, 0);
  27663. this._onVRFullScreenTriggered = function () {
  27664. if (_this._vrDisplay && _this._vrDisplay.isPresenting) {
  27665. //get the old size before we change
  27666. _this._oldSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Size"](_this.getRenderWidth(), _this.getRenderHeight());
  27667. _this._oldHardwareScaleFactor = _this.getHardwareScalingLevel();
  27668. //get the width and height, change the render size
  27669. var leftEye = _this._vrDisplay.getEyeParameters('left');
  27670. _this.setHardwareScalingLevel(1);
  27671. _this.setSize(leftEye.renderWidth * 2, leftEye.renderHeight);
  27672. }
  27673. else {
  27674. _this.setHardwareScalingLevel(_this._oldHardwareScaleFactor);
  27675. _this.setSize(_this._oldSize.width, _this._oldSize.height);
  27676. }
  27677. };
  27678. this._unpackFlipYCached = null;
  27679. /**
  27680. * In case you are sharing the context with other applications, it might
  27681. * be interested to not cache the unpack flip y state to ensure a consistent
  27682. * value would be set.
  27683. */
  27684. this.enableUnpackFlipYCached = true;
  27685. this._boundUniforms = {};
  27686. // Register promises
  27687. _Misc_promise__WEBPACK_IMPORTED_MODULE_4__["PromisePolyfill"].Apply();
  27688. var canvas = null;
  27689. Engine.Instances.push(this);
  27690. if (!canvasOrContext) {
  27691. return;
  27692. }
  27693. options = options || {};
  27694. if (canvasOrContext.getContext) {
  27695. canvas = canvasOrContext;
  27696. this._renderingCanvas = canvas;
  27697. if (antialias != null) {
  27698. options.antialias = antialias;
  27699. }
  27700. if (options.deterministicLockstep === undefined) {
  27701. options.deterministicLockstep = false;
  27702. }
  27703. if (options.lockstepMaxSteps === undefined) {
  27704. options.lockstepMaxSteps = 4;
  27705. }
  27706. if (options.preserveDrawingBuffer === undefined) {
  27707. options.preserveDrawingBuffer = false;
  27708. }
  27709. if (options.audioEngine === undefined) {
  27710. options.audioEngine = true;
  27711. }
  27712. if (options.stencil === undefined) {
  27713. options.stencil = true;
  27714. }
  27715. if (options.premultipliedAlpha === false) {
  27716. this.premultipliedAlpha = false;
  27717. }
  27718. this._deterministicLockstep = options.deterministicLockstep;
  27719. this._lockstepMaxSteps = options.lockstepMaxSteps;
  27720. this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;
  27721. // Exceptions
  27722. if (navigator && navigator.userAgent) {
  27723. var ua = navigator.userAgent;
  27724. for (var _i = 0, _a = Engine.ExceptionList; _i < _a.length; _i++) {
  27725. var exception = _a[_i];
  27726. var key = exception.key;
  27727. var targets = exception.targets;
  27728. if (ua.indexOf(key) > -1) {
  27729. if (exception.capture && exception.captureConstraint) {
  27730. var capture = exception.capture;
  27731. var constraint = exception.captureConstraint;
  27732. var regex = new RegExp(capture);
  27733. var matches = regex.exec(ua);
  27734. if (matches && matches.length > 0) {
  27735. var capturedValue = parseInt(matches[matches.length - 1]);
  27736. if (capturedValue >= constraint) {
  27737. continue;
  27738. }
  27739. }
  27740. }
  27741. for (var _b = 0, targets_1 = targets; _b < targets_1.length; _b++) {
  27742. var target = targets_1[_b];
  27743. switch (target) {
  27744. case "uniformBuffer":
  27745. this.disableUniformBuffers = true;
  27746. break;
  27747. case "textureBindingOptimization":
  27748. this.disableTextureBindingOptimization = true;
  27749. break;
  27750. }
  27751. }
  27752. }
  27753. }
  27754. }
  27755. // GL
  27756. if (!options.disableWebGL2Support) {
  27757. try {
  27758. this._gl = (canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
  27759. if (this._gl) {
  27760. this._webGLVersion = 2.0;
  27761. // Prevent weird browsers to lie :-)
  27762. if (!this._gl.deleteQuery) {
  27763. this._webGLVersion = 1.0;
  27764. }
  27765. }
  27766. }
  27767. catch (e) {
  27768. // Do nothing
  27769. }
  27770. }
  27771. if (!this._gl) {
  27772. if (!canvas) {
  27773. throw new Error("The provided canvas is null or undefined.");
  27774. }
  27775. try {
  27776. this._gl = (canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options));
  27777. }
  27778. catch (e) {
  27779. throw new Error("WebGL not supported");
  27780. }
  27781. }
  27782. if (!this._gl) {
  27783. throw new Error("WebGL not supported");
  27784. }
  27785. this._onCanvasFocus = function () {
  27786. _this.onCanvasFocusObservable.notifyObservers(_this);
  27787. };
  27788. this._onCanvasBlur = function () {
  27789. _this.onCanvasBlurObservable.notifyObservers(_this);
  27790. };
  27791. canvas.addEventListener("focus", this._onCanvasFocus);
  27792. canvas.addEventListener("blur", this._onCanvasBlur);
  27793. this._onBlur = function () {
  27794. if (_this.disablePerformanceMonitorInBackground) {
  27795. _this._performanceMonitor.disable();
  27796. }
  27797. _this._windowIsBackground = true;
  27798. };
  27799. this._onFocus = function () {
  27800. if (_this.disablePerformanceMonitorInBackground) {
  27801. _this._performanceMonitor.enable();
  27802. }
  27803. _this._windowIsBackground = false;
  27804. };
  27805. this._onCanvasPointerOut = function (ev) {
  27806. _this.onCanvasPointerOutObservable.notifyObservers(ev);
  27807. };
  27808. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  27809. window.addEventListener("blur", this._onBlur);
  27810. window.addEventListener("focus", this._onFocus);
  27811. }
  27812. canvas.addEventListener("pointerout", this._onCanvasPointerOut);
  27813. // Context lost
  27814. if (!this._doNotHandleContextLost) {
  27815. this._onContextLost = function (evt) {
  27816. evt.preventDefault();
  27817. _this._contextWasLost = true;
  27818. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context lost.");
  27819. _this.onContextLostObservable.notifyObservers(_this);
  27820. };
  27821. this._onContextRestored = function () {
  27822. // Adding a timeout to avoid race condition at browser level
  27823. setTimeout(function () {
  27824. // Rebuild gl context
  27825. _this._initGLContext();
  27826. // Rebuild effects
  27827. _this._rebuildEffects();
  27828. // Rebuild textures
  27829. _this._rebuildInternalTextures();
  27830. // Rebuild buffers
  27831. _this._rebuildBuffers();
  27832. // Cache
  27833. _this.wipeCaches(true);
  27834. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context successfully restored.");
  27835. _this.onContextRestoredObservable.notifyObservers(_this);
  27836. _this._contextWasLost = false;
  27837. }, 0);
  27838. };
  27839. canvas.addEventListener("webglcontextlost", this._onContextLost, false);
  27840. canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
  27841. }
  27842. if (!options.doNotHandleTouchAction) {
  27843. this._disableTouchAction();
  27844. }
  27845. }
  27846. else {
  27847. this._gl = canvasOrContext;
  27848. this._renderingCanvas = this._gl.canvas;
  27849. if (this._gl.renderbufferStorageMultisample) {
  27850. this._webGLVersion = 2.0;
  27851. }
  27852. var attributes = this._gl.getContextAttributes();
  27853. if (attributes) {
  27854. options.stencil = attributes.stencil;
  27855. }
  27856. }
  27857. // Viewport
  27858. var devicePixelRatio = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist() ? (window.devicePixelRatio || 1.0) : 1.0;
  27859. var limitDeviceRatio = options.limitDeviceRatio || devicePixelRatio;
  27860. this._hardwareScalingLevel = adaptToDeviceRatio ? 1.0 / Math.min(limitDeviceRatio, devicePixelRatio) : 1.0;
  27861. this.resize();
  27862. this._isStencilEnable = options.stencil ? true : false;
  27863. this._initGLContext();
  27864. if (canvas) {
  27865. // Fullscreen
  27866. this._onFullscreenChange = function () {
  27867. if (document.fullscreen !== undefined) {
  27868. _this.isFullscreen = document.fullscreen;
  27869. }
  27870. else if (document.mozFullScreen !== undefined) {
  27871. _this.isFullscreen = document.mozFullScreen;
  27872. }
  27873. else if (document.webkitIsFullScreen !== undefined) {
  27874. _this.isFullscreen = document.webkitIsFullScreen;
  27875. }
  27876. else if (document.msIsFullScreen !== undefined) {
  27877. _this.isFullscreen = document.msIsFullScreen;
  27878. }
  27879. // Pointer lock
  27880. if (_this.isFullscreen && _this._pointerLockRequested && canvas) {
  27881. canvas.requestPointerLock = canvas.requestPointerLock ||
  27882. canvas.msRequestPointerLock ||
  27883. canvas.mozRequestPointerLock ||
  27884. canvas.webkitRequestPointerLock;
  27885. if (canvas.requestPointerLock) {
  27886. canvas.requestPointerLock();
  27887. }
  27888. }
  27889. };
  27890. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  27891. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  27892. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  27893. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  27894. // Pointer lock
  27895. this._onPointerLockChange = function () {
  27896. _this.isPointerLock = (document.mozPointerLockElement === canvas ||
  27897. document.webkitPointerLockElement === canvas ||
  27898. document.msPointerLockElement === canvas ||
  27899. document.pointerLockElement === canvas);
  27900. };
  27901. document.addEventListener("pointerlockchange", this._onPointerLockChange, false);
  27902. document.addEventListener("mspointerlockchange", this._onPointerLockChange, false);
  27903. document.addEventListener("mozpointerlockchange", this._onPointerLockChange, false);
  27904. document.addEventListener("webkitpointerlockchange", this._onPointerLockChange, false);
  27905. this._onVRDisplayPointerRestricted = function () {
  27906. if (canvas) {
  27907. canvas.requestPointerLock();
  27908. }
  27909. };
  27910. this._onVRDisplayPointerUnrestricted = function () {
  27911. document.exitPointerLock();
  27912. };
  27913. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  27914. window.addEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted, false);
  27915. window.addEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted, false);
  27916. }
  27917. }
  27918. // Create Audio Engine if needed.
  27919. if (!Engine.audioEngine && options.audioEngine && Engine.AudioEngineFactory) {
  27920. Engine.audioEngine = Engine.AudioEngineFactory(this.getRenderingCanvas());
  27921. }
  27922. // Prepare buffer pointers
  27923. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  27924. this._currentBufferPointers[i] = new BufferPointer();
  27925. }
  27926. this._linkTrackers(this._firstBoundInternalTextureTracker, this._lastBoundInternalTextureTracker);
  27927. // Load WebVR Devices
  27928. if (options.autoEnableWebVR) {
  27929. this.initWebVR();
  27930. }
  27931. // Detect if we are running on a faulty buggy OS.
  27932. this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
  27933. // Detect if we are running on a faulty buggy desktop OS.
  27934. this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  27935. console.log("Babylon.js v" + Engine.Version + " - " + this.description);
  27936. this.enableOfflineSupport = Engine.OfflineProviderFactory !== undefined;
  27937. }
  27938. Object.defineProperty(Engine, "Instances", {
  27939. /** Gets the list of created engines */
  27940. get: function () {
  27941. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].Instances;
  27942. },
  27943. enumerable: true,
  27944. configurable: true
  27945. });
  27946. Object.defineProperty(Engine, "LastCreatedEngine", {
  27947. /**
  27948. * Gets the latest created engine
  27949. */
  27950. get: function () {
  27951. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine;
  27952. },
  27953. enumerable: true,
  27954. configurable: true
  27955. });
  27956. Object.defineProperty(Engine, "LastCreatedScene", {
  27957. /**
  27958. * Gets the latest created scene
  27959. */
  27960. get: function () {
  27961. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  27962. },
  27963. enumerable: true,
  27964. configurable: true
  27965. });
  27966. /**
  27967. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27968. * @param flag defines which part of the materials must be marked as dirty
  27969. * @param predicate defines a predicate used to filter which materials should be affected
  27970. */
  27971. Engine.MarkAllMaterialsAsDirty = function (flag, predicate) {
  27972. for (var engineIndex = 0; engineIndex < Engine.Instances.length; engineIndex++) {
  27973. var engine = Engine.Instances[engineIndex];
  27974. for (var sceneIndex = 0; sceneIndex < engine.scenes.length; sceneIndex++) {
  27975. engine.scenes[sceneIndex].markAllMaterialsAsDirty(flag, predicate);
  27976. }
  27977. }
  27978. };
  27979. Object.defineProperty(Engine, "Version", {
  27980. /**
  27981. * Returns the current version of the framework
  27982. */
  27983. get: function () {
  27984. return "4.0.0-alpha.22";
  27985. },
  27986. enumerable: true,
  27987. configurable: true
  27988. });
  27989. Object.defineProperty(Engine.prototype, "description", {
  27990. /**
  27991. * Returns a string describing the current engine
  27992. */
  27993. get: function () {
  27994. var description = "WebGL" + this.webGLVersion;
  27995. if (this._caps.parallelShaderCompile) {
  27996. description += " - Parallel shader compilation";
  27997. }
  27998. return description;
  27999. },
  28000. enumerable: true,
  28001. configurable: true
  28002. });
  28003. Object.defineProperty(Engine, "ShadersRepository", {
  28004. /**
  28005. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28006. */
  28007. get: function () {
  28008. return _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository;
  28009. },
  28010. set: function (value) {
  28011. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository = value;
  28012. },
  28013. enumerable: true,
  28014. configurable: true
  28015. });
  28016. /**
  28017. * Method called to create the default loading screen.
  28018. * This can be overriden in your own app.
  28019. * @param canvas The rendering canvas element
  28020. * @returns The loading screen
  28021. */
  28022. Engine.DefaultLoadingScreenFactory = function (canvas) {
  28023. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_18__["_DevTools"].WarnImport("LoadingScreen");
  28024. };
  28025. Object.defineProperty(Engine.prototype, "isInVRExclusivePointerMode", {
  28026. /**
  28027. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28028. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28029. */
  28030. get: function () {
  28031. return this._vrExclusivePointerMode;
  28032. },
  28033. enumerable: true,
  28034. configurable: true
  28035. });
  28036. Object.defineProperty(Engine.prototype, "supportsUniformBuffers", {
  28037. /**
  28038. * Gets a boolean indicating that the engine supports uniform buffers
  28039. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28040. */
  28041. get: function () {
  28042. return this.webGLVersion > 1 && !this.disableUniformBuffers;
  28043. },
  28044. enumerable: true,
  28045. configurable: true
  28046. });
  28047. Object.defineProperty(Engine.prototype, "needPOTTextures", {
  28048. /**
  28049. * Gets a boolean indicating that only power of 2 textures are supported
  28050. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28051. */
  28052. get: function () {
  28053. return this._webGLVersion < 2 || this.forcePOTTextures;
  28054. },
  28055. enumerable: true,
  28056. configurable: true
  28057. });
  28058. Object.defineProperty(Engine.prototype, "doNotHandleContextLost", {
  28059. /**
  28060. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28061. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28062. */
  28063. get: function () {
  28064. return this._doNotHandleContextLost;
  28065. },
  28066. set: function (value) {
  28067. this._doNotHandleContextLost = value;
  28068. },
  28069. enumerable: true,
  28070. configurable: true
  28071. });
  28072. Object.defineProperty(Engine.prototype, "performanceMonitor", {
  28073. /**
  28074. * Gets the performance monitor attached to this engine
  28075. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28076. */
  28077. get: function () {
  28078. return this._performanceMonitor;
  28079. },
  28080. enumerable: true,
  28081. configurable: true
  28082. });
  28083. Object.defineProperty(Engine.prototype, "texturesSupported", {
  28084. /**
  28085. * Gets the list of texture formats supported
  28086. */
  28087. get: function () {
  28088. return this._texturesSupported;
  28089. },
  28090. enumerable: true,
  28091. configurable: true
  28092. });
  28093. Object.defineProperty(Engine.prototype, "textureFormatInUse", {
  28094. /**
  28095. * Gets the list of texture formats in use
  28096. */
  28097. get: function () {
  28098. return this._textureFormatInUse;
  28099. },
  28100. enumerable: true,
  28101. configurable: true
  28102. });
  28103. Object.defineProperty(Engine.prototype, "currentViewport", {
  28104. /**
  28105. * Gets the current viewport
  28106. */
  28107. get: function () {
  28108. return this._cachedViewport;
  28109. },
  28110. enumerable: true,
  28111. configurable: true
  28112. });
  28113. Object.defineProperty(Engine.prototype, "emptyTexture", {
  28114. /**
  28115. * Gets the default empty texture
  28116. */
  28117. get: function () {
  28118. if (!this._emptyTexture) {
  28119. this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28120. }
  28121. return this._emptyTexture;
  28122. },
  28123. enumerable: true,
  28124. configurable: true
  28125. });
  28126. Object.defineProperty(Engine.prototype, "emptyTexture3D", {
  28127. /**
  28128. * Gets the default empty 3D texture
  28129. */
  28130. get: function () {
  28131. if (!this._emptyTexture3D) {
  28132. this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28133. }
  28134. return this._emptyTexture3D;
  28135. },
  28136. enumerable: true,
  28137. configurable: true
  28138. });
  28139. Object.defineProperty(Engine.prototype, "emptyCubeTexture", {
  28140. /**
  28141. * Gets the default empty cube texture
  28142. */
  28143. get: function () {
  28144. if (!this._emptyCubeTexture) {
  28145. var faceData = new Uint8Array(4);
  28146. var cubeData = [faceData, faceData, faceData, faceData, faceData, faceData];
  28147. this._emptyCubeTexture = this.createRawCubeTexture(cubeData, 1, Engine.TEXTUREFORMAT_RGBA, Engine.TEXTURETYPE_UNSIGNED_INT, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28148. }
  28149. return this._emptyCubeTexture;
  28150. },
  28151. enumerable: true,
  28152. configurable: true
  28153. });
  28154. Engine.prototype._disableTouchAction = function () {
  28155. if (!this._renderingCanvas) {
  28156. return;
  28157. }
  28158. this._renderingCanvas.setAttribute("touch-action", "none");
  28159. this._renderingCanvas.style.touchAction = "none";
  28160. this._renderingCanvas.style.msTouchAction = "none";
  28161. };
  28162. Engine.prototype._rebuildInternalTextures = function () {
  28163. var currentState = this._internalTexturesCache.slice(); // Do a copy because the rebuild will add proxies
  28164. for (var _i = 0, currentState_1 = currentState; _i < currentState_1.length; _i++) {
  28165. var internalTexture = currentState_1[_i];
  28166. internalTexture._rebuild();
  28167. }
  28168. };
  28169. Engine.prototype._rebuildEffects = function () {
  28170. for (var key in this._compiledEffects) {
  28171. var effect = this._compiledEffects[key];
  28172. effect._prepareEffect();
  28173. }
  28174. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  28175. };
  28176. /**
  28177. * Gets a boolean indicating if all created effects are ready
  28178. * @returns true if all effects are ready
  28179. */
  28180. Engine.prototype.areAllEffectsReady = function () {
  28181. for (var key in this._compiledEffects) {
  28182. var effect = this._compiledEffects[key];
  28183. if (!effect.isReady()) {
  28184. return false;
  28185. }
  28186. }
  28187. return true;
  28188. };
  28189. Engine.prototype._rebuildBuffers = function () {
  28190. // Index / Vertex
  28191. for (var _i = 0, _a = this.scenes; _i < _a.length; _i++) {
  28192. var scene = _a[_i];
  28193. scene.resetCachedMaterial();
  28194. scene._rebuildGeometries();
  28195. scene._rebuildTextures();
  28196. }
  28197. // Uniforms
  28198. for (var _b = 0, _c = this._uniformBuffers; _b < _c.length; _b++) {
  28199. var uniformBuffer = _c[_b];
  28200. uniformBuffer._rebuild();
  28201. }
  28202. };
  28203. Engine.prototype._initGLContext = function () {
  28204. // Caps
  28205. this._caps = new EngineCapabilities();
  28206. this._caps.maxTexturesImageUnits = this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);
  28207. this._caps.maxCombinedTexturesImageUnits = this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  28208. this._caps.maxVertexTextureImageUnits = this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
  28209. this._caps.maxTextureSize = this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE);
  28210. this._caps.maxCubemapTextureSize = this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE);
  28211. this._caps.maxRenderTextureSize = this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE);
  28212. this._caps.maxVertexAttribs = this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS);
  28213. this._caps.maxVaryingVectors = this._gl.getParameter(this._gl.MAX_VARYING_VECTORS);
  28214. this._caps.maxFragmentUniformVectors = this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS);
  28215. this._caps.maxVertexUniformVectors = this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS);
  28216. // Infos
  28217. this._glVersion = this._gl.getParameter(this._gl.VERSION);
  28218. var rendererInfo = this._gl.getExtension("WEBGL_debug_renderer_info");
  28219. if (rendererInfo != null) {
  28220. this._glRenderer = this._gl.getParameter(rendererInfo.UNMASKED_RENDERER_WEBGL);
  28221. this._glVendor = this._gl.getParameter(rendererInfo.UNMASKED_VENDOR_WEBGL);
  28222. }
  28223. if (!this._glVendor) {
  28224. this._glVendor = "Unknown vendor";
  28225. }
  28226. if (!this._glRenderer) {
  28227. this._glRenderer = "Unknown renderer";
  28228. }
  28229. // Constants
  28230. this._gl.HALF_FLOAT_OES = 0x8D61; // Half floating-point type (16-bit).
  28231. if (this._gl.RGBA16F !== 0x881A) {
  28232. this._gl.RGBA16F = 0x881A; // RGBA 16-bit floating-point color-renderable internal sized format.
  28233. }
  28234. if (this._gl.RGBA32F !== 0x8814) {
  28235. this._gl.RGBA32F = 0x8814; // RGBA 32-bit floating-point color-renderable internal sized format.
  28236. }
  28237. if (this._gl.DEPTH24_STENCIL8 !== 35056) {
  28238. this._gl.DEPTH24_STENCIL8 = 35056;
  28239. }
  28240. // Extensions
  28241. this._caps.standardDerivatives = this._webGLVersion > 1 || (this._gl.getExtension('OES_standard_derivatives') !== null);
  28242. this._caps.astc = this._gl.getExtension('WEBGL_compressed_texture_astc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_astc');
  28243. this._caps.s3tc = this._gl.getExtension('WEBGL_compressed_texture_s3tc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc');
  28244. this._caps.pvrtc = this._gl.getExtension('WEBGL_compressed_texture_pvrtc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc');
  28245. this._caps.etc1 = this._gl.getExtension('WEBGL_compressed_texture_etc1') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc1');
  28246. this._caps.etc2 = this._gl.getExtension('WEBGL_compressed_texture_etc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc') ||
  28247. this._gl.getExtension('WEBGL_compressed_texture_es3_0'); // also a requirement of OpenGL ES 3
  28248. 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');
  28249. this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;
  28250. this._caps.uintIndices = this._webGLVersion > 1 || this._gl.getExtension('OES_element_index_uint') !== null;
  28251. this._caps.fragmentDepthSupported = this._webGLVersion > 1 || this._gl.getExtension('EXT_frag_depth') !== null;
  28252. this._caps.highPrecisionShaderSupported = false;
  28253. this._caps.timerQuery = this._gl.getExtension('EXT_disjoint_timer_query_webgl2') || this._gl.getExtension("EXT_disjoint_timer_query");
  28254. if (this._caps.timerQuery) {
  28255. if (this._webGLVersion === 1) {
  28256. this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery);
  28257. }
  28258. this._caps.canUseTimestampForTimerQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 0;
  28259. }
  28260. // Checks if some of the format renders first to allow the use of webgl inspector.
  28261. this._caps.colorBufferFloat = this._webGLVersion > 1 && this._gl.getExtension('EXT_color_buffer_float');
  28262. this._caps.textureFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_float')) ? true : false;
  28263. this._caps.textureFloatLinearFiltering = this._caps.textureFloat && this._gl.getExtension('OES_texture_float_linear') ? true : false;
  28264. this._caps.textureFloatRender = this._caps.textureFloat && this._canRenderToFloatFramebuffer() ? true : false;
  28265. this._caps.textureHalfFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_half_float')) ? true : false;
  28266. this._caps.textureHalfFloatLinearFiltering = (this._webGLVersion > 1 || (this._caps.textureHalfFloat && this._gl.getExtension('OES_texture_half_float_linear'))) ? true : false;
  28267. if (this._webGLVersion > 1) {
  28268. this._gl.HALF_FLOAT_OES = 0x140B;
  28269. }
  28270. this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer();
  28271. this._caps.textureLOD = (this._webGLVersion > 1 || this._gl.getExtension('EXT_shader_texture_lod')) ? true : false;
  28272. // Draw buffers
  28273. if (this._webGLVersion > 1) {
  28274. this._caps.drawBuffersExtension = true;
  28275. }
  28276. else {
  28277. var drawBuffersExtension = this._gl.getExtension('WEBGL_draw_buffers');
  28278. if (drawBuffersExtension !== null) {
  28279. this._caps.drawBuffersExtension = true;
  28280. this._gl.drawBuffers = drawBuffersExtension.drawBuffersWEBGL.bind(drawBuffersExtension);
  28281. this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
  28282. for (var i = 0; i < 16; i++) {
  28283. this._gl["COLOR_ATTACHMENT" + i + "_WEBGL"] = drawBuffersExtension["COLOR_ATTACHMENT" + i + "_WEBGL"];
  28284. }
  28285. }
  28286. else {
  28287. this._caps.drawBuffersExtension = false;
  28288. }
  28289. }
  28290. // Shader compiler threads
  28291. this._caps.parallelShaderCompile = this._gl.getExtension('KHR_parallel_shader_compile');
  28292. if (this._caps.parallelShaderCompile) {
  28293. var threads = this._gl.getParameter(this._caps.parallelShaderCompile.MAX_SHADER_COMPILER_THREADS_KHR);
  28294. this._caps.parallelShaderCompile.maxShaderCompilerThreadsKHR(threads);
  28295. }
  28296. // Depth Texture
  28297. if (this._webGLVersion > 1) {
  28298. this._caps.depthTextureExtension = true;
  28299. }
  28300. else {
  28301. var depthTextureExtension = this._gl.getExtension('WEBGL_depth_texture');
  28302. if (depthTextureExtension != null) {
  28303. this._caps.depthTextureExtension = true;
  28304. this._gl.UNSIGNED_INT_24_8 = depthTextureExtension.UNSIGNED_INT_24_8_WEBGL;
  28305. }
  28306. }
  28307. // Vertex array object
  28308. if (this._webGLVersion > 1) {
  28309. this._caps.vertexArrayObject = true;
  28310. }
  28311. else {
  28312. var vertexArrayObjectExtension = this._gl.getExtension('OES_vertex_array_object');
  28313. if (vertexArrayObjectExtension != null) {
  28314. this._caps.vertexArrayObject = true;
  28315. this._gl.createVertexArray = vertexArrayObjectExtension.createVertexArrayOES.bind(vertexArrayObjectExtension);
  28316. this._gl.bindVertexArray = vertexArrayObjectExtension.bindVertexArrayOES.bind(vertexArrayObjectExtension);
  28317. this._gl.deleteVertexArray = vertexArrayObjectExtension.deleteVertexArrayOES.bind(vertexArrayObjectExtension);
  28318. }
  28319. else {
  28320. this._caps.vertexArrayObject = false;
  28321. }
  28322. }
  28323. // Instances count
  28324. if (this._webGLVersion > 1) {
  28325. this._caps.instancedArrays = true;
  28326. }
  28327. else {
  28328. var instanceExtension = this._gl.getExtension('ANGLE_instanced_arrays');
  28329. if (instanceExtension != null) {
  28330. this._caps.instancedArrays = true;
  28331. this._gl.drawArraysInstanced = instanceExtension.drawArraysInstancedANGLE.bind(instanceExtension);
  28332. this._gl.drawElementsInstanced = instanceExtension.drawElementsInstancedANGLE.bind(instanceExtension);
  28333. this._gl.vertexAttribDivisor = instanceExtension.vertexAttribDivisorANGLE.bind(instanceExtension);
  28334. }
  28335. else {
  28336. this._caps.instancedArrays = false;
  28337. }
  28338. }
  28339. // Intelligently add supported compressed formats in order to check for.
  28340. // Check for ASTC support first as it is most powerful and to be very cross platform.
  28341. // Next PVRTC & DXT, which are probably superior to ETC1/2.
  28342. // Likely no hardware which supports both PVR & DXT, so order matters little.
  28343. // ETC2 is newer and handles ETC1 (no alpha capability), so check for first.
  28344. if (this._caps.astc) {
  28345. this.texturesSupported.push('-astc.ktx');
  28346. }
  28347. if (this._caps.s3tc) {
  28348. this.texturesSupported.push('-dxt.ktx');
  28349. }
  28350. if (this._caps.pvrtc) {
  28351. this.texturesSupported.push('-pvrtc.ktx');
  28352. }
  28353. if (this._caps.etc2) {
  28354. this.texturesSupported.push('-etc2.ktx');
  28355. }
  28356. if (this._caps.etc1) {
  28357. this.texturesSupported.push('-etc1.ktx');
  28358. }
  28359. if (this._gl.getShaderPrecisionFormat) {
  28360. var vertex_highp = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT);
  28361. var fragment_highp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
  28362. if (vertex_highp && fragment_highp) {
  28363. this._caps.highPrecisionShaderSupported = vertex_highp.precision !== 0 && fragment_highp.precision !== 0;
  28364. }
  28365. }
  28366. // Depth buffer
  28367. this.setDepthBuffer(true);
  28368. this.setDepthFunctionToLessOrEqual();
  28369. this.setDepthWrite(true);
  28370. // Texture maps
  28371. this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
  28372. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  28373. this._nextFreeTextureSlots.push(slot);
  28374. }
  28375. };
  28376. Object.defineProperty(Engine.prototype, "webGLVersion", {
  28377. /**
  28378. * Gets version of the current webGL context
  28379. */
  28380. get: function () {
  28381. return this._webGLVersion;
  28382. },
  28383. enumerable: true,
  28384. configurable: true
  28385. });
  28386. Object.defineProperty(Engine.prototype, "isStencilEnable", {
  28387. /**
  28388. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28389. */
  28390. get: function () {
  28391. return this._isStencilEnable;
  28392. },
  28393. enumerable: true,
  28394. configurable: true
  28395. });
  28396. Engine.prototype._prepareWorkingCanvas = function () {
  28397. if (this._workingCanvas) {
  28398. return;
  28399. }
  28400. this._workingCanvas = document.createElement("canvas");
  28401. var context = this._workingCanvas.getContext("2d");
  28402. if (context) {
  28403. this._workingContext = context;
  28404. }
  28405. };
  28406. /**
  28407. * Reset the texture cache to empty state
  28408. */
  28409. Engine.prototype.resetTextureCache = function () {
  28410. for (var key in this._boundTexturesCache) {
  28411. if (!this._boundTexturesCache.hasOwnProperty(key)) {
  28412. continue;
  28413. }
  28414. var boundTexture = this._boundTexturesCache[key];
  28415. if (boundTexture) {
  28416. this._removeDesignatedSlot(boundTexture);
  28417. }
  28418. this._boundTexturesCache[key] = null;
  28419. }
  28420. if (!this.disableTextureBindingOptimization) {
  28421. this._nextFreeTextureSlots = [];
  28422. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  28423. this._nextFreeTextureSlots.push(slot);
  28424. }
  28425. }
  28426. this._currentTextureChannel = -1;
  28427. };
  28428. /**
  28429. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28430. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28431. * @returns true if engine is in deterministic lock step mode
  28432. */
  28433. Engine.prototype.isDeterministicLockStep = function () {
  28434. return this._deterministicLockstep;
  28435. };
  28436. /**
  28437. * Gets the max steps when engine is running in deterministic lock step
  28438. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28439. * @returns the max steps
  28440. */
  28441. Engine.prototype.getLockstepMaxSteps = function () {
  28442. return this._lockstepMaxSteps;
  28443. };
  28444. /**
  28445. * Gets an object containing information about the current webGL context
  28446. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28447. */
  28448. Engine.prototype.getGlInfo = function () {
  28449. return {
  28450. vendor: this._glVendor,
  28451. renderer: this._glRenderer,
  28452. version: this._glVersion
  28453. };
  28454. };
  28455. /**
  28456. * Gets current aspect ratio
  28457. * @param camera defines the camera to use to get the aspect ratio
  28458. * @param useScreen defines if screen size must be used (or the current render target if any)
  28459. * @returns a number defining the aspect ratio
  28460. */
  28461. Engine.prototype.getAspectRatio = function (camera, useScreen) {
  28462. if (useScreen === void 0) { useScreen = false; }
  28463. var viewport = camera.viewport;
  28464. return (this.getRenderWidth(useScreen) * viewport.width) / (this.getRenderHeight(useScreen) * viewport.height);
  28465. };
  28466. /**
  28467. * Gets current screen aspect ratio
  28468. * @returns a number defining the aspect ratio
  28469. */
  28470. Engine.prototype.getScreenAspectRatio = function () {
  28471. return (this.getRenderWidth(true)) / (this.getRenderHeight(true));
  28472. };
  28473. /**
  28474. * Gets the current render width
  28475. * @param useScreen defines if screen size must be used (or the current render target if any)
  28476. * @returns a number defining the current render width
  28477. */
  28478. Engine.prototype.getRenderWidth = function (useScreen) {
  28479. if (useScreen === void 0) { useScreen = false; }
  28480. if (!useScreen && this._currentRenderTarget) {
  28481. return this._currentRenderTarget.width;
  28482. }
  28483. return this._gl.drawingBufferWidth;
  28484. };
  28485. /**
  28486. * Gets the current render height
  28487. * @param useScreen defines if screen size must be used (or the current render target if any)
  28488. * @returns a number defining the current render height
  28489. */
  28490. Engine.prototype.getRenderHeight = function (useScreen) {
  28491. if (useScreen === void 0) { useScreen = false; }
  28492. if (!useScreen && this._currentRenderTarget) {
  28493. return this._currentRenderTarget.height;
  28494. }
  28495. return this._gl.drawingBufferHeight;
  28496. };
  28497. /**
  28498. * Gets the HTML canvas attached with the current webGL context
  28499. * @returns a HTML canvas
  28500. */
  28501. Engine.prototype.getRenderingCanvas = function () {
  28502. return this._renderingCanvas;
  28503. };
  28504. /**
  28505. * Gets the client rect of the HTML canvas attached with the current webGL context
  28506. * @returns a client rectanglee
  28507. */
  28508. Engine.prototype.getRenderingCanvasClientRect = function () {
  28509. if (!this._renderingCanvas) {
  28510. return null;
  28511. }
  28512. return this._renderingCanvas.getBoundingClientRect();
  28513. };
  28514. /**
  28515. * Defines the hardware scaling level.
  28516. * By default the hardware scaling level is computed from the window device ratio.
  28517. * 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.
  28518. * @param level defines the level to use
  28519. */
  28520. Engine.prototype.setHardwareScalingLevel = function (level) {
  28521. this._hardwareScalingLevel = level;
  28522. this.resize();
  28523. };
  28524. /**
  28525. * Gets the current hardware scaling level.
  28526. * By default the hardware scaling level is computed from the window device ratio.
  28527. * 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.
  28528. * @returns a number indicating the current hardware scaling level
  28529. */
  28530. Engine.prototype.getHardwareScalingLevel = function () {
  28531. return this._hardwareScalingLevel;
  28532. };
  28533. /**
  28534. * Gets the list of loaded textures
  28535. * @returns an array containing all loaded textures
  28536. */
  28537. Engine.prototype.getLoadedTexturesCache = function () {
  28538. return this._internalTexturesCache;
  28539. };
  28540. /**
  28541. * Gets the object containing all engine capabilities
  28542. * @returns the EngineCapabilities object
  28543. */
  28544. Engine.prototype.getCaps = function () {
  28545. return this._caps;
  28546. };
  28547. /**
  28548. * Gets the current depth function
  28549. * @returns a number defining the depth function
  28550. */
  28551. Engine.prototype.getDepthFunction = function () {
  28552. return this._depthCullingState.depthFunc;
  28553. };
  28554. /**
  28555. * Sets the current depth function
  28556. * @param depthFunc defines the function to use
  28557. */
  28558. Engine.prototype.setDepthFunction = function (depthFunc) {
  28559. this._depthCullingState.depthFunc = depthFunc;
  28560. };
  28561. /**
  28562. * Sets the current depth function to GREATER
  28563. */
  28564. Engine.prototype.setDepthFunctionToGreater = function () {
  28565. this._depthCullingState.depthFunc = this._gl.GREATER;
  28566. };
  28567. /**
  28568. * Sets the current depth function to GEQUAL
  28569. */
  28570. Engine.prototype.setDepthFunctionToGreaterOrEqual = function () {
  28571. this._depthCullingState.depthFunc = this._gl.GEQUAL;
  28572. };
  28573. /**
  28574. * Sets the current depth function to LESS
  28575. */
  28576. Engine.prototype.setDepthFunctionToLess = function () {
  28577. this._depthCullingState.depthFunc = this._gl.LESS;
  28578. };
  28579. /**
  28580. * Sets the current depth function to LEQUAL
  28581. */
  28582. Engine.prototype.setDepthFunctionToLessOrEqual = function () {
  28583. this._depthCullingState.depthFunc = this._gl.LEQUAL;
  28584. };
  28585. /**
  28586. * Gets a boolean indicating if stencil buffer is enabled
  28587. * @returns the current stencil buffer state
  28588. */
  28589. Engine.prototype.getStencilBuffer = function () {
  28590. return this._stencilState.stencilTest;
  28591. };
  28592. /**
  28593. * Enable or disable the stencil buffer
  28594. * @param enable defines if the stencil buffer must be enabled or disabled
  28595. */
  28596. Engine.prototype.setStencilBuffer = function (enable) {
  28597. this._stencilState.stencilTest = enable;
  28598. };
  28599. /**
  28600. * Gets the current stencil mask
  28601. * @returns a number defining the new stencil mask to use
  28602. */
  28603. Engine.prototype.getStencilMask = function () {
  28604. return this._stencilState.stencilMask;
  28605. };
  28606. /**
  28607. * Sets the current stencil mask
  28608. * @param mask defines the new stencil mask to use
  28609. */
  28610. Engine.prototype.setStencilMask = function (mask) {
  28611. this._stencilState.stencilMask = mask;
  28612. };
  28613. /**
  28614. * Gets the current stencil function
  28615. * @returns a number defining the stencil function to use
  28616. */
  28617. Engine.prototype.getStencilFunction = function () {
  28618. return this._stencilState.stencilFunc;
  28619. };
  28620. /**
  28621. * Gets the current stencil reference value
  28622. * @returns a number defining the stencil reference value to use
  28623. */
  28624. Engine.prototype.getStencilFunctionReference = function () {
  28625. return this._stencilState.stencilFuncRef;
  28626. };
  28627. /**
  28628. * Gets the current stencil mask
  28629. * @returns a number defining the stencil mask to use
  28630. */
  28631. Engine.prototype.getStencilFunctionMask = function () {
  28632. return this._stencilState.stencilFuncMask;
  28633. };
  28634. /**
  28635. * Sets the current stencil function
  28636. * @param stencilFunc defines the new stencil function to use
  28637. */
  28638. Engine.prototype.setStencilFunction = function (stencilFunc) {
  28639. this._stencilState.stencilFunc = stencilFunc;
  28640. };
  28641. /**
  28642. * Sets the current stencil reference
  28643. * @param reference defines the new stencil reference to use
  28644. */
  28645. Engine.prototype.setStencilFunctionReference = function (reference) {
  28646. this._stencilState.stencilFuncRef = reference;
  28647. };
  28648. /**
  28649. * Sets the current stencil mask
  28650. * @param mask defines the new stencil mask to use
  28651. */
  28652. Engine.prototype.setStencilFunctionMask = function (mask) {
  28653. this._stencilState.stencilFuncMask = mask;
  28654. };
  28655. /**
  28656. * Gets the current stencil operation when stencil fails
  28657. * @returns a number defining stencil operation to use when stencil fails
  28658. */
  28659. Engine.prototype.getStencilOperationFail = function () {
  28660. return this._stencilState.stencilOpStencilFail;
  28661. };
  28662. /**
  28663. * Gets the current stencil operation when depth fails
  28664. * @returns a number defining stencil operation to use when depth fails
  28665. */
  28666. Engine.prototype.getStencilOperationDepthFail = function () {
  28667. return this._stencilState.stencilOpDepthFail;
  28668. };
  28669. /**
  28670. * Gets the current stencil operation when stencil passes
  28671. * @returns a number defining stencil operation to use when stencil passes
  28672. */
  28673. Engine.prototype.getStencilOperationPass = function () {
  28674. return this._stencilState.stencilOpStencilDepthPass;
  28675. };
  28676. /**
  28677. * Sets the stencil operation to use when stencil fails
  28678. * @param operation defines the stencil operation to use when stencil fails
  28679. */
  28680. Engine.prototype.setStencilOperationFail = function (operation) {
  28681. this._stencilState.stencilOpStencilFail = operation;
  28682. };
  28683. /**
  28684. * Sets the stencil operation to use when depth fails
  28685. * @param operation defines the stencil operation to use when depth fails
  28686. */
  28687. Engine.prototype.setStencilOperationDepthFail = function (operation) {
  28688. this._stencilState.stencilOpDepthFail = operation;
  28689. };
  28690. /**
  28691. * Sets the stencil operation to use when stencil passes
  28692. * @param operation defines the stencil operation to use when stencil passes
  28693. */
  28694. Engine.prototype.setStencilOperationPass = function (operation) {
  28695. this._stencilState.stencilOpStencilDepthPass = operation;
  28696. };
  28697. /**
  28698. * Sets a boolean indicating if the dithering state is enabled or disabled
  28699. * @param value defines the dithering state
  28700. */
  28701. Engine.prototype.setDitheringState = function (value) {
  28702. if (value) {
  28703. this._gl.enable(this._gl.DITHER);
  28704. }
  28705. else {
  28706. this._gl.disable(this._gl.DITHER);
  28707. }
  28708. };
  28709. /**
  28710. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28711. * @param value defines the rasterizer state
  28712. */
  28713. Engine.prototype.setRasterizerState = function (value) {
  28714. if (value) {
  28715. this._gl.disable(this._gl.RASTERIZER_DISCARD);
  28716. }
  28717. else {
  28718. this._gl.enable(this._gl.RASTERIZER_DISCARD);
  28719. }
  28720. };
  28721. /**
  28722. * stop executing a render loop function and remove it from the execution array
  28723. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28724. */
  28725. Engine.prototype.stopRenderLoop = function (renderFunction) {
  28726. if (!renderFunction) {
  28727. this._activeRenderLoops = [];
  28728. return;
  28729. }
  28730. var index = this._activeRenderLoops.indexOf(renderFunction);
  28731. if (index >= 0) {
  28732. this._activeRenderLoops.splice(index, 1);
  28733. }
  28734. };
  28735. /** @hidden */
  28736. Engine.prototype._renderLoop = function () {
  28737. if (!this._contextWasLost) {
  28738. var shouldRender = true;
  28739. if (!this.renderEvenInBackground && this._windowIsBackground) {
  28740. shouldRender = false;
  28741. }
  28742. if (shouldRender) {
  28743. // Start new frame
  28744. this.beginFrame();
  28745. for (var index = 0; index < this._activeRenderLoops.length; index++) {
  28746. var renderFunction = this._activeRenderLoops[index];
  28747. renderFunction();
  28748. }
  28749. // Present
  28750. this.endFrame();
  28751. }
  28752. }
  28753. if (this._activeRenderLoops.length > 0) {
  28754. // Register new frame
  28755. if (this.customAnimationFrameRequester) {
  28756. this.customAnimationFrameRequester.requestID = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this.customAnimationFrameRequester.renderFunction || this._bindedRenderFunction, this.customAnimationFrameRequester);
  28757. this._frameHandler = this.customAnimationFrameRequester.requestID;
  28758. }
  28759. else if (this._vrDisplay && this._vrDisplay.isPresenting) {
  28760. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction, this._vrDisplay);
  28761. }
  28762. else {
  28763. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  28764. }
  28765. }
  28766. else {
  28767. this._renderingQueueLaunched = false;
  28768. }
  28769. };
  28770. /**
  28771. * Register and execute a render loop. The engine can have more than one render function
  28772. * @param renderFunction defines the function to continuously execute
  28773. */
  28774. Engine.prototype.runRenderLoop = function (renderFunction) {
  28775. if (this._activeRenderLoops.indexOf(renderFunction) !== -1) {
  28776. return;
  28777. }
  28778. this._activeRenderLoops.push(renderFunction);
  28779. if (!this._renderingQueueLaunched) {
  28780. this._renderingQueueLaunched = true;
  28781. this._bindedRenderFunction = this._renderLoop.bind(this);
  28782. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  28783. }
  28784. };
  28785. /**
  28786. * Toggle full screen mode
  28787. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28788. */
  28789. Engine.prototype.switchFullscreen = function (requestPointerLock) {
  28790. if (this.isFullscreen) {
  28791. this.exitFullscreen();
  28792. }
  28793. else {
  28794. this.enterFullscreen(requestPointerLock);
  28795. }
  28796. };
  28797. /**
  28798. * Enters full screen mode
  28799. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28800. */
  28801. Engine.prototype.enterFullscreen = function (requestPointerLock) {
  28802. if (!this.isFullscreen) {
  28803. this._pointerLockRequested = requestPointerLock;
  28804. if (this._renderingCanvas) {
  28805. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].RequestFullscreen(this._renderingCanvas);
  28806. }
  28807. }
  28808. };
  28809. /**
  28810. * Exits full screen mode
  28811. */
  28812. Engine.prototype.exitFullscreen = function () {
  28813. if (this.isFullscreen) {
  28814. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].ExitFullscreen();
  28815. }
  28816. };
  28817. /**
  28818. * Clear the current render buffer or the current render target (if any is set up)
  28819. * @param color defines the color to use
  28820. * @param backBuffer defines if the back buffer must be cleared
  28821. * @param depth defines if the depth buffer must be cleared
  28822. * @param stencil defines if the stencil buffer must be cleared
  28823. */
  28824. Engine.prototype.clear = function (color, backBuffer, depth, stencil) {
  28825. if (stencil === void 0) { stencil = false; }
  28826. this.applyStates();
  28827. var mode = 0;
  28828. if (backBuffer && color) {
  28829. this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
  28830. mode |= this._gl.COLOR_BUFFER_BIT;
  28831. }
  28832. if (depth) {
  28833. this._gl.clearDepth(1.0);
  28834. mode |= this._gl.DEPTH_BUFFER_BIT;
  28835. }
  28836. if (stencil) {
  28837. this._gl.clearStencil(0);
  28838. mode |= this._gl.STENCIL_BUFFER_BIT;
  28839. }
  28840. this._gl.clear(mode);
  28841. };
  28842. /**
  28843. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28844. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28845. * @param y defines the y-coordinate of the corner of the clear rectangle
  28846. * @param width defines the width of the clear rectangle
  28847. * @param height defines the height of the clear rectangle
  28848. * @param clearColor defines the clear color
  28849. */
  28850. Engine.prototype.scissorClear = function (x, y, width, height, clearColor) {
  28851. this.enableScissor(x, y, width, height);
  28852. this.clear(clearColor, true, true, true);
  28853. this.disableScissor();
  28854. };
  28855. /**
  28856. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28857. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28858. * @param y defines the y-coordinate of the corner of the clear rectangle
  28859. * @param width defines the width of the clear rectangle
  28860. * @param height defines the height of the clear rectangle
  28861. */
  28862. Engine.prototype.enableScissor = function (x, y, width, height) {
  28863. var gl = this._gl;
  28864. // Change state
  28865. gl.enable(gl.SCISSOR_TEST);
  28866. gl.scissor(x, y, width, height);
  28867. };
  28868. /**
  28869. * Disable previously set scissor test rectangle
  28870. */
  28871. Engine.prototype.disableScissor = function () {
  28872. var gl = this._gl;
  28873. gl.disable(gl.SCISSOR_TEST);
  28874. };
  28875. /** @hidden */
  28876. Engine.prototype._viewport = function (x, y, width, height) {
  28877. if (x !== this._viewportCached.x ||
  28878. y !== this._viewportCached.y ||
  28879. width !== this._viewportCached.z ||
  28880. height !== this._viewportCached.w) {
  28881. this._viewportCached.x = x;
  28882. this._viewportCached.y = y;
  28883. this._viewportCached.z = width;
  28884. this._viewportCached.w = height;
  28885. this._gl.viewport(x, y, width, height);
  28886. }
  28887. };
  28888. /**
  28889. * Set the WebGL's viewport
  28890. * @param viewport defines the viewport element to be used
  28891. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28892. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28893. */
  28894. Engine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  28895. var width = requiredWidth || this.getRenderWidth();
  28896. var height = requiredHeight || this.getRenderHeight();
  28897. var x = viewport.x || 0;
  28898. var y = viewport.y || 0;
  28899. this._cachedViewport = viewport;
  28900. this._viewport(x * width, y * height, width * viewport.width, height * viewport.height);
  28901. };
  28902. /**
  28903. * Directly set the WebGL Viewport
  28904. * @param x defines the x coordinate of the viewport (in screen space)
  28905. * @param y defines the y coordinate of the viewport (in screen space)
  28906. * @param width defines the width of the viewport (in screen space)
  28907. * @param height defines the height of the viewport (in screen space)
  28908. * @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
  28909. */
  28910. Engine.prototype.setDirectViewport = function (x, y, width, height) {
  28911. var currentViewport = this._cachedViewport;
  28912. this._cachedViewport = null;
  28913. this._viewport(x, y, width, height);
  28914. return currentViewport;
  28915. };
  28916. /**
  28917. * Begin a new frame
  28918. */
  28919. Engine.prototype.beginFrame = function () {
  28920. this.onBeginFrameObservable.notifyObservers(this);
  28921. this._measureFps();
  28922. };
  28923. /**
  28924. * Enf the current frame
  28925. */
  28926. Engine.prototype.endFrame = function () {
  28927. // Force a flush in case we are using a bad OS.
  28928. if (this._badOS) {
  28929. this.flushFramebuffer();
  28930. }
  28931. // Submit frame to the vr device, if enabled
  28932. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  28933. // TODO: We should only submit the frame if we read frameData successfully.
  28934. try {
  28935. this._vrDisplay.submitFrame();
  28936. }
  28937. catch (e) {
  28938. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].Warn("webVR submitFrame has had an unexpected failure: " + e);
  28939. }
  28940. }
  28941. this.onEndFrameObservable.notifyObservers(this);
  28942. };
  28943. /**
  28944. * Resize the view according to the canvas' size
  28945. */
  28946. Engine.prototype.resize = function () {
  28947. // We're not resizing the size of the canvas while in VR mode & presenting
  28948. if (!(this._vrDisplay && this._vrDisplay.isPresenting)) {
  28949. var width = this._renderingCanvas ? this._renderingCanvas.clientWidth : window.innerWidth;
  28950. var height = this._renderingCanvas ? this._renderingCanvas.clientHeight : window.innerHeight;
  28951. this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel);
  28952. }
  28953. };
  28954. /**
  28955. * Force a specific size of the canvas
  28956. * @param width defines the new canvas' width
  28957. * @param height defines the new canvas' height
  28958. */
  28959. Engine.prototype.setSize = function (width, height) {
  28960. if (!this._renderingCanvas) {
  28961. return;
  28962. }
  28963. if (this._renderingCanvas.width === width && this._renderingCanvas.height === height) {
  28964. return;
  28965. }
  28966. this._renderingCanvas.width = width;
  28967. this._renderingCanvas.height = height;
  28968. for (var index = 0; index < this.scenes.length; index++) {
  28969. var scene = this.scenes[index];
  28970. for (var camIndex = 0; camIndex < scene.cameras.length; camIndex++) {
  28971. var cam = scene.cameras[camIndex];
  28972. cam._currentRenderId = 0;
  28973. }
  28974. }
  28975. if (this.onResizeObservable.hasObservers) {
  28976. this.onResizeObservable.notifyObservers(this);
  28977. }
  28978. };
  28979. // WebVR functions
  28980. /**
  28981. * Gets a boolean indicating if a webVR device was detected
  28982. * @returns true if a webVR device was detected
  28983. */
  28984. Engine.prototype.isVRDevicePresent = function () {
  28985. return !!this._vrDisplay;
  28986. };
  28987. /**
  28988. * Gets the current webVR device
  28989. * @returns the current webVR device (or null)
  28990. */
  28991. Engine.prototype.getVRDevice = function () {
  28992. return this._vrDisplay;
  28993. };
  28994. /**
  28995. * Initializes a webVR display and starts listening to display change events
  28996. * The onVRDisplayChangedObservable will be notified upon these changes
  28997. * @returns The onVRDisplayChangedObservable
  28998. */
  28999. Engine.prototype.initWebVR = function () {
  29000. this.initWebVRAsync();
  29001. return this.onVRDisplayChangedObservable;
  29002. };
  29003. /**
  29004. * Initializes a webVR display and starts listening to display change events
  29005. * The onVRDisplayChangedObservable will be notified upon these changes
  29006. * @returns A promise containing a VRDisplay and if vr is supported
  29007. */
  29008. Engine.prototype.initWebVRAsync = function () {
  29009. var _this = this;
  29010. var notifyObservers = function () {
  29011. var eventArgs = {
  29012. vrDisplay: _this._vrDisplay,
  29013. vrSupported: _this._vrSupported
  29014. };
  29015. _this.onVRDisplayChangedObservable.notifyObservers(eventArgs);
  29016. _this._webVRInitPromise = new Promise(function (res) { res(eventArgs); });
  29017. };
  29018. if (!this._onVrDisplayConnect) {
  29019. this._onVrDisplayConnect = function (event) {
  29020. _this._vrDisplay = event.display;
  29021. notifyObservers();
  29022. };
  29023. this._onVrDisplayDisconnect = function () {
  29024. _this._vrDisplay.cancelAnimationFrame(_this._frameHandler);
  29025. _this._vrDisplay = undefined;
  29026. _this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(_this._bindedRenderFunction);
  29027. notifyObservers();
  29028. };
  29029. this._onVrDisplayPresentChange = function () {
  29030. _this._vrExclusivePointerMode = _this._vrDisplay && _this._vrDisplay.isPresenting;
  29031. };
  29032. window.addEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  29033. window.addEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  29034. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  29035. }
  29036. this._webVRInitPromise = this._webVRInitPromise || this._getVRDisplaysAsync();
  29037. this._webVRInitPromise.then(notifyObservers);
  29038. return this._webVRInitPromise;
  29039. };
  29040. /**
  29041. * Call this function to switch to webVR mode
  29042. * Will do nothing if webVR is not supported or if there is no webVR device
  29043. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29044. */
  29045. Engine.prototype.enableVR = function () {
  29046. var _this = this;
  29047. if (this._vrDisplay && !this._vrDisplay.isPresenting) {
  29048. var onResolved = function () {
  29049. _this.onVRRequestPresentComplete.notifyObservers(true);
  29050. _this._onVRFullScreenTriggered();
  29051. };
  29052. var onRejected = function () {
  29053. _this.onVRRequestPresentComplete.notifyObservers(false);
  29054. };
  29055. this.onVRRequestPresentStart.notifyObservers(this);
  29056. this._vrDisplay.requestPresent([{ source: this.getRenderingCanvas() }]).then(onResolved).catch(onRejected);
  29057. }
  29058. };
  29059. /**
  29060. * Call this function to leave webVR mode
  29061. * Will do nothing if webVR is not supported or if there is no webVR device
  29062. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29063. */
  29064. Engine.prototype.disableVR = function () {
  29065. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29066. this._vrDisplay.exitPresent().then(this._onVRFullScreenTriggered).catch(this._onVRFullScreenTriggered);
  29067. }
  29068. };
  29069. Engine.prototype._getVRDisplaysAsync = function () {
  29070. var _this = this;
  29071. return new Promise(function (res) {
  29072. if (navigator.getVRDisplays) {
  29073. navigator.getVRDisplays().then(function (devices) {
  29074. _this._vrSupported = true;
  29075. // note that devices may actually be an empty array. This is fine;
  29076. // we expect this._vrDisplay to be undefined in this case.
  29077. _this._vrDisplay = devices[0];
  29078. res({
  29079. vrDisplay: _this._vrDisplay,
  29080. vrSupported: _this._vrSupported
  29081. });
  29082. });
  29083. }
  29084. else {
  29085. _this._vrDisplay = undefined;
  29086. _this._vrSupported = false;
  29087. res({
  29088. vrDisplay: _this._vrDisplay,
  29089. vrSupported: _this._vrSupported
  29090. });
  29091. }
  29092. });
  29093. };
  29094. /**
  29095. * Binds the frame buffer to the specified texture.
  29096. * @param texture The texture to render to or null for the default canvas
  29097. * @param faceIndex The face of the texture to render to in case of cube texture
  29098. * @param requiredWidth The width of the target to render to
  29099. * @param requiredHeight The height of the target to render to
  29100. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29101. * @param depthStencilTexture The depth stencil texture to use to render
  29102. * @param lodLevel defines le lod level to bind to the frame buffer
  29103. */
  29104. Engine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport, depthStencilTexture, lodLevel) {
  29105. if (lodLevel === void 0) { lodLevel = 0; }
  29106. if (this._currentRenderTarget) {
  29107. this.unBindFramebuffer(this._currentRenderTarget);
  29108. }
  29109. this._currentRenderTarget = texture;
  29110. this.bindUnboundFramebuffer(texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer);
  29111. var gl = this._gl;
  29112. if (texture.isCube) {
  29113. if (faceIndex === undefined) {
  29114. faceIndex = 0;
  29115. }
  29116. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, lodLevel);
  29117. if (depthStencilTexture) {
  29118. if (depthStencilTexture._generateStencilBuffer) {
  29119. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  29120. }
  29121. else {
  29122. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  29123. }
  29124. }
  29125. }
  29126. if (this._cachedViewport && !forceFullscreenViewport) {
  29127. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  29128. }
  29129. else {
  29130. if (!requiredWidth) {
  29131. requiredWidth = texture.width;
  29132. if (lodLevel) {
  29133. requiredWidth = requiredWidth / Math.pow(2, lodLevel);
  29134. }
  29135. }
  29136. if (!requiredHeight) {
  29137. requiredHeight = texture.height;
  29138. if (lodLevel) {
  29139. requiredHeight = requiredHeight / Math.pow(2, lodLevel);
  29140. }
  29141. }
  29142. this._viewport(0, 0, requiredWidth, requiredHeight);
  29143. }
  29144. this.wipeCaches();
  29145. };
  29146. Engine.prototype.bindUnboundFramebuffer = function (framebuffer) {
  29147. if (this._currentFramebuffer !== framebuffer) {
  29148. this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, framebuffer);
  29149. this._currentFramebuffer = framebuffer;
  29150. }
  29151. };
  29152. /**
  29153. * Unbind the current render target texture from the webGL context
  29154. * @param texture defines the render target texture to unbind
  29155. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29156. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29157. */
  29158. Engine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  29159. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  29160. this._currentRenderTarget = null;
  29161. // If MSAA, we need to bitblt back to main texture
  29162. var gl = this._gl;
  29163. if (texture._MSAAFramebuffer) {
  29164. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, texture._MSAAFramebuffer);
  29165. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, texture._framebuffer);
  29166. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  29167. }
  29168. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  29169. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  29170. gl.generateMipmap(gl.TEXTURE_2D);
  29171. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  29172. }
  29173. if (onBeforeUnbind) {
  29174. if (texture._MSAAFramebuffer) {
  29175. // Bind the correct framebuffer
  29176. this.bindUnboundFramebuffer(texture._framebuffer);
  29177. }
  29178. onBeforeUnbind();
  29179. }
  29180. this.bindUnboundFramebuffer(null);
  29181. };
  29182. /**
  29183. * Unbind a list of render target textures from the webGL context
  29184. * This is used only when drawBuffer extension or webGL2 are active
  29185. * @param textures defines the render target textures to unbind
  29186. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29187. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29188. */
  29189. Engine.prototype.unBindMultiColorAttachmentFramebuffer = function (textures, disableGenerateMipMaps, onBeforeUnbind) {
  29190. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  29191. this._currentRenderTarget = null;
  29192. // If MSAA, we need to bitblt back to main texture
  29193. var gl = this._gl;
  29194. if (textures[0]._MSAAFramebuffer) {
  29195. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, textures[0]._MSAAFramebuffer);
  29196. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, textures[0]._framebuffer);
  29197. var attachments = textures[0]._attachments;
  29198. if (!attachments) {
  29199. attachments = new Array(textures.length);
  29200. textures[0]._attachments = attachments;
  29201. }
  29202. for (var i = 0; i < textures.length; i++) {
  29203. var texture = textures[i];
  29204. for (var j = 0; j < attachments.length; j++) {
  29205. attachments[j] = gl.NONE;
  29206. }
  29207. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  29208. gl.readBuffer(attachments[i]);
  29209. gl.drawBuffers(attachments);
  29210. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  29211. }
  29212. for (var i = 0; i < attachments.length; i++) {
  29213. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  29214. }
  29215. gl.drawBuffers(attachments);
  29216. }
  29217. for (var i = 0; i < textures.length; i++) {
  29218. var texture = textures[i];
  29219. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  29220. this._bindTextureDirectly(gl.TEXTURE_2D, texture);
  29221. gl.generateMipmap(gl.TEXTURE_2D);
  29222. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  29223. }
  29224. }
  29225. if (onBeforeUnbind) {
  29226. if (textures[0]._MSAAFramebuffer) {
  29227. // Bind the correct framebuffer
  29228. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  29229. }
  29230. onBeforeUnbind();
  29231. }
  29232. this.bindUnboundFramebuffer(null);
  29233. };
  29234. /**
  29235. * Force the mipmap generation for the given render target texture
  29236. * @param texture defines the render target texture to use
  29237. */
  29238. Engine.prototype.generateMipMapsForCubemap = function (texture) {
  29239. if (texture.generateMipMaps) {
  29240. var gl = this._gl;
  29241. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  29242. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  29243. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  29244. }
  29245. };
  29246. /**
  29247. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29248. */
  29249. Engine.prototype.flushFramebuffer = function () {
  29250. this._gl.flush();
  29251. };
  29252. /**
  29253. * Unbind the current render target and bind the default framebuffer
  29254. */
  29255. Engine.prototype.restoreDefaultFramebuffer = function () {
  29256. if (this._currentRenderTarget) {
  29257. this.unBindFramebuffer(this._currentRenderTarget);
  29258. }
  29259. else {
  29260. this.bindUnboundFramebuffer(null);
  29261. }
  29262. if (this._cachedViewport) {
  29263. this.setViewport(this._cachedViewport);
  29264. }
  29265. this.wipeCaches();
  29266. };
  29267. // UBOs
  29268. /**
  29269. * Create an uniform buffer
  29270. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29271. * @param elements defines the content of the uniform buffer
  29272. * @returns the webGL uniform buffer
  29273. */
  29274. Engine.prototype.createUniformBuffer = function (elements) {
  29275. var ubo = this._gl.createBuffer();
  29276. if (!ubo) {
  29277. throw new Error("Unable to create uniform buffer");
  29278. }
  29279. this.bindUniformBuffer(ubo);
  29280. if (elements instanceof Float32Array) {
  29281. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.STATIC_DRAW);
  29282. }
  29283. else {
  29284. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.STATIC_DRAW);
  29285. }
  29286. this.bindUniformBuffer(null);
  29287. ubo.references = 1;
  29288. return ubo;
  29289. };
  29290. /**
  29291. * Create a dynamic uniform buffer
  29292. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29293. * @param elements defines the content of the uniform buffer
  29294. * @returns the webGL uniform buffer
  29295. */
  29296. Engine.prototype.createDynamicUniformBuffer = function (elements) {
  29297. var ubo = this._gl.createBuffer();
  29298. if (!ubo) {
  29299. throw new Error("Unable to create dynamic uniform buffer");
  29300. }
  29301. this.bindUniformBuffer(ubo);
  29302. if (elements instanceof Float32Array) {
  29303. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.DYNAMIC_DRAW);
  29304. }
  29305. else {
  29306. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.DYNAMIC_DRAW);
  29307. }
  29308. this.bindUniformBuffer(null);
  29309. ubo.references = 1;
  29310. return ubo;
  29311. };
  29312. /**
  29313. * Update an existing uniform buffer
  29314. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29315. * @param uniformBuffer defines the target uniform buffer
  29316. * @param elements defines the content to update
  29317. * @param offset defines the offset in the uniform buffer where update should start
  29318. * @param count defines the size of the data to update
  29319. */
  29320. Engine.prototype.updateUniformBuffer = function (uniformBuffer, elements, offset, count) {
  29321. this.bindUniformBuffer(uniformBuffer);
  29322. if (offset === undefined) {
  29323. offset = 0;
  29324. }
  29325. if (count === undefined) {
  29326. if (elements instanceof Float32Array) {
  29327. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, elements);
  29328. }
  29329. else {
  29330. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, new Float32Array(elements));
  29331. }
  29332. }
  29333. else {
  29334. if (elements instanceof Float32Array) {
  29335. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, elements.subarray(offset, offset + count));
  29336. }
  29337. else {
  29338. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(elements).subarray(offset, offset + count));
  29339. }
  29340. }
  29341. this.bindUniformBuffer(null);
  29342. };
  29343. // VBOs
  29344. Engine.prototype._resetVertexBufferBinding = function () {
  29345. this.bindArrayBuffer(null);
  29346. this._cachedVertexBuffers = null;
  29347. };
  29348. /**
  29349. * Creates a vertex buffer
  29350. * @param data the data for the vertex buffer
  29351. * @returns the new WebGL static buffer
  29352. */
  29353. Engine.prototype.createVertexBuffer = function (data) {
  29354. var vbo = this._gl.createBuffer();
  29355. if (!vbo) {
  29356. throw new Error("Unable to create vertex buffer");
  29357. }
  29358. this.bindArrayBuffer(vbo);
  29359. if (data instanceof Array) {
  29360. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.STATIC_DRAW);
  29361. }
  29362. else {
  29363. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.STATIC_DRAW);
  29364. }
  29365. this._resetVertexBufferBinding();
  29366. vbo.references = 1;
  29367. return vbo;
  29368. };
  29369. /**
  29370. * Creates a dynamic vertex buffer
  29371. * @param data the data for the dynamic vertex buffer
  29372. * @returns the new WebGL dynamic buffer
  29373. */
  29374. Engine.prototype.createDynamicVertexBuffer = function (data) {
  29375. var vbo = this._gl.createBuffer();
  29376. if (!vbo) {
  29377. throw new Error("Unable to create dynamic vertex buffer");
  29378. }
  29379. this.bindArrayBuffer(vbo);
  29380. if (data instanceof Array) {
  29381. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.DYNAMIC_DRAW);
  29382. }
  29383. else {
  29384. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.DYNAMIC_DRAW);
  29385. }
  29386. this._resetVertexBufferBinding();
  29387. vbo.references = 1;
  29388. return vbo;
  29389. };
  29390. /**
  29391. * Update a dynamic index buffer
  29392. * @param indexBuffer defines the target index buffer
  29393. * @param indices defines the data to update
  29394. * @param offset defines the offset in the target index buffer where update should start
  29395. */
  29396. Engine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  29397. if (offset === void 0) { offset = 0; }
  29398. // Force cache update
  29399. this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;
  29400. this.bindIndexBuffer(indexBuffer);
  29401. var arrayBuffer;
  29402. if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
  29403. arrayBuffer = indices;
  29404. }
  29405. else {
  29406. arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  29407. }
  29408. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
  29409. this._resetIndexBufferBinding();
  29410. };
  29411. /**
  29412. * Updates a dynamic vertex buffer.
  29413. * @param vertexBuffer the vertex buffer to update
  29414. * @param data the data used to update the vertex buffer
  29415. * @param byteOffset the byte offset of the data
  29416. * @param byteLength the byte length of the data
  29417. */
  29418. Engine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, data, byteOffset, byteLength) {
  29419. this.bindArrayBuffer(vertexBuffer);
  29420. if (byteOffset === undefined) {
  29421. byteOffset = 0;
  29422. }
  29423. if (byteLength === undefined) {
  29424. if (data instanceof Array) {
  29425. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data));
  29426. }
  29427. else {
  29428. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data);
  29429. }
  29430. }
  29431. else {
  29432. if (data instanceof Array) {
  29433. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(data).subarray(byteOffset, byteOffset + byteLength));
  29434. }
  29435. else {
  29436. if (data instanceof ArrayBuffer) {
  29437. data = new Uint8Array(data, byteOffset, byteLength);
  29438. }
  29439. else {
  29440. data = new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength);
  29441. }
  29442. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  29443. }
  29444. }
  29445. this._resetVertexBufferBinding();
  29446. };
  29447. Engine.prototype._resetIndexBufferBinding = function () {
  29448. this.bindIndexBuffer(null);
  29449. this._cachedIndexBuffer = null;
  29450. };
  29451. /**
  29452. * Creates a new index buffer
  29453. * @param indices defines the content of the index buffer
  29454. * @param updatable defines if the index buffer must be updatable
  29455. * @returns a new webGL buffer
  29456. */
  29457. Engine.prototype.createIndexBuffer = function (indices, updatable) {
  29458. var vbo = this._gl.createBuffer();
  29459. if (!vbo) {
  29460. throw new Error("Unable to create index buffer");
  29461. }
  29462. this.bindIndexBuffer(vbo);
  29463. // Check for 32 bits indices
  29464. var arrayBuffer;
  29465. var need32Bits = false;
  29466. if (indices instanceof Uint16Array) {
  29467. arrayBuffer = indices;
  29468. }
  29469. else {
  29470. //check 32 bit support
  29471. if (this._caps.uintIndices) {
  29472. if (indices instanceof Uint32Array) {
  29473. arrayBuffer = indices;
  29474. need32Bits = true;
  29475. }
  29476. else {
  29477. //number[] or Int32Array, check if 32 bit is necessary
  29478. for (var index = 0; index < indices.length; index++) {
  29479. if (indices[index] > 65535) {
  29480. need32Bits = true;
  29481. break;
  29482. }
  29483. }
  29484. arrayBuffer = need32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  29485. }
  29486. }
  29487. else {
  29488. //no 32 bit support, force conversion to 16 bit (values greater 16 bit are lost)
  29489. arrayBuffer = new Uint16Array(indices);
  29490. }
  29491. }
  29492. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);
  29493. this._resetIndexBufferBinding();
  29494. vbo.references = 1;
  29495. vbo.is32Bits = need32Bits;
  29496. return vbo;
  29497. };
  29498. /**
  29499. * Bind a webGL buffer to the webGL context
  29500. * @param buffer defines the buffer to bind
  29501. */
  29502. Engine.prototype.bindArrayBuffer = function (buffer) {
  29503. if (!this._vaoRecordInProgress) {
  29504. this._unbindVertexArrayObject();
  29505. }
  29506. this.bindBuffer(buffer, this._gl.ARRAY_BUFFER);
  29507. };
  29508. /**
  29509. * Bind an uniform buffer to the current webGL context
  29510. * @param buffer defines the buffer to bind
  29511. */
  29512. Engine.prototype.bindUniformBuffer = function (buffer) {
  29513. this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, buffer);
  29514. };
  29515. /**
  29516. * Bind a buffer to the current webGL context at a given location
  29517. * @param buffer defines the buffer to bind
  29518. * @param location defines the index where to bind the buffer
  29519. */
  29520. Engine.prototype.bindUniformBufferBase = function (buffer, location) {
  29521. this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, location, buffer);
  29522. };
  29523. /**
  29524. * Bind a specific block at a given index in a specific shader program
  29525. * @param shaderProgram defines the shader program
  29526. * @param blockName defines the block name
  29527. * @param index defines the index where to bind the block
  29528. */
  29529. Engine.prototype.bindUniformBlock = function (shaderProgram, blockName, index) {
  29530. var uniformLocation = this._gl.getUniformBlockIndex(shaderProgram, blockName);
  29531. this._gl.uniformBlockBinding(shaderProgram, uniformLocation, index);
  29532. };
  29533. Engine.prototype.bindIndexBuffer = function (buffer) {
  29534. if (!this._vaoRecordInProgress) {
  29535. this._unbindVertexArrayObject();
  29536. }
  29537. this.bindBuffer(buffer, this._gl.ELEMENT_ARRAY_BUFFER);
  29538. };
  29539. Engine.prototype.bindBuffer = function (buffer, target) {
  29540. if (this._vaoRecordInProgress || this._currentBoundBuffer[target] !== buffer) {
  29541. this._gl.bindBuffer(target, buffer);
  29542. this._currentBoundBuffer[target] = buffer;
  29543. }
  29544. };
  29545. /**
  29546. * update the bound buffer with the given data
  29547. * @param data defines the data to update
  29548. */
  29549. Engine.prototype.updateArrayBuffer = function (data) {
  29550. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  29551. };
  29552. Engine.prototype._vertexAttribPointer = function (buffer, indx, size, type, normalized, stride, offset) {
  29553. var pointer = this._currentBufferPointers[indx];
  29554. var changed = false;
  29555. if (!pointer.active) {
  29556. changed = true;
  29557. pointer.active = true;
  29558. pointer.index = indx;
  29559. pointer.size = size;
  29560. pointer.type = type;
  29561. pointer.normalized = normalized;
  29562. pointer.stride = stride;
  29563. pointer.offset = offset;
  29564. pointer.buffer = buffer;
  29565. }
  29566. else {
  29567. if (pointer.buffer !== buffer) {
  29568. pointer.buffer = buffer;
  29569. changed = true;
  29570. }
  29571. if (pointer.size !== size) {
  29572. pointer.size = size;
  29573. changed = true;
  29574. }
  29575. if (pointer.type !== type) {
  29576. pointer.type = type;
  29577. changed = true;
  29578. }
  29579. if (pointer.normalized !== normalized) {
  29580. pointer.normalized = normalized;
  29581. changed = true;
  29582. }
  29583. if (pointer.stride !== stride) {
  29584. pointer.stride = stride;
  29585. changed = true;
  29586. }
  29587. if (pointer.offset !== offset) {
  29588. pointer.offset = offset;
  29589. changed = true;
  29590. }
  29591. }
  29592. if (changed || this._vaoRecordInProgress) {
  29593. this.bindArrayBuffer(buffer);
  29594. this._gl.vertexAttribPointer(indx, size, type, normalized, stride, offset);
  29595. }
  29596. };
  29597. Engine.prototype._bindIndexBufferWithCache = function (indexBuffer) {
  29598. if (indexBuffer == null) {
  29599. return;
  29600. }
  29601. if (this._cachedIndexBuffer !== indexBuffer) {
  29602. this._cachedIndexBuffer = indexBuffer;
  29603. this.bindIndexBuffer(indexBuffer);
  29604. this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
  29605. }
  29606. };
  29607. Engine.prototype._bindVertexBuffersAttributes = function (vertexBuffers, effect) {
  29608. var attributes = effect.getAttributesNames();
  29609. if (!this._vaoRecordInProgress) {
  29610. this._unbindVertexArrayObject();
  29611. }
  29612. this.unbindAllAttributes();
  29613. for (var index = 0; index < attributes.length; index++) {
  29614. var order = effect.getAttributeLocation(index);
  29615. if (order >= 0) {
  29616. var vertexBuffer = vertexBuffers[attributes[index]];
  29617. if (!vertexBuffer) {
  29618. continue;
  29619. }
  29620. this._gl.enableVertexAttribArray(order);
  29621. if (!this._vaoRecordInProgress) {
  29622. this._vertexAttribArraysEnabled[order] = true;
  29623. }
  29624. var buffer = vertexBuffer.getBuffer();
  29625. if (buffer) {
  29626. this._vertexAttribPointer(buffer, order, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized, vertexBuffer.byteStride, vertexBuffer.byteOffset);
  29627. if (vertexBuffer.getIsInstanced()) {
  29628. this._gl.vertexAttribDivisor(order, vertexBuffer.getInstanceDivisor());
  29629. if (!this._vaoRecordInProgress) {
  29630. this._currentInstanceLocations.push(order);
  29631. this._currentInstanceBuffers.push(buffer);
  29632. }
  29633. }
  29634. }
  29635. }
  29636. }
  29637. };
  29638. /**
  29639. * Records a vertex array object
  29640. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29641. * @param vertexBuffers defines the list of vertex buffers to store
  29642. * @param indexBuffer defines the index buffer to store
  29643. * @param effect defines the effect to store
  29644. * @returns the new vertex array object
  29645. */
  29646. Engine.prototype.recordVertexArrayObject = function (vertexBuffers, indexBuffer, effect) {
  29647. var vao = this._gl.createVertexArray();
  29648. this._vaoRecordInProgress = true;
  29649. this._gl.bindVertexArray(vao);
  29650. this._mustWipeVertexAttributes = true;
  29651. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  29652. this.bindIndexBuffer(indexBuffer);
  29653. this._vaoRecordInProgress = false;
  29654. this._gl.bindVertexArray(null);
  29655. return vao;
  29656. };
  29657. /**
  29658. * Bind a specific vertex array object
  29659. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29660. * @param vertexArrayObject defines the vertex array object to bind
  29661. * @param indexBuffer defines the index buffer to bind
  29662. */
  29663. Engine.prototype.bindVertexArrayObject = function (vertexArrayObject, indexBuffer) {
  29664. if (this._cachedVertexArrayObject !== vertexArrayObject) {
  29665. this._cachedVertexArrayObject = vertexArrayObject;
  29666. this._gl.bindVertexArray(vertexArrayObject);
  29667. this._cachedVertexBuffers = null;
  29668. this._cachedIndexBuffer = null;
  29669. this._uintIndicesCurrentlySet = indexBuffer != null && indexBuffer.is32Bits;
  29670. this._mustWipeVertexAttributes = true;
  29671. }
  29672. };
  29673. /**
  29674. * Bind webGl buffers directly to the webGL context
  29675. * @param vertexBuffer defines the vertex buffer to bind
  29676. * @param indexBuffer defines the index buffer to bind
  29677. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29678. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29679. * @param effect defines the effect associated with the vertex buffer
  29680. */
  29681. Engine.prototype.bindBuffersDirectly = function (vertexBuffer, indexBuffer, vertexDeclaration, vertexStrideSize, effect) {
  29682. if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {
  29683. this._cachedVertexBuffers = vertexBuffer;
  29684. this._cachedEffectForVertexBuffers = effect;
  29685. var attributesCount = effect.getAttributesCount();
  29686. this._unbindVertexArrayObject();
  29687. this.unbindAllAttributes();
  29688. var offset = 0;
  29689. for (var index = 0; index < attributesCount; index++) {
  29690. if (index < vertexDeclaration.length) {
  29691. var order = effect.getAttributeLocation(index);
  29692. if (order >= 0) {
  29693. this._gl.enableVertexAttribArray(order);
  29694. this._vertexAttribArraysEnabled[order] = true;
  29695. this._vertexAttribPointer(vertexBuffer, order, vertexDeclaration[index], this._gl.FLOAT, false, vertexStrideSize, offset);
  29696. }
  29697. offset += vertexDeclaration[index] * 4;
  29698. }
  29699. }
  29700. }
  29701. this._bindIndexBufferWithCache(indexBuffer);
  29702. };
  29703. Engine.prototype._unbindVertexArrayObject = function () {
  29704. if (!this._cachedVertexArrayObject) {
  29705. return;
  29706. }
  29707. this._cachedVertexArrayObject = null;
  29708. this._gl.bindVertexArray(null);
  29709. };
  29710. /**
  29711. * Bind a list of vertex buffers to the webGL context
  29712. * @param vertexBuffers defines the list of vertex buffers to bind
  29713. * @param indexBuffer defines the index buffer to bind
  29714. * @param effect defines the effect associated with the vertex buffers
  29715. */
  29716. Engine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  29717. if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {
  29718. this._cachedVertexBuffers = vertexBuffers;
  29719. this._cachedEffectForVertexBuffers = effect;
  29720. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  29721. }
  29722. this._bindIndexBufferWithCache(indexBuffer);
  29723. };
  29724. /**
  29725. * Unbind all instance attributes
  29726. */
  29727. Engine.prototype.unbindInstanceAttributes = function () {
  29728. var boundBuffer;
  29729. for (var i = 0, ul = this._currentInstanceLocations.length; i < ul; i++) {
  29730. var instancesBuffer = this._currentInstanceBuffers[i];
  29731. if (boundBuffer != instancesBuffer && instancesBuffer.references) {
  29732. boundBuffer = instancesBuffer;
  29733. this.bindArrayBuffer(instancesBuffer);
  29734. }
  29735. var offsetLocation = this._currentInstanceLocations[i];
  29736. this._gl.vertexAttribDivisor(offsetLocation, 0);
  29737. }
  29738. this._currentInstanceBuffers.length = 0;
  29739. this._currentInstanceLocations.length = 0;
  29740. };
  29741. /**
  29742. * Release and free the memory of a vertex array object
  29743. * @param vao defines the vertex array object to delete
  29744. */
  29745. Engine.prototype.releaseVertexArrayObject = function (vao) {
  29746. this._gl.deleteVertexArray(vao);
  29747. };
  29748. /** @hidden */
  29749. Engine.prototype._releaseBuffer = function (buffer) {
  29750. buffer.references--;
  29751. if (buffer.references === 0) {
  29752. this._gl.deleteBuffer(buffer);
  29753. return true;
  29754. }
  29755. return false;
  29756. };
  29757. /**
  29758. * Creates a webGL buffer to use with instanciation
  29759. * @param capacity defines the size of the buffer
  29760. * @returns the webGL buffer
  29761. */
  29762. Engine.prototype.createInstancesBuffer = function (capacity) {
  29763. var buffer = this._gl.createBuffer();
  29764. if (!buffer) {
  29765. throw new Error("Unable to create instance buffer");
  29766. }
  29767. buffer.capacity = capacity;
  29768. this.bindArrayBuffer(buffer);
  29769. this._gl.bufferData(this._gl.ARRAY_BUFFER, capacity, this._gl.DYNAMIC_DRAW);
  29770. return buffer;
  29771. };
  29772. /**
  29773. * Delete a webGL buffer used with instanciation
  29774. * @param buffer defines the webGL buffer to delete
  29775. */
  29776. Engine.prototype.deleteInstancesBuffer = function (buffer) {
  29777. this._gl.deleteBuffer(buffer);
  29778. };
  29779. /**
  29780. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29781. * @param instancesBuffer defines the webGL buffer to update and bind
  29782. * @param data defines the data to store in the buffer
  29783. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29784. */
  29785. Engine.prototype.updateAndBindInstancesBuffer = function (instancesBuffer, data, offsetLocations) {
  29786. this.bindArrayBuffer(instancesBuffer);
  29787. if (data) {
  29788. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  29789. }
  29790. if (offsetLocations[0].index !== undefined) {
  29791. var stride = 0;
  29792. for (var i = 0; i < offsetLocations.length; i++) {
  29793. var ai = offsetLocations[i];
  29794. stride += ai.attributeSize * 4;
  29795. }
  29796. for (var i = 0; i < offsetLocations.length; i++) {
  29797. var ai = offsetLocations[i];
  29798. if (!this._vertexAttribArraysEnabled[ai.index]) {
  29799. this._gl.enableVertexAttribArray(ai.index);
  29800. this._vertexAttribArraysEnabled[ai.index] = true;
  29801. }
  29802. this._vertexAttribPointer(instancesBuffer, ai.index, ai.attributeSize, ai.attribyteType || this._gl.FLOAT, ai.normalized || false, stride, ai.offset);
  29803. this._gl.vertexAttribDivisor(ai.index, 1);
  29804. this._currentInstanceLocations.push(ai.index);
  29805. this._currentInstanceBuffers.push(instancesBuffer);
  29806. }
  29807. }
  29808. else {
  29809. for (var index = 0; index < 4; index++) {
  29810. var offsetLocation = offsetLocations[index];
  29811. if (!this._vertexAttribArraysEnabled[offsetLocation]) {
  29812. this._gl.enableVertexAttribArray(offsetLocation);
  29813. this._vertexAttribArraysEnabled[offsetLocation] = true;
  29814. }
  29815. this._vertexAttribPointer(instancesBuffer, offsetLocation, 4, this._gl.FLOAT, false, 64, index * 16);
  29816. this._gl.vertexAttribDivisor(offsetLocation, 1);
  29817. this._currentInstanceLocations.push(offsetLocation);
  29818. this._currentInstanceBuffers.push(instancesBuffer);
  29819. }
  29820. }
  29821. };
  29822. /**
  29823. * Apply all cached states (depth, culling, stencil and alpha)
  29824. */
  29825. Engine.prototype.applyStates = function () {
  29826. this._depthCullingState.apply(this._gl);
  29827. this._stencilState.apply(this._gl);
  29828. this._alphaState.apply(this._gl);
  29829. };
  29830. /**
  29831. * Send a draw order
  29832. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29833. * @param indexStart defines the starting index
  29834. * @param indexCount defines the number of index to draw
  29835. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29836. */
  29837. Engine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  29838. this.drawElementsType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, indexStart, indexCount, instancesCount);
  29839. };
  29840. /**
  29841. * Draw a list of points
  29842. * @param verticesStart defines the index of first vertex to draw
  29843. * @param verticesCount defines the count of vertices to draw
  29844. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29845. */
  29846. Engine.prototype.drawPointClouds = function (verticesStart, verticesCount, instancesCount) {
  29847. this.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode, verticesStart, verticesCount, instancesCount);
  29848. };
  29849. /**
  29850. * Draw a list of unindexed primitives
  29851. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29852. * @param verticesStart defines the index of first vertex to draw
  29853. * @param verticesCount defines the count of vertices to draw
  29854. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29855. */
  29856. Engine.prototype.drawUnIndexed = function (useTriangles, verticesStart, verticesCount, instancesCount) {
  29857. this.drawArraysType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, verticesStart, verticesCount, instancesCount);
  29858. };
  29859. /**
  29860. * Draw a list of indexed primitives
  29861. * @param fillMode defines the primitive to use
  29862. * @param indexStart defines the starting index
  29863. * @param indexCount defines the number of index to draw
  29864. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29865. */
  29866. Engine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  29867. // Apply states
  29868. this.applyStates();
  29869. this._drawCalls.addCount(1, false);
  29870. // Render
  29871. var drawMode = this._drawMode(fillMode);
  29872. var indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;
  29873. var mult = this._uintIndicesCurrentlySet ? 4 : 2;
  29874. if (instancesCount) {
  29875. this._gl.drawElementsInstanced(drawMode, indexCount, indexFormat, indexStart * mult, instancesCount);
  29876. }
  29877. else {
  29878. this._gl.drawElements(drawMode, indexCount, indexFormat, indexStart * mult);
  29879. }
  29880. };
  29881. /**
  29882. * Draw a list of unindexed primitives
  29883. * @param fillMode defines the primitive to use
  29884. * @param verticesStart defines the index of first vertex to draw
  29885. * @param verticesCount defines the count of vertices to draw
  29886. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29887. */
  29888. Engine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  29889. // Apply states
  29890. this.applyStates();
  29891. this._drawCalls.addCount(1, false);
  29892. var drawMode = this._drawMode(fillMode);
  29893. if (instancesCount) {
  29894. this._gl.drawArraysInstanced(drawMode, verticesStart, verticesCount, instancesCount);
  29895. }
  29896. else {
  29897. this._gl.drawArrays(drawMode, verticesStart, verticesCount);
  29898. }
  29899. };
  29900. Engine.prototype._drawMode = function (fillMode) {
  29901. switch (fillMode) {
  29902. // Triangle views
  29903. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode:
  29904. return this._gl.TRIANGLES;
  29905. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode:
  29906. return this._gl.POINTS;
  29907. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode:
  29908. return this._gl.LINES;
  29909. // Draw modes
  29910. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointListDrawMode:
  29911. return this._gl.POINTS;
  29912. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineListDrawMode:
  29913. return this._gl.LINES;
  29914. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineLoopDrawMode:
  29915. return this._gl.LINE_LOOP;
  29916. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineStripDrawMode:
  29917. return this._gl.LINE_STRIP;
  29918. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleStripDrawMode:
  29919. return this._gl.TRIANGLE_STRIP;
  29920. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFanDrawMode:
  29921. return this._gl.TRIANGLE_FAN;
  29922. default:
  29923. return this._gl.TRIANGLES;
  29924. }
  29925. };
  29926. // Shaders
  29927. /** @hidden */
  29928. Engine.prototype._releaseEffect = function (effect) {
  29929. if (this._compiledEffects[effect._key]) {
  29930. delete this._compiledEffects[effect._key];
  29931. this._deleteProgram(effect.getProgram());
  29932. }
  29933. };
  29934. /** @hidden */
  29935. Engine.prototype._deleteProgram = function (program) {
  29936. if (program) {
  29937. program.__SPECTOR_rebuildProgram = null;
  29938. if (program.transformFeedback) {
  29939. this.deleteTransformFeedback(program.transformFeedback);
  29940. program.transformFeedback = null;
  29941. }
  29942. this._gl.deleteProgram(program);
  29943. }
  29944. };
  29945. /**
  29946. * Create a new effect (used to store vertex/fragment shaders)
  29947. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29948. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29949. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29950. * @param samplers defines an array of string used to represent textures
  29951. * @param defines defines the string containing the defines to use to compile the shaders
  29952. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29953. * @param onCompiled defines a function to call when the effect creation is successful
  29954. * @param onError defines a function to call when the effect creation has failed
  29955. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29956. * @returns the new Effect
  29957. */
  29958. Engine.prototype.createEffect = function (baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters) {
  29959. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  29960. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  29961. var name = vertex + "+" + fragment + "@" + (defines ? defines : attributesNamesOrOptions.defines);
  29962. if (this._compiledEffects[name]) {
  29963. var compiledEffect = this._compiledEffects[name];
  29964. if (onCompiled && compiledEffect.isReady()) {
  29965. onCompiled(compiledEffect);
  29966. }
  29967. return compiledEffect;
  29968. }
  29969. var effect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"](baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters);
  29970. effect._key = name;
  29971. this._compiledEffects[name] = effect;
  29972. return effect;
  29973. };
  29974. Engine.prototype._compileShader = function (source, type, defines, shaderVersion) {
  29975. return this._compileRawShader(shaderVersion + (defines ? defines + "\n" : "") + source, type);
  29976. };
  29977. Engine.prototype._compileRawShader = function (source, type) {
  29978. var gl = this._gl;
  29979. var shader = gl.createShader(type === "vertex" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);
  29980. if (!shader) {
  29981. throw new Error("Something went wrong while compile the shader.");
  29982. }
  29983. gl.shaderSource(shader, source);
  29984. gl.compileShader(shader);
  29985. if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
  29986. var log = gl.getShaderInfoLog(shader);
  29987. if (log) {
  29988. throw new Error(log);
  29989. }
  29990. }
  29991. return shader;
  29992. };
  29993. /**
  29994. * Directly creates a webGL program
  29995. * @param vertexCode defines the vertex shader code to use
  29996. * @param fragmentCode defines the fragment shader code to use
  29997. * @param context defines the webGL context to use (if not set, the current one will be used)
  29998. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29999. * @returns the new webGL program
  30000. */
  30001. Engine.prototype.createRawShaderProgram = function (vertexCode, fragmentCode, context, transformFeedbackVaryings) {
  30002. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30003. context = context || this._gl;
  30004. var vertexShader = this._compileRawShader(vertexCode, "vertex");
  30005. var fragmentShader = this._compileRawShader(fragmentCode, "fragment");
  30006. return this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  30007. };
  30008. /**
  30009. * Creates a webGL program
  30010. * @param vertexCode defines the vertex shader code to use
  30011. * @param fragmentCode defines the fragment shader code to use
  30012. * @param defines defines the string containing the defines to use to compile the shaders
  30013. * @param context defines the webGL context to use (if not set, the current one will be used)
  30014. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30015. * @returns the new webGL program
  30016. */
  30017. Engine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context, transformFeedbackVaryings) {
  30018. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30019. context = context || this._gl;
  30020. this.onBeforeShaderCompilationObservable.notifyObservers(this);
  30021. var shaderVersion = (this._webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  30022. var vertexShader = this._compileShader(vertexCode, "vertex", defines, shaderVersion);
  30023. var fragmentShader = this._compileShader(fragmentCode, "fragment", defines, shaderVersion);
  30024. var program = this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  30025. this.onAfterShaderCompilationObservable.notifyObservers(this);
  30026. return program;
  30027. };
  30028. Engine.prototype._createShaderProgram = function (vertexShader, fragmentShader, context, transformFeedbackVaryings) {
  30029. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30030. var shaderProgram = context.createProgram();
  30031. if (!shaderProgram) {
  30032. throw new Error("Unable to create program");
  30033. }
  30034. context.attachShader(shaderProgram, vertexShader);
  30035. context.attachShader(shaderProgram, fragmentShader);
  30036. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30037. var transformFeedback = this.createTransformFeedback();
  30038. this.bindTransformFeedback(transformFeedback);
  30039. this.setTranformFeedbackVaryings(shaderProgram, transformFeedbackVaryings);
  30040. shaderProgram.transformFeedback = transformFeedback;
  30041. }
  30042. context.linkProgram(shaderProgram);
  30043. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30044. this.bindTransformFeedback(null);
  30045. }
  30046. shaderProgram.context = context;
  30047. shaderProgram.vertexShader = vertexShader;
  30048. shaderProgram.fragmentShader = fragmentShader;
  30049. if (!this._caps.parallelShaderCompile) {
  30050. this._finalizeProgram(shaderProgram);
  30051. }
  30052. else {
  30053. shaderProgram.isParallelCompiled = true;
  30054. }
  30055. return shaderProgram;
  30056. };
  30057. Engine.prototype._finalizeProgram = function (shaderProgram) {
  30058. var context = shaderProgram.context;
  30059. var vertexShader = shaderProgram.vertexShader;
  30060. var fragmentShader = shaderProgram.fragmentShader;
  30061. var linked = context.getProgramParameter(shaderProgram, context.LINK_STATUS);
  30062. if (!linked) {
  30063. var error = context.getProgramInfoLog(shaderProgram);
  30064. if (error) {
  30065. throw new Error(error);
  30066. }
  30067. }
  30068. if (this.validateShaderPrograms) {
  30069. context.validateProgram(shaderProgram);
  30070. var validated = context.getProgramParameter(shaderProgram, context.VALIDATE_STATUS);
  30071. if (!validated) {
  30072. var error = context.getProgramInfoLog(shaderProgram);
  30073. if (error) {
  30074. throw new Error(error);
  30075. }
  30076. }
  30077. }
  30078. context.deleteShader(vertexShader);
  30079. context.deleteShader(fragmentShader);
  30080. shaderProgram.context = undefined;
  30081. shaderProgram.vertexShader = undefined;
  30082. shaderProgram.fragmentShader = undefined;
  30083. if (shaderProgram.onCompiled) {
  30084. shaderProgram.onCompiled();
  30085. shaderProgram.onCompiled = undefined;
  30086. }
  30087. };
  30088. /** @hidden */
  30089. Engine.prototype._isProgramCompiled = function (shaderProgram) {
  30090. if (!shaderProgram.isParallelCompiled) {
  30091. return true;
  30092. }
  30093. if (this._gl.getProgramParameter(shaderProgram, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)) {
  30094. this._finalizeProgram(shaderProgram);
  30095. return true;
  30096. }
  30097. return false;
  30098. };
  30099. /** @hidden */
  30100. Engine.prototype._executeWhenProgramIsCompiled = function (shaderProgram, action) {
  30101. if (!shaderProgram.isParallelCompiled) {
  30102. action();
  30103. return;
  30104. }
  30105. shaderProgram.onCompiled = action;
  30106. };
  30107. /**
  30108. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30109. * @param shaderProgram defines the webGL program to use
  30110. * @param uniformsNames defines the list of uniform names
  30111. * @returns an array of webGL uniform locations
  30112. */
  30113. Engine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  30114. var results = new Array();
  30115. for (var index = 0; index < uniformsNames.length; index++) {
  30116. results.push(this._gl.getUniformLocation(shaderProgram, uniformsNames[index]));
  30117. }
  30118. return results;
  30119. };
  30120. /**
  30121. * Gets the lsit of active attributes for a given webGL program
  30122. * @param shaderProgram defines the webGL program to use
  30123. * @param attributesNames defines the list of attribute names to get
  30124. * @returns an array of indices indicating the offset of each attribute
  30125. */
  30126. Engine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  30127. var results = [];
  30128. for (var index = 0; index < attributesNames.length; index++) {
  30129. try {
  30130. results.push(this._gl.getAttribLocation(shaderProgram, attributesNames[index]));
  30131. }
  30132. catch (e) {
  30133. results.push(-1);
  30134. }
  30135. }
  30136. return results;
  30137. };
  30138. /**
  30139. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30140. * @param effect defines the effect to activate
  30141. */
  30142. Engine.prototype.enableEffect = function (effect) {
  30143. if (!effect || effect === this._currentEffect) {
  30144. return;
  30145. }
  30146. // Use program
  30147. this.bindSamplers(effect);
  30148. this._currentEffect = effect;
  30149. if (effect.onBind) {
  30150. effect.onBind(effect);
  30151. }
  30152. if (effect._onBindObservable) {
  30153. effect._onBindObservable.notifyObservers(effect);
  30154. }
  30155. };
  30156. /**
  30157. * Set the value of an uniform to an array of int32
  30158. * @param uniform defines the webGL uniform location where to store the value
  30159. * @param array defines the array of int32 to store
  30160. */
  30161. Engine.prototype.setIntArray = function (uniform, array) {
  30162. if (!uniform) {
  30163. return;
  30164. }
  30165. this._gl.uniform1iv(uniform, array);
  30166. };
  30167. /**
  30168. * Set the value of an uniform to an array of int32 (stored as vec2)
  30169. * @param uniform defines the webGL uniform location where to store the value
  30170. * @param array defines the array of int32 to store
  30171. */
  30172. Engine.prototype.setIntArray2 = function (uniform, array) {
  30173. if (!uniform || array.length % 2 !== 0) {
  30174. return;
  30175. }
  30176. this._gl.uniform2iv(uniform, array);
  30177. };
  30178. /**
  30179. * Set the value of an uniform to an array of int32 (stored as vec3)
  30180. * @param uniform defines the webGL uniform location where to store the value
  30181. * @param array defines the array of int32 to store
  30182. */
  30183. Engine.prototype.setIntArray3 = function (uniform, array) {
  30184. if (!uniform || array.length % 3 !== 0) {
  30185. return;
  30186. }
  30187. this._gl.uniform3iv(uniform, array);
  30188. };
  30189. /**
  30190. * Set the value of an uniform to an array of int32 (stored as vec4)
  30191. * @param uniform defines the webGL uniform location where to store the value
  30192. * @param array defines the array of int32 to store
  30193. */
  30194. Engine.prototype.setIntArray4 = function (uniform, array) {
  30195. if (!uniform || array.length % 4 !== 0) {
  30196. return;
  30197. }
  30198. this._gl.uniform4iv(uniform, array);
  30199. };
  30200. /**
  30201. * Set the value of an uniform to an array of float32
  30202. * @param uniform defines the webGL uniform location where to store the value
  30203. * @param array defines the array of float32 to store
  30204. */
  30205. Engine.prototype.setFloatArray = function (uniform, array) {
  30206. if (!uniform) {
  30207. return;
  30208. }
  30209. this._gl.uniform1fv(uniform, array);
  30210. };
  30211. /**
  30212. * Set the value of an uniform to an array of float32 (stored as vec2)
  30213. * @param uniform defines the webGL uniform location where to store the value
  30214. * @param array defines the array of float32 to store
  30215. */
  30216. Engine.prototype.setFloatArray2 = function (uniform, array) {
  30217. if (!uniform || array.length % 2 !== 0) {
  30218. return;
  30219. }
  30220. this._gl.uniform2fv(uniform, array);
  30221. };
  30222. /**
  30223. * Set the value of an uniform to an array of float32 (stored as vec3)
  30224. * @param uniform defines the webGL uniform location where to store the value
  30225. * @param array defines the array of float32 to store
  30226. */
  30227. Engine.prototype.setFloatArray3 = function (uniform, array) {
  30228. if (!uniform || array.length % 3 !== 0) {
  30229. return;
  30230. }
  30231. this._gl.uniform3fv(uniform, array);
  30232. };
  30233. /**
  30234. * Set the value of an uniform to an array of float32 (stored as vec4)
  30235. * @param uniform defines the webGL uniform location where to store the value
  30236. * @param array defines the array of float32 to store
  30237. */
  30238. Engine.prototype.setFloatArray4 = function (uniform, array) {
  30239. if (!uniform || array.length % 4 !== 0) {
  30240. return;
  30241. }
  30242. this._gl.uniform4fv(uniform, array);
  30243. };
  30244. /**
  30245. * Set the value of an uniform to an array of number
  30246. * @param uniform defines the webGL uniform location where to store the value
  30247. * @param array defines the array of number to store
  30248. */
  30249. Engine.prototype.setArray = function (uniform, array) {
  30250. if (!uniform) {
  30251. return;
  30252. }
  30253. this._gl.uniform1fv(uniform, array);
  30254. };
  30255. /**
  30256. * Set the value of an uniform to an array of number (stored as vec2)
  30257. * @param uniform defines the webGL uniform location where to store the value
  30258. * @param array defines the array of number to store
  30259. */
  30260. Engine.prototype.setArray2 = function (uniform, array) {
  30261. if (!uniform || array.length % 2 !== 0) {
  30262. return;
  30263. }
  30264. this._gl.uniform2fv(uniform, array);
  30265. };
  30266. /**
  30267. * Set the value of an uniform to an array of number (stored as vec3)
  30268. * @param uniform defines the webGL uniform location where to store the value
  30269. * @param array defines the array of number to store
  30270. */
  30271. Engine.prototype.setArray3 = function (uniform, array) {
  30272. if (!uniform || array.length % 3 !== 0) {
  30273. return;
  30274. }
  30275. this._gl.uniform3fv(uniform, array);
  30276. };
  30277. /**
  30278. * Set the value of an uniform to an array of number (stored as vec4)
  30279. * @param uniform defines the webGL uniform location where to store the value
  30280. * @param array defines the array of number to store
  30281. */
  30282. Engine.prototype.setArray4 = function (uniform, array) {
  30283. if (!uniform || array.length % 4 !== 0) {
  30284. return;
  30285. }
  30286. this._gl.uniform4fv(uniform, array);
  30287. };
  30288. /**
  30289. * Set the value of an uniform to an array of float32 (stored as matrices)
  30290. * @param uniform defines the webGL uniform location where to store the value
  30291. * @param matrices defines the array of float32 to store
  30292. */
  30293. Engine.prototype.setMatrices = function (uniform, matrices) {
  30294. if (!uniform) {
  30295. return;
  30296. }
  30297. this._gl.uniformMatrix4fv(uniform, false, matrices);
  30298. };
  30299. /**
  30300. * Set the value of an uniform to a matrix
  30301. * @param uniform defines the webGL uniform location where to store the value
  30302. * @param matrix defines the matrix to store
  30303. */
  30304. Engine.prototype.setMatrix = function (uniform, matrix) {
  30305. if (!uniform) {
  30306. return;
  30307. }
  30308. this._gl.uniformMatrix4fv(uniform, false, matrix.toArray());
  30309. };
  30310. /**
  30311. * Set the value of an uniform to a matrix (3x3)
  30312. * @param uniform defines the webGL uniform location where to store the value
  30313. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30314. */
  30315. Engine.prototype.setMatrix3x3 = function (uniform, matrix) {
  30316. if (!uniform) {
  30317. return;
  30318. }
  30319. this._gl.uniformMatrix3fv(uniform, false, matrix);
  30320. };
  30321. /**
  30322. * Set the value of an uniform to a matrix (2x2)
  30323. * @param uniform defines the webGL uniform location where to store the value
  30324. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30325. */
  30326. Engine.prototype.setMatrix2x2 = function (uniform, matrix) {
  30327. if (!uniform) {
  30328. return;
  30329. }
  30330. this._gl.uniformMatrix2fv(uniform, false, matrix);
  30331. };
  30332. /**
  30333. * Set the value of an uniform to a number (int)
  30334. * @param uniform defines the webGL uniform location where to store the value
  30335. * @param value defines the int number to store
  30336. */
  30337. Engine.prototype.setInt = function (uniform, value) {
  30338. if (!uniform) {
  30339. return;
  30340. }
  30341. this._gl.uniform1i(uniform, value);
  30342. };
  30343. /**
  30344. * Set the value of an uniform to a number (float)
  30345. * @param uniform defines the webGL uniform location where to store the value
  30346. * @param value defines the float number to store
  30347. */
  30348. Engine.prototype.setFloat = function (uniform, value) {
  30349. if (!uniform) {
  30350. return;
  30351. }
  30352. this._gl.uniform1f(uniform, value);
  30353. };
  30354. /**
  30355. * Set the value of an uniform to a vec2
  30356. * @param uniform defines the webGL uniform location where to store the value
  30357. * @param x defines the 1st component of the value
  30358. * @param y defines the 2nd component of the value
  30359. */
  30360. Engine.prototype.setFloat2 = function (uniform, x, y) {
  30361. if (!uniform) {
  30362. return;
  30363. }
  30364. this._gl.uniform2f(uniform, x, y);
  30365. };
  30366. /**
  30367. * Set the value of an uniform to a vec3
  30368. * @param uniform defines the webGL uniform location where to store the value
  30369. * @param x defines the 1st component of the value
  30370. * @param y defines the 2nd component of the value
  30371. * @param z defines the 3rd component of the value
  30372. */
  30373. Engine.prototype.setFloat3 = function (uniform, x, y, z) {
  30374. if (!uniform) {
  30375. return;
  30376. }
  30377. this._gl.uniform3f(uniform, x, y, z);
  30378. };
  30379. /**
  30380. * Set the value of an uniform to a boolean
  30381. * @param uniform defines the webGL uniform location where to store the value
  30382. * @param bool defines the boolean to store
  30383. */
  30384. Engine.prototype.setBool = function (uniform, bool) {
  30385. if (!uniform) {
  30386. return;
  30387. }
  30388. this._gl.uniform1i(uniform, bool);
  30389. };
  30390. /**
  30391. * Set the value of an uniform to a vec4
  30392. * @param uniform defines the webGL uniform location where to store the value
  30393. * @param x defines the 1st component of the value
  30394. * @param y defines the 2nd component of the value
  30395. * @param z defines the 3rd component of the value
  30396. * @param w defines the 4th component of the value
  30397. */
  30398. Engine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  30399. if (!uniform) {
  30400. return;
  30401. }
  30402. this._gl.uniform4f(uniform, x, y, z, w);
  30403. };
  30404. /**
  30405. * Set the value of an uniform to a Color3
  30406. * @param uniform defines the webGL uniform location where to store the value
  30407. * @param color3 defines the color to store
  30408. */
  30409. Engine.prototype.setColor3 = function (uniform, color3) {
  30410. if (!uniform) {
  30411. return;
  30412. }
  30413. this._gl.uniform3f(uniform, color3.r, color3.g, color3.b);
  30414. };
  30415. /**
  30416. * Set the value of an uniform to a Color3 and an alpha value
  30417. * @param uniform defines the webGL uniform location where to store the value
  30418. * @param color3 defines the color to store
  30419. * @param alpha defines the alpha component to store
  30420. */
  30421. Engine.prototype.setColor4 = function (uniform, color3, alpha) {
  30422. if (!uniform) {
  30423. return;
  30424. }
  30425. this._gl.uniform4f(uniform, color3.r, color3.g, color3.b, alpha);
  30426. };
  30427. /**
  30428. * Sets a Color4 on a uniform variable
  30429. * @param uniform defines the uniform location
  30430. * @param color4 defines the value to be set
  30431. */
  30432. Engine.prototype.setDirectColor4 = function (uniform, color4) {
  30433. if (!uniform) {
  30434. return;
  30435. }
  30436. this._gl.uniform4f(uniform, color4.r, color4.g, color4.b, color4.a);
  30437. };
  30438. // States
  30439. /**
  30440. * Set various states to the webGL context
  30441. * @param culling defines backface culling state
  30442. * @param zOffset defines the value to apply to zOffset (0 by default)
  30443. * @param force defines if states must be applied even if cache is up to date
  30444. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  30445. */
  30446. Engine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  30447. if (zOffset === void 0) { zOffset = 0; }
  30448. if (reverseSide === void 0) { reverseSide = false; }
  30449. // Culling
  30450. if (this._depthCullingState.cull !== culling || force) {
  30451. this._depthCullingState.cull = culling;
  30452. }
  30453. // Cull face
  30454. var cullFace = this.cullBackFaces ? this._gl.BACK : this._gl.FRONT;
  30455. if (this._depthCullingState.cullFace !== cullFace || force) {
  30456. this._depthCullingState.cullFace = cullFace;
  30457. }
  30458. // Z offset
  30459. this.setZOffset(zOffset);
  30460. // Front face
  30461. var frontFace = reverseSide ? this._gl.CW : this._gl.CCW;
  30462. if (this._depthCullingState.frontFace !== frontFace || force) {
  30463. this._depthCullingState.frontFace = frontFace;
  30464. }
  30465. };
  30466. /**
  30467. * Set the z offset to apply to current rendering
  30468. * @param value defines the offset to apply
  30469. */
  30470. Engine.prototype.setZOffset = function (value) {
  30471. this._depthCullingState.zOffset = value;
  30472. };
  30473. /**
  30474. * Gets the current value of the zOffset
  30475. * @returns the current zOffset state
  30476. */
  30477. Engine.prototype.getZOffset = function () {
  30478. return this._depthCullingState.zOffset;
  30479. };
  30480. /**
  30481. * Enable or disable depth buffering
  30482. * @param enable defines the state to set
  30483. */
  30484. Engine.prototype.setDepthBuffer = function (enable) {
  30485. this._depthCullingState.depthTest = enable;
  30486. };
  30487. /**
  30488. * Gets a boolean indicating if depth writing is enabled
  30489. * @returns the current depth writing state
  30490. */
  30491. Engine.prototype.getDepthWrite = function () {
  30492. return this._depthCullingState.depthMask;
  30493. };
  30494. /**
  30495. * Enable or disable depth writing
  30496. * @param enable defines the state to set
  30497. */
  30498. Engine.prototype.setDepthWrite = function (enable) {
  30499. this._depthCullingState.depthMask = enable;
  30500. };
  30501. /**
  30502. * Enable or disable color writing
  30503. * @param enable defines the state to set
  30504. */
  30505. Engine.prototype.setColorWrite = function (enable) {
  30506. this._gl.colorMask(enable, enable, enable, enable);
  30507. this._colorWrite = enable;
  30508. };
  30509. /**
  30510. * Gets a boolean indicating if color writing is enabled
  30511. * @returns the current color writing state
  30512. */
  30513. Engine.prototype.getColorWrite = function () {
  30514. return this._colorWrite;
  30515. };
  30516. /**
  30517. * Sets alpha constants used by some alpha blending modes
  30518. * @param r defines the red component
  30519. * @param g defines the green component
  30520. * @param b defines the blue component
  30521. * @param a defines the alpha component
  30522. */
  30523. Engine.prototype.setAlphaConstants = function (r, g, b, a) {
  30524. this._alphaState.setAlphaBlendConstants(r, g, b, a);
  30525. };
  30526. /**
  30527. * Sets the current alpha mode
  30528. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  30529. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  30530. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30531. */
  30532. Engine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  30533. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  30534. if (this._alphaMode === mode) {
  30535. return;
  30536. }
  30537. switch (mode) {
  30538. case Engine.ALPHA_DISABLE:
  30539. this._alphaState.alphaBlend = false;
  30540. break;
  30541. case Engine.ALPHA_PREMULTIPLIED:
  30542. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  30543. this._alphaState.alphaBlend = true;
  30544. break;
  30545. case Engine.ALPHA_PREMULTIPLIED_PORTERDUFF:
  30546. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  30547. this._alphaState.alphaBlend = true;
  30548. break;
  30549. case Engine.ALPHA_COMBINE:
  30550. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  30551. this._alphaState.alphaBlend = true;
  30552. break;
  30553. case Engine.ALPHA_ONEONE:
  30554. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  30555. this._alphaState.alphaBlend = true;
  30556. break;
  30557. case Engine.ALPHA_ADD:
  30558. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  30559. this._alphaState.alphaBlend = true;
  30560. break;
  30561. case Engine.ALPHA_SUBTRACT:
  30562. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  30563. this._alphaState.alphaBlend = true;
  30564. break;
  30565. case Engine.ALPHA_MULTIPLY:
  30566. this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE);
  30567. this._alphaState.alphaBlend = true;
  30568. break;
  30569. case Engine.ALPHA_MAXIMIZED:
  30570. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  30571. this._alphaState.alphaBlend = true;
  30572. break;
  30573. case Engine.ALPHA_INTERPOLATE:
  30574. this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA);
  30575. this._alphaState.alphaBlend = true;
  30576. break;
  30577. case Engine.ALPHA_SCREENMODE:
  30578. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  30579. this._alphaState.alphaBlend = true;
  30580. break;
  30581. }
  30582. if (!noDepthWriteChange) {
  30583. this.setDepthWrite(mode === Engine.ALPHA_DISABLE);
  30584. }
  30585. this._alphaMode = mode;
  30586. };
  30587. /**
  30588. * Gets the current alpha mode
  30589. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30590. * @returns the current alpha mode
  30591. */
  30592. Engine.prototype.getAlphaMode = function () {
  30593. return this._alphaMode;
  30594. };
  30595. // Textures
  30596. /**
  30597. * Clears the list of texture accessible through engine.
  30598. * This can help preventing texture load conflict due to name collision.
  30599. */
  30600. Engine.prototype.clearInternalTexturesCache = function () {
  30601. this._internalTexturesCache = [];
  30602. };
  30603. /**
  30604. * Force the entire cache to be cleared
  30605. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30606. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30607. */
  30608. Engine.prototype.wipeCaches = function (bruteForce) {
  30609. if (this.preventCacheWipeBetweenFrames && !bruteForce) {
  30610. return;
  30611. }
  30612. this._currentEffect = null;
  30613. this._viewportCached.x = 0;
  30614. this._viewportCached.y = 0;
  30615. this._viewportCached.z = 0;
  30616. this._viewportCached.w = 0;
  30617. if (bruteForce) {
  30618. this.resetTextureCache();
  30619. this._currentProgram = null;
  30620. this._stencilState.reset();
  30621. this._depthCullingState.reset();
  30622. this.setDepthFunctionToLessOrEqual();
  30623. this._alphaState.reset();
  30624. this._unpackFlipYCached = null;
  30625. }
  30626. this._resetVertexBufferBinding();
  30627. this._cachedIndexBuffer = null;
  30628. this._cachedEffectForVertexBuffers = null;
  30629. this._unbindVertexArrayObject();
  30630. this.bindIndexBuffer(null);
  30631. };
  30632. /**
  30633. * Set the compressed texture format to use, based on the formats you have, and the formats
  30634. * supported by the hardware / browser.
  30635. *
  30636. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  30637. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  30638. * to API arguments needed to compressed textures. This puts the burden on the container
  30639. * generator to house the arcane code for determining these for current & future formats.
  30640. *
  30641. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  30642. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  30643. *
  30644. * Note: The result of this call is not taken into account when a texture is base64.
  30645. *
  30646. * @param formatsAvailable defines the list of those format families you have created
  30647. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  30648. *
  30649. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  30650. * @returns The extension selected.
  30651. */
  30652. Engine.prototype.setTextureFormatToUse = function (formatsAvailable) {
  30653. for (var i = 0, len1 = this.texturesSupported.length; i < len1; i++) {
  30654. for (var j = 0, len2 = formatsAvailable.length; j < len2; j++) {
  30655. if (this._texturesSupported[i] === formatsAvailable[j].toLowerCase()) {
  30656. return this._textureFormatInUse = this._texturesSupported[i];
  30657. }
  30658. }
  30659. }
  30660. // actively set format to nothing, to allow this to be called more than once
  30661. // and possibly fail the 2nd time
  30662. this._textureFormatInUse = null;
  30663. return null;
  30664. };
  30665. Engine.prototype._getSamplingParameters = function (samplingMode, generateMipMaps) {
  30666. var gl = this._gl;
  30667. var magFilter = gl.NEAREST;
  30668. var minFilter = gl.NEAREST;
  30669. switch (samplingMode) {
  30670. case Engine.TEXTURE_BILINEAR_SAMPLINGMODE:
  30671. magFilter = gl.LINEAR;
  30672. if (generateMipMaps) {
  30673. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  30674. }
  30675. else {
  30676. minFilter = gl.LINEAR;
  30677. }
  30678. break;
  30679. case Engine.TEXTURE_TRILINEAR_SAMPLINGMODE:
  30680. magFilter = gl.LINEAR;
  30681. if (generateMipMaps) {
  30682. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  30683. }
  30684. else {
  30685. minFilter = gl.LINEAR;
  30686. }
  30687. break;
  30688. case Engine.TEXTURE_NEAREST_SAMPLINGMODE:
  30689. magFilter = gl.NEAREST;
  30690. if (generateMipMaps) {
  30691. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  30692. }
  30693. else {
  30694. minFilter = gl.NEAREST;
  30695. }
  30696. break;
  30697. case Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
  30698. magFilter = gl.NEAREST;
  30699. if (generateMipMaps) {
  30700. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  30701. }
  30702. else {
  30703. minFilter = gl.NEAREST;
  30704. }
  30705. break;
  30706. case Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
  30707. magFilter = gl.NEAREST;
  30708. if (generateMipMaps) {
  30709. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  30710. }
  30711. else {
  30712. minFilter = gl.LINEAR;
  30713. }
  30714. break;
  30715. case Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
  30716. magFilter = gl.NEAREST;
  30717. if (generateMipMaps) {
  30718. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  30719. }
  30720. else {
  30721. minFilter = gl.LINEAR;
  30722. }
  30723. break;
  30724. case Engine.TEXTURE_NEAREST_LINEAR:
  30725. magFilter = gl.NEAREST;
  30726. minFilter = gl.LINEAR;
  30727. break;
  30728. case Engine.TEXTURE_NEAREST_NEAREST:
  30729. magFilter = gl.NEAREST;
  30730. minFilter = gl.NEAREST;
  30731. break;
  30732. case Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
  30733. magFilter = gl.LINEAR;
  30734. if (generateMipMaps) {
  30735. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  30736. }
  30737. else {
  30738. minFilter = gl.NEAREST;
  30739. }
  30740. break;
  30741. case Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
  30742. magFilter = gl.LINEAR;
  30743. if (generateMipMaps) {
  30744. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  30745. }
  30746. else {
  30747. minFilter = gl.NEAREST;
  30748. }
  30749. break;
  30750. case Engine.TEXTURE_LINEAR_LINEAR:
  30751. magFilter = gl.LINEAR;
  30752. minFilter = gl.LINEAR;
  30753. break;
  30754. case Engine.TEXTURE_LINEAR_NEAREST:
  30755. magFilter = gl.LINEAR;
  30756. minFilter = gl.NEAREST;
  30757. break;
  30758. }
  30759. return {
  30760. min: minFilter,
  30761. mag: magFilter
  30762. };
  30763. };
  30764. Engine.prototype._partialLoadImg = function (url, index, loadedImages, scene, onfinish, onErrorCallBack) {
  30765. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  30766. var img;
  30767. var onload = function () {
  30768. loadedImages[index] = img;
  30769. loadedImages._internalCount++;
  30770. if (scene) {
  30771. scene._removePendingData(img);
  30772. }
  30773. if (loadedImages._internalCount === 6) {
  30774. onfinish(loadedImages);
  30775. }
  30776. };
  30777. var onerror = function (message, exception) {
  30778. if (scene) {
  30779. scene._removePendingData(img);
  30780. }
  30781. if (onErrorCallBack) {
  30782. onErrorCallBack(message, exception);
  30783. }
  30784. };
  30785. img = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onerror, scene ? scene.offlineProvider : null);
  30786. if (scene) {
  30787. scene._addPendingData(img);
  30788. }
  30789. };
  30790. Engine.prototype._cascadeLoadImgs = function (scene, onfinish, files, onError) {
  30791. if (onError === void 0) { onError = null; }
  30792. var loadedImages = [];
  30793. loadedImages._internalCount = 0;
  30794. for (var index = 0; index < 6; index++) {
  30795. this._partialLoadImg(files[index], index, loadedImages, scene, onfinish, onError);
  30796. }
  30797. };
  30798. /** @hidden */
  30799. Engine.prototype._createTexture = function () {
  30800. var texture = this._gl.createTexture();
  30801. if (!texture) {
  30802. throw new Error("Unable to create texture");
  30803. }
  30804. return texture;
  30805. };
  30806. /**
  30807. * Usually called from Texture.ts.
  30808. * Passed information to create a WebGLTexture
  30809. * @param urlArg defines a value which contains one of the following:
  30810. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30811. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30812. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30813. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30814. * @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)
  30815. * @param scene needed for loading to the correct scene
  30816. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30817. * @param onLoad optional callback to be called upon successful completion
  30818. * @param onError optional callback to be called upon failure
  30819. * @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
  30820. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30821. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30822. * @param forcedExtension defines the extension to use to pick the right loader
  30823. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30824. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30825. */
  30826. Engine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, excludeLoaders) {
  30827. var _this = this;
  30828. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  30829. if (onLoad === void 0) { onLoad = null; }
  30830. if (onError === void 0) { onError = null; }
  30831. if (buffer === void 0) { buffer = null; }
  30832. if (fallback === void 0) { fallback = null; }
  30833. if (format === void 0) { format = null; }
  30834. if (forcedExtension === void 0) { forcedExtension = null; }
  30835. if (excludeLoaders === void 0) { excludeLoaders = []; }
  30836. var url = String(urlArg); // assign a new string, so that the original is still available in case of fallback
  30837. var fromData = url.substr(0, 5) === "data:";
  30838. var fromBlob = url.substr(0, 5) === "blob:";
  30839. var isBase64 = fromData && url.indexOf(";base64,") !== -1;
  30840. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_URL);
  30841. // establish the file extension, if possible
  30842. var lastDot = url.lastIndexOf('.');
  30843. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? url.substring(lastDot).toLowerCase() : "");
  30844. var loader = null;
  30845. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  30846. var availableLoader = _a[_i];
  30847. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, isBase64, buffer ? true : false)) {
  30848. loader = availableLoader;
  30849. break;
  30850. }
  30851. }
  30852. if (loader) {
  30853. url = loader.transformUrl(url, this._textureFormatInUse);
  30854. }
  30855. if (scene) {
  30856. scene._addPendingData(texture);
  30857. }
  30858. texture.url = url;
  30859. texture.generateMipMaps = !noMipmap;
  30860. texture.samplingMode = samplingMode;
  30861. texture.invertY = invertY;
  30862. if (!this._doNotHandleContextLost) {
  30863. // Keep a link to the buffer only if we plan to handle context lost
  30864. texture._buffer = buffer;
  30865. }
  30866. var onLoadObserver = null;
  30867. if (onLoad && !fallback) {
  30868. onLoadObserver = texture.onLoadedObservable.add(onLoad);
  30869. }
  30870. if (!fallback) {
  30871. this._internalTexturesCache.push(texture);
  30872. }
  30873. var onInternalError = function (message, exception) {
  30874. if (scene) {
  30875. scene._removePendingData(texture);
  30876. }
  30877. var customFallback = false;
  30878. if (loader) {
  30879. var fallbackUrl = loader.getFallbackTextureUrl(url, _this._textureFormatInUse);
  30880. if (fallbackUrl) {
  30881. // Add Back
  30882. customFallback = true;
  30883. excludeLoaders.push(loader);
  30884. _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");
  30885. _this.createTexture(urlArg, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture, undefined, undefined, excludeLoaders);
  30886. }
  30887. }
  30888. if (!customFallback) {
  30889. if (onLoadObserver) {
  30890. texture.onLoadedObservable.remove(onLoadObserver);
  30891. }
  30892. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].UseFallbackTexture) {
  30893. _this.createTexture(_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].fallbackTexture, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture);
  30894. }
  30895. }
  30896. if (onError) {
  30897. onError(message || "Unknown error", exception);
  30898. }
  30899. };
  30900. // processing for non-image formats
  30901. if (loader) {
  30902. var callback = function (data) {
  30903. loader.loadData(data, texture, function (width, height, loadMipmap, isCompressed, done, loadFailed) {
  30904. if (loadFailed) {
  30905. onInternalError("TextureLoader failed to load data");
  30906. }
  30907. else {
  30908. _this._prepareWebGLTexture(texture, scene, width, height, texture.invertY, !loadMipmap, isCompressed, function () {
  30909. done();
  30910. return false;
  30911. }, samplingMode);
  30912. }
  30913. });
  30914. };
  30915. if (!buffer) {
  30916. this._loadFile(url, callback, undefined, scene ? scene.offlineProvider : undefined, true, function (request, exception) {
  30917. onInternalError("Unable to load " + (request ? request.responseURL : url, exception));
  30918. });
  30919. }
  30920. else {
  30921. callback(buffer);
  30922. }
  30923. }
  30924. else {
  30925. var onload = function (img) {
  30926. if (fromBlob && !_this._doNotHandleContextLost) {
  30927. // We need to store the image if we need to rebuild the texture
  30928. // in case of a webgl context lost
  30929. texture._buffer = img;
  30930. }
  30931. _this._prepareWebGLTexture(texture, scene, img.width, img.height, texture.invertY, noMipmap, false, function (potWidth, potHeight, continuationCallback) {
  30932. var gl = _this._gl;
  30933. var isPot = (img.width === potWidth && img.height === potHeight);
  30934. var internalFormat = format ? _this._getInternalFormat(format) : ((extension === ".jpg") ? gl.RGB : gl.RGBA);
  30935. if (isPot) {
  30936. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  30937. return false;
  30938. }
  30939. var maxTextureSize = _this._caps.maxTextureSize;
  30940. if (img.width > maxTextureSize || img.height > maxTextureSize || Engine._RescalePostProcessFactory === null) {
  30941. _this._prepareWorkingCanvas();
  30942. if (!_this._workingCanvas || !_this._workingContext) {
  30943. return false;
  30944. }
  30945. _this._workingCanvas.width = potWidth;
  30946. _this._workingCanvas.height = potHeight;
  30947. _this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);
  30948. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  30949. texture.width = potWidth;
  30950. texture.height = potHeight;
  30951. return false;
  30952. }
  30953. else {
  30954. // Using shaders when possible to rescale because canvas.drawImage is lossy
  30955. var source_1 = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_TEMP);
  30956. _this._bindTextureDirectly(gl.TEXTURE_2D, source_1, true);
  30957. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  30958. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  30959. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  30960. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  30961. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  30962. _this._rescaleTexture(source_1, texture, scene, internalFormat, function () {
  30963. _this._releaseTexture(source_1);
  30964. _this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  30965. continuationCallback();
  30966. });
  30967. }
  30968. return true;
  30969. }, samplingMode);
  30970. };
  30971. if (!fromData || isBase64) {
  30972. if (buffer instanceof HTMLImageElement) {
  30973. onload(buffer);
  30974. }
  30975. else {
  30976. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onInternalError, scene ? scene.offlineProvider : null);
  30977. }
  30978. }
  30979. else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || buffer instanceof Blob) {
  30980. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(buffer, onload, onInternalError, scene ? scene.offlineProvider : null);
  30981. }
  30982. else {
  30983. onload(buffer);
  30984. }
  30985. }
  30986. return texture;
  30987. };
  30988. Engine.prototype._rescaleTexture = function (source, destination, scene, internalFormat, onComplete) {
  30989. var _this = this;
  30990. var rtt = this.createRenderTargetTexture({
  30991. width: destination.width,
  30992. height: destination.height,
  30993. }, {
  30994. generateMipMaps: false,
  30995. type: Engine.TEXTURETYPE_UNSIGNED_INT,
  30996. samplingMode: Engine.TEXTURE_BILINEAR_SAMPLINGMODE,
  30997. generateDepthBuffer: false,
  30998. generateStencilBuffer: false
  30999. });
  31000. if (!this._rescalePostProcess && Engine._RescalePostProcessFactory) {
  31001. this._rescalePostProcess = Engine._RescalePostProcessFactory(this);
  31002. }
  31003. this._rescalePostProcess.getEffect().executeWhenCompiled(function () {
  31004. _this._rescalePostProcess.onApply = function (effect) {
  31005. effect._bindTexture("textureSampler", source);
  31006. };
  31007. var hostingScene = scene;
  31008. if (!hostingScene) {
  31009. hostingScene = _this.scenes[_this.scenes.length - 1];
  31010. }
  31011. hostingScene.postProcessManager.directRender([_this._rescalePostProcess], rtt, true);
  31012. _this._bindTextureDirectly(_this._gl.TEXTURE_2D, destination, true);
  31013. _this._gl.copyTexImage2D(_this._gl.TEXTURE_2D, 0, internalFormat, 0, 0, destination.width, destination.height, 0);
  31014. _this.unBindFramebuffer(rtt);
  31015. _this._releaseTexture(rtt);
  31016. if (onComplete) {
  31017. onComplete();
  31018. }
  31019. });
  31020. };
  31021. /**
  31022. * Update a raw texture
  31023. * @param texture defines the texture to update
  31024. * @param data defines the data to store in the texture
  31025. * @param format defines the format of the data
  31026. * @param invertY defines if data must be stored with Y axis inverted
  31027. * @param compression defines the compression used (null by default)
  31028. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31029. */
  31030. Engine.prototype.updateRawTexture = function (texture, data, format, invertY, compression, type) {
  31031. if (compression === void 0) { compression = null; }
  31032. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31033. if (!texture) {
  31034. return;
  31035. }
  31036. // babylon's internalSizedFomat but gl's texImage2D internalFormat
  31037. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type, format);
  31038. // babylon's internalFormat but gl's texImage2D format
  31039. var internalFormat = this._getInternalFormat(format);
  31040. var textureType = this._getWebGLTextureType(type);
  31041. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31042. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  31043. if (!this._doNotHandleContextLost) {
  31044. texture._bufferView = data;
  31045. texture.format = format;
  31046. texture.type = type;
  31047. texture.invertY = invertY;
  31048. texture._compression = compression;
  31049. }
  31050. if (texture.width % 4 !== 0) {
  31051. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  31052. }
  31053. if (compression && data) {
  31054. this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, 0, data);
  31055. }
  31056. else {
  31057. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, data);
  31058. }
  31059. if (texture.generateMipMaps) {
  31060. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31061. }
  31062. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31063. // this.resetTextureCache();
  31064. texture.isReady = true;
  31065. };
  31066. /**
  31067. * Creates a raw texture
  31068. * @param data defines the data to store in the texture
  31069. * @param width defines the width of the texture
  31070. * @param height defines the height of the texture
  31071. * @param format defines the format of the data
  31072. * @param generateMipMaps defines if the engine should generate the mip levels
  31073. * @param invertY defines if data must be stored with Y axis inverted
  31074. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31075. * @param compression defines the compression used (null by default)
  31076. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31077. * @returns the raw texture inside an InternalTexture
  31078. */
  31079. Engine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression, type) {
  31080. if (compression === void 0) { compression = null; }
  31081. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31082. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW);
  31083. texture.baseWidth = width;
  31084. texture.baseHeight = height;
  31085. texture.width = width;
  31086. texture.height = height;
  31087. texture.format = format;
  31088. texture.generateMipMaps = generateMipMaps;
  31089. texture.samplingMode = samplingMode;
  31090. texture.invertY = invertY;
  31091. texture._compression = compression;
  31092. texture.type = type;
  31093. if (!this._doNotHandleContextLost) {
  31094. texture._bufferView = data;
  31095. }
  31096. this.updateRawTexture(texture, data, format, invertY, compression, type);
  31097. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31098. // Filters
  31099. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  31100. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  31101. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31102. if (generateMipMaps) {
  31103. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31104. }
  31105. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31106. this._internalTexturesCache.push(texture);
  31107. return texture;
  31108. };
  31109. /** @hidden */
  31110. Engine.prototype._unpackFlipY = function (value) {
  31111. if (this._unpackFlipYCached !== value) {
  31112. this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, value ? 1 : 0);
  31113. if (this.enableUnpackFlipYCached) {
  31114. this._unpackFlipYCached = value;
  31115. }
  31116. }
  31117. };
  31118. /** @hidden */
  31119. Engine.prototype._getUnpackAlignement = function () {
  31120. return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT);
  31121. };
  31122. /**
  31123. * Creates a dynamic texture
  31124. * @param width defines the width of the texture
  31125. * @param height defines the height of the texture
  31126. * @param generateMipMaps defines if the engine should generate the mip levels
  31127. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31128. * @returns the dynamic texture inside an InternalTexture
  31129. */
  31130. Engine.prototype.createDynamicTexture = function (width, height, generateMipMaps, samplingMode) {
  31131. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DYNAMIC);
  31132. texture.baseWidth = width;
  31133. texture.baseHeight = height;
  31134. if (generateMipMaps) {
  31135. width = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, this._caps.maxTextureSize) : width;
  31136. height = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, this._caps.maxTextureSize) : height;
  31137. }
  31138. // this.resetTextureCache();
  31139. texture.width = width;
  31140. texture.height = height;
  31141. texture.isReady = false;
  31142. texture.generateMipMaps = generateMipMaps;
  31143. texture.samplingMode = samplingMode;
  31144. this.updateTextureSamplingMode(samplingMode, texture);
  31145. this._internalTexturesCache.push(texture);
  31146. return texture;
  31147. };
  31148. /**
  31149. * Update the sampling mode of a given texture
  31150. * @param samplingMode defines the required sampling mode
  31151. * @param texture defines the texture to update
  31152. */
  31153. Engine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  31154. var filters = this._getSamplingParameters(samplingMode, texture.generateMipMaps);
  31155. if (texture.isCube) {
  31156. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31157. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31158. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31159. }
  31160. else if (texture.is3D) {
  31161. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31162. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31163. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  31164. }
  31165. else {
  31166. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31167. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31168. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31169. }
  31170. texture.samplingMode = samplingMode;
  31171. };
  31172. /**
  31173. * Update the content of a dynamic texture
  31174. * @param texture defines the texture to update
  31175. * @param canvas defines the canvas containing the source
  31176. * @param invertY defines if data must be stored with Y axis inverted
  31177. * @param premulAlpha defines if alpha is stored as premultiplied
  31178. * @param format defines the format of the data
  31179. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31180. */
  31181. Engine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format, forceBindTexture) {
  31182. if (premulAlpha === void 0) { premulAlpha = false; }
  31183. if (forceBindTexture === void 0) { forceBindTexture = false; }
  31184. if (!texture) {
  31185. return;
  31186. }
  31187. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true, forceBindTexture);
  31188. this._unpackFlipY(invertY);
  31189. if (premulAlpha) {
  31190. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
  31191. }
  31192. var internalFormat = format ? this._getInternalFormat(format) : this._gl.RGBA;
  31193. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, internalFormat, this._gl.UNSIGNED_BYTE, canvas);
  31194. if (texture.generateMipMaps) {
  31195. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31196. }
  31197. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31198. if (premulAlpha) {
  31199. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
  31200. }
  31201. texture.isReady = true;
  31202. };
  31203. /**
  31204. * Update a video texture
  31205. * @param texture defines the texture to update
  31206. * @param video defines the video element to use
  31207. * @param invertY defines if data must be stored with Y axis inverted
  31208. */
  31209. Engine.prototype.updateVideoTexture = function (texture, video, invertY) {
  31210. if (!texture || texture._isDisabled) {
  31211. return;
  31212. }
  31213. var wasPreviouslyBound = this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31214. this._unpackFlipY(!invertY); // Video are upside down by default
  31215. try {
  31216. // Testing video texture support
  31217. if (this._videoTextureSupported === undefined) {
  31218. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  31219. if (this._gl.getError() !== 0) {
  31220. this._videoTextureSupported = false;
  31221. }
  31222. else {
  31223. this._videoTextureSupported = true;
  31224. }
  31225. }
  31226. // Copy video through the current working canvas if video texture is not supported
  31227. if (!this._videoTextureSupported) {
  31228. if (!texture._workingCanvas) {
  31229. texture._workingCanvas = document.createElement("canvas");
  31230. var context = texture._workingCanvas.getContext("2d");
  31231. if (!context) {
  31232. throw new Error("Unable to get 2d context");
  31233. }
  31234. texture._workingContext = context;
  31235. texture._workingCanvas.width = texture.width;
  31236. texture._workingCanvas.height = texture.height;
  31237. }
  31238. texture._workingContext.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, texture.width, texture.height);
  31239. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, texture._workingCanvas);
  31240. }
  31241. else {
  31242. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  31243. }
  31244. if (texture.generateMipMaps) {
  31245. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31246. }
  31247. if (!wasPreviouslyBound) {
  31248. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31249. }
  31250. // this.resetTextureCache();
  31251. texture.isReady = true;
  31252. }
  31253. catch (ex) {
  31254. // Something unexpected
  31255. // Let's disable the texture
  31256. texture._isDisabled = true;
  31257. }
  31258. };
  31259. /**
  31260. * Updates a depth texture Comparison Mode and Function.
  31261. * If the comparison Function is equal to 0, the mode will be set to none.
  31262. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31263. * @param texture The texture to set the comparison function for
  31264. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31265. */
  31266. Engine.prototype.updateTextureComparisonFunction = function (texture, comparisonFunction) {
  31267. if (this.webGLVersion === 1) {
  31268. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("WebGL 1 does not support texture comparison.");
  31269. return;
  31270. }
  31271. var gl = this._gl;
  31272. if (texture.isCube) {
  31273. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  31274. if (comparisonFunction === 0) {
  31275. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31276. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31277. }
  31278. else {
  31279. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31280. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31281. }
  31282. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31283. }
  31284. else {
  31285. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31286. if (comparisonFunction === 0) {
  31287. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31288. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31289. }
  31290. else {
  31291. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31292. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31293. }
  31294. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31295. }
  31296. texture._comparisonFunction = comparisonFunction;
  31297. };
  31298. Engine.prototype._setupDepthStencilTexture = function (internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction) {
  31299. var width = size.width || size;
  31300. var height = size.height || size;
  31301. internalTexture.baseWidth = width;
  31302. internalTexture.baseHeight = height;
  31303. internalTexture.width = width;
  31304. internalTexture.height = height;
  31305. internalTexture.isReady = true;
  31306. internalTexture.samples = 1;
  31307. internalTexture.generateMipMaps = false;
  31308. internalTexture._generateDepthBuffer = true;
  31309. internalTexture._generateStencilBuffer = generateStencil;
  31310. internalTexture.samplingMode = bilinearFiltering ? Engine.TEXTURE_BILINEAR_SAMPLINGMODE : Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31311. internalTexture.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31312. internalTexture._comparisonFunction = comparisonFunction;
  31313. var gl = this._gl;
  31314. var target = internalTexture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31315. var samplingParameters = this._getSamplingParameters(internalTexture.samplingMode, false);
  31316. gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, samplingParameters.mag);
  31317. gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, samplingParameters.min);
  31318. gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31319. gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31320. if (comparisonFunction === 0) {
  31321. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31322. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31323. }
  31324. else {
  31325. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31326. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31327. }
  31328. };
  31329. /**
  31330. * Creates a depth stencil texture.
  31331. * This is only available in WebGL 2 or with the depth texture extension available.
  31332. * @param size The size of face edge in the texture.
  31333. * @param options The options defining the texture.
  31334. * @returns The texture
  31335. */
  31336. Engine.prototype.createDepthStencilTexture = function (size, options) {
  31337. if (options.isCube) {
  31338. var width = size.width || size;
  31339. return this._createDepthStencilCubeTexture(width, options);
  31340. }
  31341. else {
  31342. return this._createDepthStencilTexture(size, options);
  31343. }
  31344. };
  31345. /**
  31346. * Creates a depth stencil texture.
  31347. * This is only available in WebGL 2 or with the depth texture extension available.
  31348. * @param size The size of face edge in the texture.
  31349. * @param options The options defining the texture.
  31350. * @returns The texture
  31351. */
  31352. Engine.prototype._createDepthStencilTexture = function (size, options) {
  31353. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DEPTHTEXTURE);
  31354. if (!this._caps.depthTextureExtension) {
  31355. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth texture is not supported by your browser or hardware.");
  31356. return internalTexture;
  31357. }
  31358. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  31359. var gl = this._gl;
  31360. this._bindTextureDirectly(gl.TEXTURE_2D, internalTexture, true);
  31361. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  31362. if (this.webGLVersion > 1) {
  31363. if (internalOptions.generateStencil) {
  31364. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH24_STENCIL8, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  31365. }
  31366. else {
  31367. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT24, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31368. }
  31369. }
  31370. else {
  31371. if (internalOptions.generateStencil) {
  31372. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_STENCIL, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  31373. }
  31374. else {
  31375. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31376. }
  31377. }
  31378. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31379. return internalTexture;
  31380. };
  31381. /**
  31382. * Creates a depth stencil cube texture.
  31383. * This is only available in WebGL 2.
  31384. * @param size The size of face edge in the cube texture.
  31385. * @param options The options defining the cube texture.
  31386. * @returns The cube texture
  31387. */
  31388. Engine.prototype._createDepthStencilCubeTexture = function (size, options) {
  31389. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_UNKNOWN);
  31390. internalTexture.isCube = true;
  31391. if (this.webGLVersion === 1) {
  31392. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth cube texture is not supported by WebGL 1.");
  31393. return internalTexture;
  31394. }
  31395. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  31396. var gl = this._gl;
  31397. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, internalTexture, true);
  31398. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  31399. // Create the depth/stencil buffer
  31400. for (var face = 0; face < 6; face++) {
  31401. if (internalOptions.generateStencil) {
  31402. 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);
  31403. }
  31404. else {
  31405. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH_COMPONENT24, size, size, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31406. }
  31407. }
  31408. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31409. return internalTexture;
  31410. };
  31411. /**
  31412. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31413. * @param renderTarget The render target to set the frame buffer for
  31414. */
  31415. Engine.prototype.setFrameBufferDepthStencilTexture = function (renderTarget) {
  31416. // Create the framebuffer
  31417. var internalTexture = renderTarget.getInternalTexture();
  31418. if (!internalTexture || !internalTexture._framebuffer || !renderTarget.depthStencilTexture) {
  31419. return;
  31420. }
  31421. var gl = this._gl;
  31422. var depthStencilTexture = renderTarget.depthStencilTexture;
  31423. this.bindUnboundFramebuffer(internalTexture._framebuffer);
  31424. if (depthStencilTexture.isCube) {
  31425. if (depthStencilTexture._generateStencilBuffer) {
  31426. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  31427. }
  31428. else {
  31429. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  31430. }
  31431. }
  31432. else {
  31433. if (depthStencilTexture._generateStencilBuffer) {
  31434. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  31435. }
  31436. else {
  31437. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  31438. }
  31439. }
  31440. this.bindUnboundFramebuffer(null);
  31441. };
  31442. /**
  31443. * Creates a new render target texture
  31444. * @param size defines the size of the texture
  31445. * @param options defines the options used to create the texture
  31446. * @returns a new render target texture stored in an InternalTexture
  31447. */
  31448. Engine.prototype.createRenderTargetTexture = function (size, options) {
  31449. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__["RenderTargetCreationOptions"]();
  31450. if (options !== undefined && typeof options === "object") {
  31451. fullOptions.generateMipMaps = options.generateMipMaps;
  31452. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  31453. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  31454. fullOptions.type = options.type === undefined ? Engine.TEXTURETYPE_UNSIGNED_INT : options.type;
  31455. fullOptions.samplingMode = options.samplingMode === undefined ? Engine.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  31456. fullOptions.format = options.format === undefined ? Engine.TEXTUREFORMAT_RGBA : options.format;
  31457. }
  31458. else {
  31459. fullOptions.generateMipMaps = options;
  31460. fullOptions.generateDepthBuffer = true;
  31461. fullOptions.generateStencilBuffer = false;
  31462. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31463. fullOptions.samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  31464. fullOptions.format = Engine.TEXTUREFORMAT_RGBA;
  31465. }
  31466. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  31467. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  31468. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31469. }
  31470. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  31471. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  31472. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31473. }
  31474. var gl = this._gl;
  31475. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  31476. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  31477. var width = size.width || size;
  31478. var height = size.height || size;
  31479. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps ? true : false);
  31480. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  31481. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31482. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  31483. }
  31484. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  31485. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  31486. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31487. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31488. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(fullOptions.type, fullOptions.format), width, height, 0, this._getInternalFormat(fullOptions.format), this._getWebGLTextureType(fullOptions.type), null);
  31489. // Create the framebuffer
  31490. var currentFrameBuffer = this._currentFramebuffer;
  31491. var framebuffer = gl.createFramebuffer();
  31492. this.bindUnboundFramebuffer(framebuffer);
  31493. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
  31494. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer ? true : false, fullOptions.generateDepthBuffer, width, height);
  31495. if (fullOptions.generateMipMaps) {
  31496. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31497. }
  31498. // Unbind
  31499. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31500. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31501. this.bindUnboundFramebuffer(currentFrameBuffer);
  31502. texture._framebuffer = framebuffer;
  31503. texture.baseWidth = width;
  31504. texture.baseHeight = height;
  31505. texture.width = width;
  31506. texture.height = height;
  31507. texture.isReady = true;
  31508. texture.samples = 1;
  31509. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  31510. texture.samplingMode = fullOptions.samplingMode;
  31511. texture.type = fullOptions.type;
  31512. texture.format = fullOptions.format;
  31513. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  31514. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  31515. // this.resetTextureCache();
  31516. this._internalTexturesCache.push(texture);
  31517. return texture;
  31518. };
  31519. /**
  31520. * Create a multi render target texture
  31521. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  31522. * @param size defines the size of the texture
  31523. * @param options defines the creation options
  31524. * @returns the cube texture as an InternalTexture
  31525. */
  31526. Engine.prototype.createMultipleRenderTarget = function (size, options) {
  31527. var generateMipMaps = false;
  31528. var generateDepthBuffer = true;
  31529. var generateStencilBuffer = false;
  31530. var generateDepthTexture = false;
  31531. var textureCount = 1;
  31532. var defaultType = Engine.TEXTURETYPE_UNSIGNED_INT;
  31533. var defaultSamplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  31534. var types = new Array();
  31535. var samplingModes = new Array();
  31536. if (options !== undefined) {
  31537. generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;
  31538. generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  31539. generateStencilBuffer = options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  31540. generateDepthTexture = options.generateDepthTexture === undefined ? false : options.generateDepthTexture;
  31541. textureCount = options.textureCount || 1;
  31542. if (options.types) {
  31543. types = options.types;
  31544. }
  31545. if (options.samplingModes) {
  31546. samplingModes = options.samplingModes;
  31547. }
  31548. }
  31549. var gl = this._gl;
  31550. // Create the framebuffer
  31551. var framebuffer = gl.createFramebuffer();
  31552. this.bindUnboundFramebuffer(framebuffer);
  31553. var width = size.width || size;
  31554. var height = size.height || size;
  31555. var textures = [];
  31556. var attachments = [];
  31557. var depthStencilBuffer = this._setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height);
  31558. for (var i = 0; i < textureCount; i++) {
  31559. var samplingMode = samplingModes[i] || defaultSamplingMode;
  31560. var type = types[i] || defaultType;
  31561. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  31562. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  31563. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31564. }
  31565. else if (type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  31566. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  31567. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31568. }
  31569. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  31570. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  31571. type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31572. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  31573. }
  31574. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  31575. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  31576. textures.push(texture);
  31577. attachments.push(attachment);
  31578. gl.activeTexture(gl["TEXTURE" + i]);
  31579. gl.bindTexture(gl.TEXTURE_2D, texture._webGLTexture);
  31580. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  31581. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  31582. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31583. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31584. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), width, height, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  31585. gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, attachment, gl.TEXTURE_2D, texture._webGLTexture, 0);
  31586. if (generateMipMaps) {
  31587. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31588. }
  31589. // Unbind
  31590. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31591. texture._framebuffer = framebuffer;
  31592. texture._depthStencilBuffer = depthStencilBuffer;
  31593. texture.baseWidth = width;
  31594. texture.baseHeight = height;
  31595. texture.width = width;
  31596. texture.height = height;
  31597. texture.isReady = true;
  31598. texture.samples = 1;
  31599. texture.generateMipMaps = generateMipMaps;
  31600. texture.samplingMode = samplingMode;
  31601. texture.type = type;
  31602. texture._generateDepthBuffer = generateDepthBuffer;
  31603. texture._generateStencilBuffer = generateStencilBuffer;
  31604. texture._attachments = attachments;
  31605. this._internalTexturesCache.push(texture);
  31606. }
  31607. if (generateDepthTexture && this._caps.depthTextureExtension) {
  31608. // Depth texture
  31609. var depthTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  31610. gl.activeTexture(gl.TEXTURE0);
  31611. gl.bindTexture(gl.TEXTURE_2D, depthTexture._webGLTexture);
  31612. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  31613. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  31614. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31615. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31616. 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);
  31617. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthTexture._webGLTexture, 0);
  31618. depthTexture._framebuffer = framebuffer;
  31619. depthTexture.baseWidth = width;
  31620. depthTexture.baseHeight = height;
  31621. depthTexture.width = width;
  31622. depthTexture.height = height;
  31623. depthTexture.isReady = true;
  31624. depthTexture.samples = 1;
  31625. depthTexture.generateMipMaps = generateMipMaps;
  31626. depthTexture.samplingMode = gl.NEAREST;
  31627. depthTexture._generateDepthBuffer = generateDepthBuffer;
  31628. depthTexture._generateStencilBuffer = generateStencilBuffer;
  31629. textures.push(depthTexture);
  31630. this._internalTexturesCache.push(depthTexture);
  31631. }
  31632. gl.drawBuffers(attachments);
  31633. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31634. this.bindUnboundFramebuffer(null);
  31635. this.resetTextureCache();
  31636. return textures;
  31637. };
  31638. Engine.prototype._setupFramebufferDepthAttachments = function (generateStencilBuffer, generateDepthBuffer, width, height, samples) {
  31639. if (samples === void 0) { samples = 1; }
  31640. var depthStencilBuffer = null;
  31641. var gl = this._gl;
  31642. // Create the depth/stencil buffer
  31643. if (generateStencilBuffer) {
  31644. depthStencilBuffer = gl.createRenderbuffer();
  31645. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  31646. if (samples > 1) {
  31647. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH24_STENCIL8, width, height);
  31648. }
  31649. else {
  31650. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
  31651. }
  31652. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  31653. }
  31654. else if (generateDepthBuffer) {
  31655. depthStencilBuffer = gl.createRenderbuffer();
  31656. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  31657. if (samples > 1) {
  31658. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH_COMPONENT16, width, height);
  31659. }
  31660. else {
  31661. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
  31662. }
  31663. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  31664. }
  31665. return depthStencilBuffer;
  31666. };
  31667. /**
  31668. * Updates the sample count of a render target texture
  31669. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31670. * @param texture defines the texture to update
  31671. * @param samples defines the sample count to set
  31672. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31673. */
  31674. Engine.prototype.updateRenderTargetTextureSampleCount = function (texture, samples) {
  31675. if (this.webGLVersion < 2 || !texture) {
  31676. return 1;
  31677. }
  31678. if (texture.samples === samples) {
  31679. return samples;
  31680. }
  31681. var gl = this._gl;
  31682. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  31683. // Dispose previous render buffers
  31684. if (texture._depthStencilBuffer) {
  31685. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  31686. texture._depthStencilBuffer = null;
  31687. }
  31688. if (texture._MSAAFramebuffer) {
  31689. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  31690. texture._MSAAFramebuffer = null;
  31691. }
  31692. if (texture._MSAARenderBuffer) {
  31693. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  31694. texture._MSAARenderBuffer = null;
  31695. }
  31696. if (samples > 1) {
  31697. var framebuffer = gl.createFramebuffer();
  31698. if (!framebuffer) {
  31699. throw new Error("Unable to create multi sampled framebuffer");
  31700. }
  31701. texture._MSAAFramebuffer = framebuffer;
  31702. this.bindUnboundFramebuffer(texture._MSAAFramebuffer);
  31703. var colorRenderbuffer = gl.createRenderbuffer();
  31704. if (!colorRenderbuffer) {
  31705. throw new Error("Unable to create multi sampled framebuffer");
  31706. }
  31707. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  31708. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  31709. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorRenderbuffer);
  31710. texture._MSAARenderBuffer = colorRenderbuffer;
  31711. }
  31712. else {
  31713. this.bindUnboundFramebuffer(texture._framebuffer);
  31714. }
  31715. texture.samples = samples;
  31716. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(texture._generateStencilBuffer, texture._generateDepthBuffer, texture.width, texture.height, samples);
  31717. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31718. this.bindUnboundFramebuffer(null);
  31719. return samples;
  31720. };
  31721. /**
  31722. * Update the sample count for a given multiple render target texture
  31723. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31724. * @param textures defines the textures to update
  31725. * @param samples defines the sample count to set
  31726. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31727. */
  31728. Engine.prototype.updateMultipleRenderTargetTextureSampleCount = function (textures, samples) {
  31729. if (this.webGLVersion < 2 || !textures || textures.length == 0) {
  31730. return 1;
  31731. }
  31732. if (textures[0].samples === samples) {
  31733. return samples;
  31734. }
  31735. var gl = this._gl;
  31736. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  31737. // Dispose previous render buffers
  31738. if (textures[0]._depthStencilBuffer) {
  31739. gl.deleteRenderbuffer(textures[0]._depthStencilBuffer);
  31740. textures[0]._depthStencilBuffer = null;
  31741. }
  31742. if (textures[0]._MSAAFramebuffer) {
  31743. gl.deleteFramebuffer(textures[0]._MSAAFramebuffer);
  31744. textures[0]._MSAAFramebuffer = null;
  31745. }
  31746. for (var i = 0; i < textures.length; i++) {
  31747. if (textures[i]._MSAARenderBuffer) {
  31748. gl.deleteRenderbuffer(textures[i]._MSAARenderBuffer);
  31749. textures[i]._MSAARenderBuffer = null;
  31750. }
  31751. }
  31752. if (samples > 1) {
  31753. var framebuffer = gl.createFramebuffer();
  31754. if (!framebuffer) {
  31755. throw new Error("Unable to create multi sampled framebuffer");
  31756. }
  31757. this.bindUnboundFramebuffer(framebuffer);
  31758. var depthStencilBuffer = this._setupFramebufferDepthAttachments(textures[0]._generateStencilBuffer, textures[0]._generateDepthBuffer, textures[0].width, textures[0].height, samples);
  31759. var attachments = [];
  31760. for (var i = 0; i < textures.length; i++) {
  31761. var texture = textures[i];
  31762. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  31763. var colorRenderbuffer = gl.createRenderbuffer();
  31764. if (!colorRenderbuffer) {
  31765. throw new Error("Unable to create multi sampled framebuffer");
  31766. }
  31767. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  31768. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  31769. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, colorRenderbuffer);
  31770. texture._MSAAFramebuffer = framebuffer;
  31771. texture._MSAARenderBuffer = colorRenderbuffer;
  31772. texture.samples = samples;
  31773. texture._depthStencilBuffer = depthStencilBuffer;
  31774. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31775. attachments.push(attachment);
  31776. }
  31777. gl.drawBuffers(attachments);
  31778. }
  31779. else {
  31780. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  31781. }
  31782. this.bindUnboundFramebuffer(null);
  31783. return samples;
  31784. };
  31785. /** @hidden */
  31786. Engine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  31787. if (faceIndex === void 0) { faceIndex = 0; }
  31788. if (lod === void 0) { lod = 0; }
  31789. var gl = this._gl;
  31790. var target = gl.TEXTURE_2D;
  31791. if (texture.isCube) {
  31792. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  31793. }
  31794. this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);
  31795. };
  31796. /** @hidden */
  31797. Engine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  31798. if (faceIndex === void 0) { faceIndex = 0; }
  31799. if (lod === void 0) { lod = 0; }
  31800. var gl = this._gl;
  31801. var textureType = this._getWebGLTextureType(texture.type);
  31802. var format = this._getInternalFormat(texture.format);
  31803. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  31804. this._unpackFlipY(texture.invertY);
  31805. var target = gl.TEXTURE_2D;
  31806. if (texture.isCube) {
  31807. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  31808. }
  31809. var lodMaxWidth = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.width));
  31810. var lodMaxHeight = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.height));
  31811. var width = Math.pow(2, Math.max(lodMaxWidth - lod, 0));
  31812. var height = Math.pow(2, Math.max(lodMaxHeight - lod, 0));
  31813. gl.texImage2D(target, lod, internalFormat, width, height, 0, format, textureType, imageData);
  31814. };
  31815. /** @hidden */
  31816. Engine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  31817. if (faceIndex === void 0) { faceIndex = 0; }
  31818. if (lod === void 0) { lod = 0; }
  31819. var gl = this._gl;
  31820. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31821. this._bindTextureDirectly(bindTarget, texture, true);
  31822. this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);
  31823. this._bindTextureDirectly(bindTarget, null, true);
  31824. };
  31825. /** @hidden */
  31826. Engine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  31827. if (faceIndex === void 0) { faceIndex = 0; }
  31828. if (lod === void 0) { lod = 0; }
  31829. var gl = this._gl;
  31830. var textureType = this._getWebGLTextureType(texture.type);
  31831. var format = this._getInternalFormat(texture.format);
  31832. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  31833. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31834. this._bindTextureDirectly(bindTarget, texture, true);
  31835. this._unpackFlipY(texture.invertY);
  31836. var target = gl.TEXTURE_2D;
  31837. if (texture.isCube) {
  31838. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  31839. }
  31840. gl.texImage2D(target, lod, internalFormat, format, textureType, image);
  31841. this._bindTextureDirectly(bindTarget, null, true);
  31842. };
  31843. /**
  31844. * Creates a new render target cube texture
  31845. * @param size defines the size of the texture
  31846. * @param options defines the options used to create the texture
  31847. * @returns a new render target cube texture stored in an InternalTexture
  31848. */
  31849. Engine.prototype.createRenderTargetCubeTexture = function (size, options) {
  31850. 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);
  31851. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && fullOptions.generateStencilBuffer;
  31852. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  31853. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  31854. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31855. }
  31856. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  31857. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  31858. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31859. }
  31860. var gl = this._gl;
  31861. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  31862. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31863. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps);
  31864. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  31865. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31866. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type");
  31867. }
  31868. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  31869. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  31870. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31871. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31872. for (var face = 0; face < 6; face++) {
  31873. 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);
  31874. }
  31875. // Create the framebuffer
  31876. var framebuffer = gl.createFramebuffer();
  31877. this.bindUnboundFramebuffer(framebuffer);
  31878. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer, fullOptions.generateDepthBuffer, size, size);
  31879. // MipMaps
  31880. if (fullOptions.generateMipMaps) {
  31881. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  31882. }
  31883. // Unbind
  31884. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31885. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31886. this.bindUnboundFramebuffer(null);
  31887. texture._framebuffer = framebuffer;
  31888. texture.width = size;
  31889. texture.height = size;
  31890. texture.isReady = true;
  31891. texture.isCube = true;
  31892. texture.samples = 1;
  31893. texture.generateMipMaps = fullOptions.generateMipMaps;
  31894. texture.samplingMode = fullOptions.samplingMode;
  31895. texture.type = fullOptions.type;
  31896. texture.format = fullOptions.format;
  31897. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  31898. texture._generateStencilBuffer = fullOptions.generateStencilBuffer;
  31899. this._internalTexturesCache.push(texture);
  31900. return texture;
  31901. };
  31902. /**
  31903. * Creates a cube texture
  31904. * @param rootUrl defines the url where the files to load is located
  31905. * @param scene defines the current scene
  31906. * @param files defines the list of files to load (1 per face)
  31907. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  31908. * @param onLoad defines an optional callback raised when the texture is loaded
  31909. * @param onError defines an optional callback raised if there is an issue to load the texture
  31910. * @param format defines the format of the data
  31911. * @param forcedExtension defines the extension to use to pick the right loader
  31912. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  31913. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  31914. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  31915. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  31916. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  31917. * @returns the cube texture as an InternalTexture
  31918. */
  31919. Engine.prototype.createCubeTexture = function (rootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback, excludeLoaders) {
  31920. var _this = this;
  31921. if (onLoad === void 0) { onLoad = null; }
  31922. if (onError === void 0) { onError = null; }
  31923. if (forcedExtension === void 0) { forcedExtension = null; }
  31924. if (createPolynomials === void 0) { createPolynomials = false; }
  31925. if (lodScale === void 0) { lodScale = 0; }
  31926. if (lodOffset === void 0) { lodOffset = 0; }
  31927. if (fallback === void 0) { fallback = null; }
  31928. if (excludeLoaders === void 0) { excludeLoaders = []; }
  31929. var gl = this._gl;
  31930. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBE);
  31931. texture.isCube = true;
  31932. texture.url = rootUrl;
  31933. texture.generateMipMaps = !noMipmap;
  31934. texture._lodGenerationScale = lodScale;
  31935. texture._lodGenerationOffset = lodOffset;
  31936. if (!this._doNotHandleContextLost) {
  31937. texture._extension = forcedExtension;
  31938. texture._files = files;
  31939. }
  31940. var lastDot = rootUrl.lastIndexOf('.');
  31941. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  31942. var loader = null;
  31943. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  31944. var availableLoader = _a[_i];
  31945. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, false, false)) {
  31946. loader = availableLoader;
  31947. break;
  31948. }
  31949. }
  31950. var onInternalError = function (request, exception) {
  31951. if (loader) {
  31952. var fallbackUrl = loader.getFallbackTextureUrl(texture.url, _this._textureFormatInUse);
  31953. _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");
  31954. if (fallbackUrl) {
  31955. excludeLoaders.push(loader);
  31956. _this.createCubeTexture(fallbackUrl, scene, files, noMipmap, onLoad, onError, format, extension, createPolynomials, lodScale, lodOffset, texture, excludeLoaders);
  31957. return;
  31958. }
  31959. }
  31960. if (onError && request) {
  31961. onError(request.status + " " + request.statusText, exception);
  31962. }
  31963. };
  31964. if (loader) {
  31965. rootUrl = loader.transformUrl(rootUrl, this._textureFormatInUse);
  31966. var onloaddata = function (data) {
  31967. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31968. loader.loadCubeData(data, texture, createPolynomials, onLoad, onError);
  31969. };
  31970. if (files && files.length === 6) {
  31971. if (loader.supportCascades) {
  31972. this._cascadeLoadFiles(scene, onloaddata, files, onError);
  31973. }
  31974. else if (onError) {
  31975. onError("Textures type does not support cascades.");
  31976. }
  31977. }
  31978. else {
  31979. this._loadFile(rootUrl, onloaddata, undefined, undefined, true, onInternalError);
  31980. }
  31981. }
  31982. else {
  31983. if (!files) {
  31984. throw new Error("Cannot load cubemap because files were not defined");
  31985. }
  31986. this._cascadeLoadImgs(scene, function (imgs) {
  31987. var width = _this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(imgs[0].width, _this._caps.maxCubemapTextureSize) : imgs[0].width;
  31988. var height = width;
  31989. _this._prepareWorkingCanvas();
  31990. if (!_this._workingCanvas || !_this._workingContext) {
  31991. return;
  31992. }
  31993. _this._workingCanvas.width = width;
  31994. _this._workingCanvas.height = height;
  31995. var faces = [
  31996. gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
  31997. gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
  31998. ];
  31999. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32000. _this._unpackFlipY(false);
  32001. var internalFormat = format ? _this._getInternalFormat(format) : _this._gl.RGBA;
  32002. for (var index = 0; index < faces.length; index++) {
  32003. _this._workingContext.drawImage(imgs[index], 0, 0, imgs[index].width, imgs[index].height, 0, 0, width, height);
  32004. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  32005. }
  32006. if (!noMipmap) {
  32007. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  32008. }
  32009. _this._setCubeMapTextureParams(!noMipmap);
  32010. texture.width = width;
  32011. texture.height = height;
  32012. texture.isReady = true;
  32013. if (format) {
  32014. texture.format = format;
  32015. }
  32016. texture.onLoadedObservable.notifyObservers(texture);
  32017. texture.onLoadedObservable.clear();
  32018. if (onLoad) {
  32019. onLoad();
  32020. }
  32021. }, files, onError);
  32022. }
  32023. this._internalTexturesCache.push(texture);
  32024. return texture;
  32025. };
  32026. /**
  32027. * @hidden
  32028. */
  32029. Engine.prototype._setCubeMapTextureParams = function (loadMipmap) {
  32030. var gl = this._gl;
  32031. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  32032. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, loadMipmap ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
  32033. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32034. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32035. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32036. // this.resetTextureCache();
  32037. };
  32038. /**
  32039. * Update a raw cube texture
  32040. * @param texture defines the texture to udpdate
  32041. * @param data defines the data to store
  32042. * @param format defines the data format
  32043. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32044. * @param invertY defines if data must be stored with Y axis inverted
  32045. * @param compression defines the compression used (null by default)
  32046. * @param level defines which level of the texture to update
  32047. */
  32048. Engine.prototype.updateRawCubeTexture = function (texture, data, format, type, invertY, compression, level) {
  32049. if (compression === void 0) { compression = null; }
  32050. if (level === void 0) { level = 0; }
  32051. texture._bufferViewArray = data;
  32052. texture.format = format;
  32053. texture.type = type;
  32054. texture.invertY = invertY;
  32055. texture._compression = compression;
  32056. var gl = this._gl;
  32057. var textureType = this._getWebGLTextureType(type);
  32058. var internalFormat = this._getInternalFormat(format);
  32059. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);
  32060. var needConversion = false;
  32061. if (internalFormat === gl.RGB) {
  32062. internalFormat = gl.RGBA;
  32063. needConversion = true;
  32064. }
  32065. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32066. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32067. if (texture.width % 4 !== 0) {
  32068. gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
  32069. }
  32070. // Data are known to be in +X +Y +Z -X -Y -Z
  32071. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  32072. var faceData = data[faceIndex];
  32073. if (compression) {
  32074. gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, (this.getCaps().s3tc)[compression], texture.width, texture.height, 0, faceData);
  32075. }
  32076. else {
  32077. if (needConversion) {
  32078. faceData = this._convertRGBtoRGBATextureData(faceData, texture.width, texture.height, type);
  32079. }
  32080. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, faceData);
  32081. }
  32082. }
  32083. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  32084. if (isPot && texture.generateMipMaps && level === 0) {
  32085. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  32086. }
  32087. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32088. // this.resetTextureCache();
  32089. texture.isReady = true;
  32090. };
  32091. /**
  32092. * Creates a new raw cube texture
  32093. * @param data defines the array of data to use to create each face
  32094. * @param size defines the size of the textures
  32095. * @param format defines the format of the data
  32096. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32097. * @param generateMipMaps defines if the engine should generate the mip levels
  32098. * @param invertY defines if data must be stored with Y axis inverted
  32099. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32100. * @param compression defines the compression used (null by default)
  32101. * @returns the cube texture as an InternalTexture
  32102. */
  32103. Engine.prototype.createRawCubeTexture = function (data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  32104. if (compression === void 0) { compression = null; }
  32105. var gl = this._gl;
  32106. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBERAW);
  32107. texture.isCube = true;
  32108. texture.format = format;
  32109. texture.type = type;
  32110. if (!this._doNotHandleContextLost) {
  32111. texture._bufferViewArray = data;
  32112. }
  32113. var textureType = this._getWebGLTextureType(type);
  32114. var internalFormat = this._getInternalFormat(format);
  32115. if (internalFormat === gl.RGB) {
  32116. internalFormat = gl.RGBA;
  32117. }
  32118. // Mipmap generation needs a sized internal format that is both color-renderable and texture-filterable
  32119. if (textureType === gl.FLOAT && !this._caps.textureFloatLinearFiltering) {
  32120. generateMipMaps = false;
  32121. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32122. _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.");
  32123. }
  32124. else if (textureType === this._gl.HALF_FLOAT_OES && !this._caps.textureHalfFloatLinearFiltering) {
  32125. generateMipMaps = false;
  32126. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32127. _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.");
  32128. }
  32129. else if (textureType === gl.FLOAT && !this._caps.textureFloatRender) {
  32130. generateMipMaps = false;
  32131. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to float textures is not supported. Mipmap generation forced to false.");
  32132. }
  32133. else if (textureType === gl.HALF_FLOAT && !this._caps.colorBufferFloat) {
  32134. generateMipMaps = false;
  32135. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to half float textures is not supported. Mipmap generation forced to false.");
  32136. }
  32137. var width = size;
  32138. var height = width;
  32139. texture.width = width;
  32140. texture.height = height;
  32141. // Double check on POT to generate Mips.
  32142. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  32143. if (!isPot) {
  32144. generateMipMaps = false;
  32145. }
  32146. // Upload data if needed. The texture won't be ready until then.
  32147. if (data) {
  32148. this.updateRawCubeTexture(texture, data, format, type, invertY, compression);
  32149. }
  32150. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  32151. // Filters
  32152. if (data && generateMipMaps) {
  32153. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  32154. }
  32155. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32156. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  32157. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  32158. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32159. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32160. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32161. texture.generateMipMaps = generateMipMaps;
  32162. return texture;
  32163. };
  32164. /**
  32165. * Creates a new raw cube texture from a specified url
  32166. * @param url defines the url where the data is located
  32167. * @param scene defines the current scene
  32168. * @param size defines the size of the textures
  32169. * @param format defines the format of the data
  32170. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32171. * @param noMipmap defines if the engine should avoid generating the mip levels
  32172. * @param callback defines a callback used to extract texture data from loaded data
  32173. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  32174. * @param onLoad defines a callback called when texture is loaded
  32175. * @param onError defines a callback called if there is an error
  32176. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32177. * @param invertY defines if data must be stored with Y axis inverted
  32178. * @returns the cube texture as an InternalTexture
  32179. */
  32180. Engine.prototype.createRawCubeTextureFromUrl = function (url, scene, size, format, type, noMipmap, callback, mipmapGenerator, onLoad, onError, samplingMode, invertY) {
  32181. var _this = this;
  32182. if (onLoad === void 0) { onLoad = null; }
  32183. if (onError === void 0) { onError = null; }
  32184. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  32185. if (invertY === void 0) { invertY = false; }
  32186. var gl = this._gl;
  32187. var texture = this.createRawCubeTexture(null, size, format, type, !noMipmap, invertY, samplingMode);
  32188. scene._addPendingData(texture);
  32189. texture.url = url;
  32190. this._internalTexturesCache.push(texture);
  32191. var onerror = function (request, exception) {
  32192. scene._removePendingData(texture);
  32193. if (onError && request) {
  32194. onError(request.status + " " + request.statusText, exception);
  32195. }
  32196. };
  32197. var internalCallback = function (data) {
  32198. var width = texture.width;
  32199. var faceDataArrays = callback(data);
  32200. if (!faceDataArrays) {
  32201. return;
  32202. }
  32203. if (mipmapGenerator) {
  32204. var textureType = _this._getWebGLTextureType(type);
  32205. var internalFormat = _this._getInternalFormat(format);
  32206. var internalSizedFomat = _this._getRGBABufferInternalSizedFormat(type);
  32207. var needConversion = false;
  32208. if (internalFormat === gl.RGB) {
  32209. internalFormat = gl.RGBA;
  32210. needConversion = true;
  32211. }
  32212. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32213. _this._unpackFlipY(false);
  32214. var mipData = mipmapGenerator(faceDataArrays);
  32215. for (var level = 0; level < mipData.length; level++) {
  32216. var mipSize = width >> level;
  32217. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  32218. var mipFaceData = mipData[level][faceIndex];
  32219. if (needConversion) {
  32220. mipFaceData = _this._convertRGBtoRGBATextureData(mipFaceData, mipSize, mipSize, type);
  32221. }
  32222. gl.texImage2D(faceIndex, level, internalSizedFomat, mipSize, mipSize, 0, internalFormat, textureType, mipFaceData);
  32223. }
  32224. }
  32225. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32226. }
  32227. else {
  32228. _this.updateRawCubeTexture(texture, faceDataArrays, format, type, invertY);
  32229. }
  32230. texture.isReady = true;
  32231. // this.resetTextureCache();
  32232. scene._removePendingData(texture);
  32233. if (onLoad) {
  32234. onLoad();
  32235. }
  32236. };
  32237. this._loadFile(url, function (data) {
  32238. internalCallback(data);
  32239. }, undefined, scene.offlineProvider, true, onerror);
  32240. return texture;
  32241. };
  32242. /**
  32243. * Update a raw 3D texture
  32244. * @param texture defines the texture to update
  32245. * @param data defines the data to store
  32246. * @param format defines the data format
  32247. * @param invertY defines if data must be stored with Y axis inverted
  32248. * @param compression defines the used compression (can be null)
  32249. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  32250. */
  32251. Engine.prototype.updateRawTexture3D = function (texture, data, format, invertY, compression, textureType) {
  32252. if (compression === void 0) { compression = null; }
  32253. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  32254. var internalType = this._getWebGLTextureType(textureType);
  32255. var internalFormat = this._getInternalFormat(format);
  32256. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(textureType, format);
  32257. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  32258. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32259. if (!this._doNotHandleContextLost) {
  32260. texture._bufferView = data;
  32261. texture.format = format;
  32262. texture.invertY = invertY;
  32263. texture._compression = compression;
  32264. }
  32265. if (texture.width % 4 !== 0) {
  32266. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  32267. }
  32268. if (compression && data) {
  32269. this._gl.compressedTexImage3D(this._gl.TEXTURE_3D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, texture.depth, 0, data);
  32270. }
  32271. else {
  32272. this._gl.texImage3D(this._gl.TEXTURE_3D, 0, internalSizedFomat, texture.width, texture.height, texture.depth, 0, internalFormat, internalType, data);
  32273. }
  32274. if (texture.generateMipMaps) {
  32275. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  32276. }
  32277. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32278. // this.resetTextureCache();
  32279. texture.isReady = true;
  32280. };
  32281. /**
  32282. * Creates a new raw 3D texture
  32283. * @param data defines the data used to create the texture
  32284. * @param width defines the width of the texture
  32285. * @param height defines the height of the texture
  32286. * @param depth defines the depth of the texture
  32287. * @param format defines the format of the texture
  32288. * @param generateMipMaps defines if the engine must generate mip levels
  32289. * @param invertY defines if data must be stored with Y axis inverted
  32290. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32291. * @param compression defines the compressed used (can be null)
  32292. * @param textureType defines the compressed used (can be null)
  32293. * @returns a new raw 3D texture (stored in an InternalTexture)
  32294. */
  32295. Engine.prototype.createRawTexture3D = function (data, width, height, depth, format, generateMipMaps, invertY, samplingMode, compression, textureType) {
  32296. if (compression === void 0) { compression = null; }
  32297. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  32298. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW3D);
  32299. texture.baseWidth = width;
  32300. texture.baseHeight = height;
  32301. texture.baseDepth = depth;
  32302. texture.width = width;
  32303. texture.height = height;
  32304. texture.depth = depth;
  32305. texture.format = format;
  32306. texture.type = textureType;
  32307. texture.generateMipMaps = generateMipMaps;
  32308. texture.samplingMode = samplingMode;
  32309. texture.is3D = true;
  32310. if (!this._doNotHandleContextLost) {
  32311. texture._bufferView = data;
  32312. }
  32313. this.updateRawTexture3D(texture, data, format, invertY, compression, textureType);
  32314. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  32315. // Filters
  32316. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32317. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  32318. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  32319. if (generateMipMaps) {
  32320. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  32321. }
  32322. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32323. this._internalTexturesCache.push(texture);
  32324. return texture;
  32325. };
  32326. Engine.prototype._prepareWebGLTextureContinuation = function (texture, scene, noMipmap, isCompressed, samplingMode) {
  32327. var gl = this._gl;
  32328. if (!gl) {
  32329. return;
  32330. }
  32331. var filters = this._getSamplingParameters(samplingMode, !noMipmap);
  32332. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  32333. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  32334. if (!noMipmap && !isCompressed) {
  32335. gl.generateMipmap(gl.TEXTURE_2D);
  32336. }
  32337. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32338. // this.resetTextureCache();
  32339. if (scene) {
  32340. scene._removePendingData(texture);
  32341. }
  32342. texture.onLoadedObservable.notifyObservers(texture);
  32343. texture.onLoadedObservable.clear();
  32344. };
  32345. Engine.prototype._prepareWebGLTexture = function (texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode) {
  32346. var _this = this;
  32347. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  32348. var maxTextureSize = this.getCaps().maxTextureSize;
  32349. var potWidth = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, maxTextureSize) : width);
  32350. var potHeight = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, maxTextureSize) : height);
  32351. var gl = this._gl;
  32352. if (!gl) {
  32353. return;
  32354. }
  32355. if (!texture._webGLTexture) {
  32356. // this.resetTextureCache();
  32357. if (scene) {
  32358. scene._removePendingData(texture);
  32359. }
  32360. return;
  32361. }
  32362. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  32363. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32364. texture.baseWidth = width;
  32365. texture.baseHeight = height;
  32366. texture.width = potWidth;
  32367. texture.height = potHeight;
  32368. texture.isReady = true;
  32369. if (processFunction(potWidth, potHeight, function () {
  32370. _this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  32371. })) {
  32372. // Returning as texture needs extra async steps
  32373. return;
  32374. }
  32375. this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  32376. };
  32377. Engine.prototype._convertRGBtoRGBATextureData = function (rgbData, width, height, textureType) {
  32378. // Create new RGBA data container.
  32379. var rgbaData;
  32380. if (textureType === Engine.TEXTURETYPE_FLOAT) {
  32381. rgbaData = new Float32Array(width * height * 4);
  32382. }
  32383. else {
  32384. rgbaData = new Uint32Array(width * height * 4);
  32385. }
  32386. // Convert each pixel.
  32387. for (var x = 0; x < width; x++) {
  32388. for (var y = 0; y < height; y++) {
  32389. var index = (y * width + x) * 3;
  32390. var newIndex = (y * width + x) * 4;
  32391. // Map Old Value to new value.
  32392. rgbaData[newIndex + 0] = rgbData[index + 0];
  32393. rgbaData[newIndex + 1] = rgbData[index + 1];
  32394. rgbaData[newIndex + 2] = rgbData[index + 2];
  32395. // Add fully opaque alpha channel.
  32396. rgbaData[newIndex + 3] = 1;
  32397. }
  32398. }
  32399. return rgbaData;
  32400. };
  32401. /** @hidden */
  32402. Engine.prototype._releaseFramebufferObjects = function (texture) {
  32403. var gl = this._gl;
  32404. if (texture._framebuffer) {
  32405. gl.deleteFramebuffer(texture._framebuffer);
  32406. texture._framebuffer = null;
  32407. }
  32408. if (texture._depthStencilBuffer) {
  32409. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  32410. texture._depthStencilBuffer = null;
  32411. }
  32412. if (texture._MSAAFramebuffer) {
  32413. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  32414. texture._MSAAFramebuffer = null;
  32415. }
  32416. if (texture._MSAARenderBuffer) {
  32417. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  32418. texture._MSAARenderBuffer = null;
  32419. }
  32420. };
  32421. /** @hidden */
  32422. Engine.prototype._releaseTexture = function (texture) {
  32423. var gl = this._gl;
  32424. this._releaseFramebufferObjects(texture);
  32425. gl.deleteTexture(texture._webGLTexture);
  32426. // Unbind channels
  32427. this.unbindAllTextures();
  32428. var index = this._internalTexturesCache.indexOf(texture);
  32429. if (index !== -1) {
  32430. this._internalTexturesCache.splice(index, 1);
  32431. }
  32432. // Integrated fixed lod samplers.
  32433. if (texture._lodTextureHigh) {
  32434. texture._lodTextureHigh.dispose();
  32435. }
  32436. if (texture._lodTextureMid) {
  32437. texture._lodTextureMid.dispose();
  32438. }
  32439. if (texture._lodTextureLow) {
  32440. texture._lodTextureLow.dispose();
  32441. }
  32442. // Set output texture of post process to null if the texture has been released/disposed
  32443. this.scenes.forEach(function (scene) {
  32444. scene.postProcesses.forEach(function (postProcess) {
  32445. if (postProcess._outputTexture == texture) {
  32446. postProcess._outputTexture = null;
  32447. }
  32448. });
  32449. scene.cameras.forEach(function (camera) {
  32450. camera._postProcesses.forEach(function (postProcess) {
  32451. if (postProcess) {
  32452. if (postProcess._outputTexture == texture) {
  32453. postProcess._outputTexture = null;
  32454. }
  32455. }
  32456. });
  32457. });
  32458. });
  32459. };
  32460. Engine.prototype.setProgram = function (program) {
  32461. if (this._currentProgram !== program) {
  32462. this._gl.useProgram(program);
  32463. this._currentProgram = program;
  32464. }
  32465. };
  32466. /**
  32467. * Binds an effect to the webGL context
  32468. * @param effect defines the effect to bind
  32469. */
  32470. Engine.prototype.bindSamplers = function (effect) {
  32471. this.setProgram(effect.getProgram());
  32472. var samplers = effect.getSamplers();
  32473. for (var index = 0; index < samplers.length; index++) {
  32474. var uniform = effect.getUniform(samplers[index]);
  32475. if (uniform) {
  32476. this._boundUniforms[index] = uniform;
  32477. }
  32478. }
  32479. this._currentEffect = null;
  32480. };
  32481. Engine.prototype._moveBoundTextureOnTop = function (internalTexture) {
  32482. if (this.disableTextureBindingOptimization || this._lastBoundInternalTextureTracker.previous === internalTexture) {
  32483. return;
  32484. }
  32485. // Remove
  32486. this._linkTrackers(internalTexture.previous, internalTexture.next);
  32487. // Bind last to it
  32488. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, internalTexture);
  32489. // Bind to dummy
  32490. this._linkTrackers(internalTexture, this._lastBoundInternalTextureTracker);
  32491. };
  32492. Engine.prototype._getCorrectTextureChannel = function (channel, internalTexture) {
  32493. if (!internalTexture) {
  32494. return -1;
  32495. }
  32496. internalTexture._initialSlot = channel;
  32497. if (this.disableTextureBindingOptimization) { // We want texture sampler ID === texture channel
  32498. if (channel !== internalTexture._designatedSlot) {
  32499. this._textureCollisions.addCount(1, false);
  32500. }
  32501. }
  32502. else {
  32503. if (channel !== internalTexture._designatedSlot) {
  32504. if (internalTexture._designatedSlot > -1) { // Texture is already assigned to a slot
  32505. return internalTexture._designatedSlot;
  32506. }
  32507. else {
  32508. // No slot for this texture, let's pick a new one (if we find a free slot)
  32509. if (this._nextFreeTextureSlots.length) {
  32510. return this._nextFreeTextureSlots[0];
  32511. }
  32512. // We need to recycle the oldest bound texture, sorry.
  32513. this._textureCollisions.addCount(1, false);
  32514. return this._removeDesignatedSlot(this._firstBoundInternalTextureTracker.next);
  32515. }
  32516. }
  32517. }
  32518. return channel;
  32519. };
  32520. Engine.prototype._linkTrackers = function (previous, next) {
  32521. previous.next = next;
  32522. next.previous = previous;
  32523. };
  32524. Engine.prototype._removeDesignatedSlot = function (internalTexture) {
  32525. var currentSlot = internalTexture._designatedSlot;
  32526. if (currentSlot === -1) {
  32527. return -1;
  32528. }
  32529. internalTexture._designatedSlot = -1;
  32530. if (this.disableTextureBindingOptimization) {
  32531. return -1;
  32532. }
  32533. // Remove from bound list
  32534. this._linkTrackers(internalTexture.previous, internalTexture.next);
  32535. // Free the slot
  32536. this._boundTexturesCache[currentSlot] = null;
  32537. this._nextFreeTextureSlots.push(currentSlot);
  32538. return currentSlot;
  32539. };
  32540. Engine.prototype._activateCurrentTexture = function () {
  32541. if (this._currentTextureChannel !== this._activeChannel) {
  32542. this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel);
  32543. this._currentTextureChannel = this._activeChannel;
  32544. }
  32545. };
  32546. /** @hidden */
  32547. Engine.prototype._bindTextureDirectly = function (target, texture, forTextureDataUpdate, force) {
  32548. if (forTextureDataUpdate === void 0) { forTextureDataUpdate = false; }
  32549. if (force === void 0) { force = false; }
  32550. var wasPreviouslyBound = false;
  32551. if (forTextureDataUpdate && texture && texture._designatedSlot > -1) {
  32552. this._activeChannel = texture._designatedSlot;
  32553. }
  32554. var currentTextureBound = this._boundTexturesCache[this._activeChannel];
  32555. var isTextureForRendering = texture && texture._initialSlot > -1;
  32556. if (currentTextureBound !== texture || force) {
  32557. if (currentTextureBound) {
  32558. this._removeDesignatedSlot(currentTextureBound);
  32559. }
  32560. this._activateCurrentTexture();
  32561. this._gl.bindTexture(target, texture ? texture._webGLTexture : null);
  32562. this._boundTexturesCache[this._activeChannel] = texture;
  32563. if (texture) {
  32564. if (!this.disableTextureBindingOptimization) {
  32565. var slotIndex = this._nextFreeTextureSlots.indexOf(this._activeChannel);
  32566. if (slotIndex > -1) {
  32567. this._nextFreeTextureSlots.splice(slotIndex, 1);
  32568. }
  32569. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, texture);
  32570. this._linkTrackers(texture, this._lastBoundInternalTextureTracker);
  32571. }
  32572. texture._designatedSlot = this._activeChannel;
  32573. }
  32574. }
  32575. else if (forTextureDataUpdate) {
  32576. wasPreviouslyBound = true;
  32577. this._activateCurrentTexture();
  32578. }
  32579. if (isTextureForRendering && !forTextureDataUpdate) {
  32580. this._bindSamplerUniformToChannel(texture._initialSlot, this._activeChannel);
  32581. }
  32582. return wasPreviouslyBound;
  32583. };
  32584. /** @hidden */
  32585. Engine.prototype._bindTexture = function (channel, texture) {
  32586. if (channel < 0) {
  32587. return;
  32588. }
  32589. if (texture) {
  32590. channel = this._getCorrectTextureChannel(channel, texture);
  32591. }
  32592. this._activeChannel = channel;
  32593. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
  32594. };
  32595. /**
  32596. * Sets a texture to the webGL context from a postprocess
  32597. * @param channel defines the channel to use
  32598. * @param postProcess defines the source postprocess
  32599. */
  32600. Engine.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  32601. this._bindTexture(channel, postProcess ? postProcess._textures.data[postProcess._currentRenderTextureInd] : null);
  32602. };
  32603. /**
  32604. * Binds the output of the passed in post process to the texture channel specified
  32605. * @param channel The channel the texture should be bound to
  32606. * @param postProcess The post process which's output should be bound
  32607. */
  32608. Engine.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  32609. this._bindTexture(channel, postProcess ? postProcess._outputTexture : null);
  32610. };
  32611. /**
  32612. * Unbind all textures from the webGL context
  32613. */
  32614. Engine.prototype.unbindAllTextures = function () {
  32615. for (var channel = 0; channel < this._maxSimultaneousTextures; channel++) {
  32616. this._activeChannel = channel;
  32617. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32618. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32619. if (this.webGLVersion > 1) {
  32620. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32621. }
  32622. }
  32623. };
  32624. /**
  32625. * Sets a texture to the according uniform.
  32626. * @param channel The texture channel
  32627. * @param uniform The uniform to set
  32628. * @param texture The texture to apply
  32629. */
  32630. Engine.prototype.setTexture = function (channel, uniform, texture) {
  32631. if (channel < 0) {
  32632. return;
  32633. }
  32634. if (uniform) {
  32635. this._boundUniforms[channel] = uniform;
  32636. }
  32637. this._setTexture(channel, texture);
  32638. };
  32639. /**
  32640. * Sets a depth stencil texture from a render target to the according uniform.
  32641. * @param channel The texture channel
  32642. * @param uniform The uniform to set
  32643. * @param texture The render target texture containing the depth stencil texture to apply
  32644. */
  32645. Engine.prototype.setDepthStencilTexture = function (channel, uniform, texture) {
  32646. if (channel < 0) {
  32647. return;
  32648. }
  32649. if (uniform) {
  32650. this._boundUniforms[channel] = uniform;
  32651. }
  32652. if (!texture || !texture.depthStencilTexture) {
  32653. this._setTexture(channel, null);
  32654. }
  32655. else {
  32656. this._setTexture(channel, texture, false, true);
  32657. }
  32658. };
  32659. Engine.prototype._bindSamplerUniformToChannel = function (sourceSlot, destination) {
  32660. var uniform = this._boundUniforms[sourceSlot];
  32661. if (uniform._currentState === destination) {
  32662. return;
  32663. }
  32664. this._gl.uniform1i(uniform, destination);
  32665. uniform._currentState = destination;
  32666. };
  32667. Engine.prototype._getTextureWrapMode = function (mode) {
  32668. switch (mode) {
  32669. case Engine.TEXTURE_WRAP_ADDRESSMODE:
  32670. return this._gl.REPEAT;
  32671. case Engine.TEXTURE_CLAMP_ADDRESSMODE:
  32672. return this._gl.CLAMP_TO_EDGE;
  32673. case Engine.TEXTURE_MIRROR_ADDRESSMODE:
  32674. return this._gl.MIRRORED_REPEAT;
  32675. }
  32676. return this._gl.REPEAT;
  32677. };
  32678. Engine.prototype._setTexture = function (channel, texture, isPartOfTextureArray, depthStencilTexture) {
  32679. if (isPartOfTextureArray === void 0) { isPartOfTextureArray = false; }
  32680. if (depthStencilTexture === void 0) { depthStencilTexture = false; }
  32681. // Not ready?
  32682. if (!texture) {
  32683. if (this._boundTexturesCache[channel] != null) {
  32684. this._activeChannel = channel;
  32685. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32686. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32687. if (this.webGLVersion > 1) {
  32688. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32689. }
  32690. }
  32691. return false;
  32692. }
  32693. // Video
  32694. if (texture.video) {
  32695. this._activeChannel = channel;
  32696. texture.update();
  32697. }
  32698. else if (texture.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) { // Delay loading
  32699. texture.delayLoad();
  32700. return false;
  32701. }
  32702. var internalTexture;
  32703. if (depthStencilTexture) {
  32704. internalTexture = texture.depthStencilTexture;
  32705. }
  32706. else if (texture.isReady()) {
  32707. internalTexture = texture.getInternalTexture();
  32708. }
  32709. else if (texture.isCube) {
  32710. internalTexture = this.emptyCubeTexture;
  32711. }
  32712. else if (texture.is3D) {
  32713. internalTexture = this.emptyTexture3D;
  32714. }
  32715. else {
  32716. internalTexture = this.emptyTexture;
  32717. }
  32718. if (!isPartOfTextureArray) {
  32719. channel = this._getCorrectTextureChannel(channel, internalTexture);
  32720. }
  32721. var needToBind = true;
  32722. if (this._boundTexturesCache[channel] === internalTexture) {
  32723. this._moveBoundTextureOnTop(internalTexture);
  32724. if (!isPartOfTextureArray) {
  32725. this._bindSamplerUniformToChannel(internalTexture._initialSlot, channel);
  32726. }
  32727. needToBind = false;
  32728. }
  32729. this._activeChannel = channel;
  32730. if (internalTexture && internalTexture.is3D) {
  32731. if (needToBind) {
  32732. this._bindTextureDirectly(this._gl.TEXTURE_3D, internalTexture, isPartOfTextureArray);
  32733. }
  32734. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  32735. internalTexture._cachedWrapU = texture.wrapU;
  32736. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  32737. }
  32738. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  32739. internalTexture._cachedWrapV = texture.wrapV;
  32740. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  32741. }
  32742. if (internalTexture && internalTexture._cachedWrapR !== texture.wrapR) {
  32743. internalTexture._cachedWrapR = texture.wrapR;
  32744. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(texture.wrapR), internalTexture);
  32745. }
  32746. this._setAnisotropicLevel(this._gl.TEXTURE_3D, texture);
  32747. }
  32748. else if (internalTexture && internalTexture.isCube) {
  32749. if (needToBind) {
  32750. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, internalTexture, isPartOfTextureArray);
  32751. }
  32752. if (internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {
  32753. internalTexture._cachedCoordinatesMode = texture.coordinatesMode;
  32754. // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.
  32755. var textureWrapMode = (texture.coordinatesMode !== Engine.TEXTURE_CUBIC_MODE && texture.coordinatesMode !== Engine.TEXTURE_SKYBOX_MODE) ? this._gl.REPEAT : this._gl.CLAMP_TO_EDGE;
  32756. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_S, textureWrapMode, internalTexture);
  32757. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_T, textureWrapMode);
  32758. }
  32759. this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP, texture);
  32760. }
  32761. else {
  32762. if (needToBind) {
  32763. this._bindTextureDirectly(this._gl.TEXTURE_2D, internalTexture, isPartOfTextureArray);
  32764. }
  32765. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  32766. internalTexture._cachedWrapU = texture.wrapU;
  32767. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  32768. }
  32769. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  32770. internalTexture._cachedWrapV = texture.wrapV;
  32771. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  32772. }
  32773. this._setAnisotropicLevel(this._gl.TEXTURE_2D, texture);
  32774. }
  32775. return true;
  32776. };
  32777. /**
  32778. * Sets an array of texture to the webGL context
  32779. * @param channel defines the channel where the texture array must be set
  32780. * @param uniform defines the associated uniform location
  32781. * @param textures defines the array of textures to bind
  32782. */
  32783. Engine.prototype.setTextureArray = function (channel, uniform, textures) {
  32784. if (channel < 0 || !uniform) {
  32785. return;
  32786. }
  32787. if (!this._textureUnits || this._textureUnits.length !== textures.length) {
  32788. this._textureUnits = new Int32Array(textures.length);
  32789. }
  32790. for (var i = 0; i < textures.length; i++) {
  32791. this._textureUnits[i] = this._getCorrectTextureChannel(channel + i, textures[i].getInternalTexture());
  32792. }
  32793. this._gl.uniform1iv(uniform, this._textureUnits);
  32794. for (var index = 0; index < textures.length; index++) {
  32795. this._setTexture(this._textureUnits[index], textures[index], true);
  32796. }
  32797. };
  32798. /** @hidden */
  32799. Engine.prototype._setAnisotropicLevel = function (target, texture) {
  32800. var internalTexture = texture.getInternalTexture();
  32801. if (!internalTexture) {
  32802. return;
  32803. }
  32804. var anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;
  32805. var value = texture.anisotropicFilteringLevel;
  32806. if (internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST
  32807. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR
  32808. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR) {
  32809. value = 1; // Forcing the anisotropic to 1 because else webgl will force filters to linear
  32810. }
  32811. if (anisotropicFilterExtension && internalTexture._cachedAnisotropicFilteringLevel !== value) {
  32812. this._setTextureParameterFloat(target, anisotropicFilterExtension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(value, this._caps.maxAnisotropy), internalTexture);
  32813. internalTexture._cachedAnisotropicFilteringLevel = value;
  32814. }
  32815. };
  32816. Engine.prototype._setTextureParameterFloat = function (target, parameter, value, texture) {
  32817. this._bindTextureDirectly(target, texture, true, true);
  32818. this._gl.texParameterf(target, parameter, value);
  32819. };
  32820. Engine.prototype._setTextureParameterInteger = function (target, parameter, value, texture) {
  32821. if (texture) {
  32822. this._bindTextureDirectly(target, texture, true, true);
  32823. }
  32824. this._gl.texParameteri(target, parameter, value);
  32825. };
  32826. /**
  32827. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32828. * @param x defines the x coordinate of the rectangle where pixels must be read
  32829. * @param y defines the y coordinate of the rectangle where pixels must be read
  32830. * @param width defines the width of the rectangle where pixels must be read
  32831. * @param height defines the height of the rectangle where pixels must be read
  32832. * @returns a Uint8Array containing RGBA colors
  32833. */
  32834. Engine.prototype.readPixels = function (x, y, width, height) {
  32835. var data = new Uint8Array(height * width * 4);
  32836. this._gl.readPixels(x, y, width, height, this._gl.RGBA, this._gl.UNSIGNED_BYTE, data);
  32837. return data;
  32838. };
  32839. /**
  32840. * Add an externaly attached data from its key.
  32841. * This method call will fail and return false, if such key already exists.
  32842. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32843. * @param key the unique key that identifies the data
  32844. * @param data the data object to associate to the key for this Engine instance
  32845. * @return true if no such key were already present and the data was added successfully, false otherwise
  32846. */
  32847. Engine.prototype.addExternalData = function (key, data) {
  32848. if (!this._externalData) {
  32849. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32850. }
  32851. return this._externalData.add(key, data);
  32852. };
  32853. /**
  32854. * Get an externaly attached data from its key
  32855. * @param key the unique key that identifies the data
  32856. * @return the associated data, if present (can be null), or undefined if not present
  32857. */
  32858. Engine.prototype.getExternalData = function (key) {
  32859. if (!this._externalData) {
  32860. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32861. }
  32862. return this._externalData.get(key);
  32863. };
  32864. /**
  32865. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32866. * @param key the unique key that identifies the data
  32867. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32868. * @return the associated data, can be null if the factory returned null.
  32869. */
  32870. Engine.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  32871. if (!this._externalData) {
  32872. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32873. }
  32874. return this._externalData.getOrAddWithFactory(key, factory);
  32875. };
  32876. /**
  32877. * Remove an externaly attached data from the Engine instance
  32878. * @param key the unique key that identifies the data
  32879. * @return true if the data was successfully removed, false if it doesn't exist
  32880. */
  32881. Engine.prototype.removeExternalData = function (key) {
  32882. if (!this._externalData) {
  32883. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32884. }
  32885. return this._externalData.remove(key);
  32886. };
  32887. /**
  32888. * Unbind all vertex attributes from the webGL context
  32889. */
  32890. Engine.prototype.unbindAllAttributes = function () {
  32891. if (this._mustWipeVertexAttributes) {
  32892. this._mustWipeVertexAttributes = false;
  32893. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  32894. this._gl.disableVertexAttribArray(i);
  32895. this._vertexAttribArraysEnabled[i] = false;
  32896. this._currentBufferPointers[i].active = false;
  32897. }
  32898. return;
  32899. }
  32900. for (var i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {
  32901. if (i >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[i]) {
  32902. continue;
  32903. }
  32904. this._gl.disableVertexAttribArray(i);
  32905. this._vertexAttribArraysEnabled[i] = false;
  32906. this._currentBufferPointers[i].active = false;
  32907. }
  32908. };
  32909. /**
  32910. * 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
  32911. */
  32912. Engine.prototype.releaseEffects = function () {
  32913. for (var name in this._compiledEffects) {
  32914. this._deleteProgram(this._compiledEffects[name]._program);
  32915. }
  32916. this._compiledEffects = {};
  32917. };
  32918. /**
  32919. * Dispose and release all associated resources
  32920. */
  32921. Engine.prototype.dispose = function () {
  32922. this.hideLoadingUI();
  32923. this.stopRenderLoop();
  32924. this.onNewSceneAddedObservable.clear();
  32925. // Release postProcesses
  32926. while (this.postProcesses.length) {
  32927. this.postProcesses[0].dispose();
  32928. }
  32929. // Empty texture
  32930. if (this._emptyTexture) {
  32931. this._releaseTexture(this._emptyTexture);
  32932. this._emptyTexture = null;
  32933. }
  32934. if (this._emptyCubeTexture) {
  32935. this._releaseTexture(this._emptyCubeTexture);
  32936. this._emptyCubeTexture = null;
  32937. }
  32938. // Rescale PP
  32939. if (this._rescalePostProcess) {
  32940. this._rescalePostProcess.dispose();
  32941. }
  32942. // Release scenes
  32943. while (this.scenes.length) {
  32944. this.scenes[0].dispose();
  32945. }
  32946. // Release audio engine
  32947. if (Engine.Instances.length === 1 && Engine.audioEngine) {
  32948. Engine.audioEngine.dispose();
  32949. }
  32950. // Release effects
  32951. this.releaseEffects();
  32952. // Unbind
  32953. this.unbindAllAttributes();
  32954. this._boundUniforms = [];
  32955. if (this._dummyFramebuffer) {
  32956. this._gl.deleteFramebuffer(this._dummyFramebuffer);
  32957. }
  32958. //WebVR
  32959. this.disableVR();
  32960. // Events
  32961. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  32962. window.removeEventListener("blur", this._onBlur);
  32963. window.removeEventListener("focus", this._onFocus);
  32964. window.removeEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted);
  32965. window.removeEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted);
  32966. if (this._renderingCanvas) {
  32967. this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus);
  32968. this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur);
  32969. this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut);
  32970. if (!this._doNotHandleContextLost) {
  32971. this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost);
  32972. this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored);
  32973. }
  32974. }
  32975. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  32976. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  32977. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  32978. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  32979. document.removeEventListener("pointerlockchange", this._onPointerLockChange);
  32980. document.removeEventListener("mspointerlockchange", this._onPointerLockChange);
  32981. document.removeEventListener("mozpointerlockchange", this._onPointerLockChange);
  32982. document.removeEventListener("webkitpointerlockchange", this._onPointerLockChange);
  32983. if (this._onVrDisplayConnect) {
  32984. window.removeEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  32985. if (this._onVrDisplayDisconnect) {
  32986. window.removeEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  32987. }
  32988. if (this._onVrDisplayPresentChange) {
  32989. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  32990. }
  32991. this._onVrDisplayConnect = null;
  32992. this._onVrDisplayDisconnect = null;
  32993. }
  32994. }
  32995. // Remove from Instances
  32996. var index = Engine.Instances.indexOf(this);
  32997. if (index >= 0) {
  32998. Engine.Instances.splice(index, 1);
  32999. }
  33000. this._workingCanvas = null;
  33001. this._workingContext = null;
  33002. this._currentBufferPointers = [];
  33003. this._renderingCanvas = null;
  33004. this._currentProgram = null;
  33005. this._bindedRenderFunction = null;
  33006. this.onResizeObservable.clear();
  33007. this.onCanvasBlurObservable.clear();
  33008. this.onCanvasFocusObservable.clear();
  33009. this.onCanvasPointerOutObservable.clear();
  33010. this.onBeginFrameObservable.clear();
  33011. this.onEndFrameObservable.clear();
  33012. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  33013. // Abort active requests
  33014. for (var _i = 0, _a = this._activeRequests; _i < _a.length; _i++) {
  33015. var request = _a[_i];
  33016. request.abort();
  33017. }
  33018. };
  33019. // Loading screen
  33020. /**
  33021. * Display the loading screen
  33022. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33023. */
  33024. Engine.prototype.displayLoadingUI = function () {
  33025. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  33026. return;
  33027. }
  33028. var loadingScreen = this.loadingScreen;
  33029. if (loadingScreen) {
  33030. loadingScreen.displayLoadingUI();
  33031. }
  33032. };
  33033. /**
  33034. * Hide the loading screen
  33035. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33036. */
  33037. Engine.prototype.hideLoadingUI = function () {
  33038. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  33039. return;
  33040. }
  33041. var loadingScreen = this.loadingScreen;
  33042. if (loadingScreen) {
  33043. loadingScreen.hideLoadingUI();
  33044. }
  33045. };
  33046. Object.defineProperty(Engine.prototype, "loadingScreen", {
  33047. /**
  33048. * Gets the current loading screen object
  33049. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33050. */
  33051. get: function () {
  33052. if (!this._loadingScreen && this._renderingCanvas) {
  33053. this._loadingScreen = Engine.DefaultLoadingScreenFactory(this._renderingCanvas);
  33054. }
  33055. return this._loadingScreen;
  33056. },
  33057. /**
  33058. * Sets the current loading screen object
  33059. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33060. */
  33061. set: function (loadingScreen) {
  33062. this._loadingScreen = loadingScreen;
  33063. },
  33064. enumerable: true,
  33065. configurable: true
  33066. });
  33067. Object.defineProperty(Engine.prototype, "loadingUIText", {
  33068. /**
  33069. * Sets the current loading screen text
  33070. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33071. */
  33072. set: function (text) {
  33073. this.loadingScreen.loadingUIText = text;
  33074. },
  33075. enumerable: true,
  33076. configurable: true
  33077. });
  33078. Object.defineProperty(Engine.prototype, "loadingUIBackgroundColor", {
  33079. /**
  33080. * Sets the current loading screen background color
  33081. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33082. */
  33083. set: function (color) {
  33084. this.loadingScreen.loadingUIBackgroundColor = color;
  33085. },
  33086. enumerable: true,
  33087. configurable: true
  33088. });
  33089. /**
  33090. * Attach a new callback raised when context lost event is fired
  33091. * @param callback defines the callback to call
  33092. */
  33093. Engine.prototype.attachContextLostEvent = function (callback) {
  33094. if (this._renderingCanvas) {
  33095. this._renderingCanvas.addEventListener("webglcontextlost", callback, false);
  33096. }
  33097. };
  33098. /**
  33099. * Attach a new callback raised when context restored event is fired
  33100. * @param callback defines the callback to call
  33101. */
  33102. Engine.prototype.attachContextRestoredEvent = function (callback) {
  33103. if (this._renderingCanvas) {
  33104. this._renderingCanvas.addEventListener("webglcontextrestored", callback, false);
  33105. }
  33106. };
  33107. /**
  33108. * Gets the source code of the vertex shader associated with a specific webGL program
  33109. * @param program defines the program to use
  33110. * @returns a string containing the source code of the vertex shader associated with the program
  33111. */
  33112. Engine.prototype.getVertexShaderSource = function (program) {
  33113. var shaders = this._gl.getAttachedShaders(program);
  33114. if (!shaders) {
  33115. return null;
  33116. }
  33117. return this._gl.getShaderSource(shaders[0]);
  33118. };
  33119. /**
  33120. * Gets the source code of the fragment shader associated with a specific webGL program
  33121. * @param program defines the program to use
  33122. * @returns a string containing the source code of the fragment shader associated with the program
  33123. */
  33124. Engine.prototype.getFragmentShaderSource = function (program) {
  33125. var shaders = this._gl.getAttachedShaders(program);
  33126. if (!shaders) {
  33127. return null;
  33128. }
  33129. return this._gl.getShaderSource(shaders[1]);
  33130. };
  33131. /**
  33132. * Get the current error code of the webGL context
  33133. * @returns the error code
  33134. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33135. */
  33136. Engine.prototype.getError = function () {
  33137. return this._gl.getError();
  33138. };
  33139. // FPS
  33140. /**
  33141. * Gets the current framerate
  33142. * @returns a number representing the framerate
  33143. */
  33144. Engine.prototype.getFps = function () {
  33145. return this._fps;
  33146. };
  33147. /**
  33148. * Gets the time spent between current and previous frame
  33149. * @returns a number representing the delta time in ms
  33150. */
  33151. Engine.prototype.getDeltaTime = function () {
  33152. return this._deltaTime;
  33153. };
  33154. Engine.prototype._measureFps = function () {
  33155. this._performanceMonitor.sampleFrame();
  33156. this._fps = this._performanceMonitor.averageFPS;
  33157. this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0;
  33158. };
  33159. /** @hidden */
  33160. Engine.prototype._readTexturePixels = function (texture, width, height, faceIndex, level, buffer) {
  33161. if (faceIndex === void 0) { faceIndex = -1; }
  33162. if (level === void 0) { level = 0; }
  33163. if (buffer === void 0) { buffer = null; }
  33164. var gl = this._gl;
  33165. if (!this._dummyFramebuffer) {
  33166. var dummy = gl.createFramebuffer();
  33167. if (!dummy) {
  33168. throw new Error("Unable to create dummy framebuffer");
  33169. }
  33170. this._dummyFramebuffer = dummy;
  33171. }
  33172. gl.bindFramebuffer(gl.FRAMEBUFFER, this._dummyFramebuffer);
  33173. if (faceIndex > -1) {
  33174. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, level);
  33175. }
  33176. else {
  33177. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, level);
  33178. }
  33179. var readType = (texture.type !== undefined) ? this._getWebGLTextureType(texture.type) : gl.UNSIGNED_BYTE;
  33180. switch (readType) {
  33181. case gl.UNSIGNED_BYTE:
  33182. if (!buffer) {
  33183. buffer = new Uint8Array(4 * width * height);
  33184. }
  33185. readType = gl.UNSIGNED_BYTE;
  33186. break;
  33187. default:
  33188. if (!buffer) {
  33189. buffer = new Float32Array(4 * width * height);
  33190. }
  33191. readType = gl.FLOAT;
  33192. break;
  33193. }
  33194. gl.readPixels(0, 0, width, height, gl.RGBA, readType, buffer);
  33195. gl.bindFramebuffer(gl.FRAMEBUFFER, this._currentFramebuffer);
  33196. return buffer;
  33197. };
  33198. Engine.prototype._canRenderToFloatFramebuffer = function () {
  33199. if (this._webGLVersion > 1) {
  33200. return this._caps.colorBufferFloat;
  33201. }
  33202. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_FLOAT);
  33203. };
  33204. Engine.prototype._canRenderToHalfFloatFramebuffer = function () {
  33205. if (this._webGLVersion > 1) {
  33206. return this._caps.colorBufferFloat;
  33207. }
  33208. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_HALF_FLOAT);
  33209. };
  33210. // Thank you : http://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture
  33211. Engine.prototype._canRenderToFramebuffer = function (type) {
  33212. var gl = this._gl;
  33213. //clear existing errors
  33214. while (gl.getError() !== gl.NO_ERROR) { }
  33215. var successful = true;
  33216. var texture = gl.createTexture();
  33217. gl.bindTexture(gl.TEXTURE_2D, texture);
  33218. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), 1, 1, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  33219. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  33220. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  33221. var fb = gl.createFramebuffer();
  33222. gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
  33223. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
  33224. var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
  33225. successful = successful && (status === gl.FRAMEBUFFER_COMPLETE);
  33226. successful = successful && (gl.getError() === gl.NO_ERROR);
  33227. //try render by clearing frame buffer's color buffer
  33228. if (successful) {
  33229. gl.clear(gl.COLOR_BUFFER_BIT);
  33230. successful = successful && (gl.getError() === gl.NO_ERROR);
  33231. }
  33232. //try reading from frame to ensure render occurs (just creating the FBO is not sufficient to determine if rendering is supported)
  33233. if (successful) {
  33234. //in practice it's sufficient to just read from the backbuffer rather than handle potentially issues reading from the texture
  33235. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  33236. var readFormat = gl.RGBA;
  33237. var readType = gl.UNSIGNED_BYTE;
  33238. var buffer = new Uint8Array(4);
  33239. gl.readPixels(0, 0, 1, 1, readFormat, readType, buffer);
  33240. successful = successful && (gl.getError() === gl.NO_ERROR);
  33241. }
  33242. //clean up
  33243. gl.deleteTexture(texture);
  33244. gl.deleteFramebuffer(fb);
  33245. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  33246. //clear accumulated errors
  33247. while (!successful && (gl.getError() !== gl.NO_ERROR)) { }
  33248. return successful;
  33249. };
  33250. /** @hidden */
  33251. Engine.prototype._getWebGLTextureType = function (type) {
  33252. if (this._webGLVersion === 1) {
  33253. switch (type) {
  33254. case Engine.TEXTURETYPE_FLOAT:
  33255. return this._gl.FLOAT;
  33256. case Engine.TEXTURETYPE_HALF_FLOAT:
  33257. return this._gl.HALF_FLOAT_OES;
  33258. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33259. return this._gl.UNSIGNED_BYTE;
  33260. }
  33261. return this._gl.UNSIGNED_BYTE;
  33262. }
  33263. switch (type) {
  33264. case Engine.TEXTURETYPE_BYTE:
  33265. return this._gl.BYTE;
  33266. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33267. return this._gl.UNSIGNED_BYTE;
  33268. case Engine.TEXTURETYPE_SHORT:
  33269. return this._gl.SHORT;
  33270. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  33271. return this._gl.UNSIGNED_SHORT;
  33272. case Engine.TEXTURETYPE_INT:
  33273. return this._gl.INT;
  33274. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  33275. return this._gl.UNSIGNED_INT;
  33276. case Engine.TEXTURETYPE_FLOAT:
  33277. return this._gl.FLOAT;
  33278. case Engine.TEXTURETYPE_HALF_FLOAT:
  33279. return this._gl.HALF_FLOAT;
  33280. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  33281. return this._gl.UNSIGNED_SHORT_4_4_4_4;
  33282. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  33283. return this._gl.UNSIGNED_SHORT_5_5_5_1;
  33284. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  33285. return this._gl.UNSIGNED_SHORT_5_6_5;
  33286. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  33287. return this._gl.UNSIGNED_INT_2_10_10_10_REV;
  33288. case Engine.TEXTURETYPE_UNSIGNED_INT_24_8:
  33289. return this._gl.UNSIGNED_INT_24_8;
  33290. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  33291. return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
  33292. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  33293. return this._gl.UNSIGNED_INT_5_9_9_9_REV;
  33294. case Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
  33295. return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV;
  33296. }
  33297. return this._gl.UNSIGNED_BYTE;
  33298. };
  33299. Engine.prototype._getInternalFormat = function (format) {
  33300. var internalFormat = this._gl.RGBA;
  33301. switch (format) {
  33302. case Engine.TEXTUREFORMAT_ALPHA:
  33303. internalFormat = this._gl.ALPHA;
  33304. break;
  33305. case Engine.TEXTUREFORMAT_LUMINANCE:
  33306. internalFormat = this._gl.LUMINANCE;
  33307. break;
  33308. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  33309. internalFormat = this._gl.LUMINANCE_ALPHA;
  33310. break;
  33311. case Engine.TEXTUREFORMAT_RED:
  33312. internalFormat = this._gl.RED;
  33313. break;
  33314. case Engine.TEXTUREFORMAT_RG:
  33315. internalFormat = this._gl.RG;
  33316. break;
  33317. case Engine.TEXTUREFORMAT_RGB:
  33318. internalFormat = this._gl.RGB;
  33319. break;
  33320. case Engine.TEXTUREFORMAT_RGBA:
  33321. internalFormat = this._gl.RGBA;
  33322. break;
  33323. }
  33324. if (this._webGLVersion > 1) {
  33325. switch (format) {
  33326. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33327. internalFormat = this._gl.RED_INTEGER;
  33328. break;
  33329. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33330. internalFormat = this._gl.RG_INTEGER;
  33331. break;
  33332. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33333. internalFormat = this._gl.RGB_INTEGER;
  33334. break;
  33335. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33336. internalFormat = this._gl.RGBA_INTEGER;
  33337. break;
  33338. }
  33339. }
  33340. return internalFormat;
  33341. };
  33342. /** @hidden */
  33343. Engine.prototype._getRGBABufferInternalSizedFormat = function (type, format) {
  33344. if (this._webGLVersion === 1) {
  33345. if (format !== undefined) {
  33346. switch (format) {
  33347. case Engine.TEXTUREFORMAT_ALPHA:
  33348. return this._gl.ALPHA;
  33349. case Engine.TEXTUREFORMAT_LUMINANCE:
  33350. return this._gl.LUMINANCE;
  33351. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  33352. return this._gl.LUMINANCE_ALPHA;
  33353. }
  33354. }
  33355. return this._gl.RGBA;
  33356. }
  33357. switch (type) {
  33358. case Engine.TEXTURETYPE_BYTE:
  33359. switch (format) {
  33360. case Engine.TEXTUREFORMAT_RED:
  33361. return this._gl.R8_SNORM;
  33362. case Engine.TEXTUREFORMAT_RG:
  33363. return this._gl.RG8_SNORM;
  33364. case Engine.TEXTUREFORMAT_RGB:
  33365. return this._gl.RGB8_SNORM;
  33366. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33367. return this._gl.R8I;
  33368. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33369. return this._gl.RG8I;
  33370. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33371. return this._gl.RGB8I;
  33372. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33373. return this._gl.RGBA8I;
  33374. default:
  33375. return this._gl.RGBA8_SNORM;
  33376. }
  33377. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33378. switch (format) {
  33379. case Engine.TEXTUREFORMAT_RED:
  33380. return this._gl.R8;
  33381. case Engine.TEXTUREFORMAT_RG:
  33382. return this._gl.RG8;
  33383. case Engine.TEXTUREFORMAT_RGB:
  33384. return this._gl.RGB8; // By default. Other possibilities are RGB565, SRGB8.
  33385. case Engine.TEXTUREFORMAT_RGBA:
  33386. return this._gl.RGBA8; // By default. Other possibilities are RGB5_A1, RGBA4, SRGB8_ALPHA8.
  33387. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33388. return this._gl.R8UI;
  33389. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33390. return this._gl.RG8UI;
  33391. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33392. return this._gl.RGB8UI;
  33393. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33394. return this._gl.RGBA8UI;
  33395. default:
  33396. return this._gl.RGBA8;
  33397. }
  33398. case Engine.TEXTURETYPE_SHORT:
  33399. switch (format) {
  33400. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33401. return this._gl.R16I;
  33402. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33403. return this._gl.RG16I;
  33404. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33405. return this._gl.RGB16I;
  33406. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33407. return this._gl.RGBA16I;
  33408. default:
  33409. return this._gl.RGBA16I;
  33410. }
  33411. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  33412. switch (format) {
  33413. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33414. return this._gl.R16UI;
  33415. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33416. return this._gl.RG16UI;
  33417. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33418. return this._gl.RGB16UI;
  33419. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33420. return this._gl.RGBA16UI;
  33421. default:
  33422. return this._gl.RGBA16UI;
  33423. }
  33424. case Engine.TEXTURETYPE_INT:
  33425. switch (format) {
  33426. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33427. return this._gl.R32I;
  33428. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33429. return this._gl.RG32I;
  33430. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33431. return this._gl.RGB32I;
  33432. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33433. return this._gl.RGBA32I;
  33434. default:
  33435. return this._gl.RGBA32I;
  33436. }
  33437. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  33438. switch (format) {
  33439. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33440. return this._gl.R32UI;
  33441. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33442. return this._gl.RG32UI;
  33443. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33444. return this._gl.RGB32UI;
  33445. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33446. return this._gl.RGBA32UI;
  33447. default:
  33448. return this._gl.RGBA32UI;
  33449. }
  33450. case Engine.TEXTURETYPE_FLOAT:
  33451. switch (format) {
  33452. case Engine.TEXTUREFORMAT_RED:
  33453. return this._gl.R32F; // By default. Other possibility is R16F.
  33454. case Engine.TEXTUREFORMAT_RG:
  33455. return this._gl.RG32F; // By default. Other possibility is RG16F.
  33456. case Engine.TEXTUREFORMAT_RGB:
  33457. return this._gl.RGB32F; // By default. Other possibilities are RGB16F, R11F_G11F_B10F, RGB9_E5.
  33458. case Engine.TEXTUREFORMAT_RGBA:
  33459. return this._gl.RGBA32F; // By default. Other possibility is RGBA16F.
  33460. default:
  33461. return this._gl.RGBA32F;
  33462. }
  33463. case Engine.TEXTURETYPE_HALF_FLOAT:
  33464. switch (format) {
  33465. case Engine.TEXTUREFORMAT_RED:
  33466. return this._gl.R16F;
  33467. case Engine.TEXTUREFORMAT_RG:
  33468. return this._gl.RG16F;
  33469. case Engine.TEXTUREFORMAT_RGB:
  33470. return this._gl.RGB16F; // By default. Other possibilities are R11F_G11F_B10F, RGB9_E5.
  33471. case Engine.TEXTUREFORMAT_RGBA:
  33472. return this._gl.RGBA16F;
  33473. default:
  33474. return this._gl.RGBA16F;
  33475. }
  33476. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  33477. return this._gl.RGB565;
  33478. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  33479. return this._gl.R11F_G11F_B10F;
  33480. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  33481. return this._gl.RGB9_E5;
  33482. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  33483. return this._gl.RGBA4;
  33484. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  33485. return this._gl.RGB5_A1;
  33486. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  33487. switch (format) {
  33488. case Engine.TEXTUREFORMAT_RGBA:
  33489. return this._gl.RGB10_A2; // By default. Other possibility is RGB5_A1.
  33490. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33491. return this._gl.RGB10_A2UI;
  33492. default:
  33493. return this._gl.RGB10_A2;
  33494. }
  33495. }
  33496. return this._gl.RGBA8;
  33497. };
  33498. /** @hidden */
  33499. Engine.prototype._getRGBAMultiSampleBufferFormat = function (type) {
  33500. if (type === Engine.TEXTURETYPE_FLOAT) {
  33501. return this._gl.RGBA32F;
  33502. }
  33503. else if (type === Engine.TEXTURETYPE_HALF_FLOAT) {
  33504. return this._gl.RGBA16F;
  33505. }
  33506. return this._gl.RGBA8;
  33507. };
  33508. /** @hidden */
  33509. Engine.prototype._loadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  33510. var _this = this;
  33511. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError);
  33512. this._activeRequests.push(request);
  33513. request.onCompleteObservable.add(function (request) {
  33514. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  33515. });
  33516. return request;
  33517. };
  33518. /** @hidden */
  33519. Engine.prototype._loadFileAsync = function (url, offlineProvider, useArrayBuffer) {
  33520. var _this = this;
  33521. return new Promise(function (resolve, reject) {
  33522. _this._loadFile(url, function (data) {
  33523. resolve(data);
  33524. }, undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  33525. reject(exception);
  33526. });
  33527. });
  33528. };
  33529. Engine.prototype._partialLoadFile = function (url, index, loadedFiles, onfinish, onErrorCallBack) {
  33530. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  33531. var onload = function (data) {
  33532. loadedFiles[index] = data;
  33533. loadedFiles._internalCount++;
  33534. if (loadedFiles._internalCount === 6) {
  33535. onfinish(loadedFiles);
  33536. }
  33537. };
  33538. var onerror = function (request, exception) {
  33539. if (onErrorCallBack && request) {
  33540. onErrorCallBack(request.status + " " + request.statusText, exception);
  33541. }
  33542. };
  33543. this._loadFile(url, onload, undefined, undefined, true, onerror);
  33544. };
  33545. Engine.prototype._cascadeLoadFiles = function (scene, onfinish, files, onError) {
  33546. if (onError === void 0) { onError = null; }
  33547. var loadedFiles = [];
  33548. loadedFiles._internalCount = 0;
  33549. for (var index = 0; index < 6; index++) {
  33550. this._partialLoadFile(files[index], index, loadedFiles, onfinish, onError);
  33551. }
  33552. };
  33553. // Statics
  33554. /**
  33555. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  33556. * @returns true if the engine can be created
  33557. * @ignorenaming
  33558. */
  33559. Engine.isSupported = function () {
  33560. try {
  33561. var tempcanvas = document.createElement("canvas");
  33562. var gl = tempcanvas.getContext("webgl") || tempcanvas.getContext("experimental-webgl");
  33563. return gl != null && !!window.WebGLRenderingContext;
  33564. }
  33565. catch (e) {
  33566. return false;
  33567. }
  33568. };
  33569. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  33570. Engine.ExceptionList = [
  33571. { key: "Chrome/63.0", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] },
  33572. { key: "Firefox/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  33573. { key: "Firefox/59", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  33574. { key: "Macintosh", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  33575. { key: "iPhone", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  33576. { key: "iPad", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] }
  33577. ];
  33578. /**
  33579. * Hidden
  33580. */
  33581. Engine._TextureLoaders = [];
  33582. // Const statics
  33583. /** Defines that alpha blending is disabled */
  33584. Engine.ALPHA_DISABLE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_DISABLE;
  33585. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33586. Engine.ALPHA_ADD = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ADD;
  33587. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33588. Engine.ALPHA_COMBINE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_COMBINE;
  33589. /** Defines that alpha blending to DEST - SRC * DEST */
  33590. Engine.ALPHA_SUBTRACT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SUBTRACT;
  33591. /** Defines that alpha blending to SRC * DEST */
  33592. Engine.ALPHA_MULTIPLY = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MULTIPLY;
  33593. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33594. Engine.ALPHA_MAXIMIZED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MAXIMIZED;
  33595. /** Defines that alpha blending to SRC + DEST */
  33596. Engine.ALPHA_ONEONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ONEONE;
  33597. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33598. Engine.ALPHA_PREMULTIPLIED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED;
  33599. /**
  33600. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33601. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33602. */
  33603. Engine.ALPHA_PREMULTIPLIED_PORTERDUFF = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  33604. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33605. Engine.ALPHA_INTERPOLATE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_INTERPOLATE;
  33606. /**
  33607. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33608. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33609. */
  33610. Engine.ALPHA_SCREENMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SCREENMODE;
  33611. /** Defines that the ressource is not delayed*/
  33612. Engine.DELAYLOADSTATE_NONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NONE;
  33613. /** Defines that the ressource was successfully delay loaded */
  33614. Engine.DELAYLOADSTATE_LOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADED;
  33615. /** Defines that the ressource is currently delay loading */
  33616. Engine.DELAYLOADSTATE_LOADING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADING;
  33617. /** Defines that the ressource is delayed and has not started loading */
  33618. Engine.DELAYLOADSTATE_NOTLOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NOTLOADED;
  33619. // Depht or Stencil test Constants.
  33620. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33621. Engine.NEVER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NEVER;
  33622. /** 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 */
  33623. Engine.ALWAYS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALWAYS;
  33624. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33625. Engine.LESS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LESS;
  33626. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33627. Engine.EQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].EQUAL;
  33628. /** 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 */
  33629. Engine.LEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LEQUAL;
  33630. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33631. Engine.GREATER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GREATER;
  33632. /** 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 */
  33633. Engine.GEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GEQUAL;
  33634. /** 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 */
  33635. Engine.NOTEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NOTEQUAL;
  33636. // Stencil Actions Constants.
  33637. /** Passed to stencilOperation to specify that stencil value must be kept */
  33638. Engine.KEEP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].KEEP;
  33639. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33640. Engine.REPLACE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].REPLACE;
  33641. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33642. Engine.INCR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR;
  33643. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33644. Engine.DECR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR;
  33645. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33646. Engine.INVERT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INVERT;
  33647. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33648. Engine.INCR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR_WRAP;
  33649. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33650. Engine.DECR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR_WRAP;
  33651. /** Texture is not repeating outside of 0..1 UVs */
  33652. Engine.TEXTURE_CLAMP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  33653. /** Texture is repeating outside of 0..1 UVs */
  33654. Engine.TEXTURE_WRAP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  33655. /** Texture is repeating and mirrored */
  33656. Engine.TEXTURE_MIRROR_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  33657. /** ALPHA */
  33658. Engine.TEXTUREFORMAT_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_ALPHA;
  33659. /** LUMINANCE */
  33660. Engine.TEXTUREFORMAT_LUMINANCE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE;
  33661. /** LUMINANCE_ALPHA */
  33662. Engine.TEXTUREFORMAT_LUMINANCE_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA;
  33663. /** RGB */
  33664. Engine.TEXTUREFORMAT_RGB = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB;
  33665. /** RGBA */
  33666. Engine.TEXTUREFORMAT_RGBA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA;
  33667. /** RED */
  33668. Engine.TEXTUREFORMAT_RED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED;
  33669. /** RED (2nd reference) */
  33670. Engine.TEXTUREFORMAT_R = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R;
  33671. /** RG */
  33672. Engine.TEXTUREFORMAT_RG = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG;
  33673. /** RED_INTEGER */
  33674. Engine.TEXTUREFORMAT_RED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED_INTEGER;
  33675. /** RED_INTEGER (2nd reference) */
  33676. Engine.TEXTUREFORMAT_R_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R_INTEGER;
  33677. /** RG_INTEGER */
  33678. Engine.TEXTUREFORMAT_RG_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG_INTEGER;
  33679. /** RGB_INTEGER */
  33680. Engine.TEXTUREFORMAT_RGB_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB_INTEGER;
  33681. /** RGBA_INTEGER */
  33682. Engine.TEXTUREFORMAT_RGBA_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA_INTEGER;
  33683. /** UNSIGNED_BYTE */
  33684. Engine.TEXTURETYPE_UNSIGNED_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_BYTE;
  33685. /** UNSIGNED_BYTE (2nd reference) */
  33686. Engine.TEXTURETYPE_UNSIGNED_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  33687. /** FLOAT */
  33688. Engine.TEXTURETYPE_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT;
  33689. /** HALF_FLOAT */
  33690. Engine.TEXTURETYPE_HALF_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_HALF_FLOAT;
  33691. /** BYTE */
  33692. Engine.TEXTURETYPE_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_BYTE;
  33693. /** SHORT */
  33694. Engine.TEXTURETYPE_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_SHORT;
  33695. /** UNSIGNED_SHORT */
  33696. Engine.TEXTURETYPE_UNSIGNED_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT;
  33697. /** INT */
  33698. Engine.TEXTURETYPE_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_INT;
  33699. /** UNSIGNED_INT */
  33700. Engine.TEXTURETYPE_UNSIGNED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INTEGER;
  33701. /** UNSIGNED_SHORT_4_4_4_4 */
  33702. Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4;
  33703. /** UNSIGNED_SHORT_5_5_5_1 */
  33704. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1;
  33705. /** UNSIGNED_SHORT_5_6_5 */
  33706. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_6_5;
  33707. /** UNSIGNED_INT_2_10_10_10_REV */
  33708. Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV;
  33709. /** UNSIGNED_INT_24_8 */
  33710. Engine.TEXTURETYPE_UNSIGNED_INT_24_8 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_24_8;
  33711. /** UNSIGNED_INT_10F_11F_11F_REV */
  33712. Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV;
  33713. /** UNSIGNED_INT_5_9_9_9_REV */
  33714. Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV;
  33715. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33716. Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV;
  33717. /** nearest is mag = nearest and min = nearest and mip = linear */
  33718. Engine.TEXTURE_NEAREST_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  33719. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33720. Engine.TEXTURE_BILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  33721. /** Trilinear is mag = linear and min = linear and mip = linear */
  33722. Engine.TEXTURE_TRILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  33723. /** nearest is mag = nearest and min = nearest and mip = linear */
  33724. Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPLINEAR;
  33725. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33726. Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPNEAREST;
  33727. /** Trilinear is mag = linear and min = linear and mip = linear */
  33728. Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPLINEAR;
  33729. /** mag = nearest and min = nearest and mip = nearest */
  33730. Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  33731. /** mag = nearest and min = linear and mip = nearest */
  33732. Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  33733. /** mag = nearest and min = linear and mip = linear */
  33734. Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  33735. /** mag = nearest and min = linear and mip = none */
  33736. Engine.TEXTURE_NEAREST_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR;
  33737. /** mag = nearest and min = nearest and mip = none */
  33738. Engine.TEXTURE_NEAREST_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST;
  33739. /** mag = linear and min = nearest and mip = nearest */
  33740. Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  33741. /** mag = linear and min = nearest and mip = linear */
  33742. Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  33743. /** mag = linear and min = linear and mip = none */
  33744. Engine.TEXTURE_LINEAR_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR;
  33745. /** mag = linear and min = nearest and mip = none */
  33746. Engine.TEXTURE_LINEAR_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST;
  33747. /** Explicit coordinates mode */
  33748. Engine.TEXTURE_EXPLICIT_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EXPLICIT_MODE;
  33749. /** Spherical coordinates mode */
  33750. Engine.TEXTURE_SPHERICAL_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SPHERICAL_MODE;
  33751. /** Planar coordinates mode */
  33752. Engine.TEXTURE_PLANAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PLANAR_MODE;
  33753. /** Cubic coordinates mode */
  33754. Engine.TEXTURE_CUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CUBIC_MODE;
  33755. /** Projection coordinates mode */
  33756. Engine.TEXTURE_PROJECTION_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PROJECTION_MODE;
  33757. /** Skybox coordinates mode */
  33758. Engine.TEXTURE_SKYBOX_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SKYBOX_MODE;
  33759. /** Inverse Cubic coordinates mode */
  33760. Engine.TEXTURE_INVCUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_INVCUBIC_MODE;
  33761. /** Equirectangular coordinates mode */
  33762. Engine.TEXTURE_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  33763. /** Equirectangular Fixed coordinates mode */
  33764. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  33765. /** Equirectangular Fixed Mirrored coordinates mode */
  33766. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  33767. // Texture rescaling mode
  33768. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33769. Engine.SCALEMODE_FLOOR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_FLOOR;
  33770. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33771. Engine.SCALEMODE_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_NEAREST;
  33772. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33773. Engine.SCALEMODE_CEILING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_CEILING;
  33774. // Updatable statics so stick with vars here
  33775. /**
  33776. * Gets or sets the epsilon value used by collision engine
  33777. */
  33778. Engine.CollisionsEpsilon = 0.001;
  33779. /**
  33780. * Method called to create the default rescale post process on each engine.
  33781. */
  33782. Engine._RescalePostProcessFactory = null;
  33783. return Engine;
  33784. }());
  33785. /***/ }),
  33786. /***/ "./Engines/engineStore.ts":
  33787. /*!********************************!*\
  33788. !*** ./Engines/engineStore.ts ***!
  33789. \********************************/
  33790. /*! exports provided: EngineStore */
  33791. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33792. "use strict";
  33793. __webpack_require__.r(__webpack_exports__);
  33794. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return EngineStore; });
  33795. /**
  33796. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33797. * during the life time of the application.
  33798. */
  33799. var EngineStore = /** @class */ (function () {
  33800. function EngineStore() {
  33801. }
  33802. Object.defineProperty(EngineStore, "LastCreatedEngine", {
  33803. /**
  33804. * Gets the latest created engine
  33805. */
  33806. get: function () {
  33807. if (this.Instances.length === 0) {
  33808. return null;
  33809. }
  33810. return this.Instances[this.Instances.length - 1];
  33811. },
  33812. enumerable: true,
  33813. configurable: true
  33814. });
  33815. Object.defineProperty(EngineStore, "LastCreatedScene", {
  33816. /**
  33817. * Gets the latest created scene
  33818. */
  33819. get: function () {
  33820. var lastCreatedEngine = this.LastCreatedEngine;
  33821. if (!lastCreatedEngine) {
  33822. return null;
  33823. }
  33824. if (lastCreatedEngine.scenes.length === 0) {
  33825. return null;
  33826. }
  33827. return lastCreatedEngine.scenes[lastCreatedEngine.scenes.length - 1];
  33828. },
  33829. enumerable: true,
  33830. configurable: true
  33831. });
  33832. /** Gets the list of created engines */
  33833. EngineStore.Instances = new Array();
  33834. return EngineStore;
  33835. }());
  33836. /***/ }),
  33837. /***/ "./Engines/index.ts":
  33838. /*!**************************!*\
  33839. !*** ./Engines/index.ts ***!
  33840. \**************************/
  33841. /*! exports provided: Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  33842. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33843. "use strict";
  33844. __webpack_require__.r(__webpack_exports__);
  33845. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  33846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _constants__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  33847. /* harmony import */ var _engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine */ "./Engines/engine.ts");
  33848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["InstancingAttributeInfo"]; });
  33849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["DepthTextureCreationOptions"]; });
  33850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["EngineCapabilities"]; });
  33851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]; });
  33852. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  33853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"]; });
  33854. /* harmony import */ var _nullEngine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nullEngine */ "./Engines/nullEngine.ts");
  33855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngineOptions"]; });
  33856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngine"]; });
  33857. /* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Extensions/index */ "./Engines/Extensions/index.ts");
  33858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_OcclusionDataStorage"]; });
  33859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_forceTransformFeedbackToBundle"]; });
  33860. /***/ }),
  33861. /***/ "./Engines/nullEngine.ts":
  33862. /*!*******************************!*\
  33863. !*** ./Engines/nullEngine.ts ***!
  33864. \*******************************/
  33865. /*! exports provided: NullEngineOptions, NullEngine */
  33866. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33867. "use strict";
  33868. __webpack_require__.r(__webpack_exports__);
  33869. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return NullEngineOptions; });
  33870. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return NullEngine; });
  33871. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  33872. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  33873. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  33874. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  33875. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  33876. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  33877. /**
  33878. * Options to create the null engine
  33879. */
  33880. var NullEngineOptions = /** @class */ (function () {
  33881. function NullEngineOptions() {
  33882. /**
  33883. * Render width (Default: 512)
  33884. */
  33885. this.renderWidth = 512;
  33886. /**
  33887. * Render height (Default: 256)
  33888. */
  33889. this.renderHeight = 256;
  33890. /**
  33891. * Texture size (Default: 512)
  33892. */
  33893. this.textureSize = 512;
  33894. /**
  33895. * If delta time between frames should be constant
  33896. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33897. */
  33898. this.deterministicLockstep = false;
  33899. /**
  33900. * Maximum about of steps between frames (Default: 4)
  33901. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33902. */
  33903. this.lockstepMaxSteps = 4;
  33904. }
  33905. return NullEngineOptions;
  33906. }());
  33907. /**
  33908. * The null engine class provides support for headless version of babylon.js.
  33909. * This can be used in server side scenario or for testing purposes
  33910. */
  33911. var NullEngine = /** @class */ (function (_super) {
  33912. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NullEngine, _super);
  33913. function NullEngine(options) {
  33914. if (options === void 0) { options = new NullEngineOptions(); }
  33915. var _this = _super.call(this, null) || this;
  33916. if (options.deterministicLockstep === undefined) {
  33917. options.deterministicLockstep = false;
  33918. }
  33919. if (options.lockstepMaxSteps === undefined) {
  33920. options.lockstepMaxSteps = 4;
  33921. }
  33922. _this._options = options;
  33923. // Init caps
  33924. // We consider we are on a webgl1 capable device
  33925. _this._caps = new _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["EngineCapabilities"]();
  33926. _this._caps.maxTexturesImageUnits = 16;
  33927. _this._caps.maxVertexTextureImageUnits = 16;
  33928. _this._caps.maxTextureSize = 512;
  33929. _this._caps.maxCubemapTextureSize = 512;
  33930. _this._caps.maxRenderTextureSize = 512;
  33931. _this._caps.maxVertexAttribs = 16;
  33932. _this._caps.maxVaryingVectors = 16;
  33933. _this._caps.maxFragmentUniformVectors = 16;
  33934. _this._caps.maxVertexUniformVectors = 16;
  33935. // Extensions
  33936. _this._caps.standardDerivatives = false;
  33937. _this._caps.astc = null;
  33938. _this._caps.s3tc = null;
  33939. _this._caps.pvrtc = null;
  33940. _this._caps.etc1 = null;
  33941. _this._caps.etc2 = null;
  33942. _this._caps.textureAnisotropicFilterExtension = null;
  33943. _this._caps.maxAnisotropy = 0;
  33944. _this._caps.uintIndices = false;
  33945. _this._caps.fragmentDepthSupported = false;
  33946. _this._caps.highPrecisionShaderSupported = true;
  33947. _this._caps.colorBufferFloat = false;
  33948. _this._caps.textureFloat = false;
  33949. _this._caps.textureFloatLinearFiltering = false;
  33950. _this._caps.textureFloatRender = false;
  33951. _this._caps.textureHalfFloat = false;
  33952. _this._caps.textureHalfFloatLinearFiltering = false;
  33953. _this._caps.textureHalfFloatRender = false;
  33954. _this._caps.textureLOD = false;
  33955. _this._caps.drawBuffersExtension = false;
  33956. _this._caps.depthTextureExtension = false;
  33957. _this._caps.vertexArrayObject = false;
  33958. _this._caps.instancedArrays = false;
  33959. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("Babylon.js v" + _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].Version + " - Null engine");
  33960. // Wrappers
  33961. if (typeof URL === "undefined") {
  33962. URL = {
  33963. createObjectURL: function () { },
  33964. revokeObjectURL: function () { }
  33965. };
  33966. }
  33967. if (typeof Blob === "undefined") {
  33968. Blob = function () { };
  33969. }
  33970. return _this;
  33971. }
  33972. /**
  33973. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33974. */
  33975. NullEngine.prototype.isDeterministicLockStep = function () {
  33976. return this._options.deterministicLockstep;
  33977. };
  33978. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  33979. NullEngine.prototype.getLockstepMaxSteps = function () {
  33980. return this._options.lockstepMaxSteps;
  33981. };
  33982. /**
  33983. * Sets hardware scaling, used to save performance if needed
  33984. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  33985. */
  33986. NullEngine.prototype.getHardwareScalingLevel = function () {
  33987. return 1.0;
  33988. };
  33989. NullEngine.prototype.createVertexBuffer = function (vertices) {
  33990. return {
  33991. capacity: 0,
  33992. references: 1,
  33993. is32Bits: false
  33994. };
  33995. };
  33996. NullEngine.prototype.createIndexBuffer = function (indices) {
  33997. return {
  33998. capacity: 0,
  33999. references: 1,
  34000. is32Bits: false
  34001. };
  34002. };
  34003. NullEngine.prototype.clear = function (color, backBuffer, depth, stencil) {
  34004. if (stencil === void 0) { stencil = false; }
  34005. };
  34006. NullEngine.prototype.getRenderWidth = function (useScreen) {
  34007. if (useScreen === void 0) { useScreen = false; }
  34008. if (!useScreen && this._currentRenderTarget) {
  34009. return this._currentRenderTarget.width;
  34010. }
  34011. return this._options.renderWidth;
  34012. };
  34013. NullEngine.prototype.getRenderHeight = function (useScreen) {
  34014. if (useScreen === void 0) { useScreen = false; }
  34015. if (!useScreen && this._currentRenderTarget) {
  34016. return this._currentRenderTarget.height;
  34017. }
  34018. return this._options.renderHeight;
  34019. };
  34020. NullEngine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  34021. this._cachedViewport = viewport;
  34022. };
  34023. NullEngine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context) {
  34024. return {
  34025. transformFeedback: null,
  34026. __SPECTOR_rebuildProgram: null,
  34027. isParallelCompiled: false
  34028. };
  34029. };
  34030. NullEngine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  34031. return [];
  34032. };
  34033. NullEngine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  34034. return [];
  34035. };
  34036. NullEngine.prototype.bindSamplers = function (effect) {
  34037. this._currentEffect = null;
  34038. };
  34039. NullEngine.prototype.enableEffect = function (effect) {
  34040. this._currentEffect = effect;
  34041. if (effect.onBind) {
  34042. effect.onBind(effect);
  34043. }
  34044. if (effect._onBindObservable) {
  34045. effect._onBindObservable.notifyObservers(effect);
  34046. }
  34047. };
  34048. NullEngine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  34049. if (zOffset === void 0) { zOffset = 0; }
  34050. if (reverseSide === void 0) { reverseSide = false; }
  34051. };
  34052. NullEngine.prototype.setIntArray = function (uniform, array) {
  34053. };
  34054. NullEngine.prototype.setIntArray2 = function (uniform, array) {
  34055. };
  34056. NullEngine.prototype.setIntArray3 = function (uniform, array) {
  34057. };
  34058. NullEngine.prototype.setIntArray4 = function (uniform, array) {
  34059. };
  34060. NullEngine.prototype.setFloatArray = function (uniform, array) {
  34061. };
  34062. NullEngine.prototype.setFloatArray2 = function (uniform, array) {
  34063. };
  34064. NullEngine.prototype.setFloatArray3 = function (uniform, array) {
  34065. };
  34066. NullEngine.prototype.setFloatArray4 = function (uniform, array) {
  34067. };
  34068. NullEngine.prototype.setArray = function (uniform, array) {
  34069. };
  34070. NullEngine.prototype.setArray2 = function (uniform, array) {
  34071. };
  34072. NullEngine.prototype.setArray3 = function (uniform, array) {
  34073. };
  34074. NullEngine.prototype.setArray4 = function (uniform, array) {
  34075. };
  34076. NullEngine.prototype.setMatrices = function (uniform, matrices) {
  34077. };
  34078. NullEngine.prototype.setMatrix = function (uniform, matrix) {
  34079. };
  34080. NullEngine.prototype.setMatrix3x3 = function (uniform, matrix) {
  34081. };
  34082. NullEngine.prototype.setMatrix2x2 = function (uniform, matrix) {
  34083. };
  34084. NullEngine.prototype.setFloat = function (uniform, value) {
  34085. };
  34086. NullEngine.prototype.setFloat2 = function (uniform, x, y) {
  34087. };
  34088. NullEngine.prototype.setFloat3 = function (uniform, x, y, z) {
  34089. };
  34090. NullEngine.prototype.setBool = function (uniform, bool) {
  34091. };
  34092. NullEngine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  34093. };
  34094. NullEngine.prototype.setColor3 = function (uniform, color3) {
  34095. };
  34096. NullEngine.prototype.setColor4 = function (uniform, color3, alpha) {
  34097. };
  34098. NullEngine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  34099. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  34100. if (this._alphaMode === mode) {
  34101. return;
  34102. }
  34103. this._alphaState.alphaBlend = (mode !== _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  34104. if (!noDepthWriteChange) {
  34105. this.setDepthWrite(mode === _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  34106. }
  34107. this._alphaMode = mode;
  34108. };
  34109. NullEngine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  34110. };
  34111. NullEngine.prototype.wipeCaches = function (bruteForce) {
  34112. if (this.preventCacheWipeBetweenFrames) {
  34113. return;
  34114. }
  34115. this.resetTextureCache();
  34116. this._currentEffect = null;
  34117. if (bruteForce) {
  34118. this._currentProgram = null;
  34119. this._stencilState.reset();
  34120. this._depthCullingState.reset();
  34121. this._alphaState.reset();
  34122. }
  34123. this._cachedVertexBuffers = null;
  34124. this._cachedIndexBuffer = null;
  34125. this._cachedEffectForVertexBuffers = null;
  34126. };
  34127. NullEngine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  34128. };
  34129. NullEngine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  34130. };
  34131. NullEngine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  34132. };
  34133. /** @hidden */
  34134. NullEngine.prototype._createTexture = function () {
  34135. return {};
  34136. };
  34137. /** @hidden */
  34138. NullEngine.prototype._releaseTexture = function (texture) {
  34139. };
  34140. NullEngine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallBack, format) {
  34141. if (samplingMode === void 0) { samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  34142. if (onLoad === void 0) { onLoad = null; }
  34143. if (onError === void 0) { onError = null; }
  34144. if (buffer === void 0) { buffer = null; }
  34145. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_URL);
  34146. var url = String(urlArg);
  34147. texture.url = url;
  34148. texture.generateMipMaps = !noMipmap;
  34149. texture.samplingMode = samplingMode;
  34150. texture.invertY = invertY;
  34151. texture.baseWidth = this._options.textureSize;
  34152. texture.baseHeight = this._options.textureSize;
  34153. texture.width = this._options.textureSize;
  34154. texture.height = this._options.textureSize;
  34155. if (format) {
  34156. texture.format = format;
  34157. }
  34158. texture.isReady = true;
  34159. if (onLoad) {
  34160. onLoad();
  34161. }
  34162. this._internalTexturesCache.push(texture);
  34163. return texture;
  34164. };
  34165. NullEngine.prototype.createRenderTargetTexture = function (size, options) {
  34166. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__["RenderTargetCreationOptions"]();
  34167. if (options !== undefined && typeof options === "object") {
  34168. fullOptions.generateMipMaps = options.generateMipMaps;
  34169. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  34170. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  34171. fullOptions.type = options.type === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT : options.type;
  34172. fullOptions.samplingMode = options.samplingMode === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  34173. }
  34174. else {
  34175. fullOptions.generateMipMaps = options;
  34176. fullOptions.generateDepthBuffer = true;
  34177. fullOptions.generateStencilBuffer = false;
  34178. fullOptions.type = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  34179. fullOptions.samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  34180. }
  34181. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_RENDERTARGET);
  34182. var width = size.width || size;
  34183. var height = size.height || size;
  34184. texture._depthStencilBuffer = {};
  34185. texture._framebuffer = {};
  34186. texture.baseWidth = width;
  34187. texture.baseHeight = height;
  34188. texture.width = width;
  34189. texture.height = height;
  34190. texture.isReady = true;
  34191. texture.samples = 1;
  34192. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  34193. texture.samplingMode = fullOptions.samplingMode;
  34194. texture.type = fullOptions.type;
  34195. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  34196. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  34197. this._internalTexturesCache.push(texture);
  34198. return texture;
  34199. };
  34200. NullEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  34201. texture.samplingMode = samplingMode;
  34202. };
  34203. NullEngine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {
  34204. if (this._currentRenderTarget) {
  34205. this.unBindFramebuffer(this._currentRenderTarget);
  34206. }
  34207. this._currentRenderTarget = texture;
  34208. this._currentFramebuffer = texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer;
  34209. if (this._cachedViewport && !forceFullscreenViewport) {
  34210. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  34211. }
  34212. };
  34213. NullEngine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  34214. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  34215. this._currentRenderTarget = null;
  34216. if (onBeforeUnbind) {
  34217. if (texture._MSAAFramebuffer) {
  34218. this._currentFramebuffer = texture._framebuffer;
  34219. }
  34220. onBeforeUnbind();
  34221. }
  34222. this._currentFramebuffer = null;
  34223. };
  34224. NullEngine.prototype.createDynamicVertexBuffer = function (vertices) {
  34225. var vbo = {
  34226. capacity: 1,
  34227. references: 1,
  34228. is32Bits: false
  34229. };
  34230. return vbo;
  34231. };
  34232. NullEngine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format) {
  34233. if (premulAlpha === void 0) { premulAlpha = false; }
  34234. };
  34235. NullEngine.prototype.areAllEffectsReady = function () {
  34236. return true;
  34237. };
  34238. /**
  34239. * @hidden
  34240. * Get the current error code of the webGL context
  34241. * @returns the error code
  34242. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  34243. */
  34244. NullEngine.prototype.getError = function () {
  34245. return 0;
  34246. };
  34247. /** @hidden */
  34248. NullEngine.prototype._getUnpackAlignement = function () {
  34249. return 1;
  34250. };
  34251. /** @hidden */
  34252. NullEngine.prototype._unpackFlipY = function (value) {
  34253. };
  34254. NullEngine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  34255. if (offset === void 0) { offset = 0; }
  34256. };
  34257. /**
  34258. * Updates a dynamic vertex buffer.
  34259. * @param vertexBuffer the vertex buffer to update
  34260. * @param data the data used to update the vertex buffer
  34261. * @param byteOffset the byte offset of the data (optional)
  34262. * @param byteLength the byte length of the data (optional)
  34263. */
  34264. NullEngine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, vertices, byteOffset, byteLength) {
  34265. };
  34266. NullEngine.prototype._bindTextureDirectly = function (target, texture) {
  34267. if (this._boundTexturesCache[this._activeChannel] !== texture) {
  34268. this._boundTexturesCache[this._activeChannel] = texture;
  34269. return true;
  34270. }
  34271. return false;
  34272. };
  34273. /** @hidden */
  34274. NullEngine.prototype._bindTexture = function (channel, texture) {
  34275. if (channel < 0) {
  34276. return;
  34277. }
  34278. this._bindTextureDirectly(0, texture);
  34279. };
  34280. /** @hidden */
  34281. NullEngine.prototype._releaseBuffer = function (buffer) {
  34282. buffer.references--;
  34283. if (buffer.references === 0) {
  34284. return true;
  34285. }
  34286. return false;
  34287. };
  34288. NullEngine.prototype.releaseEffects = function () {
  34289. };
  34290. NullEngine.prototype.displayLoadingUI = function () {
  34291. };
  34292. NullEngine.prototype.hideLoadingUI = function () {
  34293. };
  34294. /** @hidden */
  34295. NullEngine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  34296. if (faceIndex === void 0) { faceIndex = 0; }
  34297. if (lod === void 0) { lod = 0; }
  34298. };
  34299. /** @hidden */
  34300. NullEngine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  34301. if (faceIndex === void 0) { faceIndex = 0; }
  34302. if (lod === void 0) { lod = 0; }
  34303. };
  34304. /** @hidden */
  34305. NullEngine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  34306. if (faceIndex === void 0) { faceIndex = 0; }
  34307. if (lod === void 0) { lod = 0; }
  34308. };
  34309. /** @hidden */
  34310. NullEngine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  34311. if (faceIndex === void 0) { faceIndex = 0; }
  34312. if (lod === void 0) { lod = 0; }
  34313. };
  34314. return NullEngine;
  34315. }(_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"]));
  34316. /***/ }),
  34317. /***/ "./Events/clipboardEvents.ts":
  34318. /*!***********************************!*\
  34319. !*** ./Events/clipboardEvents.ts ***!
  34320. \***********************************/
  34321. /*! exports provided: ClipboardEventTypes, ClipboardInfo */
  34322. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34323. "use strict";
  34324. __webpack_require__.r(__webpack_exports__);
  34325. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return ClipboardEventTypes; });
  34326. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return ClipboardInfo; });
  34327. /**
  34328. * Gather the list of clipboard event types as constants.
  34329. */
  34330. var ClipboardEventTypes = /** @class */ (function () {
  34331. function ClipboardEventTypes() {
  34332. }
  34333. /**
  34334. * The clipboard event is fired when a copy command is active (pressed).
  34335. */
  34336. ClipboardEventTypes.COPY = 0x01; //
  34337. /**
  34338. * The clipboard event is fired when a cut command is active (pressed).
  34339. */
  34340. ClipboardEventTypes.CUT = 0x02;
  34341. /**
  34342. * The clipboard event is fired when a paste command is active (pressed).
  34343. */
  34344. ClipboardEventTypes.PASTE = 0x03;
  34345. return ClipboardEventTypes;
  34346. }());
  34347. /**
  34348. * This class is used to store clipboard related info for the onClipboardObservable event.
  34349. */
  34350. var ClipboardInfo = /** @class */ (function () {
  34351. /**
  34352. *Creates an instance of ClipboardInfo.
  34353. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  34354. * @param event Defines the related dom event
  34355. */
  34356. function ClipboardInfo(
  34357. /**
  34358. * Defines the type of event (BABYLON.ClipboardEventTypes)
  34359. */
  34360. type,
  34361. /**
  34362. * Defines the related dom event
  34363. */
  34364. event) {
  34365. this.type = type;
  34366. this.event = event;
  34367. }
  34368. /**
  34369. * Get the clipboard event's type from the keycode.
  34370. * @param keyCode Defines the keyCode for the current keyboard event.
  34371. * @return {number}
  34372. */
  34373. ClipboardInfo.GetTypeFromCharacter = function (keyCode) {
  34374. var charCode = keyCode;
  34375. //TODO: add codes for extended ASCII
  34376. switch (charCode) {
  34377. case 67: return ClipboardEventTypes.COPY;
  34378. case 86: return ClipboardEventTypes.PASTE;
  34379. case 88: return ClipboardEventTypes.CUT;
  34380. default: return -1;
  34381. }
  34382. };
  34383. return ClipboardInfo;
  34384. }());
  34385. /***/ }),
  34386. /***/ "./Events/index.ts":
  34387. /*!*************************!*\
  34388. !*** ./Events/index.ts ***!
  34389. \*************************/
  34390. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo */
  34391. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34392. "use strict";
  34393. __webpack_require__.r(__webpack_exports__);
  34394. /* harmony import */ var _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./keyboardEvents */ "./Events/keyboardEvents.ts");
  34395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  34396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  34397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  34398. /* harmony import */ var _pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pointerEvents */ "./Events/pointerEvents.ts");
  34399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"]; });
  34400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoBase"]; });
  34401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoPre"]; });
  34402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfo"]; });
  34403. /* harmony import */ var _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./clipboardEvents */ "./Events/clipboardEvents.ts");
  34404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardEventTypes"]; });
  34405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardInfo"]; });
  34406. /***/ }),
  34407. /***/ "./Events/keyboardEvents.ts":
  34408. /*!**********************************!*\
  34409. !*** ./Events/keyboardEvents.ts ***!
  34410. \**********************************/
  34411. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre */
  34412. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34413. "use strict";
  34414. __webpack_require__.r(__webpack_exports__);
  34415. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return KeyboardEventTypes; });
  34416. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return KeyboardInfo; });
  34417. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return KeyboardInfoPre; });
  34418. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34419. /**
  34420. * Gather the list of keyboard event types as constants.
  34421. */
  34422. var KeyboardEventTypes = /** @class */ (function () {
  34423. function KeyboardEventTypes() {
  34424. }
  34425. /**
  34426. * The keydown event is fired when a key becomes active (pressed).
  34427. */
  34428. KeyboardEventTypes.KEYDOWN = 0x01;
  34429. /**
  34430. * The keyup event is fired when a key has been released.
  34431. */
  34432. KeyboardEventTypes.KEYUP = 0x02;
  34433. return KeyboardEventTypes;
  34434. }());
  34435. /**
  34436. * This class is used to store keyboard related info for the onKeyboardObservable event.
  34437. */
  34438. var KeyboardInfo = /** @class */ (function () {
  34439. /**
  34440. * Instantiates a new keyboard info.
  34441. * This class is used to store keyboard related info for the onKeyboardObservable event.
  34442. * @param type Defines the type of event (KeyboardEventTypes)
  34443. * @param event Defines the related dom event
  34444. */
  34445. function KeyboardInfo(
  34446. /**
  34447. * Defines the type of event (KeyboardEventTypes)
  34448. */
  34449. type,
  34450. /**
  34451. * Defines the related dom event
  34452. */
  34453. event) {
  34454. this.type = type;
  34455. this.event = event;
  34456. }
  34457. return KeyboardInfo;
  34458. }());
  34459. /**
  34460. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  34461. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  34462. */
  34463. var KeyboardInfoPre = /** @class */ (function (_super) {
  34464. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeyboardInfoPre, _super);
  34465. /**
  34466. * Instantiates a new keyboard pre info.
  34467. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  34468. * @param type Defines the type of event (KeyboardEventTypes)
  34469. * @param event Defines the related dom event
  34470. */
  34471. function KeyboardInfoPre(
  34472. /**
  34473. * Defines the type of event (KeyboardEventTypes)
  34474. */
  34475. type,
  34476. /**
  34477. * Defines the related dom event
  34478. */
  34479. event) {
  34480. var _this = _super.call(this, type, event) || this;
  34481. _this.type = type;
  34482. _this.event = event;
  34483. _this.skipOnPointerObservable = false;
  34484. return _this;
  34485. }
  34486. return KeyboardInfoPre;
  34487. }(KeyboardInfo));
  34488. /***/ }),
  34489. /***/ "./Events/pointerEvents.ts":
  34490. /*!*********************************!*\
  34491. !*** ./Events/pointerEvents.ts ***!
  34492. \*********************************/
  34493. /*! exports provided: PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo */
  34494. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34495. "use strict";
  34496. __webpack_require__.r(__webpack_exports__);
  34497. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return PointerEventTypes; });
  34498. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return PointerInfoBase; });
  34499. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return PointerInfoPre; });
  34500. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return PointerInfo; });
  34501. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34502. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  34503. /**
  34504. * Gather the list of pointer event types as constants.
  34505. */
  34506. var PointerEventTypes = /** @class */ (function () {
  34507. function PointerEventTypes() {
  34508. }
  34509. /**
  34510. * 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.
  34511. */
  34512. PointerEventTypes.POINTERDOWN = 0x01;
  34513. /**
  34514. * The pointerup event is fired when a pointer is no longer active.
  34515. */
  34516. PointerEventTypes.POINTERUP = 0x02;
  34517. /**
  34518. * The pointermove event is fired when a pointer changes coordinates.
  34519. */
  34520. PointerEventTypes.POINTERMOVE = 0x04;
  34521. /**
  34522. * The pointerwheel event is fired when a mouse wheel has been rotated.
  34523. */
  34524. PointerEventTypes.POINTERWHEEL = 0x08;
  34525. /**
  34526. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  34527. */
  34528. PointerEventTypes.POINTERPICK = 0x10;
  34529. /**
  34530. * The pointertap event is fired when a the object has been touched and released without drag.
  34531. */
  34532. PointerEventTypes.POINTERTAP = 0x20;
  34533. /**
  34534. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  34535. */
  34536. PointerEventTypes.POINTERDOUBLETAP = 0x40;
  34537. return PointerEventTypes;
  34538. }());
  34539. /**
  34540. * Base class of pointer info types.
  34541. */
  34542. var PointerInfoBase = /** @class */ (function () {
  34543. /**
  34544. * Instantiates the base class of pointers info.
  34545. * @param type Defines the type of event (PointerEventTypes)
  34546. * @param event Defines the related dom event
  34547. */
  34548. function PointerInfoBase(
  34549. /**
  34550. * Defines the type of event (PointerEventTypes)
  34551. */
  34552. type,
  34553. /**
  34554. * Defines the related dom event
  34555. */
  34556. event) {
  34557. this.type = type;
  34558. this.event = event;
  34559. }
  34560. return PointerInfoBase;
  34561. }());
  34562. /**
  34563. * This class is used to store pointer related info for the onPrePointerObservable event.
  34564. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  34565. */
  34566. var PointerInfoPre = /** @class */ (function (_super) {
  34567. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfoPre, _super);
  34568. /**
  34569. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  34570. * @param type Defines the type of event (PointerEventTypes)
  34571. * @param event Defines the related dom event
  34572. * @param localX Defines the local x coordinates of the pointer when the event occured
  34573. * @param localY Defines the local y coordinates of the pointer when the event occured
  34574. */
  34575. function PointerInfoPre(type, event, localX, localY) {
  34576. var _this = _super.call(this, type, event) || this;
  34577. /**
  34578. * Ray from a pointer if availible (eg. 6dof controller)
  34579. */
  34580. _this.ray = null;
  34581. _this.skipOnPointerObservable = false;
  34582. _this.localPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](localX, localY);
  34583. return _this;
  34584. }
  34585. return PointerInfoPre;
  34586. }(PointerInfoBase));
  34587. /**
  34588. * This type contains all the data related to a pointer event in Babylon.js.
  34589. * 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.
  34590. */
  34591. var PointerInfo = /** @class */ (function (_super) {
  34592. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfo, _super);
  34593. /**
  34594. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  34595. * @param type Defines the type of event (PointerEventTypes)
  34596. * @param event Defines the related dom event
  34597. * @param pickInfo Defines the picking info associated to the info (if any)\
  34598. */
  34599. function PointerInfo(type, event,
  34600. /**
  34601. * Defines the picking info associated to the info (if any)\
  34602. */
  34603. pickInfo) {
  34604. var _this = _super.call(this, type, event) || this;
  34605. _this.pickInfo = pickInfo;
  34606. return _this;
  34607. }
  34608. return PointerInfo;
  34609. }(PointerInfoBase));
  34610. /***/ }),
  34611. /***/ "./Gamepads/Controllers/daydreamController.ts":
  34612. /*!****************************************************!*\
  34613. !*** ./Gamepads/Controllers/daydreamController.ts ***!
  34614. \****************************************************/
  34615. /*! exports provided: DaydreamController */
  34616. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34617. "use strict";
  34618. __webpack_require__.r(__webpack_exports__);
  34619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return DaydreamController; });
  34620. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34621. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  34622. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34623. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34624. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34625. /**
  34626. * Google Daydream controller
  34627. */
  34628. var DaydreamController = /** @class */ (function (_super) {
  34629. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DaydreamController, _super);
  34630. /**
  34631. * Creates a new DaydreamController from a gamepad
  34632. * @param vrGamepad the gamepad that the controller should be created from
  34633. */
  34634. function DaydreamController(vrGamepad) {
  34635. var _this = _super.call(this, vrGamepad) || this;
  34636. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].DAYDREAM;
  34637. return _this;
  34638. }
  34639. /**
  34640. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34641. * @param scene scene in which to add meshes
  34642. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34643. */
  34644. DaydreamController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34645. var _this = this;
  34646. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", DaydreamController.MODEL_BASE_URL, DaydreamController.MODEL_FILENAME, scene, function (newMeshes) {
  34647. _this._defaultModel = newMeshes[1];
  34648. _this.attachToMesh(_this._defaultModel);
  34649. if (meshLoaded) {
  34650. meshLoaded(_this._defaultModel);
  34651. }
  34652. });
  34653. };
  34654. /**
  34655. * Called once for each button that changed state since the last frame
  34656. * @param buttonIdx Which button index changed
  34657. * @param state New state of the button
  34658. * @param changes Which properties on the state changed since last frame
  34659. */
  34660. DaydreamController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34661. // Daydream controller only has 1 GamepadButton (on the trackpad).
  34662. if (buttonIdx === 0) {
  34663. var observable = this.onTriggerStateChangedObservable;
  34664. if (observable) {
  34665. observable.notifyObservers(state);
  34666. }
  34667. }
  34668. else {
  34669. // If the app or home buttons are ever made available
  34670. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Unrecognized Daydream button index: " + buttonIdx);
  34671. }
  34672. };
  34673. /**
  34674. * Base Url for the controller model.
  34675. */
  34676. DaydreamController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  34677. /**
  34678. * File name for the controller model.
  34679. */
  34680. DaydreamController.MODEL_FILENAME = 'generic.babylon';
  34681. /**
  34682. * Gamepad Id prefix used to identify Daydream Controller.
  34683. */
  34684. DaydreamController.GAMEPAD_ID_PREFIX = 'Daydream'; // id is 'Daydream Controller'
  34685. return DaydreamController;
  34686. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  34687. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  34688. canCreate: function (gamepadInfo) {
  34689. return gamepadInfo.id.indexOf(DaydreamController.GAMEPAD_ID_PREFIX) === 0;
  34690. },
  34691. create: function (gamepadInfo) {
  34692. return new DaydreamController(gamepadInfo);
  34693. }
  34694. });
  34695. /***/ }),
  34696. /***/ "./Gamepads/Controllers/gearVRController.ts":
  34697. /*!**************************************************!*\
  34698. !*** ./Gamepads/Controllers/gearVRController.ts ***!
  34699. \**************************************************/
  34700. /*! exports provided: GearVRController */
  34701. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34702. "use strict";
  34703. __webpack_require__.r(__webpack_exports__);
  34704. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return GearVRController; });
  34705. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34706. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  34707. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  34708. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34709. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34710. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34711. /**
  34712. * Gear VR Controller
  34713. */
  34714. var GearVRController = /** @class */ (function (_super) {
  34715. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GearVRController, _super);
  34716. /**
  34717. * Creates a new GearVRController from a gamepad
  34718. * @param vrGamepad the gamepad that the controller should be created from
  34719. */
  34720. function GearVRController(vrGamepad) {
  34721. var _this = _super.call(this, vrGamepad) || this;
  34722. _this._buttonIndexToObservableNameMap = [
  34723. 'onTrackpadChangedObservable',
  34724. 'onTriggerStateChangedObservable' // Trigger
  34725. ];
  34726. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerType"].GEAR_VR;
  34727. // Initial starting position defaults to where hand would be (incase of only 3dof controller)
  34728. _this._calculatedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](_this.hand == "left" ? -0.15 : 0.15, -0.5, 0.25);
  34729. _this._disableTrackPosition(_this._calculatedPosition);
  34730. return _this;
  34731. }
  34732. /**
  34733. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34734. * @param scene scene in which to add meshes
  34735. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34736. */
  34737. GearVRController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34738. var _this = this;
  34739. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__["SceneLoader"].ImportMesh("", GearVRController.MODEL_BASE_URL, GearVRController.MODEL_FILENAME, scene, function (newMeshes) {
  34740. // Offset the controller so it will rotate around the users wrist
  34741. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", scene);
  34742. newMeshes[1].parent = mesh;
  34743. newMeshes[1].position.z = -0.15;
  34744. _this._defaultModel = mesh;
  34745. _this.attachToMesh(_this._defaultModel);
  34746. if (meshLoaded) {
  34747. meshLoaded(_this._defaultModel);
  34748. }
  34749. });
  34750. };
  34751. /**
  34752. * Called once for each button that changed state since the last frame
  34753. * @param buttonIdx Which button index changed
  34754. * @param state New state of the button
  34755. * @param changes Which properties on the state changed since last frame
  34756. */
  34757. GearVRController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34758. if (buttonIdx < this._buttonIndexToObservableNameMap.length) {
  34759. var observableName = this._buttonIndexToObservableNameMap[buttonIdx];
  34760. // Only emit events for buttons that we know how to map from index to observable
  34761. var observable = this[observableName];
  34762. if (observable) {
  34763. observable.notifyObservers(state);
  34764. }
  34765. }
  34766. };
  34767. /**
  34768. * Base Url for the controller model.
  34769. */
  34770. GearVRController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  34771. /**
  34772. * File name for the controller model.
  34773. */
  34774. GearVRController.MODEL_FILENAME = 'generic.babylon';
  34775. /**
  34776. * Gamepad Id prefix used to identify this controller.
  34777. */
  34778. GearVRController.GAMEPAD_ID_PREFIX = 'Gear VR'; // id is 'Gear VR Controller'
  34779. return GearVRController;
  34780. }(_webVRController__WEBPACK_IMPORTED_MODULE_4__["WebVRController"]));
  34781. _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  34782. canCreate: function (gamepadInfo) {
  34783. return gamepadInfo.id.indexOf(GearVRController.GAMEPAD_ID_PREFIX) === 0 ||
  34784. gamepadInfo.id.indexOf('Oculus Go') !== -1;
  34785. },
  34786. create: function (gamepadInfo) {
  34787. return new GearVRController(gamepadInfo);
  34788. }
  34789. });
  34790. /***/ }),
  34791. /***/ "./Gamepads/Controllers/genericController.ts":
  34792. /*!***************************************************!*\
  34793. !*** ./Gamepads/Controllers/genericController.ts ***!
  34794. \***************************************************/
  34795. /*! exports provided: GenericController */
  34796. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34797. "use strict";
  34798. __webpack_require__.r(__webpack_exports__);
  34799. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return GenericController; });
  34800. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34801. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34802. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34803. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34804. /**
  34805. * Generic Controller
  34806. */
  34807. var GenericController = /** @class */ (function (_super) {
  34808. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericController, _super);
  34809. /**
  34810. * Creates a new GenericController from a gamepad
  34811. * @param vrGamepad the gamepad that the controller should be created from
  34812. */
  34813. function GenericController(vrGamepad) {
  34814. return _super.call(this, vrGamepad) || this;
  34815. }
  34816. /**
  34817. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34818. * @param scene scene in which to add meshes
  34819. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34820. */
  34821. GenericController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34822. var _this = this;
  34823. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", GenericController.MODEL_BASE_URL, GenericController.MODEL_FILENAME, scene, function (newMeshes) {
  34824. _this._defaultModel = newMeshes[1];
  34825. _this.attachToMesh(_this._defaultModel);
  34826. if (meshLoaded) {
  34827. meshLoaded(_this._defaultModel);
  34828. }
  34829. });
  34830. };
  34831. /**
  34832. * Called once for each button that changed state since the last frame
  34833. * @param buttonIdx Which button index changed
  34834. * @param state New state of the button
  34835. * @param changes Which properties on the state changed since last frame
  34836. */
  34837. GenericController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34838. console.log("Button id: " + buttonIdx + "state: ");
  34839. console.dir(state);
  34840. };
  34841. /**
  34842. * Base Url for the controller model.
  34843. */
  34844. GenericController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  34845. /**
  34846. * File name for the controller model.
  34847. */
  34848. GenericController.MODEL_FILENAME = 'generic.babylon';
  34849. return GenericController;
  34850. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  34851. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._DefaultControllerFactory = function (gamepadInfo) { return new GenericController(gamepadInfo); };
  34852. /***/ }),
  34853. /***/ "./Gamepads/Controllers/index.ts":
  34854. /*!***************************************!*\
  34855. !*** ./Gamepads/Controllers/index.ts ***!
  34856. \***************************************/
  34857. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController */
  34858. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34859. "use strict";
  34860. __webpack_require__.r(__webpack_exports__);
  34861. /* harmony import */ var _daydreamController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./daydreamController */ "./Gamepads/Controllers/daydreamController.ts");
  34862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _daydreamController__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  34863. /* harmony import */ var _gearVRController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gearVRController */ "./Gamepads/Controllers/gearVRController.ts");
  34864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _gearVRController__WEBPACK_IMPORTED_MODULE_1__["GearVRController"]; });
  34865. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  34866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _genericController__WEBPACK_IMPORTED_MODULE_2__["GenericController"]; });
  34867. /* harmony import */ var _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./oculusTouchController */ "./Gamepads/Controllers/oculusTouchController.ts");
  34868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__["OculusTouchController"]; });
  34869. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"]; });
  34871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]; });
  34872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledController"]; });
  34873. /* harmony import */ var _viveController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./viveController */ "./Gamepads/Controllers/viveController.ts");
  34874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _viveController__WEBPACK_IMPORTED_MODULE_5__["ViveController"]; });
  34875. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _webVRController__WEBPACK_IMPORTED_MODULE_6__["WebVRController"]; });
  34877. /* harmony import */ var _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./windowsMotionController */ "./Gamepads/Controllers/windowsMotionController.ts");
  34878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__["WindowsMotionController"]; });
  34879. /***/ }),
  34880. /***/ "./Gamepads/Controllers/oculusTouchController.ts":
  34881. /*!*******************************************************!*\
  34882. !*** ./Gamepads/Controllers/oculusTouchController.ts ***!
  34883. \*******************************************************/
  34884. /*! exports provided: OculusTouchController */
  34885. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34886. "use strict";
  34887. __webpack_require__.r(__webpack_exports__);
  34888. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return OculusTouchController; });
  34889. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34890. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  34891. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34892. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34893. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34894. /**
  34895. * Oculus Touch Controller
  34896. */
  34897. var OculusTouchController = /** @class */ (function (_super) {
  34898. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](OculusTouchController, _super);
  34899. /**
  34900. * Creates a new OculusTouchController from a gamepad
  34901. * @param vrGamepad the gamepad that the controller should be created from
  34902. */
  34903. function OculusTouchController(vrGamepad) {
  34904. var _this = _super.call(this, vrGamepad) || this;
  34905. /**
  34906. * Fired when the secondary trigger on this controller is modified
  34907. */
  34908. _this.onSecondaryTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34909. /**
  34910. * Fired when the thumb rest on this controller is modified
  34911. */
  34912. _this.onThumbRestChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34913. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].OCULUS;
  34914. return _this;
  34915. }
  34916. /**
  34917. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34918. * @param scene scene in which to add meshes
  34919. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34920. */
  34921. OculusTouchController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34922. var _this = this;
  34923. var meshName;
  34924. // Hand
  34925. if (this.hand === 'left') {
  34926. meshName = OculusTouchController.MODEL_LEFT_FILENAME;
  34927. }
  34928. else { // Right is the default if no hand is specified
  34929. meshName = OculusTouchController.MODEL_RIGHT_FILENAME;
  34930. }
  34931. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", OculusTouchController.MODEL_BASE_URL, meshName, scene, function (newMeshes) {
  34932. /*
  34933. Parent Mesh name: oculus_touch_left
  34934. - body
  34935. - trigger
  34936. - thumbstick
  34937. - grip
  34938. - button_y
  34939. - button_x
  34940. - button_enter
  34941. */
  34942. _this._defaultModel = newMeshes[1];
  34943. _this.attachToMesh(_this._defaultModel);
  34944. if (meshLoaded) {
  34945. meshLoaded(_this._defaultModel);
  34946. }
  34947. });
  34948. };
  34949. Object.defineProperty(OculusTouchController.prototype, "onAButtonStateChangedObservable", {
  34950. /**
  34951. * Fired when the A button on this controller is modified
  34952. */
  34953. get: function () {
  34954. if (this.hand === 'right') {
  34955. return this.onMainButtonStateChangedObservable;
  34956. }
  34957. else {
  34958. throw new Error('No A button on left hand');
  34959. }
  34960. },
  34961. enumerable: true,
  34962. configurable: true
  34963. });
  34964. Object.defineProperty(OculusTouchController.prototype, "onBButtonStateChangedObservable", {
  34965. /**
  34966. * Fired when the B button on this controller is modified
  34967. */
  34968. get: function () {
  34969. if (this.hand === 'right') {
  34970. return this.onSecondaryButtonStateChangedObservable;
  34971. }
  34972. else {
  34973. throw new Error('No B button on left hand');
  34974. }
  34975. },
  34976. enumerable: true,
  34977. configurable: true
  34978. });
  34979. Object.defineProperty(OculusTouchController.prototype, "onXButtonStateChangedObservable", {
  34980. /**
  34981. * Fired when the X button on this controller is modified
  34982. */
  34983. get: function () {
  34984. if (this.hand === 'left') {
  34985. return this.onMainButtonStateChangedObservable;
  34986. }
  34987. else {
  34988. throw new Error('No X button on right hand');
  34989. }
  34990. },
  34991. enumerable: true,
  34992. configurable: true
  34993. });
  34994. Object.defineProperty(OculusTouchController.prototype, "onYButtonStateChangedObservable", {
  34995. /**
  34996. * Fired when the Y button on this controller is modified
  34997. */
  34998. get: function () {
  34999. if (this.hand === 'left') {
  35000. return this.onSecondaryButtonStateChangedObservable;
  35001. }
  35002. else {
  35003. throw new Error('No Y button on right hand');
  35004. }
  35005. },
  35006. enumerable: true,
  35007. configurable: true
  35008. });
  35009. /**
  35010. * Called once for each button that changed state since the last frame
  35011. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  35012. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  35013. * 2) secondary trigger (same)
  35014. * 3) A (right) X (left), touch, pressed = value
  35015. * 4) B / Y
  35016. * 5) thumb rest
  35017. * @param buttonIdx Which button index changed
  35018. * @param state New state of the button
  35019. * @param changes Which properties on the state changed since last frame
  35020. */
  35021. OculusTouchController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35022. var notifyObject = state; //{ state: state, changes: changes };
  35023. var triggerDirection = this.hand === 'right' ? -1 : 1;
  35024. switch (buttonIdx) {
  35025. case 0:
  35026. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  35027. return;
  35028. case 1: // index trigger
  35029. if (this._defaultModel) {
  35030. (this._defaultModel.getChildren()[3]).rotation.x = -notifyObject.value * 0.20;
  35031. (this._defaultModel.getChildren()[3]).position.y = -notifyObject.value * 0.005;
  35032. (this._defaultModel.getChildren()[3]).position.z = -notifyObject.value * 0.005;
  35033. }
  35034. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  35035. return;
  35036. case 2: // secondary trigger
  35037. if (this._defaultModel) {
  35038. (this._defaultModel.getChildren()[4]).position.x = triggerDirection * notifyObject.value * 0.0035;
  35039. }
  35040. this.onSecondaryTriggerStateChangedObservable.notifyObservers(notifyObject);
  35041. return;
  35042. case 3:
  35043. if (this._defaultModel) {
  35044. if (notifyObject.pressed) {
  35045. (this._defaultModel.getChildren()[1]).position.y = -0.001;
  35046. }
  35047. else {
  35048. (this._defaultModel.getChildren()[1]).position.y = 0;
  35049. }
  35050. }
  35051. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  35052. return;
  35053. case 4:
  35054. if (this._defaultModel) {
  35055. if (notifyObject.pressed) {
  35056. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  35057. }
  35058. else {
  35059. (this._defaultModel.getChildren()[2]).position.y = 0;
  35060. }
  35061. }
  35062. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  35063. return;
  35064. case 5:
  35065. this.onThumbRestChangedObservable.notifyObservers(notifyObject);
  35066. return;
  35067. }
  35068. };
  35069. /**
  35070. * Base Url for the controller model.
  35071. */
  35072. OculusTouchController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/oculus/';
  35073. /**
  35074. * File name for the left controller model.
  35075. */
  35076. OculusTouchController.MODEL_LEFT_FILENAME = 'left.babylon';
  35077. /**
  35078. * File name for the right controller model.
  35079. */
  35080. OculusTouchController.MODEL_RIGHT_FILENAME = 'right.babylon';
  35081. return OculusTouchController;
  35082. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  35083. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35084. canCreate: function (gamepadInfo) {
  35085. return gamepadInfo.id.indexOf('Oculus Touch') !== -1;
  35086. },
  35087. create: function (gamepadInfo) {
  35088. return new OculusTouchController(gamepadInfo);
  35089. }
  35090. });
  35091. /***/ }),
  35092. /***/ "./Gamepads/Controllers/poseEnabledController.ts":
  35093. /*!*******************************************************!*\
  35094. !*** ./Gamepads/Controllers/poseEnabledController.ts ***!
  35095. \*******************************************************/
  35096. /*! exports provided: PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController */
  35097. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35098. "use strict";
  35099. __webpack_require__.r(__webpack_exports__);
  35100. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return PoseEnabledControllerType; });
  35101. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return PoseEnabledControllerHelper; });
  35102. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return PoseEnabledController; });
  35103. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35104. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35105. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35106. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  35107. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  35108. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  35109. /**
  35110. * Defines the types of pose enabled controllers that are supported
  35111. */
  35112. var PoseEnabledControllerType;
  35113. (function (PoseEnabledControllerType) {
  35114. /**
  35115. * HTC Vive
  35116. */
  35117. PoseEnabledControllerType[PoseEnabledControllerType["VIVE"] = 0] = "VIVE";
  35118. /**
  35119. * Oculus Rift
  35120. */
  35121. PoseEnabledControllerType[PoseEnabledControllerType["OCULUS"] = 1] = "OCULUS";
  35122. /**
  35123. * Windows mixed reality
  35124. */
  35125. PoseEnabledControllerType[PoseEnabledControllerType["WINDOWS"] = 2] = "WINDOWS";
  35126. /**
  35127. * Samsung gear VR
  35128. */
  35129. PoseEnabledControllerType[PoseEnabledControllerType["GEAR_VR"] = 3] = "GEAR_VR";
  35130. /**
  35131. * Google Daydream
  35132. */
  35133. PoseEnabledControllerType[PoseEnabledControllerType["DAYDREAM"] = 4] = "DAYDREAM";
  35134. /**
  35135. * Generic
  35136. */
  35137. PoseEnabledControllerType[PoseEnabledControllerType["GENERIC"] = 5] = "GENERIC";
  35138. })(PoseEnabledControllerType || (PoseEnabledControllerType = {}));
  35139. /**
  35140. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  35141. */
  35142. var PoseEnabledControllerHelper = /** @class */ (function () {
  35143. function PoseEnabledControllerHelper() {
  35144. }
  35145. /**
  35146. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  35147. * @param vrGamepad the gamepad to initialized
  35148. * @returns a vr controller of the type the gamepad identified as
  35149. */
  35150. PoseEnabledControllerHelper.InitiateController = function (vrGamepad) {
  35151. for (var _i = 0, _a = this._ControllerFactories; _i < _a.length; _i++) {
  35152. var factory = _a[_i];
  35153. if (factory.canCreate(vrGamepad)) {
  35154. return factory.create(vrGamepad);
  35155. }
  35156. }
  35157. if (this._DefaultControllerFactory) {
  35158. return this._DefaultControllerFactory(vrGamepad);
  35159. }
  35160. throw "The type of gamepad you are trying to load needs to be imported first or is not supported.";
  35161. };
  35162. /** @hidden */
  35163. PoseEnabledControllerHelper._ControllerFactories = [];
  35164. /** @hidden */
  35165. PoseEnabledControllerHelper._DefaultControllerFactory = null;
  35166. return PoseEnabledControllerHelper;
  35167. }());
  35168. /**
  35169. * Defines the PoseEnabledController object that contains state of a vr capable controller
  35170. */
  35171. var PoseEnabledController = /** @class */ (function (_super) {
  35172. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PoseEnabledController, _super);
  35173. /**
  35174. * Creates a new PoseEnabledController from a gamepad
  35175. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  35176. */
  35177. function PoseEnabledController(browserGamepad) {
  35178. var _this = _super.call(this, browserGamepad.id, browserGamepad.index, browserGamepad) || this;
  35179. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  35180. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35181. _this._deviceRoomRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35182. /**
  35183. * The device position in babylon space
  35184. */
  35185. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35186. /**
  35187. * The device rotation in babylon space
  35188. */
  35189. _this.deviceRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35190. /**
  35191. * The scale factor of the device in babylon space
  35192. */
  35193. _this.deviceScaleFactor = 1;
  35194. // Used to convert 6dof controllers to 3dof
  35195. _this._trackPosition = true;
  35196. _this._maxRotationDistFromHeadset = Math.PI / 5;
  35197. _this._draggedRoomRotation = 0;
  35198. _this._leftHandSystemQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35199. /**
  35200. * Internal, matrix used to convert room space to babylon space
  35201. * @hidden
  35202. */
  35203. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  35204. /**
  35205. * Node to be used when casting a ray from the controller
  35206. * @hidden
  35207. */
  35208. _this._pointingPoseNode = null;
  35209. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  35210. /**
  35211. * @hidden
  35212. */
  35213. _this._meshAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35214. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED;
  35215. _this.controllerType = PoseEnabledControllerType.GENERIC;
  35216. _this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35217. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35218. _this._calculatedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35219. _this._calculatedRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35220. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(Math.PI, 0, 0, _this._leftHandSystemQuaternion);
  35221. return _this;
  35222. }
  35223. /**
  35224. * @hidden
  35225. */
  35226. PoseEnabledController.prototype._disableTrackPosition = function (fixedPosition) {
  35227. if (this._trackPosition) {
  35228. this._calculatedPosition.copyFrom(fixedPosition);
  35229. this._trackPosition = false;
  35230. }
  35231. };
  35232. /**
  35233. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  35234. */
  35235. PoseEnabledController.prototype.update = function () {
  35236. _super.prototype.update.call(this);
  35237. this._updatePoseAndMesh();
  35238. };
  35239. /**
  35240. * Updates only the pose device and mesh without doing any button event checking
  35241. */
  35242. PoseEnabledController.prototype._updatePoseAndMesh = function () {
  35243. var pose = this.browserGamepad.pose;
  35244. this.updateFromDevice(pose);
  35245. 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) {
  35246. var camera = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene.activeCamera;
  35247. camera._computeDevicePosition();
  35248. this._deviceToWorld.setTranslation(camera.devicePosition);
  35249. if (camera.deviceRotationQuaternion) {
  35250. var camera = camera;
  35251. camera._deviceRoomRotationQuaternion.toEulerAnglesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[0]);
  35252. // Find the radian distance away that the headset is from the controllers rotation
  35253. 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));
  35254. if (Math.abs(distanceAway) > this._maxRotationDistFromHeadset) {
  35255. // Only rotate enouph to be within the _maxRotationDistFromHeadset
  35256. var rotationAmount = distanceAway - (distanceAway < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset);
  35257. this._draggedRoomRotation += rotationAmount;
  35258. // Rotate controller around headset
  35259. var sin = Math.sin(-rotationAmount);
  35260. var cos = Math.cos(-rotationAmount);
  35261. this._calculatedPosition.x = this._calculatedPosition.x * cos - this._calculatedPosition.z * sin;
  35262. this._calculatedPosition.z = this._calculatedPosition.x * sin + this._calculatedPosition.z * cos;
  35263. }
  35264. }
  35265. }
  35266. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition);
  35267. this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix);
  35268. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  35269. this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation);
  35270. if (this._mesh) {
  35271. this._mesh.position.copyFrom(this.devicePosition);
  35272. if (this._mesh.rotationQuaternion) {
  35273. this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion);
  35274. }
  35275. }
  35276. };
  35277. /**
  35278. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  35279. * @param poseData raw pose fromthe device
  35280. */
  35281. PoseEnabledController.prototype.updateFromDevice = function (poseData) {
  35282. if (poseData) {
  35283. this.rawPose = poseData;
  35284. if (poseData.position) {
  35285. this._deviceRoomPosition.copyFromFloats(poseData.position[0], poseData.position[1], -poseData.position[2]);
  35286. if (this._mesh && this._mesh.getScene().useRightHandedSystem) {
  35287. this._deviceRoomPosition.z *= -1;
  35288. }
  35289. if (this._trackPosition) {
  35290. this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor, this._calculatedPosition);
  35291. }
  35292. this._calculatedPosition.addInPlace(this.position);
  35293. }
  35294. var pose = this.rawPose;
  35295. if (poseData.orientation && pose.orientation) {
  35296. this._deviceRoomRotationQuaternion.copyFromFloats(pose.orientation[0], pose.orientation[1], -pose.orientation[2], -pose.orientation[3]);
  35297. if (this._mesh) {
  35298. if (this._mesh.getScene().useRightHandedSystem) {
  35299. this._deviceRoomRotationQuaternion.z *= -1;
  35300. this._deviceRoomRotationQuaternion.w *= -1;
  35301. }
  35302. else {
  35303. this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion, this._deviceRoomRotationQuaternion);
  35304. }
  35305. }
  35306. // if the camera is set, rotate to the camera's rotation
  35307. this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion, this._calculatedRotation);
  35308. }
  35309. }
  35310. };
  35311. /**
  35312. * Attaches a mesh to the controller
  35313. * @param mesh the mesh to be attached
  35314. */
  35315. PoseEnabledController.prototype.attachToMesh = function (mesh) {
  35316. if (this._mesh) {
  35317. this._mesh.parent = null;
  35318. }
  35319. this._mesh = mesh;
  35320. if (this._poseControlledCamera) {
  35321. this._mesh.parent = this._poseControlledCamera;
  35322. }
  35323. if (!this._mesh.rotationQuaternion) {
  35324. this._mesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35325. }
  35326. // 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
  35327. this._updatePoseAndMesh();
  35328. if (this._pointingPoseNode) {
  35329. var parents = [];
  35330. var obj = this._pointingPoseNode;
  35331. while (obj.parent) {
  35332. parents.push(obj.parent);
  35333. obj = obj.parent;
  35334. }
  35335. parents.reverse().forEach(function (p) { p.computeWorldMatrix(true); });
  35336. }
  35337. this._meshAttachedObservable.notifyObservers(mesh);
  35338. };
  35339. /**
  35340. * Attaches the controllers mesh to a camera
  35341. * @param camera the camera the mesh should be attached to
  35342. */
  35343. PoseEnabledController.prototype.attachToPoseControlledCamera = function (camera) {
  35344. this._poseControlledCamera = camera;
  35345. if (this._mesh) {
  35346. this._mesh.parent = this._poseControlledCamera;
  35347. }
  35348. };
  35349. /**
  35350. * Disposes of the controller
  35351. */
  35352. PoseEnabledController.prototype.dispose = function () {
  35353. if (this._mesh) {
  35354. this._mesh.dispose();
  35355. }
  35356. this._mesh = null;
  35357. _super.prototype.dispose.call(this);
  35358. };
  35359. Object.defineProperty(PoseEnabledController.prototype, "mesh", {
  35360. /**
  35361. * The mesh that is attached to the controller
  35362. */
  35363. get: function () {
  35364. return this._mesh;
  35365. },
  35366. enumerable: true,
  35367. configurable: true
  35368. });
  35369. /**
  35370. * Gets the ray of the controller in the direction the controller is pointing
  35371. * @param length the length the resulting ray should be
  35372. * @returns a ray in the direction the controller is pointing
  35373. */
  35374. PoseEnabledController.prototype.getForwardRay = function (length) {
  35375. if (length === void 0) { length = 100; }
  35376. if (!this.mesh) {
  35377. 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);
  35378. }
  35379. var m = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix();
  35380. var origin = m.getTranslation();
  35381. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, -1);
  35382. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(forward, m);
  35383. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(forwardWorld);
  35384. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](origin, direction, length);
  35385. };
  35386. /**
  35387. * Name of the child mesh that can be used to cast a ray from the controller
  35388. */
  35389. PoseEnabledController.POINTING_POSE = "POINTING_POSE";
  35390. return PoseEnabledController;
  35391. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"]));
  35392. /***/ }),
  35393. /***/ "./Gamepads/Controllers/viveController.ts":
  35394. /*!************************************************!*\
  35395. !*** ./Gamepads/Controllers/viveController.ts ***!
  35396. \************************************************/
  35397. /*! exports provided: ViveController */
  35398. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35399. "use strict";
  35400. __webpack_require__.r(__webpack_exports__);
  35401. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return ViveController; });
  35402. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35403. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35404. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35405. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35406. /**
  35407. * Vive Controller
  35408. */
  35409. var ViveController = /** @class */ (function (_super) {
  35410. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ViveController, _super);
  35411. /**
  35412. * Creates a new ViveController from a gamepad
  35413. * @param vrGamepad the gamepad that the controller should be created from
  35414. */
  35415. function ViveController(vrGamepad) {
  35416. var _this = _super.call(this, vrGamepad) || this;
  35417. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerType"].VIVE;
  35418. _this._invertLeftStickY = true;
  35419. return _this;
  35420. }
  35421. /**
  35422. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35423. * @param scene scene in which to add meshes
  35424. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35425. */
  35426. ViveController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35427. var _this = this;
  35428. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", ViveController.MODEL_BASE_URL, ViveController.MODEL_FILENAME, scene, function (newMeshes) {
  35429. /*
  35430. Parent Mesh name: ViveWand
  35431. - body
  35432. - r_gripper
  35433. - l_gripper
  35434. - menu_button
  35435. - system_button
  35436. - trackpad
  35437. - trigger
  35438. - LED
  35439. */
  35440. _this._defaultModel = newMeshes[1];
  35441. _this.attachToMesh(_this._defaultModel);
  35442. if (meshLoaded) {
  35443. meshLoaded(_this._defaultModel);
  35444. }
  35445. });
  35446. };
  35447. Object.defineProperty(ViveController.prototype, "onLeftButtonStateChangedObservable", {
  35448. /**
  35449. * Fired when the left button on this controller is modified
  35450. */
  35451. get: function () {
  35452. return this.onMainButtonStateChangedObservable;
  35453. },
  35454. enumerable: true,
  35455. configurable: true
  35456. });
  35457. Object.defineProperty(ViveController.prototype, "onRightButtonStateChangedObservable", {
  35458. /**
  35459. * Fired when the right button on this controller is modified
  35460. */
  35461. get: function () {
  35462. return this.onMainButtonStateChangedObservable;
  35463. },
  35464. enumerable: true,
  35465. configurable: true
  35466. });
  35467. Object.defineProperty(ViveController.prototype, "onMenuButtonStateChangedObservable", {
  35468. /**
  35469. * Fired when the menu button on this controller is modified
  35470. */
  35471. get: function () {
  35472. return this.onSecondaryButtonStateChangedObservable;
  35473. },
  35474. enumerable: true,
  35475. configurable: true
  35476. });
  35477. /**
  35478. * Called once for each button that changed state since the last frame
  35479. * Vive mapping:
  35480. * 0: touchpad
  35481. * 1: trigger
  35482. * 2: left AND right buttons
  35483. * 3: menu button
  35484. * @param buttonIdx Which button index changed
  35485. * @param state New state of the button
  35486. * @param changes Which properties on the state changed since last frame
  35487. */
  35488. ViveController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35489. var notifyObject = state; //{ state: state, changes: changes };
  35490. switch (buttonIdx) {
  35491. case 0:
  35492. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  35493. return;
  35494. case 1: // index trigger
  35495. if (this._defaultModel) {
  35496. (this._defaultModel.getChildren()[6]).rotation.x = -notifyObject.value * 0.15;
  35497. }
  35498. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  35499. return;
  35500. case 2: // left AND right button
  35501. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  35502. return;
  35503. case 3:
  35504. if (this._defaultModel) {
  35505. if (notifyObject.pressed) {
  35506. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  35507. }
  35508. else {
  35509. (this._defaultModel.getChildren()[2]).position.y = 0;
  35510. }
  35511. }
  35512. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  35513. return;
  35514. }
  35515. };
  35516. /**
  35517. * Base Url for the controller model.
  35518. */
  35519. ViveController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/vive/';
  35520. /**
  35521. * File name for the controller model.
  35522. */
  35523. ViveController.MODEL_FILENAME = 'wand.babylon';
  35524. return ViveController;
  35525. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  35526. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35527. canCreate: function (gamepadInfo) {
  35528. return gamepadInfo.id.toLowerCase().indexOf('openvr') !== -1;
  35529. },
  35530. create: function (gamepadInfo) {
  35531. return new ViveController(gamepadInfo);
  35532. }
  35533. });
  35534. /***/ }),
  35535. /***/ "./Gamepads/Controllers/webVRController.ts":
  35536. /*!*************************************************!*\
  35537. !*** ./Gamepads/Controllers/webVRController.ts ***!
  35538. \*************************************************/
  35539. /*! exports provided: WebVRController */
  35540. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35541. "use strict";
  35542. __webpack_require__.r(__webpack_exports__);
  35543. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return WebVRController; });
  35544. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35545. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35546. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35547. /**
  35548. * Defines the WebVRController object that represents controllers tracked in 3D space
  35549. */
  35550. var WebVRController = /** @class */ (function (_super) {
  35551. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRController, _super);
  35552. /**
  35553. * Creates a new WebVRController from a gamepad
  35554. * @param vrGamepad the gamepad that the WebVRController should be created from
  35555. */
  35556. function WebVRController(vrGamepad) {
  35557. var _this = _super.call(this, vrGamepad) || this;
  35558. // Observables
  35559. /**
  35560. * Fired when the trigger state has changed
  35561. */
  35562. _this.onTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35563. /**
  35564. * Fired when the main button state has changed
  35565. */
  35566. _this.onMainButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35567. /**
  35568. * Fired when the secondary button state has changed
  35569. */
  35570. _this.onSecondaryButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35571. /**
  35572. * Fired when the pad state has changed
  35573. */
  35574. _this.onPadStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35575. /**
  35576. * Fired when controllers stick values have changed
  35577. */
  35578. _this.onPadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35579. /**
  35580. * X and Y axis corrisponding to the controllers joystick
  35581. */
  35582. _this.pad = { x: 0, y: 0 };
  35583. // avoid GC, store state in a tmp object
  35584. _this._changes = {
  35585. pressChanged: false,
  35586. touchChanged: false,
  35587. valueChanged: false,
  35588. changed: false
  35589. };
  35590. _this._buttons = new Array(vrGamepad.buttons.length);
  35591. _this.hand = vrGamepad.hand;
  35592. return _this;
  35593. }
  35594. /**
  35595. * Fired when a controller button's state has changed
  35596. * @param callback the callback containing the button that was modified
  35597. */
  35598. WebVRController.prototype.onButtonStateChange = function (callback) {
  35599. this._onButtonStateChange = callback;
  35600. };
  35601. Object.defineProperty(WebVRController.prototype, "defaultModel", {
  35602. /**
  35603. * The default controller model for the controller
  35604. */
  35605. get: function () {
  35606. return this._defaultModel;
  35607. },
  35608. enumerable: true,
  35609. configurable: true
  35610. });
  35611. /**
  35612. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  35613. */
  35614. WebVRController.prototype.update = function () {
  35615. _super.prototype.update.call(this);
  35616. for (var index = 0; index < this._buttons.length; index++) {
  35617. this._setButtonValue(this.browserGamepad.buttons[index], this._buttons[index], index);
  35618. }
  35619. if (this.leftStick.x !== this.pad.x || this.leftStick.y !== this.pad.y) {
  35620. this.pad.x = this.leftStick.x;
  35621. this.pad.y = this.leftStick.y;
  35622. this.onPadValuesChangedObservable.notifyObservers(this.pad);
  35623. }
  35624. };
  35625. WebVRController.prototype._setButtonValue = function (newState, currentState, buttonIndex) {
  35626. if (!newState) {
  35627. newState = {
  35628. pressed: false,
  35629. touched: false,
  35630. value: 0
  35631. };
  35632. }
  35633. if (!currentState) {
  35634. this._buttons[buttonIndex] = {
  35635. pressed: newState.pressed,
  35636. touched: newState.touched,
  35637. value: newState.value
  35638. };
  35639. return;
  35640. }
  35641. this._checkChanges(newState, currentState);
  35642. if (this._changes.changed) {
  35643. this._onButtonStateChange && this._onButtonStateChange(this.index, buttonIndex, newState);
  35644. this._handleButtonChange(buttonIndex, newState, this._changes);
  35645. }
  35646. this._buttons[buttonIndex].pressed = newState.pressed;
  35647. this._buttons[buttonIndex].touched = newState.touched;
  35648. // oculus triggers are never 0, thou not touched.
  35649. this._buttons[buttonIndex].value = newState.value < 0.00000001 ? 0 : newState.value;
  35650. };
  35651. WebVRController.prototype._checkChanges = function (newState, currentState) {
  35652. this._changes.pressChanged = newState.pressed !== currentState.pressed;
  35653. this._changes.touchChanged = newState.touched !== currentState.touched;
  35654. this._changes.valueChanged = newState.value !== currentState.value;
  35655. this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged;
  35656. return this._changes;
  35657. };
  35658. /**
  35659. * Disposes of th webVRCOntroller
  35660. */
  35661. WebVRController.prototype.dispose = function () {
  35662. _super.prototype.dispose.call(this);
  35663. this.onTriggerStateChangedObservable.clear();
  35664. this.onMainButtonStateChangedObservable.clear();
  35665. this.onSecondaryButtonStateChangedObservable.clear();
  35666. this.onPadStateChangedObservable.clear();
  35667. this.onPadValuesChangedObservable.clear();
  35668. };
  35669. return WebVRController;
  35670. }(_poseEnabledController__WEBPACK_IMPORTED_MODULE_2__["PoseEnabledController"]));
  35671. /***/ }),
  35672. /***/ "./Gamepads/Controllers/windowsMotionController.ts":
  35673. /*!*********************************************************!*\
  35674. !*** ./Gamepads/Controllers/windowsMotionController.ts ***!
  35675. \*********************************************************/
  35676. /*! exports provided: WindowsMotionController */
  35677. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35678. "use strict";
  35679. __webpack_require__.r(__webpack_exports__);
  35680. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return WindowsMotionController; });
  35681. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35682. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  35683. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35684. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35685. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  35686. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  35687. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35688. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35689. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  35690. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35691. /**
  35692. * Defines the LoadedMeshInfo object that describes information about the loaded webVR controller mesh
  35693. */
  35694. var LoadedMeshInfo = /** @class */ (function () {
  35695. function LoadedMeshInfo() {
  35696. /**
  35697. * Map of the button meshes contained in the controller
  35698. */
  35699. this.buttonMeshes = {};
  35700. /**
  35701. * Map of the axis meshes contained in the controller
  35702. */
  35703. this.axisMeshes = {};
  35704. }
  35705. return LoadedMeshInfo;
  35706. }());
  35707. /**
  35708. * Defines the WindowsMotionController object that the state of the windows motion controller
  35709. */
  35710. var WindowsMotionController = /** @class */ (function (_super) {
  35711. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WindowsMotionController, _super);
  35712. /**
  35713. * Creates a new WindowsMotionController from a gamepad
  35714. * @param vrGamepad the gamepad that the controller should be created from
  35715. */
  35716. function WindowsMotionController(vrGamepad) {
  35717. var _this = _super.call(this, vrGamepad) || this;
  35718. _this._mapping = {
  35719. // Semantic button names
  35720. buttons: ['thumbstick', 'trigger', 'grip', 'menu', 'trackpad'],
  35721. // A mapping of the button name to glTF model node name
  35722. // that should be transformed by button value.
  35723. buttonMeshNames: {
  35724. 'trigger': 'SELECT',
  35725. 'menu': 'MENU',
  35726. 'grip': 'GRASP',
  35727. 'thumbstick': 'THUMBSTICK_PRESS',
  35728. 'trackpad': 'TOUCHPAD_PRESS'
  35729. },
  35730. // This mapping is used to translate from the Motion Controller to Babylon semantics
  35731. buttonObservableNames: {
  35732. 'trigger': 'onTriggerStateChangedObservable',
  35733. 'menu': 'onSecondaryButtonStateChangedObservable',
  35734. 'grip': 'onMainButtonStateChangedObservable',
  35735. 'thumbstick': 'onPadStateChangedObservable',
  35736. 'trackpad': 'onTrackpadChangedObservable'
  35737. },
  35738. // A mapping of the axis name to glTF model node name
  35739. // that should be transformed by axis value.
  35740. // This array mirrors the browserGamepad.axes array, such that
  35741. // the mesh corresponding to axis 0 is in this array index 0.
  35742. axisMeshNames: [
  35743. 'THUMBSTICK_X',
  35744. 'THUMBSTICK_Y',
  35745. 'TOUCHPAD_TOUCH_X',
  35746. 'TOUCHPAD_TOUCH_Y'
  35747. ],
  35748. pointingPoseMeshName: _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledController"].POINTING_POSE
  35749. };
  35750. /**
  35751. * Fired when the trackpad on this controller is clicked
  35752. */
  35753. _this.onTrackpadChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  35754. /**
  35755. * Fired when the trackpad on this controller is modified
  35756. */
  35757. _this.onTrackpadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  35758. /**
  35759. * The current x and y values of this controller's trackpad
  35760. */
  35761. _this.trackpad = { x: 0, y: 0 };
  35762. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerType"].WINDOWS;
  35763. _this._loadedMeshInfo = null;
  35764. return _this;
  35765. }
  35766. Object.defineProperty(WindowsMotionController.prototype, "onTriggerButtonStateChangedObservable", {
  35767. /**
  35768. * Fired when the trigger on this controller is modified
  35769. */
  35770. get: function () {
  35771. return this.onTriggerStateChangedObservable;
  35772. },
  35773. enumerable: true,
  35774. configurable: true
  35775. });
  35776. Object.defineProperty(WindowsMotionController.prototype, "onMenuButtonStateChangedObservable", {
  35777. /**
  35778. * Fired when the menu button on this controller is modified
  35779. */
  35780. get: function () {
  35781. return this.onSecondaryButtonStateChangedObservable;
  35782. },
  35783. enumerable: true,
  35784. configurable: true
  35785. });
  35786. Object.defineProperty(WindowsMotionController.prototype, "onGripButtonStateChangedObservable", {
  35787. /**
  35788. * Fired when the grip button on this controller is modified
  35789. */
  35790. get: function () {
  35791. return this.onMainButtonStateChangedObservable;
  35792. },
  35793. enumerable: true,
  35794. configurable: true
  35795. });
  35796. Object.defineProperty(WindowsMotionController.prototype, "onThumbstickButtonStateChangedObservable", {
  35797. /**
  35798. * Fired when the thumbstick button on this controller is modified
  35799. */
  35800. get: function () {
  35801. return this.onPadStateChangedObservable;
  35802. },
  35803. enumerable: true,
  35804. configurable: true
  35805. });
  35806. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadButtonStateChangedObservable", {
  35807. /**
  35808. * Fired when the touchpad button on this controller is modified
  35809. */
  35810. get: function () {
  35811. return this.onTrackpadChangedObservable;
  35812. },
  35813. enumerable: true,
  35814. configurable: true
  35815. });
  35816. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadValuesChangedObservable", {
  35817. /**
  35818. * Fired when the touchpad values on this controller are modified
  35819. */
  35820. get: function () {
  35821. return this.onTrackpadValuesChangedObservable;
  35822. },
  35823. enumerable: true,
  35824. configurable: true
  35825. });
  35826. WindowsMotionController.prototype._updateTrackpad = function () {
  35827. if (this.browserGamepad.axes && (this.browserGamepad.axes[2] != this.trackpad.x || this.browserGamepad.axes[3] != this.trackpad.y)) {
  35828. this.trackpad.x = this.browserGamepad["axes"][2];
  35829. this.trackpad.y = this.browserGamepad["axes"][3];
  35830. this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad);
  35831. }
  35832. };
  35833. /**
  35834. * Called once per frame by the engine.
  35835. */
  35836. WindowsMotionController.prototype.update = function () {
  35837. _super.prototype.update.call(this);
  35838. if (this.browserGamepad.axes) {
  35839. this._updateTrackpad();
  35840. // Only need to animate axes if there is a loaded mesh
  35841. if (this._loadedMeshInfo) {
  35842. for (var axis = 0; axis < this._mapping.axisMeshNames.length; axis++) {
  35843. this._lerpAxisTransform(axis, this.browserGamepad.axes[axis]);
  35844. }
  35845. }
  35846. }
  35847. };
  35848. /**
  35849. * Called once for each button that changed state since the last frame
  35850. * @param buttonIdx Which button index changed
  35851. * @param state New state of the button
  35852. * @param changes Which properties on the state changed since last frame
  35853. */
  35854. WindowsMotionController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35855. var buttonName = this._mapping.buttons[buttonIdx];
  35856. if (!buttonName) {
  35857. return;
  35858. }
  35859. // Update the trackpad to ensure trackpad.x/y are accurate during button events between frames
  35860. this._updateTrackpad();
  35861. // Only emit events for buttons that we know how to map from index to name
  35862. var observable = this[(this._mapping.buttonObservableNames)[buttonName]];
  35863. if (observable) {
  35864. observable.notifyObservers(state);
  35865. }
  35866. this._lerpButtonTransform(buttonName, state.value);
  35867. };
  35868. /**
  35869. * Moves the buttons on the controller mesh based on their current state
  35870. * @param buttonName the name of the button to move
  35871. * @param buttonValue the value of the button which determines the buttons new position
  35872. */
  35873. WindowsMotionController.prototype._lerpButtonTransform = function (buttonName, buttonValue) {
  35874. // If there is no loaded mesh, there is nothing to transform.
  35875. if (!this._loadedMeshInfo) {
  35876. return;
  35877. }
  35878. var meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
  35879. if (!meshInfo.unpressed.rotationQuaternion || !meshInfo.pressed.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  35880. return;
  35881. }
  35882. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.unpressed.rotationQuaternion, meshInfo.pressed.rotationQuaternion, buttonValue, meshInfo.value.rotationQuaternion);
  35883. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.unpressed.position, meshInfo.pressed.position, buttonValue, meshInfo.value.position);
  35884. };
  35885. /**
  35886. * Moves the axis on the controller mesh based on its current state
  35887. * @param axis the index of the axis
  35888. * @param axisValue the value of the axis which determines the meshes new position
  35889. * @hidden
  35890. */
  35891. WindowsMotionController.prototype._lerpAxisTransform = function (axis, axisValue) {
  35892. if (!this._loadedMeshInfo) {
  35893. return;
  35894. }
  35895. var meshInfo = this._loadedMeshInfo.axisMeshes[axis];
  35896. if (!meshInfo) {
  35897. return;
  35898. }
  35899. if (!meshInfo.min.rotationQuaternion || !meshInfo.max.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  35900. return;
  35901. }
  35902. // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
  35903. var lerpValue = axisValue * 0.5 + 0.5;
  35904. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.min.rotationQuaternion, meshInfo.max.rotationQuaternion, lerpValue, meshInfo.value.rotationQuaternion);
  35905. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.min.position, meshInfo.max.position, lerpValue, meshInfo.value.position);
  35906. };
  35907. /**
  35908. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35909. * @param scene scene in which to add meshes
  35910. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35911. */
  35912. WindowsMotionController.prototype.initControllerMesh = function (scene, meshLoaded, forceDefault) {
  35913. var _this = this;
  35914. if (forceDefault === void 0) { forceDefault = false; }
  35915. var path;
  35916. var filename;
  35917. // Checking if GLB loader is present
  35918. if (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].IsPluginForExtensionAvailable(".glb")) {
  35919. // Determine the device specific folder based on the ID suffix
  35920. var device = 'default';
  35921. if (this.id && !forceDefault) {
  35922. var match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
  35923. device = ((match && match[0]) || device);
  35924. }
  35925. // Hand
  35926. if (this.hand === 'left') {
  35927. filename = WindowsMotionController.MODEL_LEFT_FILENAME;
  35928. }
  35929. else { // Right is the default if no hand is specified
  35930. filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
  35931. }
  35932. path = WindowsMotionController.MODEL_BASE_URL + device + '/';
  35933. }
  35934. else {
  35935. _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");
  35936. path = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_BASE_URL;
  35937. filename = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_FILENAME;
  35938. }
  35939. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].ImportMesh("", path, filename, scene, function (meshes) {
  35940. // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
  35941. _this._loadedMeshInfo = _this.processModel(scene, meshes);
  35942. if (!_this._loadedMeshInfo) {
  35943. return;
  35944. }
  35945. _this._defaultModel = _this._loadedMeshInfo.rootNode;
  35946. _this.attachToMesh(_this._defaultModel);
  35947. if (meshLoaded) {
  35948. meshLoaded(_this._defaultModel);
  35949. }
  35950. }, null, function (scene, message) {
  35951. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log(message);
  35952. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Failed to retrieve controller model from the remote server: ' + path + filename);
  35953. if (!forceDefault) {
  35954. _this.initControllerMesh(scene, meshLoaded, true);
  35955. }
  35956. });
  35957. };
  35958. /**
  35959. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  35960. * can be transformed by button presses and axes values, based on this._mapping.
  35961. *
  35962. * @param scene scene in which the meshes exist
  35963. * @param meshes list of meshes that make up the controller model to process
  35964. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  35965. */
  35966. WindowsMotionController.prototype.processModel = function (scene, meshes) {
  35967. var loadedMeshInfo = null;
  35968. // Create a new mesh to contain the glTF hierarchy
  35969. var parentMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this.id + " " + this.hand, scene);
  35970. // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'
  35971. var childMesh = null;
  35972. for (var i = 0; i < meshes.length; i++) {
  35973. var mesh = meshes[i];
  35974. if (!mesh.parent) {
  35975. // Exclude controller meshes from picking results
  35976. mesh.isPickable = false;
  35977. // Handle root node, attach to the new parentMesh
  35978. childMesh = mesh;
  35979. break;
  35980. }
  35981. }
  35982. if (childMesh) {
  35983. childMesh.setParent(parentMesh);
  35984. // Create our mesh info. Note that this method will always return non-null.
  35985. loadedMeshInfo = this.createMeshInfo(parentMesh);
  35986. }
  35987. else {
  35988. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Could not find root node in model file.');
  35989. }
  35990. return loadedMeshInfo;
  35991. };
  35992. WindowsMotionController.prototype.createMeshInfo = function (rootNode) {
  35993. var loadedMeshInfo = new LoadedMeshInfo();
  35994. var i;
  35995. loadedMeshInfo.rootNode = rootNode;
  35996. // Reset the caches
  35997. loadedMeshInfo.buttonMeshes = {};
  35998. loadedMeshInfo.axisMeshes = {};
  35999. // Button Meshes
  36000. for (i = 0; i < this._mapping.buttons.length; i++) {
  36001. var buttonMeshName = this._mapping.buttonMeshNames[this._mapping.buttons[i]];
  36002. if (!buttonMeshName) {
  36003. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown button at index: ' + i + ' with mapped name: ' + this._mapping.buttons[i]);
  36004. continue;
  36005. }
  36006. var buttonMesh = getChildByName(rootNode, buttonMeshName);
  36007. if (!buttonMesh) {
  36008. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button mesh with name: ' + buttonMeshName);
  36009. continue;
  36010. }
  36011. var buttonMeshInfo = {
  36012. index: i,
  36013. value: getImmediateChildByName(buttonMesh, 'VALUE'),
  36014. pressed: getImmediateChildByName(buttonMesh, 'PRESSED'),
  36015. unpressed: getImmediateChildByName(buttonMesh, 'UNPRESSED')
  36016. };
  36017. if (buttonMeshInfo.value && buttonMeshInfo.pressed && buttonMeshInfo.unpressed) {
  36018. loadedMeshInfo.buttonMeshes[this._mapping.buttons[i]] = buttonMeshInfo;
  36019. }
  36020. else {
  36021. // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.
  36022. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button submesh under mesh with name: ' + buttonMeshName +
  36023. '(VALUE: ' + !!buttonMeshInfo.value +
  36024. ', PRESSED: ' + !!buttonMeshInfo.pressed +
  36025. ', UNPRESSED:' + !!buttonMeshInfo.unpressed +
  36026. ')');
  36027. }
  36028. }
  36029. // Axis Meshes
  36030. for (i = 0; i < this._mapping.axisMeshNames.length; i++) {
  36031. var axisMeshName = this._mapping.axisMeshNames[i];
  36032. if (!axisMeshName) {
  36033. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown axis at index: ' + i);
  36034. continue;
  36035. }
  36036. var axisMesh = getChildByName(rootNode, axisMeshName);
  36037. if (!axisMesh) {
  36038. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis mesh with name: ' + axisMeshName);
  36039. continue;
  36040. }
  36041. var axisMeshInfo = {
  36042. index: i,
  36043. value: getImmediateChildByName(axisMesh, 'VALUE'),
  36044. min: getImmediateChildByName(axisMesh, 'MIN'),
  36045. max: getImmediateChildByName(axisMesh, 'MAX')
  36046. };
  36047. if (axisMeshInfo.value && axisMeshInfo.min && axisMeshInfo.max) {
  36048. loadedMeshInfo.axisMeshes[i] = axisMeshInfo;
  36049. }
  36050. else {
  36051. // If we didn't find the mesh, it simply means thit axis won't have transforms applied as mapped axis values change.
  36052. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis submesh under mesh with name: ' + axisMeshName +
  36053. '(VALUE: ' + !!axisMeshInfo.value +
  36054. ', MIN: ' + !!axisMeshInfo.min +
  36055. ', MAX:' + !!axisMeshInfo.max +
  36056. ')');
  36057. }
  36058. }
  36059. // Pointing Ray
  36060. loadedMeshInfo.pointingPoseNode = getChildByName(rootNode, this._mapping.pointingPoseMeshName);
  36061. if (!loadedMeshInfo.pointingPoseNode) {
  36062. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing pointing pose mesh with name: ' + this._mapping.pointingPoseMeshName);
  36063. }
  36064. else {
  36065. this._pointingPoseNode = loadedMeshInfo.pointingPoseNode;
  36066. }
  36067. return loadedMeshInfo;
  36068. // Look through all children recursively. This will return null if no mesh exists with the given name.
  36069. function getChildByName(node, name) {
  36070. return node.getChildren(function (n) { return n.name === name; }, false)[0];
  36071. }
  36072. // Look through only immediate children. This will return null if no mesh exists with the given name.
  36073. function getImmediateChildByName(node, name) {
  36074. return node.getChildren(function (n) { return n.name == name; }, true)[0];
  36075. }
  36076. };
  36077. /**
  36078. * Gets the ray of the controller in the direction the controller is pointing
  36079. * @param length the length the resulting ray should be
  36080. * @returns a ray in the direction the controller is pointing
  36081. */
  36082. WindowsMotionController.prototype.getForwardRay = function (length) {
  36083. if (length === void 0) { length = 100; }
  36084. if (!(this._loadedMeshInfo && this._loadedMeshInfo.pointingPoseNode)) {
  36085. return _super.prototype.getForwardRay.call(this, length);
  36086. }
  36087. var m = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix();
  36088. var origin = m.getTranslation();
  36089. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  36090. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(forward, m);
  36091. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(forwardWorld);
  36092. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, length);
  36093. };
  36094. /**
  36095. * Disposes of the controller
  36096. */
  36097. WindowsMotionController.prototype.dispose = function () {
  36098. _super.prototype.dispose.call(this);
  36099. this.onTrackpadChangedObservable.clear();
  36100. };
  36101. /**
  36102. * The base url used to load the left and right controller models
  36103. */
  36104. WindowsMotionController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/microsoft/';
  36105. /**
  36106. * The name of the left controller model file
  36107. */
  36108. WindowsMotionController.MODEL_LEFT_FILENAME = 'left.glb';
  36109. /**
  36110. * The name of the right controller model file
  36111. */
  36112. WindowsMotionController.MODEL_RIGHT_FILENAME = 'right.glb';
  36113. /**
  36114. * The controller name prefix for this controller type
  36115. */
  36116. WindowsMotionController.GAMEPAD_ID_PREFIX = 'Spatial Controller (Spatial Interaction Source) ';
  36117. /**
  36118. * The controller id pattern for this controller type
  36119. */
  36120. WindowsMotionController.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
  36121. return WindowsMotionController;
  36122. }(_webVRController__WEBPACK_IMPORTED_MODULE_7__["WebVRController"]));
  36123. _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  36124. canCreate: function (gamepadInfo) {
  36125. return gamepadInfo.id.indexOf(WindowsMotionController.GAMEPAD_ID_PREFIX) === 0;
  36126. },
  36127. create: function (gamepadInfo) {
  36128. return new WindowsMotionController(gamepadInfo);
  36129. }
  36130. });
  36131. /***/ }),
  36132. /***/ "./Gamepads/gamepad.ts":
  36133. /*!*****************************!*\
  36134. !*** ./Gamepads/gamepad.ts ***!
  36135. \*****************************/
  36136. /*! exports provided: StickValues, Gamepad, GenericPad */
  36137. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36138. "use strict";
  36139. __webpack_require__.r(__webpack_exports__);
  36140. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return StickValues; });
  36141. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return Gamepad; });
  36142. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return GenericPad; });
  36143. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36144. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36145. /**
  36146. * Represents a gamepad control stick position
  36147. */
  36148. var StickValues = /** @class */ (function () {
  36149. /**
  36150. * Initializes the gamepad x and y control stick values
  36151. * @param x The x component of the gamepad control stick value
  36152. * @param y The y component of the gamepad control stick value
  36153. */
  36154. function StickValues(
  36155. /**
  36156. * The x component of the control stick
  36157. */
  36158. x,
  36159. /**
  36160. * The y component of the control stick
  36161. */
  36162. y) {
  36163. this.x = x;
  36164. this.y = y;
  36165. }
  36166. return StickValues;
  36167. }());
  36168. /**
  36169. * Represents a gamepad
  36170. */
  36171. var Gamepad = /** @class */ (function () {
  36172. /**
  36173. * Initializes the gamepad
  36174. * @param id The id of the gamepad
  36175. * @param index The index of the gamepad
  36176. * @param browserGamepad The browser gamepad
  36177. * @param leftStickX The x component of the left joystick
  36178. * @param leftStickY The y component of the left joystick
  36179. * @param rightStickX The x component of the right joystick
  36180. * @param rightStickY The y component of the right joystick
  36181. */
  36182. function Gamepad(
  36183. /**
  36184. * The id of the gamepad
  36185. */
  36186. id,
  36187. /**
  36188. * The index of the gamepad
  36189. */
  36190. index,
  36191. /**
  36192. * The browser gamepad
  36193. */
  36194. browserGamepad, leftStickX, leftStickY, rightStickX, rightStickY) {
  36195. if (leftStickX === void 0) { leftStickX = 0; }
  36196. if (leftStickY === void 0) { leftStickY = 1; }
  36197. if (rightStickX === void 0) { rightStickX = 2; }
  36198. if (rightStickY === void 0) { rightStickY = 3; }
  36199. this.id = id;
  36200. this.index = index;
  36201. this.browserGamepad = browserGamepad;
  36202. this._leftStick = { x: 0, y: 0 };
  36203. this._rightStick = { x: 0, y: 0 };
  36204. /** @hidden */
  36205. this._isConnected = true;
  36206. /**
  36207. * Specifies whether the left control stick should be Y-inverted
  36208. */
  36209. this._invertLeftStickY = false;
  36210. this.type = Gamepad.GAMEPAD;
  36211. this._leftStickAxisX = leftStickX;
  36212. this._leftStickAxisY = leftStickY;
  36213. this._rightStickAxisX = rightStickX;
  36214. this._rightStickAxisY = rightStickY;
  36215. if (this.browserGamepad.axes.length >= 2) {
  36216. this._leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  36217. }
  36218. if (this.browserGamepad.axes.length >= 4) {
  36219. this._rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  36220. }
  36221. }
  36222. Object.defineProperty(Gamepad.prototype, "isConnected", {
  36223. /**
  36224. * Specifies if the gamepad has been connected
  36225. */
  36226. get: function () {
  36227. return this._isConnected;
  36228. },
  36229. enumerable: true,
  36230. configurable: true
  36231. });
  36232. /**
  36233. * Callback triggered when the left joystick has changed
  36234. * @param callback
  36235. */
  36236. Gamepad.prototype.onleftstickchanged = function (callback) {
  36237. this._onleftstickchanged = callback;
  36238. };
  36239. /**
  36240. * Callback triggered when the right joystick has changed
  36241. * @param callback
  36242. */
  36243. Gamepad.prototype.onrightstickchanged = function (callback) {
  36244. this._onrightstickchanged = callback;
  36245. };
  36246. Object.defineProperty(Gamepad.prototype, "leftStick", {
  36247. /**
  36248. * Gets the left joystick
  36249. */
  36250. get: function () {
  36251. return this._leftStick;
  36252. },
  36253. /**
  36254. * Sets the left joystick values
  36255. */
  36256. set: function (newValues) {
  36257. if (this._onleftstickchanged && (this._leftStick.x !== newValues.x || this._leftStick.y !== newValues.y)) {
  36258. this._onleftstickchanged(newValues);
  36259. }
  36260. this._leftStick = newValues;
  36261. },
  36262. enumerable: true,
  36263. configurable: true
  36264. });
  36265. Object.defineProperty(Gamepad.prototype, "rightStick", {
  36266. /**
  36267. * Gets the right joystick
  36268. */
  36269. get: function () {
  36270. return this._rightStick;
  36271. },
  36272. /**
  36273. * Sets the right joystick value
  36274. */
  36275. set: function (newValues) {
  36276. if (this._onrightstickchanged && (this._rightStick.x !== newValues.x || this._rightStick.y !== newValues.y)) {
  36277. this._onrightstickchanged(newValues);
  36278. }
  36279. this._rightStick = newValues;
  36280. },
  36281. enumerable: true,
  36282. configurable: true
  36283. });
  36284. /**
  36285. * Updates the gamepad joystick positions
  36286. */
  36287. Gamepad.prototype.update = function () {
  36288. if (this._leftStick) {
  36289. this.leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  36290. if (this._invertLeftStickY) {
  36291. this.leftStick.y *= -1;
  36292. }
  36293. }
  36294. if (this._rightStick) {
  36295. this.rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  36296. }
  36297. };
  36298. /**
  36299. * Disposes the gamepad
  36300. */
  36301. Gamepad.prototype.dispose = function () {
  36302. };
  36303. /**
  36304. * Represents a gamepad controller
  36305. */
  36306. Gamepad.GAMEPAD = 0;
  36307. /**
  36308. * Represents a generic controller
  36309. */
  36310. Gamepad.GENERIC = 1;
  36311. /**
  36312. * Represents an XBox controller
  36313. */
  36314. Gamepad.XBOX = 2;
  36315. /**
  36316. * Represents a pose-enabled controller
  36317. */
  36318. Gamepad.POSE_ENABLED = 3;
  36319. return Gamepad;
  36320. }());
  36321. /**
  36322. * Represents a generic gamepad
  36323. */
  36324. var GenericPad = /** @class */ (function (_super) {
  36325. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericPad, _super);
  36326. /**
  36327. * Initializes the generic gamepad
  36328. * @param id The id of the generic gamepad
  36329. * @param index The index of the generic gamepad
  36330. * @param browserGamepad The browser gamepad
  36331. */
  36332. function GenericPad(id, index, browserGamepad) {
  36333. var _this = _super.call(this, id, index, browserGamepad) || this;
  36334. /**
  36335. * Observable triggered when a button has been pressed
  36336. */
  36337. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36338. /**
  36339. * Observable triggered when a button has been released
  36340. */
  36341. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36342. _this.type = Gamepad.GENERIC;
  36343. _this._buttons = new Array(browserGamepad.buttons.length);
  36344. return _this;
  36345. }
  36346. /**
  36347. * Callback triggered when a button has been pressed
  36348. * @param callback Called when a button has been pressed
  36349. */
  36350. GenericPad.prototype.onbuttondown = function (callback) {
  36351. this._onbuttondown = callback;
  36352. };
  36353. /**
  36354. * Callback triggered when a button has been released
  36355. * @param callback Called when a button has been released
  36356. */
  36357. GenericPad.prototype.onbuttonup = function (callback) {
  36358. this._onbuttonup = callback;
  36359. };
  36360. GenericPad.prototype._setButtonValue = function (newValue, currentValue, buttonIndex) {
  36361. if (newValue !== currentValue) {
  36362. if (newValue === 1) {
  36363. if (this._onbuttondown) {
  36364. this._onbuttondown(buttonIndex);
  36365. }
  36366. this.onButtonDownObservable.notifyObservers(buttonIndex);
  36367. }
  36368. if (newValue === 0) {
  36369. if (this._onbuttonup) {
  36370. this._onbuttonup(buttonIndex);
  36371. }
  36372. this.onButtonUpObservable.notifyObservers(buttonIndex);
  36373. }
  36374. }
  36375. return newValue;
  36376. };
  36377. /**
  36378. * Updates the generic gamepad
  36379. */
  36380. GenericPad.prototype.update = function () {
  36381. _super.prototype.update.call(this);
  36382. for (var index = 0; index < this._buttons.length; index++) {
  36383. this._buttons[index] = this._setButtonValue(this.browserGamepad.buttons[index].value, this._buttons[index], index);
  36384. }
  36385. };
  36386. /**
  36387. * Disposes the generic gamepad
  36388. */
  36389. GenericPad.prototype.dispose = function () {
  36390. _super.prototype.dispose.call(this);
  36391. this.onButtonDownObservable.clear();
  36392. this.onButtonUpObservable.clear();
  36393. };
  36394. return GenericPad;
  36395. }(Gamepad));
  36396. /***/ }),
  36397. /***/ "./Gamepads/gamepadManager.ts":
  36398. /*!************************************!*\
  36399. !*** ./Gamepads/gamepadManager.ts ***!
  36400. \************************************/
  36401. /*! exports provided: GamepadManager */
  36402. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36403. "use strict";
  36404. __webpack_require__.r(__webpack_exports__);
  36405. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return GamepadManager; });
  36406. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  36407. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36408. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  36409. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36410. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  36411. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  36412. /**
  36413. * Manager for handling gamepads
  36414. */
  36415. var GamepadManager = /** @class */ (function () {
  36416. /**
  36417. * Initializes the gamepad manager
  36418. * @param _scene BabylonJS scene
  36419. */
  36420. function GamepadManager(_scene) {
  36421. var _this = this;
  36422. this._scene = _scene;
  36423. this._babylonGamepads = [];
  36424. this._oneGamepadConnected = false;
  36425. /** @hidden */
  36426. this._isMonitoring = false;
  36427. /**
  36428. * observable to be triggered when the gamepad controller has been disconnected
  36429. */
  36430. this.onGamepadDisconnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36431. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  36432. this._gamepadEventSupported = false;
  36433. }
  36434. else {
  36435. this._gamepadEventSupported = 'GamepadEvent' in window;
  36436. this._gamepadSupport = (navigator.getGamepads ||
  36437. navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
  36438. }
  36439. this.onGamepadConnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"](function (observer) {
  36440. // This will be used to raise the onGamepadConnected for all gamepads ALREADY connected
  36441. for (var i in _this._babylonGamepads) {
  36442. var gamepad = _this._babylonGamepads[i];
  36443. if (gamepad && gamepad._isConnected) {
  36444. _this.onGamepadConnectedObservable.notifyObserver(observer, gamepad);
  36445. }
  36446. }
  36447. });
  36448. this._onGamepadConnectedEvent = function (evt) {
  36449. var gamepad = evt.gamepad;
  36450. if (gamepad.index in _this._babylonGamepads) {
  36451. if (_this._babylonGamepads[gamepad.index].isConnected) {
  36452. return;
  36453. }
  36454. }
  36455. var newGamepad;
  36456. if (_this._babylonGamepads[gamepad.index]) {
  36457. newGamepad = _this._babylonGamepads[gamepad.index];
  36458. newGamepad.browserGamepad = gamepad;
  36459. newGamepad._isConnected = true;
  36460. }
  36461. else {
  36462. newGamepad = _this._addNewGamepad(gamepad);
  36463. }
  36464. _this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  36465. _this._startMonitoringGamepads();
  36466. };
  36467. this._onGamepadDisconnectedEvent = function (evt) {
  36468. var gamepad = evt.gamepad;
  36469. // Remove the gamepad from the list of gamepads to monitor.
  36470. for (var i in _this._babylonGamepads) {
  36471. if (_this._babylonGamepads[i].index === gamepad.index) {
  36472. var disconnectedGamepad = _this._babylonGamepads[i];
  36473. disconnectedGamepad._isConnected = false;
  36474. _this.onGamepadDisconnectedObservable.notifyObservers(disconnectedGamepad);
  36475. break;
  36476. }
  36477. }
  36478. };
  36479. if (this._gamepadSupport) {
  36480. //first add already-connected gamepads
  36481. this._updateGamepadObjects();
  36482. if (this._babylonGamepads.length) {
  36483. this._startMonitoringGamepads();
  36484. }
  36485. // Checking if the gamepad connected event is supported (like in Firefox)
  36486. if (this._gamepadEventSupported) {
  36487. window.addEventListener('gamepadconnected', this._onGamepadConnectedEvent, false);
  36488. window.addEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent, false);
  36489. }
  36490. else {
  36491. this._startMonitoringGamepads();
  36492. }
  36493. }
  36494. }
  36495. Object.defineProperty(GamepadManager.prototype, "gamepads", {
  36496. /**
  36497. * The gamepads in the game pad manager
  36498. */
  36499. get: function () {
  36500. return this._babylonGamepads;
  36501. },
  36502. enumerable: true,
  36503. configurable: true
  36504. });
  36505. /**
  36506. * Get the gamepad controllers based on type
  36507. * @param type The type of gamepad controller
  36508. * @returns Nullable gamepad
  36509. */
  36510. GamepadManager.prototype.getGamepadByType = function (type) {
  36511. if (type === void 0) { type = _gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].XBOX; }
  36512. for (var _i = 0, _a = this._babylonGamepads; _i < _a.length; _i++) {
  36513. var gamepad = _a[_i];
  36514. if (gamepad && gamepad.type === type) {
  36515. return gamepad;
  36516. }
  36517. }
  36518. return null;
  36519. };
  36520. /**
  36521. * Disposes the gamepad manager
  36522. */
  36523. GamepadManager.prototype.dispose = function () {
  36524. if (this._gamepadEventSupported) {
  36525. if (this._onGamepadConnectedEvent) {
  36526. window.removeEventListener('gamepadconnected', this._onGamepadConnectedEvent);
  36527. }
  36528. if (this._onGamepadDisconnectedEvent) {
  36529. window.removeEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent);
  36530. }
  36531. this._onGamepadConnectedEvent = null;
  36532. this._onGamepadDisconnectedEvent = null;
  36533. }
  36534. this._babylonGamepads.forEach(function (gamepad) {
  36535. gamepad.dispose();
  36536. });
  36537. this.onGamepadConnectedObservable.clear();
  36538. this.onGamepadDisconnectedObservable.clear();
  36539. this._oneGamepadConnected = false;
  36540. this._stopMonitoringGamepads();
  36541. this._babylonGamepads = [];
  36542. };
  36543. GamepadManager.prototype._addNewGamepad = function (gamepad) {
  36544. if (!this._oneGamepadConnected) {
  36545. this._oneGamepadConnected = true;
  36546. }
  36547. var newGamepad;
  36548. var xboxOne = (gamepad.id.search("Xbox One") !== -1);
  36549. if (xboxOne || gamepad.id.search("Xbox 360") !== -1 || gamepad.id.search("xinput") !== -1) {
  36550. newGamepad = new _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"](gamepad.id, gamepad.index, gamepad, xboxOne);
  36551. }
  36552. // if pose is supported, use the (WebVR) pose enabled controller
  36553. else if (gamepad.pose) {
  36554. newGamepad = _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"].InitiateController(gamepad);
  36555. }
  36556. else {
  36557. newGamepad = new _gamepad__WEBPACK_IMPORTED_MODULE_5__["GenericPad"](gamepad.id, gamepad.index, gamepad);
  36558. }
  36559. this._babylonGamepads[newGamepad.index] = newGamepad;
  36560. return newGamepad;
  36561. };
  36562. GamepadManager.prototype._startMonitoringGamepads = function () {
  36563. if (!this._isMonitoring) {
  36564. this._isMonitoring = true;
  36565. //back-comp
  36566. if (!this._scene) {
  36567. this._checkGamepadsStatus();
  36568. }
  36569. }
  36570. };
  36571. GamepadManager.prototype._stopMonitoringGamepads = function () {
  36572. this._isMonitoring = false;
  36573. };
  36574. /** @hidden */
  36575. GamepadManager.prototype._checkGamepadsStatus = function () {
  36576. var _this = this;
  36577. // Hack to be compatible Chrome
  36578. this._updateGamepadObjects();
  36579. for (var i in this._babylonGamepads) {
  36580. var gamepad = this._babylonGamepads[i];
  36581. if (!gamepad || !gamepad.isConnected) {
  36582. continue;
  36583. }
  36584. gamepad.update();
  36585. }
  36586. if (this._isMonitoring && !this._scene) {
  36587. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].QueueNewFrame(function () { _this._checkGamepadsStatus(); });
  36588. }
  36589. };
  36590. // This function is called only on Chrome, which does not properly support
  36591. // connection/disconnection events and forces you to recopy again the gamepad object
  36592. GamepadManager.prototype._updateGamepadObjects = function () {
  36593. var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);
  36594. for (var i = 0; i < gamepads.length; i++) {
  36595. var gamepad = gamepads[i];
  36596. if (gamepad) {
  36597. if (!this._babylonGamepads[gamepad.index]) {
  36598. var newGamepad = this._addNewGamepad(gamepad);
  36599. this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  36600. }
  36601. else {
  36602. // Forced to copy again this object for Chrome for unknown reason
  36603. this._babylonGamepads[i].browserGamepad = gamepad;
  36604. if (!this._babylonGamepads[i].isConnected) {
  36605. this._babylonGamepads[i]._isConnected = true;
  36606. this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[i]);
  36607. }
  36608. }
  36609. }
  36610. }
  36611. };
  36612. return GamepadManager;
  36613. }());
  36614. /***/ }),
  36615. /***/ "./Gamepads/gamepadSceneComponent.ts":
  36616. /*!*******************************************!*\
  36617. !*** ./Gamepads/gamepadSceneComponent.ts ***!
  36618. \*******************************************/
  36619. /*! exports provided: GamepadSystemSceneComponent */
  36620. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36621. "use strict";
  36622. __webpack_require__.r(__webpack_exports__);
  36623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return GamepadSystemSceneComponent; });
  36624. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  36625. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  36626. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  36627. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  36628. /* harmony import */ var _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  36629. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  36630. /* harmony import */ var _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  36631. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "gamepadManager", {
  36632. get: function () {
  36633. if (!this._gamepadManager) {
  36634. this._gamepadManager = new _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"](this);
  36635. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD);
  36636. if (!component) {
  36637. component = new GamepadSystemSceneComponent(this);
  36638. this._addComponent(component);
  36639. }
  36640. }
  36641. return this._gamepadManager;
  36642. },
  36643. enumerable: true,
  36644. configurable: true
  36645. });
  36646. /**
  36647. * Adds a gamepad to the free camera inputs manager
  36648. */
  36649. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addGamepad = function () {
  36650. this.add(new _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraGamepadInput"]());
  36651. return this;
  36652. };
  36653. /**
  36654. * Adds a gamepad to the arc rotate camera inputs manager
  36655. */
  36656. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["ArcRotateCameraInputsManager"].prototype.addGamepad = function () {
  36657. this.add(new _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__["ArcRotateCameraGamepadInput"]());
  36658. return this;
  36659. };
  36660. /**
  36661. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  36662. */
  36663. var GamepadSystemSceneComponent = /** @class */ (function () {
  36664. /**
  36665. * Creates a new instance of the component for the given scene
  36666. * @param scene Defines the scene to register the component in
  36667. */
  36668. function GamepadSystemSceneComponent(scene) {
  36669. /**
  36670. * The component name helpfull to identify the component in the list of scene components.
  36671. */
  36672. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD;
  36673. this.scene = scene;
  36674. }
  36675. /**
  36676. * Registers the component in a given scene
  36677. */
  36678. GamepadSystemSceneComponent.prototype.register = function () {
  36679. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate);
  36680. };
  36681. /**
  36682. * Rebuilds the elements related to this component in case of
  36683. * context lost for instance.
  36684. */
  36685. GamepadSystemSceneComponent.prototype.rebuild = function () {
  36686. // Nothing to do for gamepads
  36687. };
  36688. /**
  36689. * Disposes the component and the associated ressources
  36690. */
  36691. GamepadSystemSceneComponent.prototype.dispose = function () {
  36692. var gamepadManager = this.scene._gamepadManager;
  36693. if (gamepadManager) {
  36694. gamepadManager.dispose();
  36695. this.scene._gamepadManager = null;
  36696. }
  36697. };
  36698. GamepadSystemSceneComponent.prototype._beforeCameraUpdate = function () {
  36699. var gamepadManager = this.scene._gamepadManager;
  36700. if (gamepadManager && gamepadManager._isMonitoring) {
  36701. gamepadManager._checkGamepadsStatus();
  36702. }
  36703. };
  36704. return GamepadSystemSceneComponent;
  36705. }());
  36706. /***/ }),
  36707. /***/ "./Gamepads/index.ts":
  36708. /*!***************************!*\
  36709. !*** ./Gamepads/index.ts ***!
  36710. \***************************/
  36711. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad */
  36712. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36713. "use strict";
  36714. __webpack_require__.r(__webpack_exports__);
  36715. /* harmony import */ var _Controllers_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Controllers/index */ "./Gamepads/Controllers/index.ts");
  36716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  36717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  36718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  36719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  36720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  36721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  36722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  36723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  36724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  36725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  36726. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  36727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["StickValues"]; });
  36728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["Gamepad"]; });
  36729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["GenericPad"]; });
  36730. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  36731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"]; });
  36732. /* harmony import */ var _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  36733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__["GamepadSystemSceneComponent"]; });
  36734. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  36735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Button"]; });
  36736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Dpad"]; });
  36737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"]; });
  36738. /***/ }),
  36739. /***/ "./Gamepads/xboxGamepad.ts":
  36740. /*!*********************************!*\
  36741. !*** ./Gamepads/xboxGamepad.ts ***!
  36742. \*********************************/
  36743. /*! exports provided: Xbox360Button, Xbox360Dpad, Xbox360Pad */
  36744. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36745. "use strict";
  36746. __webpack_require__.r(__webpack_exports__);
  36747. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return Xbox360Button; });
  36748. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return Xbox360Dpad; });
  36749. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return Xbox360Pad; });
  36750. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36751. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36752. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  36753. /**
  36754. * Defines supported buttons for XBox360 compatible gamepads
  36755. */
  36756. var Xbox360Button;
  36757. (function (Xbox360Button) {
  36758. /** A */
  36759. Xbox360Button[Xbox360Button["A"] = 0] = "A";
  36760. /** B */
  36761. Xbox360Button[Xbox360Button["B"] = 1] = "B";
  36762. /** X */
  36763. Xbox360Button[Xbox360Button["X"] = 2] = "X";
  36764. /** Y */
  36765. Xbox360Button[Xbox360Button["Y"] = 3] = "Y";
  36766. /** Start */
  36767. Xbox360Button[Xbox360Button["Start"] = 4] = "Start";
  36768. /** Back */
  36769. Xbox360Button[Xbox360Button["Back"] = 5] = "Back";
  36770. /** Left button */
  36771. Xbox360Button[Xbox360Button["LB"] = 6] = "LB";
  36772. /** Right button */
  36773. Xbox360Button[Xbox360Button["RB"] = 7] = "RB";
  36774. /** Left stick */
  36775. Xbox360Button[Xbox360Button["LeftStick"] = 8] = "LeftStick";
  36776. /** Right stick */
  36777. Xbox360Button[Xbox360Button["RightStick"] = 9] = "RightStick";
  36778. })(Xbox360Button || (Xbox360Button = {}));
  36779. /** Defines values for XBox360 DPad */
  36780. var Xbox360Dpad;
  36781. (function (Xbox360Dpad) {
  36782. /** Up */
  36783. Xbox360Dpad[Xbox360Dpad["Up"] = 0] = "Up";
  36784. /** Down */
  36785. Xbox360Dpad[Xbox360Dpad["Down"] = 1] = "Down";
  36786. /** Left */
  36787. Xbox360Dpad[Xbox360Dpad["Left"] = 2] = "Left";
  36788. /** Right */
  36789. Xbox360Dpad[Xbox360Dpad["Right"] = 3] = "Right";
  36790. })(Xbox360Dpad || (Xbox360Dpad = {}));
  36791. /**
  36792. * Defines a XBox360 gamepad
  36793. */
  36794. var Xbox360Pad = /** @class */ (function (_super) {
  36795. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Xbox360Pad, _super);
  36796. /**
  36797. * Creates a new XBox360 gamepad object
  36798. * @param id defines the id of this gamepad
  36799. * @param index defines its index
  36800. * @param gamepad defines the internal HTML gamepad object
  36801. * @param xboxOne defines if it is a XBox One gamepad
  36802. */
  36803. function Xbox360Pad(id, index, gamepad, xboxOne) {
  36804. if (xboxOne === void 0) { xboxOne = false; }
  36805. var _this = _super.call(this, id, index, gamepad, 0, 1, 2, 3) || this;
  36806. _this._leftTrigger = 0;
  36807. _this._rightTrigger = 0;
  36808. /** Observable raised when a button is pressed */
  36809. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36810. /** Observable raised when a button is released */
  36811. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36812. /** Observable raised when a pad is pressed */
  36813. _this.onPadDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36814. /** Observable raised when a pad is released */
  36815. _this.onPadUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36816. _this._buttonA = 0;
  36817. _this._buttonB = 0;
  36818. _this._buttonX = 0;
  36819. _this._buttonY = 0;
  36820. _this._buttonBack = 0;
  36821. _this._buttonStart = 0;
  36822. _this._buttonLB = 0;
  36823. _this._buttonRB = 0;
  36824. _this._buttonLeftStick = 0;
  36825. _this._buttonRightStick = 0;
  36826. _this._dPadUp = 0;
  36827. _this._dPadDown = 0;
  36828. _this._dPadLeft = 0;
  36829. _this._dPadRight = 0;
  36830. _this._isXboxOnePad = false;
  36831. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"].XBOX;
  36832. _this._isXboxOnePad = xboxOne;
  36833. return _this;
  36834. }
  36835. /**
  36836. * Defines the callback to call when left trigger is pressed
  36837. * @param callback defines the callback to use
  36838. */
  36839. Xbox360Pad.prototype.onlefttriggerchanged = function (callback) {
  36840. this._onlefttriggerchanged = callback;
  36841. };
  36842. /**
  36843. * Defines the callback to call when right trigger is pressed
  36844. * @param callback defines the callback to use
  36845. */
  36846. Xbox360Pad.prototype.onrighttriggerchanged = function (callback) {
  36847. this._onrighttriggerchanged = callback;
  36848. };
  36849. Object.defineProperty(Xbox360Pad.prototype, "leftTrigger", {
  36850. /**
  36851. * Gets the left trigger value
  36852. */
  36853. get: function () {
  36854. return this._leftTrigger;
  36855. },
  36856. /**
  36857. * Sets the left trigger value
  36858. */
  36859. set: function (newValue) {
  36860. if (this._onlefttriggerchanged && this._leftTrigger !== newValue) {
  36861. this._onlefttriggerchanged(newValue);
  36862. }
  36863. this._leftTrigger = newValue;
  36864. },
  36865. enumerable: true,
  36866. configurable: true
  36867. });
  36868. Object.defineProperty(Xbox360Pad.prototype, "rightTrigger", {
  36869. /**
  36870. * Gets the right trigger value
  36871. */
  36872. get: function () {
  36873. return this._rightTrigger;
  36874. },
  36875. /**
  36876. * Sets the right trigger value
  36877. */
  36878. set: function (newValue) {
  36879. if (this._onrighttriggerchanged && this._rightTrigger !== newValue) {
  36880. this._onrighttriggerchanged(newValue);
  36881. }
  36882. this._rightTrigger = newValue;
  36883. },
  36884. enumerable: true,
  36885. configurable: true
  36886. });
  36887. /**
  36888. * Defines the callback to call when a button is pressed
  36889. * @param callback defines the callback to use
  36890. */
  36891. Xbox360Pad.prototype.onbuttondown = function (callback) {
  36892. this._onbuttondown = callback;
  36893. };
  36894. /**
  36895. * Defines the callback to call when a button is released
  36896. * @param callback defines the callback to use
  36897. */
  36898. Xbox360Pad.prototype.onbuttonup = function (callback) {
  36899. this._onbuttonup = callback;
  36900. };
  36901. /**
  36902. * Defines the callback to call when a pad is pressed
  36903. * @param callback defines the callback to use
  36904. */
  36905. Xbox360Pad.prototype.ondpaddown = function (callback) {
  36906. this._ondpaddown = callback;
  36907. };
  36908. /**
  36909. * Defines the callback to call when a pad is released
  36910. * @param callback defines the callback to use
  36911. */
  36912. Xbox360Pad.prototype.ondpadup = function (callback) {
  36913. this._ondpadup = callback;
  36914. };
  36915. Xbox360Pad.prototype._setButtonValue = function (newValue, currentValue, buttonType) {
  36916. if (newValue !== currentValue) {
  36917. if (newValue === 1) {
  36918. if (this._onbuttondown) {
  36919. this._onbuttondown(buttonType);
  36920. }
  36921. this.onButtonDownObservable.notifyObservers(buttonType);
  36922. }
  36923. if (newValue === 0) {
  36924. if (this._onbuttonup) {
  36925. this._onbuttonup(buttonType);
  36926. }
  36927. this.onButtonUpObservable.notifyObservers(buttonType);
  36928. }
  36929. }
  36930. return newValue;
  36931. };
  36932. Xbox360Pad.prototype._setDPadValue = function (newValue, currentValue, buttonType) {
  36933. if (newValue !== currentValue) {
  36934. if (newValue === 1) {
  36935. if (this._ondpaddown) {
  36936. this._ondpaddown(buttonType);
  36937. }
  36938. this.onPadDownObservable.notifyObservers(buttonType);
  36939. }
  36940. if (newValue === 0) {
  36941. if (this._ondpadup) {
  36942. this._ondpadup(buttonType);
  36943. }
  36944. this.onPadUpObservable.notifyObservers(buttonType);
  36945. }
  36946. }
  36947. return newValue;
  36948. };
  36949. Object.defineProperty(Xbox360Pad.prototype, "buttonA", {
  36950. /**
  36951. * Gets the value of the `A` button
  36952. */
  36953. get: function () {
  36954. return this._buttonA;
  36955. },
  36956. /**
  36957. * Sets the value of the `A` button
  36958. */
  36959. set: function (value) {
  36960. this._buttonA = this._setButtonValue(value, this._buttonA, Xbox360Button.A);
  36961. },
  36962. enumerable: true,
  36963. configurable: true
  36964. });
  36965. Object.defineProperty(Xbox360Pad.prototype, "buttonB", {
  36966. /**
  36967. * Gets the value of the `B` button
  36968. */
  36969. get: function () {
  36970. return this._buttonB;
  36971. },
  36972. /**
  36973. * Sets the value of the `B` button
  36974. */
  36975. set: function (value) {
  36976. this._buttonB = this._setButtonValue(value, this._buttonB, Xbox360Button.B);
  36977. },
  36978. enumerable: true,
  36979. configurable: true
  36980. });
  36981. Object.defineProperty(Xbox360Pad.prototype, "buttonX", {
  36982. /**
  36983. * Gets the value of the `X` button
  36984. */
  36985. get: function () {
  36986. return this._buttonX;
  36987. },
  36988. /**
  36989. * Sets the value of the `X` button
  36990. */
  36991. set: function (value) {
  36992. this._buttonX = this._setButtonValue(value, this._buttonX, Xbox360Button.X);
  36993. },
  36994. enumerable: true,
  36995. configurable: true
  36996. });
  36997. Object.defineProperty(Xbox360Pad.prototype, "buttonY", {
  36998. /**
  36999. * Gets the value of the `Y` button
  37000. */
  37001. get: function () {
  37002. return this._buttonY;
  37003. },
  37004. /**
  37005. * Sets the value of the `Y` button
  37006. */
  37007. set: function (value) {
  37008. this._buttonY = this._setButtonValue(value, this._buttonY, Xbox360Button.Y);
  37009. },
  37010. enumerable: true,
  37011. configurable: true
  37012. });
  37013. Object.defineProperty(Xbox360Pad.prototype, "buttonStart", {
  37014. /**
  37015. * Gets the value of the `Start` button
  37016. */
  37017. get: function () {
  37018. return this._buttonStart;
  37019. },
  37020. /**
  37021. * Sets the value of the `Start` button
  37022. */
  37023. set: function (value) {
  37024. this._buttonStart = this._setButtonValue(value, this._buttonStart, Xbox360Button.Start);
  37025. },
  37026. enumerable: true,
  37027. configurable: true
  37028. });
  37029. Object.defineProperty(Xbox360Pad.prototype, "buttonBack", {
  37030. /**
  37031. * Gets the value of the `Back` button
  37032. */
  37033. get: function () {
  37034. return this._buttonBack;
  37035. },
  37036. /**
  37037. * Sets the value of the `Back` button
  37038. */
  37039. set: function (value) {
  37040. this._buttonBack = this._setButtonValue(value, this._buttonBack, Xbox360Button.Back);
  37041. },
  37042. enumerable: true,
  37043. configurable: true
  37044. });
  37045. Object.defineProperty(Xbox360Pad.prototype, "buttonLB", {
  37046. /**
  37047. * Gets the value of the `Left` button
  37048. */
  37049. get: function () {
  37050. return this._buttonLB;
  37051. },
  37052. /**
  37053. * Sets the value of the `Left` button
  37054. */
  37055. set: function (value) {
  37056. this._buttonLB = this._setButtonValue(value, this._buttonLB, Xbox360Button.LB);
  37057. },
  37058. enumerable: true,
  37059. configurable: true
  37060. });
  37061. Object.defineProperty(Xbox360Pad.prototype, "buttonRB", {
  37062. /**
  37063. * Gets the value of the `Right` button
  37064. */
  37065. get: function () {
  37066. return this._buttonRB;
  37067. },
  37068. /**
  37069. * Sets the value of the `Right` button
  37070. */
  37071. set: function (value) {
  37072. this._buttonRB = this._setButtonValue(value, this._buttonRB, Xbox360Button.RB);
  37073. },
  37074. enumerable: true,
  37075. configurable: true
  37076. });
  37077. Object.defineProperty(Xbox360Pad.prototype, "buttonLeftStick", {
  37078. /**
  37079. * Gets the value of the Left joystick
  37080. */
  37081. get: function () {
  37082. return this._buttonLeftStick;
  37083. },
  37084. /**
  37085. * Sets the value of the Left joystick
  37086. */
  37087. set: function (value) {
  37088. this._buttonLeftStick = this._setButtonValue(value, this._buttonLeftStick, Xbox360Button.LeftStick);
  37089. },
  37090. enumerable: true,
  37091. configurable: true
  37092. });
  37093. Object.defineProperty(Xbox360Pad.prototype, "buttonRightStick", {
  37094. /**
  37095. * Gets the value of the Right joystick
  37096. */
  37097. get: function () {
  37098. return this._buttonRightStick;
  37099. },
  37100. /**
  37101. * Sets the value of the Right joystick
  37102. */
  37103. set: function (value) {
  37104. this._buttonRightStick = this._setButtonValue(value, this._buttonRightStick, Xbox360Button.RightStick);
  37105. },
  37106. enumerable: true,
  37107. configurable: true
  37108. });
  37109. Object.defineProperty(Xbox360Pad.prototype, "dPadUp", {
  37110. /**
  37111. * Gets the value of D-pad up
  37112. */
  37113. get: function () {
  37114. return this._dPadUp;
  37115. },
  37116. /**
  37117. * Sets the value of D-pad up
  37118. */
  37119. set: function (value) {
  37120. this._dPadUp = this._setDPadValue(value, this._dPadUp, Xbox360Dpad.Up);
  37121. },
  37122. enumerable: true,
  37123. configurable: true
  37124. });
  37125. Object.defineProperty(Xbox360Pad.prototype, "dPadDown", {
  37126. /**
  37127. * Gets the value of D-pad down
  37128. */
  37129. get: function () {
  37130. return this._dPadDown;
  37131. },
  37132. /**
  37133. * Sets the value of D-pad down
  37134. */
  37135. set: function (value) {
  37136. this._dPadDown = this._setDPadValue(value, this._dPadDown, Xbox360Dpad.Down);
  37137. },
  37138. enumerable: true,
  37139. configurable: true
  37140. });
  37141. Object.defineProperty(Xbox360Pad.prototype, "dPadLeft", {
  37142. /**
  37143. * Gets the value of D-pad left
  37144. */
  37145. get: function () {
  37146. return this._dPadLeft;
  37147. },
  37148. /**
  37149. * Sets the value of D-pad left
  37150. */
  37151. set: function (value) {
  37152. this._dPadLeft = this._setDPadValue(value, this._dPadLeft, Xbox360Dpad.Left);
  37153. },
  37154. enumerable: true,
  37155. configurable: true
  37156. });
  37157. Object.defineProperty(Xbox360Pad.prototype, "dPadRight", {
  37158. /**
  37159. * Gets the value of D-pad right
  37160. */
  37161. get: function () {
  37162. return this._dPadRight;
  37163. },
  37164. /**
  37165. * Sets the value of D-pad right
  37166. */
  37167. set: function (value) {
  37168. this._dPadRight = this._setDPadValue(value, this._dPadRight, Xbox360Dpad.Right);
  37169. },
  37170. enumerable: true,
  37171. configurable: true
  37172. });
  37173. /**
  37174. * Force the gamepad to synchronize with device values
  37175. */
  37176. Xbox360Pad.prototype.update = function () {
  37177. _super.prototype.update.call(this);
  37178. if (this._isXboxOnePad) {
  37179. this.buttonA = this.browserGamepad.buttons[0].value;
  37180. this.buttonB = this.browserGamepad.buttons[1].value;
  37181. this.buttonX = this.browserGamepad.buttons[2].value;
  37182. this.buttonY = this.browserGamepad.buttons[3].value;
  37183. this.buttonLB = this.browserGamepad.buttons[4].value;
  37184. this.buttonRB = this.browserGamepad.buttons[5].value;
  37185. this.leftTrigger = this.browserGamepad.axes[2];
  37186. this.rightTrigger = this.browserGamepad.axes[5];
  37187. this.buttonBack = this.browserGamepad.buttons[9].value;
  37188. this.buttonStart = this.browserGamepad.buttons[8].value;
  37189. this.buttonLeftStick = this.browserGamepad.buttons[6].value;
  37190. this.buttonRightStick = this.browserGamepad.buttons[7].value;
  37191. this.dPadUp = this.browserGamepad.buttons[11].value;
  37192. this.dPadDown = this.browserGamepad.buttons[12].value;
  37193. this.dPadLeft = this.browserGamepad.buttons[13].value;
  37194. this.dPadRight = this.browserGamepad.buttons[14].value;
  37195. }
  37196. else {
  37197. this.buttonA = this.browserGamepad.buttons[0].value;
  37198. this.buttonB = this.browserGamepad.buttons[1].value;
  37199. this.buttonX = this.browserGamepad.buttons[2].value;
  37200. this.buttonY = this.browserGamepad.buttons[3].value;
  37201. this.buttonLB = this.browserGamepad.buttons[4].value;
  37202. this.buttonRB = this.browserGamepad.buttons[5].value;
  37203. this.leftTrigger = this.browserGamepad.buttons[6].value;
  37204. this.rightTrigger = this.browserGamepad.buttons[7].value;
  37205. this.buttonBack = this.browserGamepad.buttons[8].value;
  37206. this.buttonStart = this.browserGamepad.buttons[9].value;
  37207. this.buttonLeftStick = this.browserGamepad.buttons[10].value;
  37208. this.buttonRightStick = this.browserGamepad.buttons[11].value;
  37209. this.dPadUp = this.browserGamepad.buttons[12].value;
  37210. this.dPadDown = this.browserGamepad.buttons[13].value;
  37211. this.dPadLeft = this.browserGamepad.buttons[14].value;
  37212. this.dPadRight = this.browserGamepad.buttons[15].value;
  37213. }
  37214. };
  37215. /**
  37216. * Disposes the gamepad
  37217. */
  37218. Xbox360Pad.prototype.dispose = function () {
  37219. _super.prototype.dispose.call(this);
  37220. this.onButtonDownObservable.clear();
  37221. this.onButtonUpObservable.clear();
  37222. this.onPadDownObservable.clear();
  37223. this.onPadUpObservable.clear();
  37224. };
  37225. return Xbox360Pad;
  37226. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"]));
  37227. /***/ }),
  37228. /***/ "./Gizmos/axisDragGizmo.ts":
  37229. /*!*********************************!*\
  37230. !*** ./Gizmos/axisDragGizmo.ts ***!
  37231. \*********************************/
  37232. /*! exports provided: AxisDragGizmo */
  37233. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37234. "use strict";
  37235. __webpack_require__.r(__webpack_exports__);
  37236. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return AxisDragGizmo; });
  37237. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37238. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37239. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37240. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  37241. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  37242. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  37243. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37244. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37245. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37246. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37247. /**
  37248. * Single axis drag gizmo
  37249. */
  37250. var AxisDragGizmo = /** @class */ (function (_super) {
  37251. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisDragGizmo, _super);
  37252. /**
  37253. * Creates an AxisDragGizmo
  37254. * @param gizmoLayer The utility layer the gizmo will be added to
  37255. * @param dragAxis The axis which the gizmo will be able to drag on
  37256. * @param color The color of the gizmo
  37257. */
  37258. function AxisDragGizmo(dragAxis, color, gizmoLayer) {
  37259. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  37260. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37261. var _this = _super.call(this, gizmoLayer) || this;
  37262. _this._pointerObserver = null;
  37263. /**
  37264. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  37265. */
  37266. _this.snapDistance = 0;
  37267. /**
  37268. * Event that fires each time the gizmo snaps to a new location.
  37269. * * snapDistance is the the change in distance
  37270. */
  37271. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37272. // Create Material
  37273. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37274. coloredMaterial.disableLighting = true;
  37275. coloredMaterial.emissiveColor = color;
  37276. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37277. hoverMaterial.disableLighting = true;
  37278. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  37279. // Build mesh on root node
  37280. var arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, coloredMaterial);
  37281. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  37282. arrow.scaling.scaleInPlace(1 / 3);
  37283. arrow.parent = _this._rootMesh;
  37284. var currentSnapDragDistance = 0;
  37285. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37286. var tmpSnapEvent = { snapDistance: 0 };
  37287. // Add drag behavior to handle events when the gizmo is dragged
  37288. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__["PointerDragBehavior"]({ dragAxis: dragAxis });
  37289. _this.dragBehavior.moveAttached = false;
  37290. _this._rootMesh.addBehavior(_this.dragBehavior);
  37291. var localDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37292. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  37293. _this.dragBehavior.onDragObservable.add(function (event) {
  37294. if (_this.attachedMesh) {
  37295. // Convert delta to local translation if it has a parent
  37296. if (_this.attachedMesh.parent) {
  37297. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  37298. tmpMatrix.setTranslationFromFloats(0, 0, 0);
  37299. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(event.delta, tmpMatrix, localDelta);
  37300. }
  37301. else {
  37302. localDelta.copyFrom(event.delta);
  37303. }
  37304. // Snapping logic
  37305. if (_this.snapDistance == 0) {
  37306. _this.attachedMesh.position.addInPlace(localDelta);
  37307. }
  37308. else {
  37309. currentSnapDragDistance += event.dragDistance;
  37310. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  37311. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  37312. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  37313. localDelta.normalizeToRef(tmpVector);
  37314. tmpVector.scaleInPlace(_this.snapDistance * dragSteps);
  37315. _this.attachedMesh.position.addInPlace(tmpVector);
  37316. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  37317. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  37318. }
  37319. }
  37320. }
  37321. });
  37322. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37323. if (_this._customMeshSet) {
  37324. return;
  37325. }
  37326. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  37327. var material = isHovered ? hoverMaterial : coloredMaterial;
  37328. _this._rootMesh.getChildMeshes().forEach(function (m) {
  37329. m.material = material;
  37330. if (m.color) {
  37331. m.color = material.emissiveColor;
  37332. }
  37333. });
  37334. });
  37335. return _this;
  37336. }
  37337. /** @hidden */
  37338. AxisDragGizmo._CreateArrow = function (scene, material) {
  37339. var arrow = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  37340. var cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0, height: 1.5, diameterBottom: 0.75, tessellation: 96 }, scene);
  37341. 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);
  37342. line.color = material.emissiveColor;
  37343. cylinder.parent = arrow;
  37344. line.parent = arrow;
  37345. // Position arrow pointing in its drag axis
  37346. cylinder.scaling.scaleInPlace(0.05);
  37347. cylinder.material = material;
  37348. cylinder.rotation.x = Math.PI / 2;
  37349. cylinder.position.z += 0.3;
  37350. line.scaling.scaleInPlace(0.26);
  37351. line.rotation.x = Math.PI / 2;
  37352. line.material = material;
  37353. return arrow;
  37354. };
  37355. /** @hidden */
  37356. AxisDragGizmo._CreateArrowInstance = function (scene, arrow) {
  37357. var instance = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  37358. for (var _i = 0, _a = arrow.getChildMeshes(); _i < _a.length; _i++) {
  37359. var mesh = _a[_i];
  37360. var childInstance = mesh.createInstance(mesh.name);
  37361. childInstance.parent = instance;
  37362. }
  37363. return instance;
  37364. };
  37365. AxisDragGizmo.prototype._attachedMeshChanged = function (value) {
  37366. if (this.dragBehavior) {
  37367. this.dragBehavior.enabled = value ? true : false;
  37368. }
  37369. };
  37370. /**
  37371. * Disposes of the gizmo
  37372. */
  37373. AxisDragGizmo.prototype.dispose = function () {
  37374. this.onSnapObservable.clear();
  37375. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  37376. this.dragBehavior.detach();
  37377. _super.prototype.dispose.call(this);
  37378. };
  37379. return AxisDragGizmo;
  37380. }(_gizmo__WEBPACK_IMPORTED_MODULE_7__["Gizmo"]));
  37381. /***/ }),
  37382. /***/ "./Gizmos/axisScaleGizmo.ts":
  37383. /*!**********************************!*\
  37384. !*** ./Gizmos/axisScaleGizmo.ts ***!
  37385. \**********************************/
  37386. /*! exports provided: AxisScaleGizmo */
  37387. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37388. "use strict";
  37389. __webpack_require__.r(__webpack_exports__);
  37390. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return AxisScaleGizmo; });
  37391. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37392. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37393. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37394. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  37395. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  37396. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  37397. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37398. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37399. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37400. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37401. /**
  37402. * Single axis scale gizmo
  37403. */
  37404. var AxisScaleGizmo = /** @class */ (function (_super) {
  37405. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisScaleGizmo, _super);
  37406. /**
  37407. * Creates an AxisScaleGizmo
  37408. * @param gizmoLayer The utility layer the gizmo will be added to
  37409. * @param dragAxis The axis which the gizmo will be able to scale on
  37410. * @param color The color of the gizmo
  37411. */
  37412. function AxisScaleGizmo(dragAxis, color, gizmoLayer) {
  37413. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  37414. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37415. var _this = _super.call(this, gizmoLayer) || this;
  37416. _this._pointerObserver = null;
  37417. /**
  37418. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  37419. */
  37420. _this.snapDistance = 0;
  37421. /**
  37422. * Event that fires each time the gizmo snaps to a new location.
  37423. * * snapDistance is the the change in distance
  37424. */
  37425. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37426. /**
  37427. * If the scaling operation should be done on all axis (default: false)
  37428. */
  37429. _this.uniformScaling = false;
  37430. // Create Material
  37431. _this._coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37432. _this._coloredMaterial.disableLighting = true;
  37433. _this._coloredMaterial.emissiveColor = color;
  37434. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37435. hoverMaterial.disableLighting = true;
  37436. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  37437. // Build mesh on root node
  37438. var arrow = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37439. var arrowMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__["BoxBuilder"].CreateBox("yPosMesh", { size: 0.4 }, gizmoLayer.utilityLayerScene);
  37440. 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);
  37441. arrowTail.color = _this._coloredMaterial.emissiveColor;
  37442. arrow.addChild(arrowMesh);
  37443. arrow.addChild(arrowTail);
  37444. // Position arrow pointing in its drag axis
  37445. arrowMesh.scaling.scaleInPlace(0.1);
  37446. arrowMesh.material = _this._coloredMaterial;
  37447. arrowMesh.rotation.x = Math.PI / 2;
  37448. arrowMesh.position.z += 0.3;
  37449. arrowTail.scaling.scaleInPlace(0.26);
  37450. arrowTail.rotation.x = Math.PI / 2;
  37451. arrowTail.material = _this._coloredMaterial;
  37452. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  37453. _this._rootMesh.addChild(arrow);
  37454. arrow.scaling.scaleInPlace(1 / 3);
  37455. // Add drag behavior to handle events when the gizmo is dragged
  37456. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__["PointerDragBehavior"]({ dragAxis: dragAxis });
  37457. _this.dragBehavior.moveAttached = false;
  37458. _this._rootMesh.addBehavior(_this.dragBehavior);
  37459. var currentSnapDragDistance = 0;
  37460. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37461. var tmpSnapEvent = { snapDistance: 0 };
  37462. _this.dragBehavior.onDragObservable.add(function (event) {
  37463. if (_this.attachedMesh) {
  37464. // Snapping logic
  37465. var snapped = false;
  37466. var dragSteps = 0;
  37467. if (_this.uniformScaling) {
  37468. _this.attachedMesh.scaling.normalizeToRef(tmpVector);
  37469. if (tmpVector.y < 0) {
  37470. tmpVector.scaleInPlace(-1);
  37471. }
  37472. }
  37473. else {
  37474. tmpVector.copyFrom(dragAxis);
  37475. }
  37476. if (_this.snapDistance == 0) {
  37477. tmpVector.scaleToRef(event.dragDistance, tmpVector);
  37478. }
  37479. else {
  37480. currentSnapDragDistance += event.dragDistance;
  37481. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  37482. dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  37483. if (currentSnapDragDistance < 0) {
  37484. dragSteps *= -1;
  37485. }
  37486. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  37487. tmpVector.scaleToRef(_this.snapDistance * dragSteps, tmpVector);
  37488. snapped = true;
  37489. }
  37490. else {
  37491. tmpVector.scaleInPlace(0);
  37492. }
  37493. }
  37494. _this.attachedMesh.scaling.addInPlace(tmpVector);
  37495. if (snapped) {
  37496. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  37497. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  37498. }
  37499. }
  37500. });
  37501. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37502. if (_this._customMeshSet) {
  37503. return;
  37504. }
  37505. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  37506. var material = isHovered ? hoverMaterial : _this._coloredMaterial;
  37507. _this._rootMesh.getChildMeshes().forEach(function (m) {
  37508. m.material = material;
  37509. if (m.color) {
  37510. m.color = material.emissiveColor;
  37511. }
  37512. });
  37513. });
  37514. return _this;
  37515. }
  37516. AxisScaleGizmo.prototype._attachedMeshChanged = function (value) {
  37517. if (this.dragBehavior) {
  37518. this.dragBehavior.enabled = value ? true : false;
  37519. }
  37520. };
  37521. /**
  37522. * Disposes of the gizmo
  37523. */
  37524. AxisScaleGizmo.prototype.dispose = function () {
  37525. this.onSnapObservable.clear();
  37526. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  37527. this.dragBehavior.detach();
  37528. _super.prototype.dispose.call(this);
  37529. };
  37530. /**
  37531. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  37532. * @param mesh The mesh to replace the default mesh of the gizmo
  37533. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  37534. */
  37535. AxisScaleGizmo.prototype.setCustomMesh = function (mesh, useGizmoMaterial) {
  37536. var _this = this;
  37537. if (useGizmoMaterial === void 0) { useGizmoMaterial = false; }
  37538. _super.prototype.setCustomMesh.call(this, mesh);
  37539. if (useGizmoMaterial) {
  37540. this._rootMesh.getChildMeshes().forEach(function (m) {
  37541. m.material = _this._coloredMaterial;
  37542. if (m.color) {
  37543. m.color = _this._coloredMaterial.emissiveColor;
  37544. }
  37545. });
  37546. this._customMeshSet = false;
  37547. }
  37548. };
  37549. return AxisScaleGizmo;
  37550. }(_gizmo__WEBPACK_IMPORTED_MODULE_8__["Gizmo"]));
  37551. /***/ }),
  37552. /***/ "./Gizmos/boundingBoxGizmo.ts":
  37553. /*!************************************!*\
  37554. !*** ./Gizmos/boundingBoxGizmo.ts ***!
  37555. \************************************/
  37556. /*! exports provided: BoundingBoxGizmo */
  37557. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37558. "use strict";
  37559. __webpack_require__.r(__webpack_exports__);
  37560. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return BoundingBoxGizmo; });
  37561. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37562. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37563. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  37564. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37565. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  37566. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  37567. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  37568. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  37569. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  37570. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37571. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37572. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37573. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37574. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Misc/pivotTools */ "./Misc/pivotTools.ts");
  37575. /**
  37576. * Bounding box gizmo
  37577. */
  37578. var BoundingBoxGizmo = /** @class */ (function (_super) {
  37579. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoundingBoxGizmo, _super);
  37580. /**
  37581. * Creates an BoundingBoxGizmo
  37582. * @param gizmoLayer The utility layer the gizmo will be added to
  37583. * @param color The color of the gizmo
  37584. */
  37585. function BoundingBoxGizmo(color, gizmoLayer) {
  37586. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Gray(); }
  37587. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__["UtilityLayerRenderer"].DefaultKeepDepthUtilityLayer; }
  37588. var _this = _super.call(this, gizmoLayer) || this;
  37589. _this._boundingDimensions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 1);
  37590. _this._renderObserver = null;
  37591. _this._pointerObserver = null;
  37592. _this._scaleDragSpeed = 0.2;
  37593. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37594. _this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  37595. _this._tmpRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  37596. /**
  37597. * 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)
  37598. */
  37599. _this.ignoreChildren = false;
  37600. /**
  37601. * 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)
  37602. */
  37603. _this.includeChildPredicate = null;
  37604. /**
  37605. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  37606. */
  37607. _this.rotationSphereSize = 0.1;
  37608. /**
  37609. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  37610. */
  37611. _this.scaleBoxSize = 0.1;
  37612. /**
  37613. * 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)
  37614. */
  37615. _this.fixedDragMeshScreenSize = false;
  37616. /**
  37617. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  37618. */
  37619. _this.fixedDragMeshScreenSizeDistanceFactor = 10;
  37620. /**
  37621. * Fired when a rotation sphere or scale box is dragged
  37622. */
  37623. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37624. /**
  37625. * Fired when a scale box is dragged
  37626. */
  37627. _this.onScaleBoxDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37628. /**
  37629. * Fired when a scale box drag is ended
  37630. */
  37631. _this.onScaleBoxDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37632. /**
  37633. * Fired when a rotation sphere is dragged
  37634. */
  37635. _this.onRotationSphereDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37636. /**
  37637. * Fired when a rotation sphere drag is ended
  37638. */
  37639. _this.onRotationSphereDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37640. /**
  37641. * 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)
  37642. */
  37643. _this.scalePivot = null;
  37644. _this._existingMeshScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  37645. // Dragging
  37646. _this._dragMesh = null;
  37647. _this.pointerDragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]();
  37648. // Do not update the gizmo's scale so it has a fixed size to the object its attached to
  37649. _this._updateScale = false;
  37650. _this._anchorMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("anchor", gizmoLayer.utilityLayerScene);
  37651. // Create Materials
  37652. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37653. coloredMaterial.disableLighting = true;
  37654. coloredMaterial.emissiveColor = color;
  37655. var hoverColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37656. hoverColoredMaterial.disableLighting = true;
  37657. hoverColoredMaterial.emissiveColor = color.clone().add(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.3, 0.3, 0.3));
  37658. // Build bounding box out of lines
  37659. _this._lineBoundingBox = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37660. _this._lineBoundingBox.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37661. var lines = [];
  37662. 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));
  37663. 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));
  37664. 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));
  37665. 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));
  37666. 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));
  37667. 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));
  37668. 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));
  37669. 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));
  37670. 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));
  37671. 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));
  37672. 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));
  37673. 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));
  37674. lines.forEach(function (l) {
  37675. l.color = color;
  37676. l.position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-_this._boundingDimensions.x / 2, -_this._boundingDimensions.y / 2, -_this._boundingDimensions.z / 2));
  37677. l.isPickable = false;
  37678. _this._lineBoundingBox.addChild(l);
  37679. });
  37680. _this._rootMesh.addChild(_this._lineBoundingBox);
  37681. // Create rotation spheres
  37682. _this._rotateSpheresParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37683. _this._rotateSpheresParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37684. var _loop_1 = function (i_1) {
  37685. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__["SphereBuilder"].CreateSphere("", { diameter: 1 }, gizmoLayer.utilityLayerScene);
  37686. sphere.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37687. sphere.material = coloredMaterial;
  37688. // Drag behavior
  37689. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({});
  37690. _dragBehavior.moveAttached = false;
  37691. _dragBehavior.updateDragPlane = false;
  37692. sphere.addBehavior(_dragBehavior);
  37693. var startingTurnDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  37694. var totalTurnAmountOfDrag = 0;
  37695. _dragBehavior.onDragStartObservable.add(function () {
  37696. startingTurnDirection.copyFrom(sphere.forward);
  37697. totalTurnAmountOfDrag = 0;
  37698. });
  37699. _dragBehavior.onDragObservable.add(function (event) {
  37700. _this.onRotationSphereDragObservable.notifyObservers({});
  37701. if (_this.attachedMesh) {
  37702. var originalParent = _this.attachedMesh.parent;
  37703. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  37704. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  37705. return;
  37706. }
  37707. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  37708. var worldDragDirection = startingTurnDirection;
  37709. // Project the world right on to the drag plane
  37710. var toSub = event.dragPlaneNormal.scale(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(event.dragPlaneNormal, worldDragDirection));
  37711. var dragAxis = worldDragDirection.subtract(toSub).normalizeToNew();
  37712. // project drag delta on to the resulting drag axis and rotate based on that
  37713. var projectDist = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(dragAxis, event.delta) < 0 ? Math.abs(event.delta.length()) : -Math.abs(event.delta.length());
  37714. // Make rotation relative to size of mesh.
  37715. projectDist = (projectDist / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  37716. // Rotate based on axis
  37717. if (!_this.attachedMesh.rotationQuaternion) {
  37718. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  37719. }
  37720. if (!_this._anchorMesh.rotationQuaternion) {
  37721. _this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this._anchorMesh.rotation.y, _this._anchorMesh.rotation.x, _this._anchorMesh.rotation.z);
  37722. }
  37723. // Do not allow the object to turn more than a full circle
  37724. totalTurnAmountOfDrag += projectDist;
  37725. if (Math.abs(totalTurnAmountOfDrag) <= 2 * Math.PI) {
  37726. if (i_1 >= 8) {
  37727. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, 0, projectDist, _this._tmpQuaternion);
  37728. }
  37729. else if (i_1 >= 4) {
  37730. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(projectDist, 0, 0, _this._tmpQuaternion);
  37731. }
  37732. else {
  37733. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, projectDist, 0, _this._tmpQuaternion);
  37734. }
  37735. // Rotate around center of bounding box
  37736. _this._anchorMesh.addChild(_this.attachedMesh);
  37737. _this._anchorMesh.rotationQuaternion.multiplyToRef(_this._tmpQuaternion, _this._anchorMesh.rotationQuaternion);
  37738. _this._anchorMesh.removeChild(_this.attachedMesh);
  37739. _this.attachedMesh.setParent(originalParent);
  37740. }
  37741. _this.updateBoundingBox();
  37742. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  37743. }
  37744. _this._updateDummy();
  37745. });
  37746. // Selection/deselection
  37747. _dragBehavior.onDragStartObservable.add(function () {
  37748. _this.onDragStartObservable.notifyObservers({});
  37749. _this._selectNode(sphere);
  37750. });
  37751. _dragBehavior.onDragEndObservable.add(function () {
  37752. _this.onRotationSphereDragEndObservable.notifyObservers({});
  37753. _this._selectNode(null);
  37754. _this._updateDummy();
  37755. });
  37756. this_1._rotateSpheresParent.addChild(sphere);
  37757. };
  37758. var this_1 = this, _dragBehavior;
  37759. for (var i_1 = 0; i_1 < 12; i_1++) {
  37760. _loop_1(i_1);
  37761. }
  37762. _this._rootMesh.addChild(_this._rotateSpheresParent);
  37763. // Create scale cubes
  37764. _this._scaleBoxesParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37765. _this._scaleBoxesParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37766. for (var i = 0; i < 2; i++) {
  37767. for (var j = 0; j < 2; j++) {
  37768. var _loop_2 = function () {
  37769. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("", { size: 1 }, gizmoLayer.utilityLayerScene);
  37770. box.material = coloredMaterial;
  37771. // Dragging logic
  37772. var dragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](i == 0 ? -1 : 1, j == 0 ? -1 : 1, k == 0 ? -1 : 1);
  37773. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({ dragAxis: dragAxis });
  37774. _dragBehavior.moveAttached = false;
  37775. box.addBehavior(_dragBehavior);
  37776. _dragBehavior.onDragObservable.add(function (event) {
  37777. _this.onScaleBoxDragObservable.notifyObservers({});
  37778. if (_this.attachedMesh) {
  37779. var originalParent = _this.attachedMesh.parent;
  37780. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  37781. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  37782. return;
  37783. }
  37784. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  37785. var relativeDragDistance = (event.dragDistance / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  37786. var deltaScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](relativeDragDistance, relativeDragDistance, relativeDragDistance);
  37787. deltaScale.scaleInPlace(_this._scaleDragSpeed);
  37788. _this.updateBoundingBox();
  37789. if (_this.scalePivot) {
  37790. _this.attachedMesh.getWorldMatrix().getRotationMatrixToRef(_this._tmpRotationMatrix);
  37791. // Move anchor to desired pivot point (Bottom left corner + dimension/2)
  37792. _this._boundingDimensions.scaleToRef(0.5, _this._tmpVector);
  37793. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  37794. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  37795. _this._boundingDimensions.multiplyToRef(_this.scalePivot, _this._tmpVector);
  37796. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  37797. _this._anchorMesh.position.addInPlace(_this._tmpVector);
  37798. }
  37799. else {
  37800. // Scale from the position of the opposite corner
  37801. box.absolutePosition.subtractToRef(_this._anchorMesh.position, _this._tmpVector);
  37802. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  37803. }
  37804. _this._anchorMesh.addChild(_this.attachedMesh);
  37805. _this._anchorMesh.scaling.addInPlace(deltaScale);
  37806. if (_this._anchorMesh.scaling.x < 0 || _this._anchorMesh.scaling.y < 0 || _this._anchorMesh.scaling.z < 0) {
  37807. _this._anchorMesh.scaling.subtractInPlace(deltaScale);
  37808. }
  37809. _this._anchorMesh.removeChild(_this.attachedMesh);
  37810. _this.attachedMesh.setParent(originalParent);
  37811. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  37812. }
  37813. _this._updateDummy();
  37814. });
  37815. // Selection/deselection
  37816. _dragBehavior.onDragStartObservable.add(function () {
  37817. _this.onDragStartObservable.notifyObservers({});
  37818. _this._selectNode(box);
  37819. });
  37820. _dragBehavior.onDragEndObservable.add(function () {
  37821. _this.onScaleBoxDragEndObservable.notifyObservers({});
  37822. _this._selectNode(null);
  37823. _this._updateDummy();
  37824. });
  37825. this_2._scaleBoxesParent.addChild(box);
  37826. };
  37827. var this_2 = this, _dragBehavior;
  37828. for (var k = 0; k < 2; k++) {
  37829. _loop_2();
  37830. }
  37831. }
  37832. }
  37833. _this._rootMesh.addChild(_this._scaleBoxesParent);
  37834. // Hover color change
  37835. var pointerIds = new Array();
  37836. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37837. if (!pointerIds[pointerInfo.event.pointerId]) {
  37838. _this._rotateSpheresParent.getChildMeshes().concat(_this._scaleBoxesParent.getChildMeshes()).forEach(function (mesh) {
  37839. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh == mesh) {
  37840. pointerIds[pointerInfo.event.pointerId] = mesh;
  37841. mesh.material = hoverColoredMaterial;
  37842. }
  37843. });
  37844. }
  37845. else {
  37846. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh != pointerIds[pointerInfo.event.pointerId]) {
  37847. pointerIds[pointerInfo.event.pointerId].material = coloredMaterial;
  37848. delete pointerIds[pointerInfo.event.pointerId];
  37849. }
  37850. }
  37851. });
  37852. // Update bounding box positions
  37853. _this._renderObserver = _this.gizmoLayer.originalScene.onBeforeRenderObservable.add(function () {
  37854. // Only update the bouding box if scaling has changed
  37855. if (_this.attachedMesh && !_this._existingMeshScale.equals(_this.attachedMesh.scaling)) {
  37856. _this.updateBoundingBox();
  37857. }
  37858. else if (_this.fixedDragMeshScreenSize) {
  37859. _this._updateRotationSpheres();
  37860. _this._updateScaleBoxes();
  37861. }
  37862. // If dragg mesh is enabled and dragging, update the attached mesh pose to match the drag mesh
  37863. if (_this._dragMesh && _this.attachedMesh && _this.pointerDragBehavior.dragging) {
  37864. _this._lineBoundingBox.position.rotateByQuaternionToRef(_this._rootMesh.rotationQuaternion, _this._tmpVector);
  37865. _this.attachedMesh.setAbsolutePosition(_this._dragMesh.position.add(_this._tmpVector.scale(-1)));
  37866. }
  37867. });
  37868. _this.updateBoundingBox();
  37869. return _this;
  37870. }
  37871. BoundingBoxGizmo.prototype._attachedMeshChanged = function (value) {
  37872. var _this = this;
  37873. if (value) {
  37874. // Reset anchor mesh to match attached mesh's scale
  37875. // This is needed to avoid invalid box/sphere position on first drag
  37876. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(value);
  37877. var originalParent = value.parent;
  37878. this._anchorMesh.addChild(value);
  37879. this._anchorMesh.removeChild(value);
  37880. value.setParent(originalParent);
  37881. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(value);
  37882. this.updateBoundingBox();
  37883. value.getChildMeshes(false).forEach(function (m) {
  37884. m.markAsDirty("scaling");
  37885. });
  37886. this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function () {
  37887. _this._updateDummy();
  37888. });
  37889. }
  37890. };
  37891. BoundingBoxGizmo.prototype._selectNode = function (selectedMesh) {
  37892. this._rotateSpheresParent.getChildMeshes()
  37893. .concat(this._scaleBoxesParent.getChildMeshes()).forEach(function (m) {
  37894. m.isVisible = (!selectedMesh || m == selectedMesh);
  37895. });
  37896. };
  37897. /**
  37898. * Updates the bounding box information for the Gizmo
  37899. */
  37900. BoundingBoxGizmo.prototype.updateBoundingBox = function () {
  37901. if (this.attachedMesh) {
  37902. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(this.attachedMesh);
  37903. var originalParent = this.attachedMesh.parent;
  37904. this.attachedMesh.setParent(null);
  37905. this._update();
  37906. // Rotate based on axis
  37907. if (!this.attachedMesh.rotationQuaternion) {
  37908. this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);
  37909. }
  37910. if (!this._anchorMesh.rotationQuaternion) {
  37911. this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z);
  37912. }
  37913. this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  37914. // Store original position and reset mesh to origin before computing the bounding box
  37915. this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  37916. this._tmpVector.copyFrom(this.attachedMesh.position);
  37917. this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1);
  37918. this.attachedMesh.position.set(0, 0, 0);
  37919. // Update bounding dimensions/positions
  37920. var boundingMinMax = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
  37921. boundingMinMax.max.subtractToRef(boundingMinMax.min, this._boundingDimensions);
  37922. // Update gizmo to match bounding box scaling and rotation
  37923. this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions);
  37924. 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);
  37925. this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position);
  37926. this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position);
  37927. this._lineBoundingBox.computeWorldMatrix();
  37928. this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition);
  37929. // restore position/rotation values
  37930. this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion);
  37931. this.attachedMesh.position.copyFrom(this._tmpVector);
  37932. this.attachedMesh.setParent(originalParent);
  37933. }
  37934. this._updateRotationSpheres();
  37935. this._updateScaleBoxes();
  37936. if (this.attachedMesh) {
  37937. this._existingMeshScale.copyFrom(this.attachedMesh.scaling);
  37938. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(this.attachedMesh);
  37939. }
  37940. };
  37941. BoundingBoxGizmo.prototype._updateRotationSpheres = function () {
  37942. var rotateSpheres = this._rotateSpheresParent.getChildMeshes();
  37943. for (var i = 0; i < 3; i++) {
  37944. for (var j = 0; j < 2; j++) {
  37945. for (var k = 0; k < 2; k++) {
  37946. var index = ((i * 4) + (j * 2)) + k;
  37947. if (i == 0) {
  37948. rotateSpheres[index].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  37949. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37950. 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));
  37951. }
  37952. if (i == 1) {
  37953. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y / 2, this._boundingDimensions.z * k);
  37954. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37955. 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));
  37956. }
  37957. if (i == 2) {
  37958. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y * k, this._boundingDimensions.z / 2);
  37959. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37960. 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));
  37961. }
  37962. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  37963. rotateSpheres[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  37964. var distanceFromCamera = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  37965. rotateSpheres[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  37966. }
  37967. else {
  37968. rotateSpheres[index].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize);
  37969. }
  37970. }
  37971. }
  37972. }
  37973. };
  37974. BoundingBoxGizmo.prototype._updateScaleBoxes = function () {
  37975. var scaleBoxes = this._scaleBoxesParent.getChildMeshes();
  37976. for (var i = 0; i < 2; i++) {
  37977. for (var j = 0; j < 2; j++) {
  37978. for (var k = 0; k < 2; k++) {
  37979. var index = ((i * 4) + (j * 2)) + k;
  37980. if (scaleBoxes[index]) {
  37981. scaleBoxes[index].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  37982. scaleBoxes[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37983. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  37984. scaleBoxes[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  37985. var distanceFromCamera = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  37986. scaleBoxes[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  37987. }
  37988. else {
  37989. scaleBoxes[index].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);
  37990. }
  37991. }
  37992. }
  37993. }
  37994. }
  37995. };
  37996. /**
  37997. * Enables rotation on the specified axis and disables rotation on the others
  37998. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  37999. */
  38000. BoundingBoxGizmo.prototype.setEnabledRotationAxis = function (axis) {
  38001. this._rotateSpheresParent.getChildMeshes().forEach(function (m, i) {
  38002. if (i < 4) {
  38003. m.setEnabled(axis.indexOf("x") != -1);
  38004. }
  38005. else if (i < 8) {
  38006. m.setEnabled(axis.indexOf("y") != -1);
  38007. }
  38008. else {
  38009. m.setEnabled(axis.indexOf("z") != -1);
  38010. }
  38011. });
  38012. };
  38013. /**
  38014. * Enables/disables scaling
  38015. * @param enable if scaling should be enabled
  38016. */
  38017. BoundingBoxGizmo.prototype.setEnabledScaling = function (enable) {
  38018. this._scaleBoxesParent.getChildMeshes().forEach(function (m, i) {
  38019. m.setEnabled(enable);
  38020. });
  38021. };
  38022. BoundingBoxGizmo.prototype._updateDummy = function () {
  38023. if (this._dragMesh) {
  38024. this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition());
  38025. this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling);
  38026. this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion);
  38027. }
  38028. };
  38029. /**
  38030. * Enables a pointer drag behavior on the bounding box of the gizmo
  38031. */
  38032. BoundingBoxGizmo.prototype.enableDragBehavior = function () {
  38033. this._dragMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].CreateBox("dummy", 1, this.gizmoLayer.utilityLayerScene);
  38034. this._dragMesh.visibility = 0;
  38035. this._dragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38036. this.pointerDragBehavior.useObjectOrienationForDragging = false;
  38037. this._dragMesh.addBehavior(this.pointerDragBehavior);
  38038. };
  38039. /**
  38040. * Disposes of the gizmo
  38041. */
  38042. BoundingBoxGizmo.prototype.dispose = function () {
  38043. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38044. this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver);
  38045. this._lineBoundingBox.dispose();
  38046. this._rotateSpheresParent.dispose();
  38047. this._scaleBoxesParent.dispose();
  38048. if (this._dragMesh) {
  38049. this._dragMesh.dispose();
  38050. }
  38051. _super.prototype.dispose.call(this);
  38052. };
  38053. /**
  38054. * 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)
  38055. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  38056. * @returns the bounding box mesh with the passed in mesh as a child
  38057. */
  38058. BoundingBoxGizmo.MakeNotPickableAndWrapInBoundingBox = function (mesh) {
  38059. var makeNotPickable = function (root) {
  38060. root.isPickable = false;
  38061. root.getChildMeshes().forEach(function (c) {
  38062. makeNotPickable(c);
  38063. });
  38064. };
  38065. makeNotPickable(mesh);
  38066. // Reset position to get boudning box from origin with no rotation
  38067. if (!mesh.rotationQuaternion) {
  38068. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);
  38069. }
  38070. var oldPos = mesh.position.clone();
  38071. var oldRot = mesh.rotationQuaternion.clone();
  38072. mesh.rotationQuaternion.set(0, 0, 0, 1);
  38073. mesh.position.set(0, 0, 0);
  38074. // Update bounding dimensions/positions
  38075. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("box", { size: 1 }, mesh.getScene());
  38076. var boundingMinMax = mesh.getHierarchyBoundingVectors();
  38077. boundingMinMax.max.subtractToRef(boundingMinMax.min, box.scaling);
  38078. // Adjust scale to avoid undefined behavior when adding child
  38079. if (box.scaling.y === 0) {
  38080. box.scaling.y = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38081. }
  38082. if (box.scaling.x === 0) {
  38083. box.scaling.x = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38084. }
  38085. if (box.scaling.z === 0) {
  38086. box.scaling.z = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38087. }
  38088. box.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);
  38089. // Restore original positions
  38090. mesh.addChild(box);
  38091. mesh.rotationQuaternion.copyFrom(oldRot);
  38092. mesh.position.copyFrom(oldPos);
  38093. // Reverse parenting
  38094. mesh.removeChild(box);
  38095. box.addChild(mesh);
  38096. box.visibility = 0;
  38097. return box;
  38098. };
  38099. /**
  38100. * CustomMeshes are not supported by this gizmo
  38101. * @param mesh The mesh to replace the default mesh of the gizmo
  38102. */
  38103. BoundingBoxGizmo.prototype.setCustomMesh = function (mesh) {
  38104. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("Custom meshes are not supported on this gizmo");
  38105. };
  38106. return BoundingBoxGizmo;
  38107. }(_gizmo__WEBPACK_IMPORTED_MODULE_10__["Gizmo"]));
  38108. /***/ }),
  38109. /***/ "./Gizmos/gizmo.ts":
  38110. /*!*************************!*\
  38111. !*** ./Gizmos/gizmo.ts ***!
  38112. \*************************/
  38113. /*! exports provided: Gizmo */
  38114. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38115. "use strict";
  38116. __webpack_require__.r(__webpack_exports__);
  38117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return Gizmo; });
  38118. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38119. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38120. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38121. /**
  38122. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  38123. */
  38124. var Gizmo = /** @class */ (function () {
  38125. /**
  38126. * Creates a gizmo
  38127. * @param gizmoLayer The utility layer the gizmo will be added to
  38128. */
  38129. function Gizmo(
  38130. /** The utility layer the gizmo will be added to */
  38131. gizmoLayer) {
  38132. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38133. var _this = this;
  38134. this.gizmoLayer = gizmoLayer;
  38135. /**
  38136. * Ratio for the scale of the gizmo (Default: 1)
  38137. */
  38138. this.scaleRatio = 1;
  38139. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  38140. /**
  38141. * If a custom mesh has been set (Default: false)
  38142. */
  38143. this._customMeshSet = false;
  38144. /**
  38145. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  38146. */
  38147. this.updateGizmoRotationToMatchAttachedMesh = true;
  38148. /**
  38149. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  38150. */
  38151. this.updateGizmoPositionToMatchAttachedMesh = true;
  38152. /**
  38153. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  38154. */
  38155. this._updateScale = true;
  38156. this._interactionsEnabled = true;
  38157. this._tempVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  38158. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]("gizmoRootNode", gizmoLayer.utilityLayerScene);
  38159. this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function () {
  38160. _this._update();
  38161. });
  38162. this.attachedMesh = null;
  38163. }
  38164. Object.defineProperty(Gizmo.prototype, "attachedMesh", {
  38165. /**
  38166. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  38167. * * When set, interactions will be enabled
  38168. */
  38169. get: function () {
  38170. return this._attachedMesh;
  38171. },
  38172. set: function (value) {
  38173. this._attachedMesh = value;
  38174. this._rootMesh.setEnabled(value ? true : false);
  38175. this._attachedMeshChanged(value);
  38176. },
  38177. enumerable: true,
  38178. configurable: true
  38179. });
  38180. /**
  38181. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  38182. * @param mesh The mesh to replace the default mesh of the gizmo
  38183. */
  38184. Gizmo.prototype.setCustomMesh = function (mesh) {
  38185. if (mesh.getScene() != this.gizmoLayer.utilityLayerScene) {
  38186. throw "When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";
  38187. }
  38188. this._rootMesh.getChildMeshes().forEach(function (c) {
  38189. c.dispose();
  38190. });
  38191. mesh.parent = this._rootMesh;
  38192. this._customMeshSet = true;
  38193. };
  38194. Gizmo.prototype._attachedMeshChanged = function (value) {
  38195. };
  38196. /**
  38197. * @hidden
  38198. * Updates the gizmo to match the attached mesh's position/rotation
  38199. */
  38200. Gizmo.prototype._update = function () {
  38201. if (this.attachedMesh) {
  38202. if (this.updateGizmoRotationToMatchAttachedMesh) {
  38203. if (!this._rootMesh.rotationQuaternion) {
  38204. this._rootMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(this._rootMesh.rotation.y, this._rootMesh.rotation.x, this._rootMesh.rotation.z);
  38205. }
  38206. // Remove scaling before getting rotation matrix to get rotation matrix unmodified by scale
  38207. this._tempVector.copyFrom(this.attachedMesh.scaling);
  38208. if (this.attachedMesh.scaling.x < 0) {
  38209. this.attachedMesh.scaling.x *= -1;
  38210. }
  38211. if (this.attachedMesh.scaling.y < 0) {
  38212. this.attachedMesh.scaling.y *= -1;
  38213. }
  38214. if (this.attachedMesh.scaling.z < 0) {
  38215. this.attachedMesh.scaling.z *= -1;
  38216. }
  38217. this.attachedMesh.computeWorldMatrix().getRotationMatrixToRef(this._tmpMatrix);
  38218. this.attachedMesh.scaling.copyFrom(this._tempVector);
  38219. this.attachedMesh.computeWorldMatrix();
  38220. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._tmpMatrix, this._rootMesh.rotationQuaternion);
  38221. }
  38222. else if (this._rootMesh.rotationQuaternion) {
  38223. this._rootMesh.rotationQuaternion.set(0, 0, 0, 1);
  38224. }
  38225. if (this.updateGizmoPositionToMatchAttachedMesh) {
  38226. this._rootMesh.position.copyFrom(this.attachedMesh.absolutePosition);
  38227. }
  38228. if (this._updateScale && this.gizmoLayer.utilityLayerScene.activeCamera && this.attachedMesh) {
  38229. var cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.globalPosition;
  38230. if (this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition) {
  38231. cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition;
  38232. }
  38233. this._rootMesh.position.subtractToRef(cameraPosition, this._tempVector);
  38234. var dist = this._tempVector.length() * this.scaleRatio;
  38235. this._rootMesh.scaling.set(dist, dist, dist);
  38236. }
  38237. }
  38238. };
  38239. /**
  38240. * Disposes of the gizmo
  38241. */
  38242. Gizmo.prototype.dispose = function () {
  38243. this._rootMesh.dispose();
  38244. if (this._beforeRenderObserver) {
  38245. this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  38246. }
  38247. };
  38248. return Gizmo;
  38249. }());
  38250. /***/ }),
  38251. /***/ "./Gizmos/gizmoManager.ts":
  38252. /*!********************************!*\
  38253. !*** ./Gizmos/gizmoManager.ts ***!
  38254. \********************************/
  38255. /*! exports provided: GizmoManager */
  38256. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38257. "use strict";
  38258. __webpack_require__.r(__webpack_exports__);
  38259. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return GizmoManager; });
  38260. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38261. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  38262. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38263. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38264. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38265. /* harmony import */ var _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  38266. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  38267. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  38268. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  38269. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  38270. /**
  38271. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  38272. */
  38273. var GizmoManager = /** @class */ (function () {
  38274. /**
  38275. * Instatiates a gizmo manager
  38276. * @param scene the scene to overlay the gizmos on top of
  38277. */
  38278. function GizmoManager(scene) {
  38279. var _this = this;
  38280. this.scene = scene;
  38281. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  38282. this.clearGizmoOnEmptyPointerEvent = false;
  38283. /** Fires an event when the manager is attached to a mesh */
  38284. this.onAttachedToMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  38285. this._gizmosEnabled = { positionGizmo: false, rotationGizmo: false, scaleGizmo: false, boundingBoxGizmo: false };
  38286. this._pointerObserver = null;
  38287. this._attachedMesh = null;
  38288. this._boundingBoxColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromHexString("#0984e3");
  38289. /**
  38290. * When bounding box gizmo is enabled, this can be used to track drag/end events
  38291. */
  38292. this.boundingBoxDragBehavior = new _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]();
  38293. /**
  38294. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  38295. */
  38296. this.attachableMeshes = null;
  38297. /**
  38298. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  38299. */
  38300. this.usePointerToAttachGizmos = true;
  38301. this._defaultKeepDepthUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  38302. this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  38303. this._defaultUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  38304. this.gizmos = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };
  38305. // Instatiate/dispose gizmos based on pointer actions
  38306. this._pointerObserver = scene.onPointerObservable.add(function (pointerInfo) {
  38307. if (!_this.usePointerToAttachGizmos) {
  38308. return;
  38309. }
  38310. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  38311. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh) {
  38312. var node = pointerInfo.pickInfo.pickedMesh;
  38313. if (_this.attachableMeshes == null) {
  38314. // Attach to the most parent node
  38315. while (node && node.parent != null) {
  38316. node = node.parent;
  38317. }
  38318. }
  38319. else {
  38320. // Attach to the parent node that is an attachableMesh
  38321. var found = false;
  38322. _this.attachableMeshes.forEach(function (mesh) {
  38323. if (node && (node == mesh || node.isDescendantOf(mesh))) {
  38324. node = mesh;
  38325. found = true;
  38326. }
  38327. });
  38328. if (!found) {
  38329. node = null;
  38330. }
  38331. }
  38332. if (node instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]) {
  38333. if (_this._attachedMesh != node) {
  38334. _this.attachToMesh(node);
  38335. }
  38336. }
  38337. else {
  38338. if (_this.clearGizmoOnEmptyPointerEvent) {
  38339. _this.attachToMesh(null);
  38340. }
  38341. }
  38342. }
  38343. else {
  38344. if (_this.clearGizmoOnEmptyPointerEvent) {
  38345. _this.attachToMesh(null);
  38346. }
  38347. }
  38348. }
  38349. });
  38350. }
  38351. /**
  38352. * Attaches a set of gizmos to the specified mesh
  38353. * @param mesh The mesh the gizmo's should be attached to
  38354. */
  38355. GizmoManager.prototype.attachToMesh = function (mesh) {
  38356. if (this._attachedMesh) {
  38357. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  38358. }
  38359. this._attachedMesh = mesh;
  38360. for (var key in this.gizmos) {
  38361. var gizmo = (this.gizmos[key]);
  38362. if (gizmo && this._gizmosEnabled[key]) {
  38363. gizmo.attachedMesh = mesh;
  38364. }
  38365. }
  38366. if (this.boundingBoxGizmoEnabled && this._attachedMesh) {
  38367. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  38368. }
  38369. this.onAttachedToMeshObservable.notifyObservers(mesh);
  38370. };
  38371. Object.defineProperty(GizmoManager.prototype, "positionGizmoEnabled", {
  38372. get: function () {
  38373. return this._gizmosEnabled.positionGizmo;
  38374. },
  38375. /**
  38376. * If the position gizmo is enabled
  38377. */
  38378. set: function (value) {
  38379. if (value) {
  38380. if (!this.gizmos.positionGizmo) {
  38381. this.gizmos.positionGizmo = new _positionGizmo__WEBPACK_IMPORTED_MODULE_7__["PositionGizmo"](this._defaultUtilityLayer);
  38382. }
  38383. this.gizmos.positionGizmo.attachedMesh = this._attachedMesh;
  38384. }
  38385. else if (this.gizmos.positionGizmo) {
  38386. this.gizmos.positionGizmo.attachedMesh = null;
  38387. }
  38388. this._gizmosEnabled.positionGizmo = value;
  38389. },
  38390. enumerable: true,
  38391. configurable: true
  38392. });
  38393. Object.defineProperty(GizmoManager.prototype, "rotationGizmoEnabled", {
  38394. get: function () {
  38395. return this._gizmosEnabled.rotationGizmo;
  38396. },
  38397. /**
  38398. * If the rotation gizmo is enabled
  38399. */
  38400. set: function (value) {
  38401. if (value) {
  38402. if (!this.gizmos.rotationGizmo) {
  38403. this.gizmos.rotationGizmo = new _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__["RotationGizmo"](this._defaultUtilityLayer);
  38404. }
  38405. this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh;
  38406. }
  38407. else if (this.gizmos.rotationGizmo) {
  38408. this.gizmos.rotationGizmo.attachedMesh = null;
  38409. }
  38410. this._gizmosEnabled.rotationGizmo = value;
  38411. },
  38412. enumerable: true,
  38413. configurable: true
  38414. });
  38415. Object.defineProperty(GizmoManager.prototype, "scaleGizmoEnabled", {
  38416. get: function () {
  38417. return this._gizmosEnabled.scaleGizmo;
  38418. },
  38419. /**
  38420. * If the scale gizmo is enabled
  38421. */
  38422. set: function (value) {
  38423. if (value) {
  38424. this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"](this._defaultUtilityLayer);
  38425. this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh;
  38426. }
  38427. else if (this.gizmos.scaleGizmo) {
  38428. this.gizmos.scaleGizmo.attachedMesh = null;
  38429. }
  38430. this._gizmosEnabled.scaleGizmo = value;
  38431. },
  38432. enumerable: true,
  38433. configurable: true
  38434. });
  38435. Object.defineProperty(GizmoManager.prototype, "boundingBoxGizmoEnabled", {
  38436. get: function () {
  38437. return this._gizmosEnabled.boundingBoxGizmo;
  38438. },
  38439. /**
  38440. * If the boundingBox gizmo is enabled
  38441. */
  38442. set: function (value) {
  38443. if (value) {
  38444. this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__["BoundingBoxGizmo"](this._boundingBoxColor, this._defaultKeepDepthUtilityLayer);
  38445. this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh;
  38446. if (this._attachedMesh) {
  38447. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  38448. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  38449. }
  38450. }
  38451. else if (this.gizmos.boundingBoxGizmo) {
  38452. this.gizmos.boundingBoxGizmo.attachedMesh = null;
  38453. }
  38454. this._gizmosEnabled.boundingBoxGizmo = value;
  38455. },
  38456. enumerable: true,
  38457. configurable: true
  38458. });
  38459. /**
  38460. * Disposes of the gizmo manager
  38461. */
  38462. GizmoManager.prototype.dispose = function () {
  38463. this.scene.onPointerObservable.remove(this._pointerObserver);
  38464. for (var key in this.gizmos) {
  38465. var gizmo = (this.gizmos[key]);
  38466. if (gizmo) {
  38467. gizmo.dispose();
  38468. }
  38469. }
  38470. this._defaultKeepDepthUtilityLayer.dispose();
  38471. this._defaultUtilityLayer.dispose();
  38472. this.boundingBoxDragBehavior.detach();
  38473. this.onAttachedToMeshObservable.clear();
  38474. };
  38475. return GizmoManager;
  38476. }());
  38477. /***/ }),
  38478. /***/ "./Gizmos/index.ts":
  38479. /*!*************************!*\
  38480. !*** ./Gizmos/index.ts ***!
  38481. \*************************/
  38482. /*! exports provided: AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo */
  38483. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38484. "use strict";
  38485. __webpack_require__.r(__webpack_exports__);
  38486. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  38487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  38488. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  38489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__["AxisScaleGizmo"]; });
  38490. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  38491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__["BoundingBoxGizmo"]; });
  38492. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _gizmo__WEBPACK_IMPORTED_MODULE_3__["Gizmo"]; });
  38494. /* harmony import */ var _gizmoManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmoManager */ "./Gizmos/gizmoManager.ts");
  38495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _gizmoManager__WEBPACK_IMPORTED_MODULE_4__["GizmoManager"]; });
  38496. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  38497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__["PlaneRotationGizmo"]; });
  38498. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  38499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _positionGizmo__WEBPACK_IMPORTED_MODULE_6__["PositionGizmo"]; });
  38500. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  38501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__["RotationGizmo"]; });
  38502. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  38503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"]; });
  38504. /* harmony import */ var _lightGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./lightGizmo */ "./Gizmos/lightGizmo.ts");
  38505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _lightGizmo__WEBPACK_IMPORTED_MODULE_9__["LightGizmo"]; });
  38506. /***/ }),
  38507. /***/ "./Gizmos/lightGizmo.ts":
  38508. /*!******************************!*\
  38509. !*** ./Gizmos/lightGizmo.ts ***!
  38510. \******************************/
  38511. /*! exports provided: LightGizmo */
  38512. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38513. "use strict";
  38514. __webpack_require__.r(__webpack_exports__);
  38515. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return LightGizmo; });
  38516. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38517. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38518. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38519. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38520. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38521. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38522. /**
  38523. * Gizmo that enables viewing a light
  38524. */
  38525. var LightGizmo = /** @class */ (function (_super) {
  38526. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LightGizmo, _super);
  38527. /**
  38528. * Creates a LightGizmo
  38529. * @param gizmoLayer The utility layer the gizmo will be added to
  38530. */
  38531. function LightGizmo(gizmoLayer) {
  38532. var _this = _super.call(this, gizmoLayer) || this;
  38533. _this._light = null;
  38534. _this._box = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder("light", 0.02, 0, 0.02, 16, 1, _this.gizmoLayer.utilityLayerScene);
  38535. _this._box.rotation.x = -Math.PI / 2;
  38536. _this._box.bakeCurrentTransformIntoVertices();
  38537. _this._box.material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("", _this.gizmoLayer.utilityLayerScene);
  38538. _this._box.material.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Yellow();
  38539. _this._rootMesh.addChild(_this._box);
  38540. _this.attachedMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", _this.gizmoLayer.utilityLayerScene);
  38541. return _this;
  38542. }
  38543. Object.defineProperty(LightGizmo.prototype, "light", {
  38544. get: function () {
  38545. return this._light;
  38546. },
  38547. /**
  38548. * The light that the gizmo is attached to
  38549. */
  38550. set: function (light) {
  38551. this._light = light;
  38552. if (light.position) {
  38553. this.attachedMesh.position.copyFrom(light.position);
  38554. }
  38555. if (light.direction) {
  38556. this._box.setDirection(light.direction);
  38557. }
  38558. },
  38559. enumerable: true,
  38560. configurable: true
  38561. });
  38562. /**
  38563. * @hidden
  38564. * Updates the gizmo to match the attached mesh's position/rotation
  38565. */
  38566. LightGizmo.prototype._update = function () {
  38567. _super.prototype._update.call(this);
  38568. if (!this._light) {
  38569. return;
  38570. }
  38571. if (this._light.position) {
  38572. this._light.position.copyFrom(this.attachedMesh.position);
  38573. }
  38574. if (this._light.direction) {
  38575. this._light.direction.copyFrom(this._box.forward);
  38576. }
  38577. if (!this._light.isEnabled()) {
  38578. this._box.material.emissiveColor.set(0, 0, 0);
  38579. }
  38580. else {
  38581. this._box.material.emissiveColor.set(1, 1, 1);
  38582. }
  38583. };
  38584. return LightGizmo;
  38585. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  38586. /***/ }),
  38587. /***/ "./Gizmos/planeRotationGizmo.ts":
  38588. /*!**************************************!*\
  38589. !*** ./Gizmos/planeRotationGizmo.ts ***!
  38590. \**************************************/
  38591. /*! exports provided: PlaneRotationGizmo */
  38592. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38593. "use strict";
  38594. __webpack_require__.r(__webpack_exports__);
  38595. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return PlaneRotationGizmo; });
  38596. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38597. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38598. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38599. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38600. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38601. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38602. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38603. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38604. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38605. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  38606. /**
  38607. * Single plane rotation gizmo
  38608. */
  38609. var PlaneRotationGizmo = /** @class */ (function (_super) {
  38610. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaneRotationGizmo, _super);
  38611. /**
  38612. * Creates a PlaneRotationGizmo
  38613. * @param gizmoLayer The utility layer the gizmo will be added to
  38614. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  38615. * @param color The color of the gizmo
  38616. * @param tessellation Amount of tessellation to be used when creating rotation circles
  38617. */
  38618. function PlaneRotationGizmo(planeNormal, color, gizmoLayer, tessellation) {
  38619. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  38620. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38621. if (tessellation === void 0) { tessellation = 32; }
  38622. var _this = _super.call(this, gizmoLayer) || this;
  38623. _this._pointerObserver = null;
  38624. /**
  38625. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  38626. */
  38627. _this.snapDistance = 0;
  38628. /**
  38629. * Event that fires each time the gizmo snaps to a new location.
  38630. * * snapDistance is the the change in distance
  38631. */
  38632. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38633. // Create Material
  38634. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38635. coloredMaterial.disableLighting = true;
  38636. coloredMaterial.emissiveColor = color;
  38637. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38638. hoverMaterial.disableLighting = true;
  38639. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  38640. // Build mesh on root node
  38641. var parentMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38642. // Create circle out of lines
  38643. var radius = 0.8;
  38644. var points = new Array();
  38645. for (var i = 0; i < tessellation; i++) {
  38646. var radian = (2 * Math.PI) * (i / (tessellation - 1));
  38647. points.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](radius * Math.sin(radian), 0, radius * Math.cos(radian)));
  38648. }
  38649. var rotationMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateLines("", points, gizmoLayer.utilityLayerScene);
  38650. rotationMesh.color = coloredMaterial.emissiveColor;
  38651. // Position arrow pointing in its drag axis
  38652. rotationMesh.scaling.scaleInPlace(0.26);
  38653. rotationMesh.material = coloredMaterial;
  38654. rotationMesh.rotation.x = Math.PI / 2;
  38655. parentMesh.addChild(rotationMesh);
  38656. parentMesh.lookAt(_this._rootMesh.position.add(planeNormal));
  38657. _this._rootMesh.addChild(parentMesh);
  38658. parentMesh.scaling.scaleInPlace(1 / 3);
  38659. // Add drag behavior to handle events when the gizmo is dragged
  38660. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragPlaneNormal: planeNormal });
  38661. _this.dragBehavior.moveAttached = false;
  38662. _this.dragBehavior.maxDragAngle = Math.PI * 9 / 20;
  38663. _this.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = true;
  38664. _this._rootMesh.addBehavior(_this.dragBehavior);
  38665. var lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38666. _this.dragBehavior.onDragStartObservable.add(function (e) {
  38667. if (_this.attachedMesh) {
  38668. lastDragPosition.copyFrom(e.dragPlanePoint);
  38669. }
  38670. });
  38671. var rotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  38672. var planeNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38673. var localPlaneNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38674. var tmpSnapEvent = { snapDistance: 0 };
  38675. var currentSnapDragDistance = 0;
  38676. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  38677. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38678. var amountToRotate = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  38679. _this.dragBehavior.onDragObservable.add(function (event) {
  38680. if (_this.attachedMesh) {
  38681. if (!_this.attachedMesh.rotationQuaternion) {
  38682. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  38683. }
  38684. // Calc angle over full 360 degree (https://stackoverflow.com/questions/43493711/the-angle-between-two-3d-vectors-with-a-result-range-0-360)
  38685. var newVector = event.dragPlanePoint.subtract(_this.attachedMesh.absolutePosition).normalize();
  38686. var originalVector = lastDragPosition.subtract(_this.attachedMesh.absolutePosition).normalize();
  38687. var cross = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(newVector, originalVector);
  38688. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(newVector, originalVector);
  38689. var angle = Math.atan2(cross.length(), dot);
  38690. planeNormalTowardsCamera.copyFrom(planeNormal);
  38691. localPlaneNormalTowardsCamera.copyFrom(planeNormal);
  38692. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  38693. _this.attachedMesh.rotationQuaternion.toRotationMatrix(rotationMatrix);
  38694. localPlaneNormalTowardsCamera = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(planeNormalTowardsCamera, rotationMatrix);
  38695. }
  38696. // Flip up vector depending on which side the camera is on
  38697. if (gizmoLayer.utilityLayerScene.activeCamera) {
  38698. var camVec = gizmoLayer.utilityLayerScene.activeCamera.position.subtract(_this.attachedMesh.position);
  38699. if (_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(camVec, localPlaneNormalTowardsCamera) > 0) {
  38700. planeNormalTowardsCamera.scaleInPlace(-1);
  38701. localPlaneNormalTowardsCamera.scaleInPlace(-1);
  38702. }
  38703. }
  38704. var halfCircleSide = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(localPlaneNormalTowardsCamera, cross) > 0.0;
  38705. if (halfCircleSide) {
  38706. angle = -angle;
  38707. }
  38708. // Snapping logic
  38709. var snapped = false;
  38710. if (_this.snapDistance != 0) {
  38711. currentSnapDragDistance += angle;
  38712. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  38713. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  38714. if (currentSnapDragDistance < 0) {
  38715. dragSteps *= -1;
  38716. }
  38717. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  38718. angle = _this.snapDistance * dragSteps;
  38719. snapped = true;
  38720. }
  38721. else {
  38722. angle = 0;
  38723. }
  38724. }
  38725. // If the mesh has a parent, convert needed world rotation to local rotation
  38726. tmpMatrix.reset();
  38727. if (_this.attachedMesh.parent) {
  38728. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  38729. tmpMatrix.getRotationMatrixToRef(tmpMatrix);
  38730. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(planeNormalTowardsCamera, tmpMatrix, planeNormalTowardsCamera);
  38731. }
  38732. // Convert angle and axis to quaternion (http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm)
  38733. var quaternionCoefficient = Math.sin(angle / 2);
  38734. amountToRotate.set(planeNormalTowardsCamera.x * quaternionCoefficient, planeNormalTowardsCamera.y * quaternionCoefficient, planeNormalTowardsCamera.z * quaternionCoefficient, Math.cos(angle / 2));
  38735. // 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
  38736. if (tmpMatrix.determinant() > 0) {
  38737. amountToRotate.toEulerAnglesToRef(tmpVector);
  38738. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(tmpVector.y, -tmpVector.x, -tmpVector.z, amountToRotate);
  38739. }
  38740. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  38741. // Rotate selected mesh quaternion over fixed axis
  38742. _this.attachedMesh.rotationQuaternion.multiplyToRef(amountToRotate, _this.attachedMesh.rotationQuaternion);
  38743. }
  38744. else {
  38745. // Rotate selected mesh quaternion over rotated axis
  38746. amountToRotate.multiplyToRef(_this.attachedMesh.rotationQuaternion, _this.attachedMesh.rotationQuaternion);
  38747. }
  38748. lastDragPosition.copyFrom(event.dragPlanePoint);
  38749. if (snapped) {
  38750. tmpSnapEvent.snapDistance = angle;
  38751. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  38752. }
  38753. }
  38754. });
  38755. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38756. if (_this._customMeshSet) {
  38757. return;
  38758. }
  38759. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  38760. var material = isHovered ? hoverMaterial : coloredMaterial;
  38761. _this._rootMesh.getChildMeshes().forEach(function (m) {
  38762. m.material = material;
  38763. if (m.color) {
  38764. m.color = material.emissiveColor;
  38765. }
  38766. });
  38767. });
  38768. return _this;
  38769. }
  38770. PlaneRotationGizmo.prototype._attachedMeshChanged = function (value) {
  38771. if (this.dragBehavior) {
  38772. this.dragBehavior.enabled = value ? true : false;
  38773. }
  38774. };
  38775. /**
  38776. * Disposes of the gizmo
  38777. */
  38778. PlaneRotationGizmo.prototype.dispose = function () {
  38779. this.onSnapObservable.clear();
  38780. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38781. this.dragBehavior.detach();
  38782. _super.prototype.dispose.call(this);
  38783. };
  38784. return PlaneRotationGizmo;
  38785. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  38786. /***/ }),
  38787. /***/ "./Gizmos/positionGizmo.ts":
  38788. /*!*********************************!*\
  38789. !*** ./Gizmos/positionGizmo.ts ***!
  38790. \*********************************/
  38791. /*! exports provided: PositionGizmo */
  38792. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38793. "use strict";
  38794. __webpack_require__.r(__webpack_exports__);
  38795. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return PositionGizmo; });
  38796. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38797. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38798. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38799. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38800. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38801. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  38802. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38803. /**
  38804. * Gizmo that enables dragging a mesh along 3 axis
  38805. */
  38806. var PositionGizmo = /** @class */ (function (_super) {
  38807. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PositionGizmo, _super);
  38808. /**
  38809. * Creates a PositionGizmo
  38810. * @param gizmoLayer The utility layer the gizmo will be added to
  38811. */
  38812. function PositionGizmo(gizmoLayer) {
  38813. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38814. var _this = _super.call(this, gizmoLayer) || this;
  38815. /** Fires an event when any of it's sub gizmos are dragged */
  38816. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38817. /** Fires an event when any of it's sub gizmos are released from dragging */
  38818. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38819. _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);
  38820. _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);
  38821. _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);
  38822. // Relay drag events
  38823. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  38824. gizmo.dragBehavior.onDragStartObservable.add(function () {
  38825. _this.onDragStartObservable.notifyObservers({});
  38826. });
  38827. gizmo.dragBehavior.onDragEndObservable.add(function () {
  38828. _this.onDragEndObservable.notifyObservers({});
  38829. });
  38830. });
  38831. _this.attachedMesh = null;
  38832. return _this;
  38833. }
  38834. Object.defineProperty(PositionGizmo.prototype, "attachedMesh", {
  38835. set: function (mesh) {
  38836. if (this.xGizmo) {
  38837. this.xGizmo.attachedMesh = mesh;
  38838. this.yGizmo.attachedMesh = mesh;
  38839. this.zGizmo.attachedMesh = mesh;
  38840. }
  38841. },
  38842. enumerable: true,
  38843. configurable: true
  38844. });
  38845. Object.defineProperty(PositionGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  38846. get: function () {
  38847. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  38848. },
  38849. set: function (value) {
  38850. if (this.xGizmo) {
  38851. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38852. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38853. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38854. }
  38855. },
  38856. enumerable: true,
  38857. configurable: true
  38858. });
  38859. Object.defineProperty(PositionGizmo.prototype, "snapDistance", {
  38860. get: function () {
  38861. return this.xGizmo.snapDistance;
  38862. },
  38863. /**
  38864. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38865. */
  38866. set: function (value) {
  38867. if (this.xGizmo) {
  38868. this.xGizmo.snapDistance = value;
  38869. this.yGizmo.snapDistance = value;
  38870. this.zGizmo.snapDistance = value;
  38871. }
  38872. },
  38873. enumerable: true,
  38874. configurable: true
  38875. });
  38876. Object.defineProperty(PositionGizmo.prototype, "scaleRatio", {
  38877. get: function () {
  38878. return this.xGizmo.scaleRatio;
  38879. },
  38880. /**
  38881. * Ratio for the scale of the gizmo (Default: 1)
  38882. */
  38883. set: function (value) {
  38884. if (this.xGizmo) {
  38885. this.xGizmo.scaleRatio = value;
  38886. this.yGizmo.scaleRatio = value;
  38887. this.zGizmo.scaleRatio = value;
  38888. }
  38889. },
  38890. enumerable: true,
  38891. configurable: true
  38892. });
  38893. /**
  38894. * Disposes of the gizmo
  38895. */
  38896. PositionGizmo.prototype.dispose = function () {
  38897. this.xGizmo.dispose();
  38898. this.yGizmo.dispose();
  38899. this.zGizmo.dispose();
  38900. this.onDragStartObservable.clear();
  38901. this.onDragEndObservable.clear();
  38902. };
  38903. /**
  38904. * CustomMeshes are not supported by this gizmo
  38905. * @param mesh The mesh to replace the default mesh of the gizmo
  38906. */
  38907. PositionGizmo.prototype.setCustomMesh = function (mesh) {
  38908. _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)");
  38909. };
  38910. return PositionGizmo;
  38911. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  38912. /***/ }),
  38913. /***/ "./Gizmos/rotationGizmo.ts":
  38914. /*!*********************************!*\
  38915. !*** ./Gizmos/rotationGizmo.ts ***!
  38916. \*********************************/
  38917. /*! exports provided: RotationGizmo */
  38918. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38919. "use strict";
  38920. __webpack_require__.r(__webpack_exports__);
  38921. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return RotationGizmo; });
  38922. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38923. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38924. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38925. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38926. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38927. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  38928. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38929. /**
  38930. * Gizmo that enables rotating a mesh along 3 axis
  38931. */
  38932. var RotationGizmo = /** @class */ (function (_super) {
  38933. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RotationGizmo, _super);
  38934. /**
  38935. * Creates a RotationGizmo
  38936. * @param gizmoLayer The utility layer the gizmo will be added to
  38937. * @param tessellation Amount of tessellation to be used when creating rotation circles
  38938. */
  38939. function RotationGizmo(gizmoLayer, tessellation) {
  38940. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38941. if (tessellation === void 0) { tessellation = 32; }
  38942. var _this = _super.call(this, gizmoLayer) || this;
  38943. /** Fires an event when any of it's sub gizmos are dragged */
  38944. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38945. /** Fires an event when any of it's sub gizmos are released from dragging */
  38946. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38947. _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);
  38948. _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);
  38949. _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);
  38950. // Relay drag events
  38951. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  38952. gizmo.dragBehavior.onDragStartObservable.add(function () {
  38953. _this.onDragStartObservable.notifyObservers({});
  38954. });
  38955. gizmo.dragBehavior.onDragEndObservable.add(function () {
  38956. _this.onDragEndObservable.notifyObservers({});
  38957. });
  38958. });
  38959. _this.attachedMesh = null;
  38960. return _this;
  38961. }
  38962. Object.defineProperty(RotationGizmo.prototype, "attachedMesh", {
  38963. set: function (mesh) {
  38964. if (this.xGizmo) {
  38965. this.xGizmo.attachedMesh = mesh;
  38966. this.yGizmo.attachedMesh = mesh;
  38967. this.zGizmo.attachedMesh = mesh;
  38968. }
  38969. },
  38970. enumerable: true,
  38971. configurable: true
  38972. });
  38973. Object.defineProperty(RotationGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  38974. get: function () {
  38975. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  38976. },
  38977. set: function (value) {
  38978. if (this.xGizmo) {
  38979. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38980. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38981. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38982. }
  38983. },
  38984. enumerable: true,
  38985. configurable: true
  38986. });
  38987. Object.defineProperty(RotationGizmo.prototype, "snapDistance", {
  38988. get: function () {
  38989. return this.xGizmo.snapDistance;
  38990. },
  38991. /**
  38992. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38993. */
  38994. set: function (value) {
  38995. if (this.xGizmo) {
  38996. this.xGizmo.snapDistance = value;
  38997. this.yGizmo.snapDistance = value;
  38998. this.zGizmo.snapDistance = value;
  38999. }
  39000. },
  39001. enumerable: true,
  39002. configurable: true
  39003. });
  39004. Object.defineProperty(RotationGizmo.prototype, "scaleRatio", {
  39005. get: function () {
  39006. return this.xGizmo.scaleRatio;
  39007. },
  39008. /**
  39009. * Ratio for the scale of the gizmo (Default: 1)
  39010. */
  39011. set: function (value) {
  39012. if (this.xGizmo) {
  39013. this.xGizmo.scaleRatio = value;
  39014. this.yGizmo.scaleRatio = value;
  39015. this.zGizmo.scaleRatio = value;
  39016. }
  39017. },
  39018. enumerable: true,
  39019. configurable: true
  39020. });
  39021. /**
  39022. * Disposes of the gizmo
  39023. */
  39024. RotationGizmo.prototype.dispose = function () {
  39025. this.xGizmo.dispose();
  39026. this.yGizmo.dispose();
  39027. this.zGizmo.dispose();
  39028. this.onDragStartObservable.clear();
  39029. this.onDragEndObservable.clear();
  39030. };
  39031. /**
  39032. * CustomMeshes are not supported by this gizmo
  39033. * @param mesh The mesh to replace the default mesh of the gizmo
  39034. */
  39035. RotationGizmo.prototype.setCustomMesh = function (mesh) {
  39036. _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)");
  39037. };
  39038. return RotationGizmo;
  39039. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  39040. /***/ }),
  39041. /***/ "./Gizmos/scaleGizmo.ts":
  39042. /*!******************************!*\
  39043. !*** ./Gizmos/scaleGizmo.ts ***!
  39044. \******************************/
  39045. /*! exports provided: ScaleGizmo */
  39046. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39047. "use strict";
  39048. __webpack_require__.r(__webpack_exports__);
  39049. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return ScaleGizmo; });
  39050. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39051. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39052. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39053. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39054. /* harmony import */ var _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  39055. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39056. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  39057. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39058. /**
  39059. * Gizmo that enables scaling a mesh along 3 axis
  39060. */
  39061. var ScaleGizmo = /** @class */ (function (_super) {
  39062. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScaleGizmo, _super);
  39063. /**
  39064. * Creates a ScaleGizmo
  39065. * @param gizmoLayer The utility layer the gizmo will be added to
  39066. */
  39067. function ScaleGizmo(gizmoLayer) {
  39068. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39069. var _this = _super.call(this, gizmoLayer) || this;
  39070. /** Fires an event when any of it's sub gizmos are dragged */
  39071. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39072. /** Fires an event when any of it's sub gizmos are released from dragging */
  39073. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39074. _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);
  39075. _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);
  39076. _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);
  39077. // Create uniform scale gizmo
  39078. _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);
  39079. _this.uniformScaleGizmo.updateGizmoRotationToMatchAttachedMesh = false;
  39080. _this.uniformScaleGizmo.uniformScaling = true;
  39081. var uniformScalingMesh = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  39082. uniformScalingMesh.scaling.scaleInPlace(0.02);
  39083. uniformScalingMesh.visibility = 0;
  39084. var octahedron = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  39085. octahedron.scaling.scaleInPlace(0.007);
  39086. uniformScalingMesh.addChild(octahedron);
  39087. _this.uniformScaleGizmo.setCustomMesh(uniformScalingMesh, true);
  39088. // Relay drag events
  39089. [_this.xGizmo, _this.yGizmo, _this.zGizmo, _this.uniformScaleGizmo].forEach(function (gizmo) {
  39090. gizmo.dragBehavior.onDragStartObservable.add(function () {
  39091. _this.onDragStartObservable.notifyObservers({});
  39092. });
  39093. gizmo.dragBehavior.onDragEndObservable.add(function () {
  39094. _this.onDragEndObservable.notifyObservers({});
  39095. });
  39096. });
  39097. _this.attachedMesh = null;
  39098. return _this;
  39099. }
  39100. Object.defineProperty(ScaleGizmo.prototype, "attachedMesh", {
  39101. set: function (mesh) {
  39102. if (this.xGizmo) {
  39103. this.xGizmo.attachedMesh = mesh;
  39104. this.yGizmo.attachedMesh = mesh;
  39105. this.zGizmo.attachedMesh = mesh;
  39106. this.uniformScaleGizmo.attachedMesh = mesh;
  39107. }
  39108. },
  39109. enumerable: true,
  39110. configurable: true
  39111. });
  39112. Object.defineProperty(ScaleGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  39113. get: function () {
  39114. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  39115. },
  39116. set: function (value) {
  39117. if (!value) {
  39118. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.");
  39119. }
  39120. if (this.xGizmo) {
  39121. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39122. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39123. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39124. }
  39125. },
  39126. enumerable: true,
  39127. configurable: true
  39128. });
  39129. Object.defineProperty(ScaleGizmo.prototype, "snapDistance", {
  39130. get: function () {
  39131. return this.xGizmo.snapDistance;
  39132. },
  39133. /**
  39134. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39135. */
  39136. set: function (value) {
  39137. if (this.xGizmo) {
  39138. this.xGizmo.snapDistance = value;
  39139. this.yGizmo.snapDistance = value;
  39140. this.zGizmo.snapDistance = value;
  39141. this.uniformScaleGizmo.snapDistance = value;
  39142. }
  39143. },
  39144. enumerable: true,
  39145. configurable: true
  39146. });
  39147. Object.defineProperty(ScaleGizmo.prototype, "scaleRatio", {
  39148. get: function () {
  39149. return this.xGizmo.scaleRatio;
  39150. },
  39151. /**
  39152. * Ratio for the scale of the gizmo (Default: 1)
  39153. */
  39154. set: function (value) {
  39155. if (this.xGizmo) {
  39156. this.xGizmo.scaleRatio = value;
  39157. this.yGizmo.scaleRatio = value;
  39158. this.zGizmo.scaleRatio = value;
  39159. this.uniformScaleGizmo.scaleRatio = value;
  39160. }
  39161. },
  39162. enumerable: true,
  39163. configurable: true
  39164. });
  39165. /**
  39166. * Disposes of the gizmo
  39167. */
  39168. ScaleGizmo.prototype.dispose = function () {
  39169. this.xGizmo.dispose();
  39170. this.yGizmo.dispose();
  39171. this.zGizmo.dispose();
  39172. this.uniformScaleGizmo.dispose();
  39173. this.onDragStartObservable.clear();
  39174. this.onDragEndObservable.clear();
  39175. };
  39176. return ScaleGizmo;
  39177. }(_gizmo__WEBPACK_IMPORTED_MODULE_5__["Gizmo"]));
  39178. /***/ }),
  39179. /***/ "./Helpers/environmentHelper.ts":
  39180. /*!**************************************!*\
  39181. !*** ./Helpers/environmentHelper.ts ***!
  39182. \**************************************/
  39183. /*! exports provided: EnvironmentHelper */
  39184. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39185. "use strict";
  39186. __webpack_require__.r(__webpack_exports__);
  39187. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return EnvironmentHelper; });
  39188. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39189. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39190. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  39191. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39192. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39193. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  39194. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39195. /* harmony import */ var _Materials_Textures_mirrorTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  39196. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  39197. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  39198. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  39199. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  39200. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  39201. /**
  39202. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  39203. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  39204. * It also helps with the default setup of your imageProcessing configuration.
  39205. */
  39206. var EnvironmentHelper = /** @class */ (function () {
  39207. /**
  39208. * constructor
  39209. * @param options Defines the options we want to customize the helper
  39210. * @param scene The scene to add the material to
  39211. */
  39212. function EnvironmentHelper(options, scene) {
  39213. var _this = this;
  39214. this._errorHandler = function (message, exception) {
  39215. _this.onErrorObservable.notifyObservers({ message: message, exception: exception });
  39216. };
  39217. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, EnvironmentHelper._getDefaultOptions(), options);
  39218. this._scene = scene;
  39219. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39220. this._setupBackground();
  39221. this._setupImageProcessing();
  39222. }
  39223. /**
  39224. * Creates the default options for the helper.
  39225. */
  39226. EnvironmentHelper._getDefaultOptions = function () {
  39227. return {
  39228. createGround: true,
  39229. groundSize: 15,
  39230. groundTexture: this._groundTextureCDNUrl,
  39231. groundColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  39232. groundOpacity: 0.9,
  39233. enableGroundShadow: true,
  39234. groundShadowLevel: 0.5,
  39235. enableGroundMirror: false,
  39236. groundMirrorSizeRatio: 0.3,
  39237. groundMirrorBlurKernel: 64,
  39238. groundMirrorAmount: 1,
  39239. groundMirrorFresnelWeight: 1,
  39240. groundMirrorFallOffDistance: 0,
  39241. groundMirrorTextureType: _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT,
  39242. groundYBias: 0.00001,
  39243. createSkybox: true,
  39244. skyboxSize: 20,
  39245. skyboxTexture: this._skyboxTextureCDNUrl,
  39246. skyboxColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  39247. backgroundYRotation: 0,
  39248. sizeAuto: true,
  39249. rootPosition: _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(),
  39250. setupImageProcessing: true,
  39251. environmentTexture: this._environmentTextureCDNUrl,
  39252. cameraExposure: 0.8,
  39253. cameraContrast: 1.2,
  39254. toneMappingEnabled: true,
  39255. };
  39256. };
  39257. Object.defineProperty(EnvironmentHelper.prototype, "rootMesh", {
  39258. /**
  39259. * Gets the root mesh created by the helper.
  39260. */
  39261. get: function () {
  39262. return this._rootMesh;
  39263. },
  39264. enumerable: true,
  39265. configurable: true
  39266. });
  39267. Object.defineProperty(EnvironmentHelper.prototype, "skybox", {
  39268. /**
  39269. * Gets the skybox created by the helper.
  39270. */
  39271. get: function () {
  39272. return this._skybox;
  39273. },
  39274. enumerable: true,
  39275. configurable: true
  39276. });
  39277. Object.defineProperty(EnvironmentHelper.prototype, "skyboxTexture", {
  39278. /**
  39279. * Gets the skybox texture created by the helper.
  39280. */
  39281. get: function () {
  39282. return this._skyboxTexture;
  39283. },
  39284. enumerable: true,
  39285. configurable: true
  39286. });
  39287. Object.defineProperty(EnvironmentHelper.prototype, "skyboxMaterial", {
  39288. /**
  39289. * Gets the skybox material created by the helper.
  39290. */
  39291. get: function () {
  39292. return this._skyboxMaterial;
  39293. },
  39294. enumerable: true,
  39295. configurable: true
  39296. });
  39297. Object.defineProperty(EnvironmentHelper.prototype, "ground", {
  39298. /**
  39299. * Gets the ground mesh created by the helper.
  39300. */
  39301. get: function () {
  39302. return this._ground;
  39303. },
  39304. enumerable: true,
  39305. configurable: true
  39306. });
  39307. Object.defineProperty(EnvironmentHelper.prototype, "groundTexture", {
  39308. /**
  39309. * Gets the ground texture created by the helper.
  39310. */
  39311. get: function () {
  39312. return this._groundTexture;
  39313. },
  39314. enumerable: true,
  39315. configurable: true
  39316. });
  39317. Object.defineProperty(EnvironmentHelper.prototype, "groundMirror", {
  39318. /**
  39319. * Gets the ground mirror created by the helper.
  39320. */
  39321. get: function () {
  39322. return this._groundMirror;
  39323. },
  39324. enumerable: true,
  39325. configurable: true
  39326. });
  39327. Object.defineProperty(EnvironmentHelper.prototype, "groundMirrorRenderList", {
  39328. /**
  39329. * Gets the ground mirror render list to helps pushing the meshes
  39330. * you wish in the ground reflection.
  39331. */
  39332. get: function () {
  39333. if (this._groundMirror) {
  39334. return this._groundMirror.renderList;
  39335. }
  39336. return null;
  39337. },
  39338. enumerable: true,
  39339. configurable: true
  39340. });
  39341. Object.defineProperty(EnvironmentHelper.prototype, "groundMaterial", {
  39342. /**
  39343. * Gets the ground material created by the helper.
  39344. */
  39345. get: function () {
  39346. return this._groundMaterial;
  39347. },
  39348. enumerable: true,
  39349. configurable: true
  39350. });
  39351. /**
  39352. * Updates the background according to the new options
  39353. * @param options
  39354. */
  39355. EnvironmentHelper.prototype.updateOptions = function (options) {
  39356. var newOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, this._options, options);
  39357. if (this._ground && !newOptions.createGround) {
  39358. this._ground.dispose();
  39359. this._ground = null;
  39360. }
  39361. if (this._groundMaterial && !newOptions.createGround) {
  39362. this._groundMaterial.dispose();
  39363. this._groundMaterial = null;
  39364. }
  39365. if (this._groundTexture) {
  39366. if (this._options.groundTexture != newOptions.groundTexture) {
  39367. this._groundTexture.dispose();
  39368. this._groundTexture = null;
  39369. }
  39370. }
  39371. if (this._skybox && !newOptions.createSkybox) {
  39372. this._skybox.dispose();
  39373. this._skybox = null;
  39374. }
  39375. if (this._skyboxMaterial && !newOptions.createSkybox) {
  39376. this._skyboxMaterial.dispose();
  39377. this._skyboxMaterial = null;
  39378. }
  39379. if (this._skyboxTexture) {
  39380. if (this._options.skyboxTexture != newOptions.skyboxTexture) {
  39381. this._skyboxTexture.dispose();
  39382. this._skyboxTexture = null;
  39383. }
  39384. }
  39385. if (this._groundMirror && !newOptions.enableGroundMirror) {
  39386. this._groundMirror.dispose();
  39387. this._groundMirror = null;
  39388. }
  39389. if (this._scene.environmentTexture) {
  39390. if (this._options.environmentTexture != newOptions.environmentTexture) {
  39391. this._scene.environmentTexture.dispose();
  39392. }
  39393. }
  39394. this._options = newOptions;
  39395. this._setupBackground();
  39396. this._setupImageProcessing();
  39397. };
  39398. /**
  39399. * Sets the primary color of all the available elements.
  39400. * @param color the main color to affect to the ground and the background
  39401. */
  39402. EnvironmentHelper.prototype.setMainColor = function (color) {
  39403. if (this.groundMaterial) {
  39404. this.groundMaterial.primaryColor = color;
  39405. }
  39406. if (this.skyboxMaterial) {
  39407. this.skyboxMaterial.primaryColor = color;
  39408. }
  39409. if (this.groundMirror) {
  39410. this.groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](color.r, color.g, color.b, 1.0);
  39411. }
  39412. };
  39413. /**
  39414. * Setup the image processing according to the specified options.
  39415. */
  39416. EnvironmentHelper.prototype._setupImageProcessing = function () {
  39417. if (this._options.setupImageProcessing) {
  39418. this._scene.imageProcessingConfiguration.contrast = this._options.cameraContrast;
  39419. this._scene.imageProcessingConfiguration.exposure = this._options.cameraExposure;
  39420. this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled;
  39421. this._setupEnvironmentTexture();
  39422. }
  39423. };
  39424. /**
  39425. * Setup the environment texture according to the specified options.
  39426. */
  39427. EnvironmentHelper.prototype._setupEnvironmentTexture = function () {
  39428. if (this._scene.environmentTexture) {
  39429. return;
  39430. }
  39431. if (this._options.environmentTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  39432. this._scene.environmentTexture = this._options.environmentTexture;
  39433. return;
  39434. }
  39435. var environmentTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
  39436. this._scene.environmentTexture = environmentTexture;
  39437. };
  39438. /**
  39439. * Setup the background according to the specified options.
  39440. */
  39441. EnvironmentHelper.prototype._setupBackground = function () {
  39442. if (!this._rootMesh) {
  39443. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]("BackgroundHelper", this._scene);
  39444. }
  39445. this._rootMesh.rotation.y = this._options.backgroundYRotation;
  39446. var sceneSize = this._getSceneSize();
  39447. if (this._options.createGround) {
  39448. this._setupGround(sceneSize);
  39449. this._setupGroundMaterial();
  39450. this._setupGroundDiffuseTexture();
  39451. if (this._options.enableGroundMirror) {
  39452. this._setupGroundMirrorTexture(sceneSize);
  39453. }
  39454. this._setupMirrorInGroundMaterial();
  39455. }
  39456. if (this._options.createSkybox) {
  39457. this._setupSkybox(sceneSize);
  39458. this._setupSkyboxMaterial();
  39459. this._setupSkyboxReflectionTexture();
  39460. }
  39461. this._rootMesh.position.x = sceneSize.rootPosition.x;
  39462. this._rootMesh.position.z = sceneSize.rootPosition.z;
  39463. this._rootMesh.position.y = sceneSize.rootPosition.y;
  39464. };
  39465. /**
  39466. * Get the scene sizes according to the setup.
  39467. */
  39468. EnvironmentHelper.prototype._getSceneSize = function () {
  39469. var _this = this;
  39470. var groundSize = this._options.groundSize;
  39471. var skyboxSize = this._options.skyboxSize;
  39472. var rootPosition = this._options.rootPosition;
  39473. if (!this._scene.meshes || this._scene.meshes.length === 1) { // 1 only means the root of the helper.
  39474. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  39475. }
  39476. var sceneExtends = this._scene.getWorldExtends(function (mesh) {
  39477. return (mesh !== _this._ground && mesh !== _this._rootMesh && mesh !== _this._skybox);
  39478. });
  39479. var sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
  39480. if (this._options.sizeAuto) {
  39481. if (this._scene.activeCamera instanceof _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"] &&
  39482. this._scene.activeCamera.upperRadiusLimit) {
  39483. groundSize = this._scene.activeCamera.upperRadiusLimit * 2;
  39484. skyboxSize = groundSize;
  39485. }
  39486. var sceneDiagonalLenght = sceneDiagonal.length();
  39487. if (sceneDiagonalLenght > groundSize) {
  39488. groundSize = sceneDiagonalLenght * 2;
  39489. skyboxSize = groundSize;
  39490. }
  39491. // 10 % bigger.
  39492. groundSize *= 1.1;
  39493. skyboxSize *= 1.5;
  39494. rootPosition = sceneExtends.min.add(sceneDiagonal.scale(0.5));
  39495. rootPosition.y = sceneExtends.min.y - this._options.groundYBias;
  39496. }
  39497. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  39498. };
  39499. /**
  39500. * Setup the ground according to the specified options.
  39501. */
  39502. EnvironmentHelper.prototype._setupGround = function (sceneSize) {
  39503. var _this = this;
  39504. if (!this._ground || this._ground.isDisposed()) {
  39505. this._ground = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreatePlane("BackgroundPlane", sceneSize.groundSize, this._scene);
  39506. this._ground.rotation.x = Math.PI / 2; // Face up by default.
  39507. this._ground.parent = this._rootMesh;
  39508. this._ground.onDisposeObservable.add(function () { _this._ground = null; });
  39509. }
  39510. this._ground.receiveShadows = this._options.enableGroundShadow;
  39511. };
  39512. /**
  39513. * Setup the ground material according to the specified options.
  39514. */
  39515. EnvironmentHelper.prototype._setupGroundMaterial = function () {
  39516. if (!this._groundMaterial) {
  39517. this._groundMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundPlaneMaterial", this._scene);
  39518. }
  39519. this._groundMaterial.alpha = this._options.groundOpacity;
  39520. this._groundMaterial.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  39521. this._groundMaterial.shadowLevel = this._options.groundShadowLevel;
  39522. this._groundMaterial.primaryColor = this._options.groundColor;
  39523. this._groundMaterial.useRGBColor = false;
  39524. this._groundMaterial.enableNoise = true;
  39525. if (this._ground) {
  39526. this._ground.material = this._groundMaterial;
  39527. }
  39528. };
  39529. /**
  39530. * Setup the ground diffuse texture according to the specified options.
  39531. */
  39532. EnvironmentHelper.prototype._setupGroundDiffuseTexture = function () {
  39533. if (!this._groundMaterial) {
  39534. return;
  39535. }
  39536. if (this._groundTexture) {
  39537. return;
  39538. }
  39539. if (this._options.groundTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  39540. this._groundMaterial.diffuseTexture = this._options.groundTexture;
  39541. return;
  39542. }
  39543. var diffuseTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](this._options.groundTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  39544. diffuseTexture.gammaSpace = false;
  39545. diffuseTexture.hasAlpha = true;
  39546. this._groundMaterial.diffuseTexture = diffuseTexture;
  39547. };
  39548. /**
  39549. * Setup the ground mirror texture according to the specified options.
  39550. */
  39551. EnvironmentHelper.prototype._setupGroundMirrorTexture = function (sceneSize) {
  39552. var wrapping = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  39553. if (!this._groundMirror) {
  39554. 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);
  39555. this._groundMirror.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Plane"](0, -1, 0, sceneSize.rootPosition.y);
  39556. this._groundMirror.anisotropicFilteringLevel = 1;
  39557. this._groundMirror.wrapU = wrapping;
  39558. this._groundMirror.wrapV = wrapping;
  39559. this._groundMirror.gammaSpace = false;
  39560. if (this._groundMirror.renderList) {
  39561. for (var i = 0; i < this._scene.meshes.length; i++) {
  39562. var mesh = this._scene.meshes[i];
  39563. if (mesh !== this._ground &&
  39564. mesh !== this._skybox &&
  39565. mesh !== this._rootMesh) {
  39566. this._groundMirror.renderList.push(mesh);
  39567. }
  39568. }
  39569. }
  39570. }
  39571. this._groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](this._options.groundColor.r, this._options.groundColor.g, this._options.groundColor.b, 1);
  39572. this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel;
  39573. };
  39574. /**
  39575. * Setup the ground to receive the mirror texture.
  39576. */
  39577. EnvironmentHelper.prototype._setupMirrorInGroundMaterial = function () {
  39578. if (this._groundMaterial) {
  39579. this._groundMaterial.reflectionTexture = this._groundMirror;
  39580. this._groundMaterial.reflectionFresnel = true;
  39581. this._groundMaterial.reflectionAmount = this._options.groundMirrorAmount;
  39582. this._groundMaterial.reflectionStandardFresnelWeight = this._options.groundMirrorFresnelWeight;
  39583. this._groundMaterial.reflectionFalloffDistance = this._options.groundMirrorFallOffDistance;
  39584. }
  39585. };
  39586. /**
  39587. * Setup the skybox according to the specified options.
  39588. */
  39589. EnvironmentHelper.prototype._setupSkybox = function (sceneSize) {
  39590. var _this = this;
  39591. if (!this._skybox || this._skybox.isDisposed()) {
  39592. this._skybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateBox("BackgroundSkybox", sceneSize.skyboxSize, this._scene, undefined, _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].BACKSIDE);
  39593. this._skybox.onDisposeObservable.add(function () { _this._skybox = null; });
  39594. }
  39595. this._skybox.parent = this._rootMesh;
  39596. };
  39597. /**
  39598. * Setup the skybox material according to the specified options.
  39599. */
  39600. EnvironmentHelper.prototype._setupSkyboxMaterial = function () {
  39601. if (!this._skybox) {
  39602. return;
  39603. }
  39604. if (!this._skyboxMaterial) {
  39605. this._skyboxMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundSkyboxMaterial", this._scene);
  39606. }
  39607. this._skyboxMaterial.useRGBColor = false;
  39608. this._skyboxMaterial.primaryColor = this._options.skyboxColor;
  39609. this._skyboxMaterial.enableNoise = true;
  39610. this._skybox.material = this._skyboxMaterial;
  39611. };
  39612. /**
  39613. * Setup the skybox reflection texture according to the specified options.
  39614. */
  39615. EnvironmentHelper.prototype._setupSkyboxReflectionTexture = function () {
  39616. if (!this._skyboxMaterial) {
  39617. return;
  39618. }
  39619. if (this._skyboxTexture) {
  39620. return;
  39621. }
  39622. if (this._options.skyboxTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  39623. this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture;
  39624. return;
  39625. }
  39626. this._skyboxTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"](this._options.skyboxTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  39627. this._skyboxTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].SKYBOX_MODE;
  39628. this._skyboxTexture.gammaSpace = false;
  39629. this._skyboxMaterial.reflectionTexture = this._skyboxTexture;
  39630. };
  39631. /**
  39632. * Dispose all the elements created by the Helper.
  39633. */
  39634. EnvironmentHelper.prototype.dispose = function () {
  39635. if (this._groundMaterial) {
  39636. this._groundMaterial.dispose(true, true);
  39637. }
  39638. if (this._skyboxMaterial) {
  39639. this._skyboxMaterial.dispose(true, true);
  39640. }
  39641. this._rootMesh.dispose(false);
  39642. };
  39643. /**
  39644. * Default ground texture URL.
  39645. */
  39646. EnvironmentHelper._groundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png";
  39647. /**
  39648. * Default skybox texture URL.
  39649. */
  39650. EnvironmentHelper._skyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds";
  39651. /**
  39652. * Default environment texture URL.
  39653. */
  39654. EnvironmentHelper._environmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env";
  39655. return EnvironmentHelper;
  39656. }());
  39657. /***/ }),
  39658. /***/ "./Helpers/index.ts":
  39659. /*!**************************!*\
  39660. !*** ./Helpers/index.ts ***!
  39661. \**************************/
  39662. /*! exports provided: EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome */
  39663. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39664. "use strict";
  39665. __webpack_require__.r(__webpack_exports__);
  39666. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  39667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _environmentHelper__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  39668. /* harmony import */ var _photoDome__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./photoDome */ "./Helpers/photoDome.ts");
  39669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _photoDome__WEBPACK_IMPORTED_MODULE_1__["PhotoDome"]; });
  39670. /* harmony import */ var _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneHelpers */ "./Helpers/sceneHelpers.ts");
  39671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__["_forceSceneHelpersToBundle"]; });
  39672. /* harmony import */ var _videoDome__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./videoDome */ "./Helpers/videoDome.ts");
  39673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _videoDome__WEBPACK_IMPORTED_MODULE_3__["VideoDome"]; });
  39674. /***/ }),
  39675. /***/ "./Helpers/photoDome.ts":
  39676. /*!******************************!*\
  39677. !*** ./Helpers/photoDome.ts ***!
  39678. \******************************/
  39679. /*! exports provided: PhotoDome */
  39680. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39681. "use strict";
  39682. __webpack_require__.r(__webpack_exports__);
  39683. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return PhotoDome; });
  39684. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39685. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39686. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  39687. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39688. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39689. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  39690. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  39691. /**
  39692. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  39693. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  39694. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  39695. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  39696. */
  39697. var PhotoDome = /** @class */ (function (_super) {
  39698. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PhotoDome, _super);
  39699. /**
  39700. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  39701. * @param name Element's name, child elements will append suffixes for their own names.
  39702. * @param urlsOfPhoto defines the url of the photo to display
  39703. * @param options defines an object containing optional or exposed sub element properties
  39704. * @param onError defines a callback called when an error occured while loading the texture
  39705. */
  39706. function PhotoDome(name, urlOfPhoto, options, scene, onError) {
  39707. if (onError === void 0) { onError = null; }
  39708. var _this = _super.call(this, name, scene) || this;
  39709. _this._useDirectMapping = false;
  39710. /**
  39711. * Observable raised when an error occured while loading the 360 image
  39712. */
  39713. _this.onLoadErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39714. // set defaults and manage values
  39715. name = name || "photoDome";
  39716. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  39717. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  39718. if (options.useDirectMapping === undefined) {
  39719. _this._useDirectMapping = true;
  39720. }
  39721. else {
  39722. _this._useDirectMapping = options.useDirectMapping;
  39723. }
  39724. _this._setReady(false);
  39725. // create
  39726. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  39727. _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);
  39728. // configure material
  39729. material.opacityFresnel = false;
  39730. material.useEquirectangularFOV = true;
  39731. material.fovMultiplier = 1.0;
  39732. _this.photoTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](urlOfPhoto, scene, true, !_this._useDirectMapping, undefined, undefined, function (message, exception) {
  39733. _this.onLoadErrorObservable.notifyObservers(message || "Unknown error occured");
  39734. if (onError) {
  39735. onError(message, exception);
  39736. }
  39737. });
  39738. _this.photoTexture.onLoadObservable.addOnce(function () {
  39739. _this._setReady(true);
  39740. });
  39741. // configure mesh
  39742. _this._mesh.material = material;
  39743. _this._mesh.parent = _this;
  39744. return _this;
  39745. }
  39746. Object.defineProperty(PhotoDome.prototype, "photoTexture", {
  39747. /**
  39748. * Gets or sets the texture being displayed on the sphere
  39749. */
  39750. get: function () {
  39751. return this._photoTexture;
  39752. },
  39753. set: function (value) {
  39754. if (this._photoTexture === value) {
  39755. return;
  39756. }
  39757. this._photoTexture = value;
  39758. if (this._useDirectMapping) {
  39759. this._photoTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  39760. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  39761. this._material.diffuseTexture = this._photoTexture;
  39762. }
  39763. else {
  39764. this._photoTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  39765. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  39766. this._material.reflectionTexture = this._photoTexture;
  39767. }
  39768. },
  39769. enumerable: true,
  39770. configurable: true
  39771. });
  39772. Object.defineProperty(PhotoDome.prototype, "fovMultiplier", {
  39773. /**
  39774. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  39775. * Also see the options.resolution property.
  39776. */
  39777. get: function () {
  39778. return this._material.fovMultiplier;
  39779. },
  39780. set: function (value) {
  39781. this._material.fovMultiplier = value;
  39782. },
  39783. enumerable: true,
  39784. configurable: true
  39785. });
  39786. /**
  39787. * Releases resources associated with this node.
  39788. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  39789. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  39790. */
  39791. PhotoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  39792. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  39793. this._photoTexture.dispose();
  39794. this._mesh.dispose();
  39795. this._material.dispose();
  39796. this.onLoadErrorObservable.clear();
  39797. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  39798. };
  39799. return PhotoDome;
  39800. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__["TransformNode"]));
  39801. /***/ }),
  39802. /***/ "./Helpers/sceneHelpers.ts":
  39803. /*!*********************************!*\
  39804. !*** ./Helpers/sceneHelpers.ts ***!
  39805. \*********************************/
  39806. /*! exports provided: _forceSceneHelpersToBundle */
  39807. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39808. "use strict";
  39809. __webpack_require__.r(__webpack_exports__);
  39810. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _forceSceneHelpersToBundle; });
  39811. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39812. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  39813. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39814. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39815. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39816. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  39817. /* harmony import */ var _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/PBR/pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  39818. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  39819. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  39820. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  39821. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  39822. /* harmony import */ var _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/XR/webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  39823. /* harmony import */ var _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Cameras/XR/webXRInput */ "./Cameras/XR/webXRInput.ts");
  39824. /* harmony import */ var _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Cameras/XR/webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  39825. /* harmony import */ var _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Cameras/XR/webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  39826. /* harmony import */ var _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Cameras/VR/vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  39827. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  39828. /** @hidden */
  39829. var _forceSceneHelpersToBundle = true;
  39830. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultLight = function (replace) {
  39831. if (replace === void 0) { replace = false; }
  39832. // Dispose existing light in replace mode.
  39833. if (replace) {
  39834. if (this.lights) {
  39835. for (var i = 0; i < this.lights.length; i++) {
  39836. this.lights[i].dispose();
  39837. }
  39838. }
  39839. }
  39840. // Light
  39841. if (this.lights.length === 0) {
  39842. new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__["HemisphericLight"]("default light", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up(), this);
  39843. }
  39844. };
  39845. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCamera = function (createArcRotateCamera, replace, attachCameraControls) {
  39846. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  39847. if (replace === void 0) { replace = false; }
  39848. if (attachCameraControls === void 0) { attachCameraControls = false; }
  39849. // Dispose existing camera in replace mode.
  39850. if (replace) {
  39851. if (this.activeCamera) {
  39852. this.activeCamera.dispose();
  39853. this.activeCamera = null;
  39854. }
  39855. }
  39856. // Camera
  39857. if (!this.activeCamera) {
  39858. var worldExtends = this.getWorldExtends();
  39859. var worldSize = worldExtends.max.subtract(worldExtends.min);
  39860. var worldCenter = worldExtends.min.add(worldSize.scale(0.5));
  39861. var camera;
  39862. var radius = worldSize.length() * 1.5;
  39863. // empty scene scenario!
  39864. if (!isFinite(radius)) {
  39865. radius = 1;
  39866. worldCenter.copyFromFloats(0, 0, 0);
  39867. }
  39868. if (createArcRotateCamera) {
  39869. var arcRotateCamera = new _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__["ArcRotateCamera"]("default camera", -(Math.PI / 2), Math.PI / 2, radius, worldCenter, this);
  39870. arcRotateCamera.lowerRadiusLimit = radius * 0.01;
  39871. arcRotateCamera.wheelPrecision = 100 / radius;
  39872. camera = arcRotateCamera;
  39873. }
  39874. else {
  39875. 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);
  39876. freeCamera.setTarget(worldCenter);
  39877. camera = freeCamera;
  39878. }
  39879. camera.minZ = radius * 0.01;
  39880. camera.maxZ = radius * 1000;
  39881. camera.speed = radius * 0.2;
  39882. this.activeCamera = camera;
  39883. var canvas = this.getEngine().getRenderingCanvas();
  39884. if (attachCameraControls && canvas) {
  39885. camera.attachControl(canvas);
  39886. }
  39887. }
  39888. };
  39889. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCameraOrLight = function (createArcRotateCamera, replace, attachCameraControls) {
  39890. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  39891. if (replace === void 0) { replace = false; }
  39892. if (attachCameraControls === void 0) { attachCameraControls = false; }
  39893. this.createDefaultLight(replace);
  39894. this.createDefaultCamera(createArcRotateCamera, replace, attachCameraControls);
  39895. };
  39896. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultSkybox = function (environmentTexture, pbr, scale, blur, setGlobalEnvTexture) {
  39897. if (pbr === void 0) { pbr = false; }
  39898. if (scale === void 0) { scale = 1000; }
  39899. if (blur === void 0) { blur = 0; }
  39900. if (setGlobalEnvTexture === void 0) { setGlobalEnvTexture = true; }
  39901. if (!environmentTexture) {
  39902. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Can not create default skybox without environment texture.");
  39903. return null;
  39904. }
  39905. if (setGlobalEnvTexture) {
  39906. if (environmentTexture) {
  39907. this.environmentTexture = environmentTexture;
  39908. }
  39909. }
  39910. // Skybox
  39911. var hdrSkybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateBox("hdrSkyBox", scale, this);
  39912. if (pbr) {
  39913. var hdrSkyboxMaterial = new _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__["PBRMaterial"]("skyBox", this);
  39914. hdrSkyboxMaterial.backFaceCulling = false;
  39915. hdrSkyboxMaterial.reflectionTexture = environmentTexture.clone();
  39916. if (hdrSkyboxMaterial.reflectionTexture) {
  39917. hdrSkyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  39918. }
  39919. hdrSkyboxMaterial.microSurface = 1.0 - blur;
  39920. hdrSkyboxMaterial.disableLighting = true;
  39921. hdrSkyboxMaterial.twoSidedLighting = true;
  39922. hdrSkybox.infiniteDistance = true;
  39923. hdrSkybox.material = hdrSkyboxMaterial;
  39924. }
  39925. else {
  39926. var skyboxMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("skyBox", this);
  39927. skyboxMaterial.backFaceCulling = false;
  39928. skyboxMaterial.reflectionTexture = environmentTexture.clone();
  39929. if (skyboxMaterial.reflectionTexture) {
  39930. skyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  39931. }
  39932. skyboxMaterial.disableLighting = true;
  39933. hdrSkybox.infiniteDistance = true;
  39934. hdrSkybox.material = skyboxMaterial;
  39935. }
  39936. hdrSkybox.isPickable = false;
  39937. return hdrSkybox;
  39938. };
  39939. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultEnvironment = function (options) {
  39940. if (_environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"]) {
  39941. return new _environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"](options, this);
  39942. }
  39943. return null;
  39944. };
  39945. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultVRExperience = function (webVROptions) {
  39946. if (webVROptions === void 0) { webVROptions = {}; }
  39947. return new _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__["VRExperienceHelper"](this, webVROptions);
  39948. };
  39949. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultXRExperienceAsync = function () {
  39950. var _this = this;
  39951. return _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__["WebXRExperienceHelper"].CreateAsync(this).then(function (helper) {
  39952. var outputCanvas = new _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__["WebXRManagedOutputCanvas"](helper);
  39953. return _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__["WebXREnterExitUI"].CreateAsync(_this, helper, { outputCanvasContext: outputCanvas.canvasContext })
  39954. .then(function (ui) {
  39955. new _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__["WebXRInput"](helper);
  39956. return helper;
  39957. });
  39958. });
  39959. };
  39960. /***/ }),
  39961. /***/ "./Helpers/videoDome.ts":
  39962. /*!******************************!*\
  39963. !*** ./Helpers/videoDome.ts ***!
  39964. \******************************/
  39965. /*! exports provided: VideoDome */
  39966. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39967. "use strict";
  39968. __webpack_require__.r(__webpack_exports__);
  39969. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return VideoDome; });
  39970. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39971. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  39972. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39973. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39974. /* harmony import */ var _Materials_Textures_videoTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/videoTexture */ "./Materials/Textures/videoTexture.ts");
  39975. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  39976. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  39977. /**
  39978. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  39979. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  39980. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  39981. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  39982. */
  39983. var VideoDome = /** @class */ (function (_super) {
  39984. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoDome, _super);
  39985. /**
  39986. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  39987. * @param name Element's name, child elements will append suffixes for their own names.
  39988. * @param urlsOrVideo defines the url(s) or the video element to use
  39989. * @param options An object containing optional or exposed sub element properties
  39990. */
  39991. function VideoDome(name, urlsOrVideo, options, scene) {
  39992. var _this = _super.call(this, name, scene) || this;
  39993. _this._useDirectMapping = false;
  39994. // set defaults and manage values
  39995. name = name || "videoDome";
  39996. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  39997. options.clickToPlay = Boolean(options.clickToPlay);
  39998. options.autoPlay = options.autoPlay === undefined ? true : Boolean(options.autoPlay);
  39999. options.loop = options.loop === undefined ? true : Boolean(options.loop);
  40000. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  40001. if (options.useDirectMapping === undefined) {
  40002. _this._useDirectMapping = true;
  40003. }
  40004. else {
  40005. _this._useDirectMapping = options.useDirectMapping;
  40006. }
  40007. _this._setReady(false);
  40008. // create
  40009. var tempOptions = { loop: options.loop, autoPlay: options.autoPlay, autoUpdateTexture: true, poster: options.poster };
  40010. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  40011. 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);
  40012. _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);
  40013. texture.onLoadObservable.addOnce(function () {
  40014. _this._setReady(true);
  40015. });
  40016. // configure material
  40017. material.useEquirectangularFOV = true;
  40018. material.fovMultiplier = 1.0;
  40019. material.opacityFresnel = false;
  40020. if (_this._useDirectMapping) {
  40021. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  40022. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  40023. material.diffuseTexture = texture;
  40024. }
  40025. else {
  40026. texture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  40027. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  40028. material.reflectionTexture = texture;
  40029. }
  40030. // configure mesh
  40031. _this._mesh.material = material;
  40032. _this._mesh.parent = _this;
  40033. // optional configuration
  40034. if (options.clickToPlay) {
  40035. scene.onPointerUp = function () {
  40036. _this._videoTexture.video.play();
  40037. };
  40038. }
  40039. return _this;
  40040. }
  40041. Object.defineProperty(VideoDome.prototype, "videoTexture", {
  40042. /**
  40043. * Gets the video texture being displayed on the sphere
  40044. */
  40045. get: function () {
  40046. return this._videoTexture;
  40047. },
  40048. enumerable: true,
  40049. configurable: true
  40050. });
  40051. Object.defineProperty(VideoDome.prototype, "fovMultiplier", {
  40052. /**
  40053. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  40054. * Also see the options.resolution property.
  40055. */
  40056. get: function () {
  40057. return this._material.fovMultiplier;
  40058. },
  40059. set: function (value) {
  40060. this._material.fovMultiplier = value;
  40061. },
  40062. enumerable: true,
  40063. configurable: true
  40064. });
  40065. /**
  40066. * Releases resources associated with this node.
  40067. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  40068. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  40069. */
  40070. VideoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  40071. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  40072. this._videoTexture.dispose();
  40073. this._mesh.dispose();
  40074. this._material.dispose();
  40075. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  40076. };
  40077. return VideoDome;
  40078. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]));
  40079. /***/ }),
  40080. /***/ "./Instrumentation/engineInstrumentation.ts":
  40081. /*!**************************************************!*\
  40082. !*** ./Instrumentation/engineInstrumentation.ts ***!
  40083. \**************************************************/
  40084. /*! exports provided: EngineInstrumentation */
  40085. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40086. "use strict";
  40087. __webpack_require__.r(__webpack_exports__);
  40088. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return EngineInstrumentation; });
  40089. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40090. /**
  40091. * This class can be used to get instrumentation data from a Babylon engine
  40092. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40093. */
  40094. var EngineInstrumentation = /** @class */ (function () {
  40095. /**
  40096. * Instantiates a new engine instrumentation.
  40097. * This class can be used to get instrumentation data from a Babylon engine
  40098. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40099. * @param engine Defines the engine to instrument
  40100. */
  40101. function EngineInstrumentation(
  40102. /**
  40103. * Define the instrumented engine.
  40104. */
  40105. engine) {
  40106. this.engine = engine;
  40107. this._captureGPUFrameTime = false;
  40108. this._gpuFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40109. this._captureShaderCompilationTime = false;
  40110. this._shaderCompilationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40111. // Observers
  40112. this._onBeginFrameObserver = null;
  40113. this._onEndFrameObserver = null;
  40114. this._onBeforeShaderCompilationObserver = null;
  40115. this._onAfterShaderCompilationObserver = null;
  40116. }
  40117. Object.defineProperty(EngineInstrumentation.prototype, "gpuFrameTimeCounter", {
  40118. // Properties
  40119. /**
  40120. * Gets the perf counter used for GPU frame time
  40121. */
  40122. get: function () {
  40123. return this._gpuFrameTime;
  40124. },
  40125. enumerable: true,
  40126. configurable: true
  40127. });
  40128. Object.defineProperty(EngineInstrumentation.prototype, "captureGPUFrameTime", {
  40129. /**
  40130. * Gets the GPU frame time capture status
  40131. */
  40132. get: function () {
  40133. return this._captureGPUFrameTime;
  40134. },
  40135. /**
  40136. * Enable or disable the GPU frame time capture
  40137. */
  40138. set: function (value) {
  40139. var _this = this;
  40140. if (value === this._captureGPUFrameTime) {
  40141. return;
  40142. }
  40143. this._captureGPUFrameTime = value;
  40144. if (value) {
  40145. this._onBeginFrameObserver = this.engine.onBeginFrameObservable.add(function () {
  40146. if (!_this._gpuFrameTimeToken) {
  40147. _this._gpuFrameTimeToken = _this.engine.startTimeQuery();
  40148. }
  40149. });
  40150. this._onEndFrameObserver = this.engine.onEndFrameObservable.add(function () {
  40151. if (!_this._gpuFrameTimeToken) {
  40152. return;
  40153. }
  40154. var time = _this.engine.endTimeQuery(_this._gpuFrameTimeToken);
  40155. if (time > -1) {
  40156. _this._gpuFrameTimeToken = null;
  40157. _this._gpuFrameTime.fetchNewFrame();
  40158. _this._gpuFrameTime.addCount(time, true);
  40159. }
  40160. });
  40161. }
  40162. else {
  40163. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  40164. this._onBeginFrameObserver = null;
  40165. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  40166. this._onEndFrameObserver = null;
  40167. }
  40168. },
  40169. enumerable: true,
  40170. configurable: true
  40171. });
  40172. Object.defineProperty(EngineInstrumentation.prototype, "shaderCompilationTimeCounter", {
  40173. /**
  40174. * Gets the perf counter used for shader compilation time
  40175. */
  40176. get: function () {
  40177. return this._shaderCompilationTime;
  40178. },
  40179. enumerable: true,
  40180. configurable: true
  40181. });
  40182. Object.defineProperty(EngineInstrumentation.prototype, "captureShaderCompilationTime", {
  40183. /**
  40184. * Gets the shader compilation time capture status
  40185. */
  40186. get: function () {
  40187. return this._captureShaderCompilationTime;
  40188. },
  40189. /**
  40190. * Enable or disable the shader compilation time capture
  40191. */
  40192. set: function (value) {
  40193. var _this = this;
  40194. if (value === this._captureShaderCompilationTime) {
  40195. return;
  40196. }
  40197. this._captureShaderCompilationTime = value;
  40198. if (value) {
  40199. this._onBeforeShaderCompilationObserver = this.engine.onBeforeShaderCompilationObservable.add(function () {
  40200. _this._shaderCompilationTime.fetchNewFrame();
  40201. _this._shaderCompilationTime.beginMonitoring();
  40202. });
  40203. this._onAfterShaderCompilationObserver = this.engine.onAfterShaderCompilationObservable.add(function () {
  40204. _this._shaderCompilationTime.endMonitoring();
  40205. });
  40206. }
  40207. else {
  40208. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  40209. this._onBeforeShaderCompilationObserver = null;
  40210. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  40211. this._onAfterShaderCompilationObserver = null;
  40212. }
  40213. },
  40214. enumerable: true,
  40215. configurable: true
  40216. });
  40217. /**
  40218. * Dispose and release associated resources.
  40219. */
  40220. EngineInstrumentation.prototype.dispose = function () {
  40221. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  40222. this._onBeginFrameObserver = null;
  40223. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  40224. this._onEndFrameObserver = null;
  40225. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  40226. this._onBeforeShaderCompilationObserver = null;
  40227. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  40228. this._onAfterShaderCompilationObserver = null;
  40229. this.engine = null;
  40230. };
  40231. return EngineInstrumentation;
  40232. }());
  40233. /***/ }),
  40234. /***/ "./Instrumentation/index.ts":
  40235. /*!**********************************!*\
  40236. !*** ./Instrumentation/index.ts ***!
  40237. \**********************************/
  40238. /*! exports provided: EngineInstrumentation, SceneInstrumentation, _TimeToken */
  40239. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40240. "use strict";
  40241. __webpack_require__.r(__webpack_exports__);
  40242. /* harmony import */ var _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engineInstrumentation */ "./Instrumentation/engineInstrumentation.ts");
  40243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  40244. /* harmony import */ var _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sceneInstrumentation */ "./Instrumentation/sceneInstrumentation.ts");
  40245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__["SceneInstrumentation"]; });
  40246. /* harmony import */ var _timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./timeToken */ "./Instrumentation/timeToken.ts");
  40247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]; });
  40248. /***/ }),
  40249. /***/ "./Instrumentation/sceneInstrumentation.ts":
  40250. /*!*************************************************!*\
  40251. !*** ./Instrumentation/sceneInstrumentation.ts ***!
  40252. \*************************************************/
  40253. /*! exports provided: SceneInstrumentation */
  40254. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40255. "use strict";
  40256. __webpack_require__.r(__webpack_exports__);
  40257. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return SceneInstrumentation; });
  40258. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40259. /**
  40260. * This class can be used to get instrumentation data from a Babylon engine
  40261. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  40262. */
  40263. var SceneInstrumentation = /** @class */ (function () {
  40264. /**
  40265. * Instantiates a new scene instrumentation.
  40266. * This class can be used to get instrumentation data from a Babylon engine
  40267. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  40268. * @param scene Defines the scene to instrument
  40269. */
  40270. function SceneInstrumentation(
  40271. /**
  40272. * Defines the scene to instrument
  40273. */
  40274. scene) {
  40275. var _this = this;
  40276. this.scene = scene;
  40277. this._captureActiveMeshesEvaluationTime = false;
  40278. this._activeMeshesEvaluationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40279. this._captureRenderTargetsRenderTime = false;
  40280. this._renderTargetsRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40281. this._captureFrameTime = false;
  40282. this._frameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40283. this._captureRenderTime = false;
  40284. this._renderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40285. this._captureInterFrameTime = false;
  40286. this._interFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40287. this._captureParticlesRenderTime = false;
  40288. this._particlesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40289. this._captureSpritesRenderTime = false;
  40290. this._spritesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40291. this._capturePhysicsTime = false;
  40292. this._physicsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40293. this._captureAnimationsTime = false;
  40294. this._animationsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40295. this._captureCameraRenderTime = false;
  40296. this._cameraRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40297. // Observers
  40298. this._onBeforeActiveMeshesEvaluationObserver = null;
  40299. this._onAfterActiveMeshesEvaluationObserver = null;
  40300. this._onBeforeRenderTargetsRenderObserver = null;
  40301. this._onAfterRenderTargetsRenderObserver = null;
  40302. this._onAfterRenderObserver = null;
  40303. this._onBeforeDrawPhaseObserver = null;
  40304. this._onAfterDrawPhaseObserver = null;
  40305. this._onBeforeAnimationsObserver = null;
  40306. this._onBeforeParticlesRenderingObserver = null;
  40307. this._onAfterParticlesRenderingObserver = null;
  40308. this._onBeforeSpritesRenderingObserver = null;
  40309. this._onAfterSpritesRenderingObserver = null;
  40310. this._onBeforePhysicsObserver = null;
  40311. this._onAfterPhysicsObserver = null;
  40312. this._onAfterAnimationsObserver = null;
  40313. this._onBeforeCameraRenderObserver = null;
  40314. this._onAfterCameraRenderObserver = null;
  40315. // Before render
  40316. this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(function () {
  40317. if (_this._captureActiveMeshesEvaluationTime) {
  40318. _this._activeMeshesEvaluationTime.fetchNewFrame();
  40319. }
  40320. if (_this._captureRenderTargetsRenderTime) {
  40321. _this._renderTargetsRenderTime.fetchNewFrame();
  40322. }
  40323. if (_this._captureFrameTime) {
  40324. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Scene rendering");
  40325. _this._frameTime.beginMonitoring();
  40326. }
  40327. if (_this._captureInterFrameTime) {
  40328. _this._interFrameTime.endMonitoring();
  40329. }
  40330. if (_this._captureParticlesRenderTime) {
  40331. _this._particlesRenderTime.fetchNewFrame();
  40332. }
  40333. if (_this._captureSpritesRenderTime) {
  40334. _this._spritesRenderTime.fetchNewFrame();
  40335. }
  40336. if (_this._captureAnimationsTime) {
  40337. _this._animationsTime.beginMonitoring();
  40338. }
  40339. _this.scene.getEngine()._drawCalls.fetchNewFrame();
  40340. _this.scene.getEngine()._textureCollisions.fetchNewFrame();
  40341. });
  40342. // After render
  40343. this._onAfterRenderObserver = scene.onAfterRenderObservable.add(function () {
  40344. if (_this._captureFrameTime) {
  40345. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Scene rendering");
  40346. _this._frameTime.endMonitoring();
  40347. }
  40348. if (_this._captureRenderTime) {
  40349. _this._renderTime.endMonitoring(false);
  40350. }
  40351. if (_this._captureInterFrameTime) {
  40352. _this._interFrameTime.beginMonitoring();
  40353. }
  40354. });
  40355. }
  40356. Object.defineProperty(SceneInstrumentation.prototype, "activeMeshesEvaluationTimeCounter", {
  40357. // Properties
  40358. /**
  40359. * Gets the perf counter used for active meshes evaluation time
  40360. */
  40361. get: function () {
  40362. return this._activeMeshesEvaluationTime;
  40363. },
  40364. enumerable: true,
  40365. configurable: true
  40366. });
  40367. Object.defineProperty(SceneInstrumentation.prototype, "captureActiveMeshesEvaluationTime", {
  40368. /**
  40369. * Gets the active meshes evaluation time capture status
  40370. */
  40371. get: function () {
  40372. return this._captureActiveMeshesEvaluationTime;
  40373. },
  40374. /**
  40375. * Enable or disable the active meshes evaluation time capture
  40376. */
  40377. set: function (value) {
  40378. var _this = this;
  40379. if (value === this._captureActiveMeshesEvaluationTime) {
  40380. return;
  40381. }
  40382. this._captureActiveMeshesEvaluationTime = value;
  40383. if (value) {
  40384. this._onBeforeActiveMeshesEvaluationObserver = this.scene.onBeforeActiveMeshesEvaluationObservable.add(function () {
  40385. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Active meshes evaluation");
  40386. _this._activeMeshesEvaluationTime.beginMonitoring();
  40387. });
  40388. this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add(function () {
  40389. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Active meshes evaluation");
  40390. _this._activeMeshesEvaluationTime.endMonitoring();
  40391. });
  40392. }
  40393. else {
  40394. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  40395. this._onBeforeActiveMeshesEvaluationObserver = null;
  40396. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  40397. this._onAfterActiveMeshesEvaluationObserver = null;
  40398. }
  40399. },
  40400. enumerable: true,
  40401. configurable: true
  40402. });
  40403. Object.defineProperty(SceneInstrumentation.prototype, "renderTargetsRenderTimeCounter", {
  40404. /**
  40405. * Gets the perf counter used for render targets render time
  40406. */
  40407. get: function () {
  40408. return this._renderTargetsRenderTime;
  40409. },
  40410. enumerable: true,
  40411. configurable: true
  40412. });
  40413. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTargetsRenderTime", {
  40414. /**
  40415. * Gets the render targets render time capture status
  40416. */
  40417. get: function () {
  40418. return this._captureRenderTargetsRenderTime;
  40419. },
  40420. /**
  40421. * Enable or disable the render targets render time capture
  40422. */
  40423. set: function (value) {
  40424. var _this = this;
  40425. if (value === this._captureRenderTargetsRenderTime) {
  40426. return;
  40427. }
  40428. this._captureRenderTargetsRenderTime = value;
  40429. if (value) {
  40430. this._onBeforeRenderTargetsRenderObserver = this.scene.onBeforeRenderTargetsRenderObservable.add(function () {
  40431. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Render targets rendering");
  40432. _this._renderTargetsRenderTime.beginMonitoring();
  40433. });
  40434. this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add(function () {
  40435. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Render targets rendering");
  40436. _this._renderTargetsRenderTime.endMonitoring(false);
  40437. });
  40438. }
  40439. else {
  40440. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  40441. this._onBeforeRenderTargetsRenderObserver = null;
  40442. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  40443. this._onAfterRenderTargetsRenderObserver = null;
  40444. }
  40445. },
  40446. enumerable: true,
  40447. configurable: true
  40448. });
  40449. Object.defineProperty(SceneInstrumentation.prototype, "particlesRenderTimeCounter", {
  40450. /**
  40451. * Gets the perf counter used for particles render time
  40452. */
  40453. get: function () {
  40454. return this._particlesRenderTime;
  40455. },
  40456. enumerable: true,
  40457. configurable: true
  40458. });
  40459. Object.defineProperty(SceneInstrumentation.prototype, "captureParticlesRenderTime", {
  40460. /**
  40461. * Gets the particles render time capture status
  40462. */
  40463. get: function () {
  40464. return this._captureParticlesRenderTime;
  40465. },
  40466. /**
  40467. * Enable or disable the particles render time capture
  40468. */
  40469. set: function (value) {
  40470. var _this = this;
  40471. if (value === this._captureParticlesRenderTime) {
  40472. return;
  40473. }
  40474. this._captureParticlesRenderTime = value;
  40475. if (value) {
  40476. this._onBeforeParticlesRenderingObserver = this.scene.onBeforeParticlesRenderingObservable.add(function () {
  40477. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Particles");
  40478. _this._particlesRenderTime.beginMonitoring();
  40479. });
  40480. this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add(function () {
  40481. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Particles");
  40482. _this._particlesRenderTime.endMonitoring(false);
  40483. });
  40484. }
  40485. else {
  40486. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  40487. this._onBeforeParticlesRenderingObserver = null;
  40488. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  40489. this._onAfterParticlesRenderingObserver = null;
  40490. }
  40491. },
  40492. enumerable: true,
  40493. configurable: true
  40494. });
  40495. Object.defineProperty(SceneInstrumentation.prototype, "spritesRenderTimeCounter", {
  40496. /**
  40497. * Gets the perf counter used for sprites render time
  40498. */
  40499. get: function () {
  40500. return this._spritesRenderTime;
  40501. },
  40502. enumerable: true,
  40503. configurable: true
  40504. });
  40505. Object.defineProperty(SceneInstrumentation.prototype, "captureSpritesRenderTime", {
  40506. /**
  40507. * Gets the sprites render time capture status
  40508. */
  40509. get: function () {
  40510. return this._captureSpritesRenderTime;
  40511. },
  40512. /**
  40513. * Enable or disable the sprites render time capture
  40514. */
  40515. set: function (value) {
  40516. var _this = this;
  40517. if (value === this._captureSpritesRenderTime) {
  40518. return;
  40519. }
  40520. this._captureSpritesRenderTime = value;
  40521. if (!this.scene.spriteManagers) {
  40522. return;
  40523. }
  40524. if (value) {
  40525. this._onBeforeSpritesRenderingObserver = this.scene.onBeforeSpritesRenderingObservable.add(function () {
  40526. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Sprites");
  40527. _this._spritesRenderTime.beginMonitoring();
  40528. });
  40529. this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add(function () {
  40530. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Sprites");
  40531. _this._spritesRenderTime.endMonitoring(false);
  40532. });
  40533. }
  40534. else {
  40535. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  40536. this._onBeforeSpritesRenderingObserver = null;
  40537. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  40538. this._onAfterSpritesRenderingObserver = null;
  40539. }
  40540. },
  40541. enumerable: true,
  40542. configurable: true
  40543. });
  40544. Object.defineProperty(SceneInstrumentation.prototype, "physicsTimeCounter", {
  40545. /**
  40546. * Gets the perf counter used for physics time
  40547. */
  40548. get: function () {
  40549. return this._physicsTime;
  40550. },
  40551. enumerable: true,
  40552. configurable: true
  40553. });
  40554. Object.defineProperty(SceneInstrumentation.prototype, "capturePhysicsTime", {
  40555. /**
  40556. * Gets the physics time capture status
  40557. */
  40558. get: function () {
  40559. return this._capturePhysicsTime;
  40560. },
  40561. /**
  40562. * Enable or disable the physics time capture
  40563. */
  40564. set: function (value) {
  40565. var _this = this;
  40566. if (value === this._capturePhysicsTime) {
  40567. return;
  40568. }
  40569. if (!this.scene.onBeforePhysicsObservable) {
  40570. return;
  40571. }
  40572. this._capturePhysicsTime = value;
  40573. if (value) {
  40574. this._onBeforePhysicsObserver = this.scene.onBeforePhysicsObservable.add(function () {
  40575. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Physics");
  40576. _this._physicsTime.beginMonitoring();
  40577. });
  40578. this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add(function () {
  40579. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Physics");
  40580. _this._physicsTime.endMonitoring();
  40581. });
  40582. }
  40583. else {
  40584. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  40585. this._onBeforePhysicsObserver = null;
  40586. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  40587. this._onAfterPhysicsObserver = null;
  40588. }
  40589. },
  40590. enumerable: true,
  40591. configurable: true
  40592. });
  40593. Object.defineProperty(SceneInstrumentation.prototype, "animationsTimeCounter", {
  40594. /**
  40595. * Gets the perf counter used for animations time
  40596. */
  40597. get: function () {
  40598. return this._animationsTime;
  40599. },
  40600. enumerable: true,
  40601. configurable: true
  40602. });
  40603. Object.defineProperty(SceneInstrumentation.prototype, "captureAnimationsTime", {
  40604. /**
  40605. * Gets the animations time capture status
  40606. */
  40607. get: function () {
  40608. return this._captureAnimationsTime;
  40609. },
  40610. /**
  40611. * Enable or disable the animations time capture
  40612. */
  40613. set: function (value) {
  40614. var _this = this;
  40615. if (value === this._captureAnimationsTime) {
  40616. return;
  40617. }
  40618. this._captureAnimationsTime = value;
  40619. if (value) {
  40620. this._onAfterAnimationsObserver = this.scene.onAfterAnimationsObservable.add(function () {
  40621. _this._animationsTime.endMonitoring();
  40622. });
  40623. }
  40624. else {
  40625. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  40626. this._onAfterAnimationsObserver = null;
  40627. }
  40628. },
  40629. enumerable: true,
  40630. configurable: true
  40631. });
  40632. Object.defineProperty(SceneInstrumentation.prototype, "frameTimeCounter", {
  40633. /**
  40634. * Gets the perf counter used for frame time capture
  40635. */
  40636. get: function () {
  40637. return this._frameTime;
  40638. },
  40639. enumerable: true,
  40640. configurable: true
  40641. });
  40642. Object.defineProperty(SceneInstrumentation.prototype, "captureFrameTime", {
  40643. /**
  40644. * Gets the frame time capture status
  40645. */
  40646. get: function () {
  40647. return this._captureFrameTime;
  40648. },
  40649. /**
  40650. * Enable or disable the frame time capture
  40651. */
  40652. set: function (value) {
  40653. this._captureFrameTime = value;
  40654. },
  40655. enumerable: true,
  40656. configurable: true
  40657. });
  40658. Object.defineProperty(SceneInstrumentation.prototype, "interFrameTimeCounter", {
  40659. /**
  40660. * Gets the perf counter used for inter-frames time capture
  40661. */
  40662. get: function () {
  40663. return this._interFrameTime;
  40664. },
  40665. enumerable: true,
  40666. configurable: true
  40667. });
  40668. Object.defineProperty(SceneInstrumentation.prototype, "captureInterFrameTime", {
  40669. /**
  40670. * Gets the inter-frames time capture status
  40671. */
  40672. get: function () {
  40673. return this._captureInterFrameTime;
  40674. },
  40675. /**
  40676. * Enable or disable the inter-frames time capture
  40677. */
  40678. set: function (value) {
  40679. this._captureInterFrameTime = value;
  40680. },
  40681. enumerable: true,
  40682. configurable: true
  40683. });
  40684. Object.defineProperty(SceneInstrumentation.prototype, "renderTimeCounter", {
  40685. /**
  40686. * Gets the perf counter used for render time capture
  40687. */
  40688. get: function () {
  40689. return this._renderTime;
  40690. },
  40691. enumerable: true,
  40692. configurable: true
  40693. });
  40694. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTime", {
  40695. /**
  40696. * Gets the render time capture status
  40697. */
  40698. get: function () {
  40699. return this._captureRenderTime;
  40700. },
  40701. /**
  40702. * Enable or disable the render time capture
  40703. */
  40704. set: function (value) {
  40705. var _this = this;
  40706. if (value === this._captureRenderTime) {
  40707. return;
  40708. }
  40709. this._captureRenderTime = value;
  40710. if (value) {
  40711. this._onBeforeDrawPhaseObserver = this.scene.onBeforeDrawPhaseObservable.add(function () {
  40712. _this._renderTime.beginMonitoring();
  40713. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Main render");
  40714. });
  40715. this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add(function () {
  40716. _this._renderTime.endMonitoring(false);
  40717. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Main render");
  40718. });
  40719. }
  40720. else {
  40721. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  40722. this._onBeforeDrawPhaseObserver = null;
  40723. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  40724. this._onAfterDrawPhaseObserver = null;
  40725. }
  40726. },
  40727. enumerable: true,
  40728. configurable: true
  40729. });
  40730. Object.defineProperty(SceneInstrumentation.prototype, "cameraRenderTimeCounter", {
  40731. /**
  40732. * Gets the perf counter used for camera render time capture
  40733. */
  40734. get: function () {
  40735. return this._cameraRenderTime;
  40736. },
  40737. enumerable: true,
  40738. configurable: true
  40739. });
  40740. Object.defineProperty(SceneInstrumentation.prototype, "captureCameraRenderTime", {
  40741. /**
  40742. * Gets the camera render time capture status
  40743. */
  40744. get: function () {
  40745. return this._captureCameraRenderTime;
  40746. },
  40747. /**
  40748. * Enable or disable the camera render time capture
  40749. */
  40750. set: function (value) {
  40751. var _this = this;
  40752. if (value === this._captureCameraRenderTime) {
  40753. return;
  40754. }
  40755. this._captureCameraRenderTime = value;
  40756. if (value) {
  40757. this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function (camera) {
  40758. _this._cameraRenderTime.beginMonitoring();
  40759. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Rendering camera " + camera.name);
  40760. });
  40761. this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function (camera) {
  40762. _this._cameraRenderTime.endMonitoring(false);
  40763. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Rendering camera " + camera.name);
  40764. });
  40765. }
  40766. else {
  40767. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  40768. this._onBeforeCameraRenderObserver = null;
  40769. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  40770. this._onAfterCameraRenderObserver = null;
  40771. }
  40772. },
  40773. enumerable: true,
  40774. configurable: true
  40775. });
  40776. Object.defineProperty(SceneInstrumentation.prototype, "drawCallsCounter", {
  40777. /**
  40778. * Gets the perf counter used for draw calls
  40779. */
  40780. get: function () {
  40781. return this.scene.getEngine()._drawCalls;
  40782. },
  40783. enumerable: true,
  40784. configurable: true
  40785. });
  40786. Object.defineProperty(SceneInstrumentation.prototype, "textureCollisionsCounter", {
  40787. /**
  40788. * Gets the perf counter used for texture collisions
  40789. */
  40790. get: function () {
  40791. return this.scene.getEngine()._textureCollisions;
  40792. },
  40793. enumerable: true,
  40794. configurable: true
  40795. });
  40796. /**
  40797. * Dispose and release associated resources.
  40798. */
  40799. SceneInstrumentation.prototype.dispose = function () {
  40800. this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  40801. this._onAfterRenderObserver = null;
  40802. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  40803. this._onBeforeActiveMeshesEvaluationObserver = null;
  40804. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  40805. this._onAfterActiveMeshesEvaluationObserver = null;
  40806. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  40807. this._onBeforeRenderTargetsRenderObserver = null;
  40808. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  40809. this._onAfterRenderTargetsRenderObserver = null;
  40810. this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver);
  40811. this._onBeforeAnimationsObserver = null;
  40812. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  40813. this._onBeforeParticlesRenderingObserver = null;
  40814. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  40815. this._onAfterParticlesRenderingObserver = null;
  40816. if (this._onBeforeSpritesRenderingObserver) {
  40817. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  40818. this._onBeforeSpritesRenderingObserver = null;
  40819. }
  40820. if (this._onAfterSpritesRenderingObserver) {
  40821. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  40822. this._onAfterSpritesRenderingObserver = null;
  40823. }
  40824. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  40825. this._onBeforeDrawPhaseObserver = null;
  40826. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  40827. this._onAfterDrawPhaseObserver = null;
  40828. if (this._onBeforePhysicsObserver) {
  40829. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  40830. this._onBeforePhysicsObserver = null;
  40831. }
  40832. if (this._onAfterPhysicsObserver) {
  40833. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  40834. this._onAfterPhysicsObserver = null;
  40835. }
  40836. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  40837. this._onAfterAnimationsObserver = null;
  40838. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  40839. this._onBeforeCameraRenderObserver = null;
  40840. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  40841. this._onAfterCameraRenderObserver = null;
  40842. this.scene = null;
  40843. };
  40844. return SceneInstrumentation;
  40845. }());
  40846. /***/ }),
  40847. /***/ "./Instrumentation/timeToken.ts":
  40848. /*!**************************************!*\
  40849. !*** ./Instrumentation/timeToken.ts ***!
  40850. \**************************************/
  40851. /*! exports provided: _TimeToken */
  40852. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40853. "use strict";
  40854. __webpack_require__.r(__webpack_exports__);
  40855. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _TimeToken; });
  40856. /**
  40857. * @hidden
  40858. **/
  40859. var _TimeToken = /** @class */ (function () {
  40860. function _TimeToken() {
  40861. this._timeElapsedQueryEnded = false;
  40862. }
  40863. return _TimeToken;
  40864. }());
  40865. /***/ }),
  40866. /***/ "./Layers/effectLayer.ts":
  40867. /*!*******************************!*\
  40868. !*** ./Layers/effectLayer.ts ***!
  40869. \*******************************/
  40870. /*! exports provided: EffectLayer */
  40871. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40872. "use strict";
  40873. __webpack_require__.r(__webpack_exports__);
  40874. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return EffectLayer; });
  40875. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40876. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  40877. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40878. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40879. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40880. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  40881. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  40882. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40883. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  40884. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  40885. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  40886. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  40887. /* harmony import */ var _Shaders_glowMapGeneration_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.fragment */ "./Shaders/glowMapGeneration.fragment.ts");
  40888. /* harmony import */ var _Shaders_glowMapGeneration_vertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.vertex */ "./Shaders/glowMapGeneration.vertex.ts");
  40889. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  40890. /**
  40891. * The effect layer Helps adding post process effect blended with the main pass.
  40892. *
  40893. * This can be for instance use to generate glow or higlight effects on the scene.
  40894. *
  40895. * The effect layer class can not be used directly and is intented to inherited from to be
  40896. * customized per effects.
  40897. */
  40898. var EffectLayer = /** @class */ (function () {
  40899. /**
  40900. * Instantiates a new effect Layer and references it in the scene.
  40901. * @param name The name of the layer
  40902. * @param scene The scene to use the layer in
  40903. */
  40904. function EffectLayer(
  40905. /** The Friendly of the effect in the scene */
  40906. name, scene) {
  40907. this._vertexBuffers = {};
  40908. this._maxSize = 0;
  40909. this._mainTextureDesiredSize = { width: 0, height: 0 };
  40910. this._shouldRender = true;
  40911. this._postProcesses = [];
  40912. this._textures = [];
  40913. this._emissiveTextureAndColor = { texture: null, color: new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]() };
  40914. /**
  40915. * The clear color of the texture used to generate the glow map.
  40916. */
  40917. this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]();
  40918. /**
  40919. * Specifies wether the highlight layer is enabled or not.
  40920. */
  40921. this.isEnabled = true;
  40922. /**
  40923. * An event triggered when the effect layer has been disposed.
  40924. */
  40925. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40926. /**
  40927. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  40928. */
  40929. this.onBeforeRenderMainTextureObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40930. /**
  40931. * An event triggered when the generated texture is being merged in the scene.
  40932. */
  40933. this.onBeforeComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40934. /**
  40935. * An event triggered when the generated texture has been merged in the scene.
  40936. */
  40937. this.onAfterComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40938. /**
  40939. * An event triggered when the efffect layer changes its size.
  40940. */
  40941. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40942. this.name = name;
  40943. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  40944. EffectLayer._SceneComponentInitialization(this._scene);
  40945. this._engine = this._scene.getEngine();
  40946. this._maxSize = this._engine.getCaps().maxTextureSize;
  40947. this._scene.effectLayers.push(this);
  40948. // Generate Buffers
  40949. this._generateIndexBuffer();
  40950. this._genrateVertexBuffer();
  40951. }
  40952. Object.defineProperty(EffectLayer.prototype, "camera", {
  40953. /**
  40954. * Gets the camera attached to the layer.
  40955. */
  40956. get: function () {
  40957. return this._effectLayerOptions.camera;
  40958. },
  40959. enumerable: true,
  40960. configurable: true
  40961. });
  40962. Object.defineProperty(EffectLayer.prototype, "renderingGroupId", {
  40963. /**
  40964. * Gets the rendering group id the layer should render in.
  40965. */
  40966. get: function () {
  40967. return this._effectLayerOptions.renderingGroupId;
  40968. },
  40969. enumerable: true,
  40970. configurable: true
  40971. });
  40972. /**
  40973. * Initializes the effect layer with the required options.
  40974. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  40975. */
  40976. EffectLayer.prototype._init = function (options) {
  40977. // Adapt options
  40978. 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);
  40979. this._setMainTextureSize();
  40980. this._createMainTexture();
  40981. this._createTextureAndPostProcesses();
  40982. this._mergeEffect = this._createMergeEffect();
  40983. };
  40984. /**
  40985. * Generates the index buffer of the full screen quad blending to the main canvas.
  40986. */
  40987. EffectLayer.prototype._generateIndexBuffer = function () {
  40988. // Indices
  40989. var indices = [];
  40990. indices.push(0);
  40991. indices.push(1);
  40992. indices.push(2);
  40993. indices.push(0);
  40994. indices.push(2);
  40995. indices.push(3);
  40996. this._indexBuffer = this._engine.createIndexBuffer(indices);
  40997. };
  40998. /**
  40999. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  41000. */
  41001. EffectLayer.prototype._genrateVertexBuffer = function () {
  41002. // VBO
  41003. var vertices = [];
  41004. vertices.push(1, 1);
  41005. vertices.push(-1, 1);
  41006. vertices.push(-1, -1);
  41007. vertices.push(1, -1);
  41008. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"](this._engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind, false, false, 2);
  41009. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = vertexBuffer;
  41010. };
  41011. /**
  41012. * Sets the main texture desired size which is the closest power of two
  41013. * of the engine canvas size.
  41014. */
  41015. EffectLayer.prototype._setMainTextureSize = function () {
  41016. if (this._effectLayerOptions.mainTextureFixedSize) {
  41017. this._mainTextureDesiredSize.width = this._effectLayerOptions.mainTextureFixedSize;
  41018. this._mainTextureDesiredSize.height = this._effectLayerOptions.mainTextureFixedSize;
  41019. }
  41020. else {
  41021. this._mainTextureDesiredSize.width = this._engine.getRenderWidth() * this._effectLayerOptions.mainTextureRatio;
  41022. this._mainTextureDesiredSize.height = this._engine.getRenderHeight() * this._effectLayerOptions.mainTextureRatio;
  41023. this._mainTextureDesiredSize.width = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.width, this._maxSize) : this._mainTextureDesiredSize.width;
  41024. this._mainTextureDesiredSize.height = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.height, this._maxSize) : this._mainTextureDesiredSize.height;
  41025. }
  41026. this._mainTextureDesiredSize.width = Math.floor(this._mainTextureDesiredSize.width);
  41027. this._mainTextureDesiredSize.height = Math.floor(this._mainTextureDesiredSize.height);
  41028. };
  41029. /**
  41030. * Creates the main texture for the effect layer.
  41031. */
  41032. EffectLayer.prototype._createMainTexture = function () {
  41033. var _this = this;
  41034. this._mainTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerMainRTT", {
  41035. width: this._mainTextureDesiredSize.width,
  41036. height: this._mainTextureDesiredSize.height
  41037. }, this._scene, false, true, _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  41038. this._mainTexture.activeCamera = this._effectLayerOptions.camera;
  41039. this._mainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  41040. this._mainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  41041. this._mainTexture.anisotropicFilteringLevel = 1;
  41042. this._mainTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE);
  41043. this._mainTexture.renderParticles = false;
  41044. this._mainTexture.renderList = null;
  41045. this._mainTexture.ignoreCameraViewport = true;
  41046. // Custom render function
  41047. this._mainTexture.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  41048. _this.onBeforeRenderMainTextureObservable.notifyObservers(_this);
  41049. var index;
  41050. var engine = _this._scene.getEngine();
  41051. if (depthOnlySubMeshes.length) {
  41052. engine.setColorWrite(false);
  41053. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  41054. _this._renderSubMesh(depthOnlySubMeshes.data[index]);
  41055. }
  41056. engine.setColorWrite(true);
  41057. }
  41058. for (index = 0; index < opaqueSubMeshes.length; index++) {
  41059. _this._renderSubMesh(opaqueSubMeshes.data[index]);
  41060. }
  41061. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  41062. _this._renderSubMesh(alphaTestSubMeshes.data[index]);
  41063. }
  41064. for (index = 0; index < transparentSubMeshes.length; index++) {
  41065. _this._renderSubMesh(transparentSubMeshes.data[index]);
  41066. }
  41067. };
  41068. this._mainTexture.onClearObservable.add(function (engine) {
  41069. engine.clear(_this.neutralColor, true, true, true);
  41070. });
  41071. };
  41072. /**
  41073. * Adds specific effects defines.
  41074. * @param defines The defines to add specifics to.
  41075. */
  41076. EffectLayer.prototype._addCustomEffectDefines = function (defines) {
  41077. // Nothing to add by default.
  41078. };
  41079. /**
  41080. * Checks for the readiness of the element composing the layer.
  41081. * @param subMesh the mesh to check for
  41082. * @param useInstances specify wether or not to use instances to render the mesh
  41083. * @param emissiveTexture the associated emissive texture used to generate the glow
  41084. * @return true if ready otherwise, false
  41085. */
  41086. EffectLayer.prototype._isReady = function (subMesh, useInstances, emissiveTexture) {
  41087. var material = subMesh.getMaterial();
  41088. if (!material) {
  41089. return false;
  41090. }
  41091. if (!material.isReadyForSubMesh(subMesh.getMesh(), subMesh, useInstances)) {
  41092. return false;
  41093. }
  41094. var defines = [];
  41095. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  41096. var mesh = subMesh.getMesh();
  41097. var uv1 = false;
  41098. var uv2 = false;
  41099. // Diffuse
  41100. if (material) {
  41101. var needAlphaTest = material.needAlphaTesting();
  41102. var diffuseTexture = material.getAlphaTestTexture();
  41103. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  41104. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  41105. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  41106. defines.push("#define DIFFUSE");
  41107. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41108. diffuseTexture.coordinatesIndex === 1) {
  41109. defines.push("#define DIFFUSEUV2");
  41110. uv2 = true;
  41111. }
  41112. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41113. defines.push("#define DIFFUSEUV1");
  41114. uv1 = true;
  41115. }
  41116. if (needAlphaTest) {
  41117. defines.push("#define ALPHATEST");
  41118. defines.push("#define ALPHATESTVALUE 0.4");
  41119. }
  41120. }
  41121. var opacityTexture = material.opacityTexture;
  41122. if (opacityTexture) {
  41123. defines.push("#define OPACITY");
  41124. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41125. opacityTexture.coordinatesIndex === 1) {
  41126. defines.push("#define OPACITYUV2");
  41127. uv2 = true;
  41128. }
  41129. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41130. defines.push("#define OPACITYUV1");
  41131. uv1 = true;
  41132. }
  41133. }
  41134. }
  41135. // Emissive
  41136. if (emissiveTexture) {
  41137. defines.push("#define EMISSIVE");
  41138. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41139. emissiveTexture.coordinatesIndex === 1) {
  41140. defines.push("#define EMISSIVEUV2");
  41141. uv2 = true;
  41142. }
  41143. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41144. defines.push("#define EMISSIVEUV1");
  41145. uv1 = true;
  41146. }
  41147. }
  41148. // Vertex
  41149. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind) && mesh.hasVertexAlpha) {
  41150. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind);
  41151. defines.push("#define VERTEXALPHA");
  41152. }
  41153. if (uv1) {
  41154. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind);
  41155. defines.push("#define UV1");
  41156. }
  41157. if (uv2) {
  41158. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind);
  41159. defines.push("#define UV2");
  41160. }
  41161. // Bones
  41162. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  41163. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesKind);
  41164. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsKind);
  41165. if (mesh.numBoneInfluencers > 4) {
  41166. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesExtraKind);
  41167. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsExtraKind);
  41168. }
  41169. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  41170. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  41171. }
  41172. else {
  41173. defines.push("#define NUM_BONE_INFLUENCERS 0");
  41174. }
  41175. // Morph targets
  41176. var manager = mesh.morphTargetManager;
  41177. var morphInfluencers = 0;
  41178. if (manager) {
  41179. if (manager.numInfluencers > 0) {
  41180. defines.push("#define MORPHTARGETS");
  41181. morphInfluencers = manager.numInfluencers;
  41182. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  41183. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  41184. }
  41185. }
  41186. // Instances
  41187. if (useInstances) {
  41188. defines.push("#define INSTANCES");
  41189. attribs.push("world0");
  41190. attribs.push("world1");
  41191. attribs.push("world2");
  41192. attribs.push("world3");
  41193. }
  41194. this._addCustomEffectDefines(defines);
  41195. // Get correct effect
  41196. var join = defines.join("\n");
  41197. if (this._cachedDefines !== join) {
  41198. this._cachedDefines = join;
  41199. this._effectLayerMapGenerationEffect = this._scene.getEngine().createEffect("glowMapGeneration", attribs, ["world", "mBones", "viewProjection",
  41200. "color", "morphTargetInfluences",
  41201. "diffuseMatrix", "emissiveMatrix", "opacityMatrix", "opacityIntensity"], ["diffuseSampler", "emissiveSampler", "opacitySampler"], join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  41202. }
  41203. return this._effectLayerMapGenerationEffect.isReady();
  41204. };
  41205. /**
  41206. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  41207. */
  41208. EffectLayer.prototype.render = function () {
  41209. var currentEffect = this._mergeEffect;
  41210. // Check
  41211. if (!currentEffect.isReady()) {
  41212. return;
  41213. }
  41214. for (var i = 0; i < this._postProcesses.length; i++) {
  41215. if (!this._postProcesses[i].isReady()) {
  41216. return;
  41217. }
  41218. }
  41219. var engine = this._scene.getEngine();
  41220. this.onBeforeComposeObservable.notifyObservers(this);
  41221. // Render
  41222. engine.enableEffect(currentEffect);
  41223. engine.setState(false);
  41224. // VBOs
  41225. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  41226. // Cache
  41227. var previousAlphaMode = engine.getAlphaMode();
  41228. // Go Blend.
  41229. engine.setAlphaMode(this._effectLayerOptions.alphaBlendingMode);
  41230. // Blends the map on the main canvas.
  41231. this._internalRender(currentEffect);
  41232. // Restore Alpha
  41233. engine.setAlphaMode(previousAlphaMode);
  41234. this.onAfterComposeObservable.notifyObservers(this);
  41235. // Handle size changes.
  41236. var size = this._mainTexture.getSize();
  41237. this._setMainTextureSize();
  41238. if (size.width !== this._mainTextureDesiredSize.width || size.height !== this._mainTextureDesiredSize.height) {
  41239. // Recreate RTT and post processes on size change.
  41240. this.onSizeChangedObservable.notifyObservers(this);
  41241. this._disposeTextureAndPostProcesses();
  41242. this._createMainTexture();
  41243. this._createTextureAndPostProcesses();
  41244. }
  41245. };
  41246. /**
  41247. * Determine if a given mesh will be used in the current effect.
  41248. * @param mesh mesh to test
  41249. * @returns true if the mesh will be used
  41250. */
  41251. EffectLayer.prototype.hasMesh = function (mesh) {
  41252. if (this.renderingGroupId === -1 || mesh.renderingGroupId === this.renderingGroupId) {
  41253. return true;
  41254. }
  41255. return false;
  41256. };
  41257. /**
  41258. * Returns true if the layer contains information to display, otherwise false.
  41259. * @returns true if the glow layer should be rendered
  41260. */
  41261. EffectLayer.prototype.shouldRender = function () {
  41262. return this.isEnabled && this._shouldRender;
  41263. };
  41264. /**
  41265. * Returns true if the mesh should render, otherwise false.
  41266. * @param mesh The mesh to render
  41267. * @returns true if it should render otherwise false
  41268. */
  41269. EffectLayer.prototype._shouldRenderMesh = function (mesh) {
  41270. return true;
  41271. };
  41272. /**
  41273. * Returns true if the mesh can be rendered, otherwise false.
  41274. * @param mesh The mesh to render
  41275. * @param material The material used on the mesh
  41276. * @returns true if it can be rendered otherwise false
  41277. */
  41278. EffectLayer.prototype._canRenderMesh = function (mesh, material) {
  41279. return !material.needAlphaBlendingForMesh(mesh);
  41280. };
  41281. /**
  41282. * Returns true if the mesh should render, otherwise false.
  41283. * @param mesh The mesh to render
  41284. * @returns true if it should render otherwise false
  41285. */
  41286. EffectLayer.prototype._shouldRenderEmissiveTextureForMesh = function () {
  41287. return true;
  41288. };
  41289. /**
  41290. * Renders the submesh passed in parameter to the generation map.
  41291. */
  41292. EffectLayer.prototype._renderSubMesh = function (subMesh) {
  41293. var _this = this;
  41294. if (!this.shouldRender()) {
  41295. return;
  41296. }
  41297. var material = subMesh.getMaterial();
  41298. var mesh = subMesh.getRenderingMesh();
  41299. var scene = this._scene;
  41300. var engine = scene.getEngine();
  41301. if (!material) {
  41302. return;
  41303. }
  41304. // Do not block in blend mode.
  41305. if (!this._canRenderMesh(mesh, material)) {
  41306. return;
  41307. }
  41308. // Culling
  41309. engine.setState(material.backFaceCulling);
  41310. // Managing instances
  41311. var batch = mesh._getInstancesRenderList(subMesh._id);
  41312. if (batch.mustReturn) {
  41313. return;
  41314. }
  41315. // Early Exit per mesh
  41316. if (!this._shouldRenderMesh(mesh)) {
  41317. return;
  41318. }
  41319. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  41320. this._setEmissiveTextureAndColor(mesh, subMesh, material);
  41321. if (this._isReady(subMesh, hardwareInstancedRendering, this._emissiveTextureAndColor.texture)) {
  41322. engine.enableEffect(this._effectLayerMapGenerationEffect);
  41323. mesh._bind(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode);
  41324. this._effectLayerMapGenerationEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  41325. this._effectLayerMapGenerationEffect.setFloat4("color", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a);
  41326. var needAlphaTest = material.needAlphaTesting();
  41327. var diffuseTexture = material.getAlphaTestTexture();
  41328. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  41329. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  41330. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  41331. this._effectLayerMapGenerationEffect.setTexture("diffuseSampler", diffuseTexture);
  41332. var textureMatrix = diffuseTexture.getTextureMatrix();
  41333. if (textureMatrix) {
  41334. this._effectLayerMapGenerationEffect.setMatrix("diffuseMatrix", textureMatrix);
  41335. }
  41336. }
  41337. var opacityTexture = material.opacityTexture;
  41338. if (opacityTexture) {
  41339. this._effectLayerMapGenerationEffect.setTexture("opacitySampler", opacityTexture);
  41340. this._effectLayerMapGenerationEffect.setFloat("opacityIntensity", opacityTexture.level);
  41341. var textureMatrix = opacityTexture.getTextureMatrix();
  41342. if (textureMatrix) {
  41343. this._effectLayerMapGenerationEffect.setMatrix("opacityMatrix", textureMatrix);
  41344. }
  41345. }
  41346. // Glow emissive only
  41347. if (this._emissiveTextureAndColor.texture) {
  41348. this._effectLayerMapGenerationEffect.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture);
  41349. this._effectLayerMapGenerationEffect.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix());
  41350. }
  41351. // Bones
  41352. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  41353. this._effectLayerMapGenerationEffect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  41354. }
  41355. // Morph targets
  41356. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effectLayerMapGenerationEffect);
  41357. // Draw
  41358. mesh._processRendering(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effectLayerMapGenerationEffect.setMatrix("world", world); });
  41359. }
  41360. else {
  41361. // Need to reset refresh rate of the main map
  41362. this._mainTexture.resetRefreshCounter();
  41363. }
  41364. };
  41365. /**
  41366. * Rebuild the required buffers.
  41367. * @hidden Internal use only.
  41368. */
  41369. EffectLayer.prototype._rebuild = function () {
  41370. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  41371. if (vb) {
  41372. vb._rebuild();
  41373. }
  41374. this._generateIndexBuffer();
  41375. };
  41376. /**
  41377. * Dispose only the render target textures and post process.
  41378. */
  41379. EffectLayer.prototype._disposeTextureAndPostProcesses = function () {
  41380. this._mainTexture.dispose();
  41381. for (var i = 0; i < this._postProcesses.length; i++) {
  41382. if (this._postProcesses[i]) {
  41383. this._postProcesses[i].dispose();
  41384. }
  41385. }
  41386. this._postProcesses = [];
  41387. for (var i = 0; i < this._textures.length; i++) {
  41388. if (this._textures[i]) {
  41389. this._textures[i].dispose();
  41390. }
  41391. }
  41392. this._textures = [];
  41393. };
  41394. /**
  41395. * Dispose the highlight layer and free resources.
  41396. */
  41397. EffectLayer.prototype.dispose = function () {
  41398. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  41399. if (vertexBuffer) {
  41400. vertexBuffer.dispose();
  41401. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = null;
  41402. }
  41403. if (this._indexBuffer) {
  41404. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  41405. this._indexBuffer = null;
  41406. }
  41407. // Clean textures and post processes
  41408. this._disposeTextureAndPostProcesses();
  41409. // Remove from scene
  41410. var index = this._scene.effectLayers.indexOf(this, 0);
  41411. if (index > -1) {
  41412. this._scene.effectLayers.splice(index, 1);
  41413. }
  41414. // Callback
  41415. this.onDisposeObservable.notifyObservers(this);
  41416. this.onDisposeObservable.clear();
  41417. this.onBeforeRenderMainTextureObservable.clear();
  41418. this.onBeforeComposeObservable.clear();
  41419. this.onAfterComposeObservable.clear();
  41420. this.onSizeChangedObservable.clear();
  41421. };
  41422. /**
  41423. * Gets the class name of the effect layer
  41424. * @returns the string with the class name of the effect layer
  41425. */
  41426. EffectLayer.prototype.getClassName = function () {
  41427. return "EffectLayer";
  41428. };
  41429. /**
  41430. * Creates an effect layer from parsed effect layer data
  41431. * @param parsedEffectLayer defines effect layer data
  41432. * @param scene defines the current scene
  41433. * @param rootUrl defines the root URL containing the effect layer information
  41434. * @returns a parsed effect Layer
  41435. */
  41436. EffectLayer.Parse = function (parsedEffectLayer, scene, rootUrl) {
  41437. var effectLayerType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedEffectLayer.customType);
  41438. return effectLayerType.Parse(parsedEffectLayer, scene, rootUrl);
  41439. };
  41440. /** @hidden */
  41441. EffectLayer._SceneComponentInitialization = function (_) {
  41442. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__["_DevTools"].WarnImport("EffectLayerSceneComponent");
  41443. };
  41444. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41445. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41446. ], EffectLayer.prototype, "name", void 0);
  41447. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41448. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  41449. ], EffectLayer.prototype, "neutralColor", void 0);
  41450. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41451. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41452. ], EffectLayer.prototype, "isEnabled", void 0);
  41453. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41454. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsCameraReference"])()
  41455. ], EffectLayer.prototype, "camera", null);
  41456. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41457. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41458. ], EffectLayer.prototype, "renderingGroupId", null);
  41459. return EffectLayer;
  41460. }());
  41461. /***/ }),
  41462. /***/ "./Layers/effectLayerSceneComponent.ts":
  41463. /*!*********************************************!*\
  41464. !*** ./Layers/effectLayerSceneComponent.ts ***!
  41465. \*********************************************/
  41466. /*! exports provided: EffectLayerSceneComponent */
  41467. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41468. "use strict";
  41469. __webpack_require__.r(__webpack_exports__);
  41470. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return EffectLayerSceneComponent; });
  41471. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  41472. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  41473. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  41474. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  41475. // Adds the parser to the scene parsers.
  41476. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER, function (parsedData, scene, container, rootUrl) {
  41477. if (parsedData.effectLayers) {
  41478. if (!container.effectLayers) {
  41479. container.effectLayers = new Array();
  41480. }
  41481. for (var index = 0; index < parsedData.effectLayers.length; index++) {
  41482. var effectLayer = _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"].Parse(parsedData.effectLayers[index], scene, rootUrl);
  41483. container.effectLayers.push(effectLayer);
  41484. }
  41485. }
  41486. });
  41487. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.removeEffectLayer = function (toRemove) {
  41488. var index = this.effectLayers.indexOf(toRemove);
  41489. if (index !== -1) {
  41490. this.effectLayers.splice(index, 1);
  41491. }
  41492. return index;
  41493. };
  41494. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.addEffectLayer = function (newEffectLayer) {
  41495. this.effectLayers.push(newEffectLayer);
  41496. };
  41497. /**
  41498. * Defines the layer scene component responsible to manage any effect layers
  41499. * in a given scene.
  41500. */
  41501. var EffectLayerSceneComponent = /** @class */ (function () {
  41502. /**
  41503. * Creates a new instance of the component for the given scene
  41504. * @param scene Defines the scene to register the component in
  41505. */
  41506. function EffectLayerSceneComponent(scene) {
  41507. /**
  41508. * The component name helpfull to identify the component in the list of scene components.
  41509. */
  41510. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER;
  41511. this._renderEffects = false;
  41512. this._needStencil = false;
  41513. this._previousStencilState = false;
  41514. this.scene = scene;
  41515. this._engine = scene.getEngine();
  41516. scene.effectLayers = new Array();
  41517. }
  41518. /**
  41519. * Registers the component in a given scene
  41520. */
  41521. EffectLayerSceneComponent.prototype.register = function () {
  41522. this.scene._isReadyForMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh);
  41523. this.scene._cameraDrawRenderTargetStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture);
  41524. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil);
  41525. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup);
  41526. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack);
  41527. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera);
  41528. };
  41529. /**
  41530. * Rebuilds the elements related to this component in case of
  41531. * context lost for instance.
  41532. */
  41533. EffectLayerSceneComponent.prototype.rebuild = function () {
  41534. var layers = this.scene.effectLayers;
  41535. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  41536. var effectLayer = layers_1[_i];
  41537. effectLayer._rebuild();
  41538. }
  41539. };
  41540. /**
  41541. * Serializes the component data to the specified json object
  41542. * @param serializationObject The object to serialize to
  41543. */
  41544. EffectLayerSceneComponent.prototype.serialize = function (serializationObject) {
  41545. // Effect layers
  41546. serializationObject.effectLayers = [];
  41547. var layers = this.scene.effectLayers;
  41548. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  41549. var effectLayer = layers_2[_i];
  41550. if (effectLayer.serialize) {
  41551. serializationObject.effectLayers.push(effectLayer.serialize());
  41552. }
  41553. }
  41554. };
  41555. /**
  41556. * Adds all the element from the container to the scene
  41557. * @param container the container holding the elements
  41558. */
  41559. EffectLayerSceneComponent.prototype.addFromContainer = function (container) {
  41560. var _this = this;
  41561. if (!container.effectLayers) {
  41562. return;
  41563. }
  41564. container.effectLayers.forEach(function (o) {
  41565. _this.scene.addEffectLayer(o);
  41566. });
  41567. };
  41568. /**
  41569. * Removes all the elements in the container from the scene
  41570. * @param container contains the elements to remove
  41571. */
  41572. EffectLayerSceneComponent.prototype.removeFromContainer = function (container) {
  41573. var _this = this;
  41574. if (!container.effectLayers) {
  41575. return;
  41576. }
  41577. container.effectLayers.forEach(function (o) {
  41578. _this.scene.removeEffectLayer(o);
  41579. });
  41580. };
  41581. /**
  41582. * Disposes the component and the associated ressources.
  41583. */
  41584. EffectLayerSceneComponent.prototype.dispose = function () {
  41585. var layers = this.scene.effectLayers;
  41586. while (layers.length) {
  41587. layers[0].dispose();
  41588. }
  41589. };
  41590. EffectLayerSceneComponent.prototype._isReadyForMesh = function (mesh, hardwareInstancedRendering) {
  41591. var layers = this.scene.effectLayers;
  41592. for (var _i = 0, layers_3 = layers; _i < layers_3.length; _i++) {
  41593. var layer = layers_3[_i];
  41594. if (!layer.hasMesh(mesh)) {
  41595. continue;
  41596. }
  41597. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  41598. var subMesh = _b[_a];
  41599. if (!layer.isReady(subMesh, hardwareInstancedRendering)) {
  41600. return false;
  41601. }
  41602. }
  41603. }
  41604. return true;
  41605. };
  41606. EffectLayerSceneComponent.prototype._renderMainTexture = function (camera) {
  41607. this._renderEffects = false;
  41608. this._needStencil = false;
  41609. var layers = this.scene.effectLayers;
  41610. if (layers && layers.length > 0) {
  41611. this._previousStencilState = this._engine.getStencilBuffer();
  41612. for (var _i = 0, layers_4 = layers; _i < layers_4.length; _i++) {
  41613. var effectLayer = layers_4[_i];
  41614. if (effectLayer.shouldRender() &&
  41615. (!effectLayer.camera ||
  41616. (effectLayer.camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && camera === effectLayer.camera) ||
  41617. (effectLayer.camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && effectLayer.camera._rigCameras.indexOf(camera) > -1))) {
  41618. this._renderEffects = true;
  41619. this._needStencil = this._needStencil || effectLayer.needStencil();
  41620. var renderTarget = effectLayer._mainTexture;
  41621. if (renderTarget._shouldRender()) {
  41622. this.scene.incrementRenderId();
  41623. renderTarget.render(false, false);
  41624. }
  41625. }
  41626. }
  41627. this.scene.incrementRenderId();
  41628. }
  41629. };
  41630. EffectLayerSceneComponent.prototype._setStencil = function () {
  41631. // Activate effect Layer stencil
  41632. if (this._needStencil) {
  41633. this._engine.setStencilBuffer(true);
  41634. }
  41635. };
  41636. EffectLayerSceneComponent.prototype._setStencilBack = function () {
  41637. // Restore effect Layer stencil
  41638. if (this._needStencil) {
  41639. this._engine.setStencilBuffer(this._previousStencilState);
  41640. }
  41641. };
  41642. EffectLayerSceneComponent.prototype._draw = function (renderingGroupId) {
  41643. if (this._renderEffects) {
  41644. this._engine.setDepthBuffer(false);
  41645. var layers = this.scene.effectLayers;
  41646. for (var i = 0; i < layers.length; i++) {
  41647. var effectLayer = layers[i];
  41648. if (effectLayer.renderingGroupId === renderingGroupId) {
  41649. if (effectLayer.shouldRender()) {
  41650. effectLayer.render();
  41651. }
  41652. }
  41653. }
  41654. this._engine.setDepthBuffer(true);
  41655. }
  41656. };
  41657. EffectLayerSceneComponent.prototype._drawCamera = function () {
  41658. if (this._renderEffects) {
  41659. this._draw(-1);
  41660. }
  41661. };
  41662. EffectLayerSceneComponent.prototype._drawRenderingGroup = function (index) {
  41663. if (!this.scene._isInIntermediateRendering() && this._renderEffects) {
  41664. this._draw(index);
  41665. }
  41666. };
  41667. return EffectLayerSceneComponent;
  41668. }());
  41669. _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"]._SceneComponentInitialization = function (scene) {
  41670. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER);
  41671. if (!component) {
  41672. component = new EffectLayerSceneComponent(scene);
  41673. scene._addComponent(component);
  41674. }
  41675. };
  41676. /***/ }),
  41677. /***/ "./Layers/glowLayer.ts":
  41678. /*!*****************************!*\
  41679. !*** ./Layers/glowLayer.ts ***!
  41680. \*****************************/
  41681. /*! exports provided: GlowLayer */
  41682. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41683. "use strict";
  41684. __webpack_require__.r(__webpack_exports__);
  41685. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return GlowLayer; });
  41686. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  41687. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  41688. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  41689. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  41690. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  41691. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  41692. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  41693. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  41694. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  41695. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  41696. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  41697. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  41698. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  41699. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  41700. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  41701. _abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"].prototype.getGlowLayerByName = function (name) {
  41702. for (var index = 0; index < this.effectLayers.length; index++) {
  41703. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === GlowLayer.EffectName) {
  41704. return this.effectLayers[index];
  41705. }
  41706. }
  41707. return null;
  41708. };
  41709. /**
  41710. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  41711. *
  41712. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  41713. * glowy meshes to your scene.
  41714. *
  41715. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  41716. */
  41717. var GlowLayer = /** @class */ (function (_super) {
  41718. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowLayer, _super);
  41719. /**
  41720. * Instantiates a new glow Layer and references it to the scene.
  41721. * @param name The name of the layer
  41722. * @param scene The scene to use the layer in
  41723. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  41724. */
  41725. function GlowLayer(name, scene, options) {
  41726. var _this = _super.call(this, name, scene) || this;
  41727. _this._intensity = 1.0;
  41728. _this._includedOnlyMeshes = [];
  41729. _this._excludedMeshes = [];
  41730. _this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 1);
  41731. // Adapt options
  41732. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ mainTextureRatio: GlowLayer.DefaultTextureRatio, blurKernelSize: 32, mainTextureFixedSize: undefined, camera: null, mainTextureSamples: 1, renderingGroupId: -1 }, options);
  41733. // Initialize the layer
  41734. _this._init({
  41735. alphaBlendingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ALPHA_ADD,
  41736. camera: _this._options.camera,
  41737. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  41738. mainTextureRatio: _this._options.mainTextureRatio,
  41739. renderingGroupId: _this._options.renderingGroupId
  41740. });
  41741. return _this;
  41742. }
  41743. Object.defineProperty(GlowLayer.prototype, "blurKernelSize", {
  41744. /**
  41745. * Gets the kernel size of the blur.
  41746. */
  41747. get: function () {
  41748. return this._horizontalBlurPostprocess1.kernel;
  41749. },
  41750. /**
  41751. * Sets the kernel size of the blur.
  41752. */
  41753. set: function (value) {
  41754. this._horizontalBlurPostprocess1.kernel = value;
  41755. this._verticalBlurPostprocess1.kernel = value;
  41756. this._horizontalBlurPostprocess2.kernel = value;
  41757. this._verticalBlurPostprocess2.kernel = value;
  41758. },
  41759. enumerable: true,
  41760. configurable: true
  41761. });
  41762. Object.defineProperty(GlowLayer.prototype, "intensity", {
  41763. /**
  41764. * Gets the glow intensity.
  41765. */
  41766. get: function () {
  41767. return this._intensity;
  41768. },
  41769. /**
  41770. * Sets the glow intensity.
  41771. */
  41772. set: function (value) {
  41773. this._intensity = value;
  41774. },
  41775. enumerable: true,
  41776. configurable: true
  41777. });
  41778. /**
  41779. * Get the effect name of the layer.
  41780. * @return The effect name
  41781. */
  41782. GlowLayer.prototype.getEffectName = function () {
  41783. return GlowLayer.EffectName;
  41784. };
  41785. /**
  41786. * Create the merge effect. This is the shader use to blit the information back
  41787. * to the main canvas at the end of the scene rendering.
  41788. */
  41789. GlowLayer.prototype._createMergeEffect = function () {
  41790. // Effect
  41791. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler", "textureSampler2"], "#define EMISSIVE \n");
  41792. };
  41793. /**
  41794. * Creates the render target textures and post processes used in the glow layer.
  41795. */
  41796. GlowLayer.prototype._createTextureAndPostProcesses = function () {
  41797. var _this = this;
  41798. var blurTextureWidth = this._mainTextureDesiredSize.width;
  41799. var blurTextureHeight = this._mainTextureDesiredSize.height;
  41800. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  41801. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  41802. var textureType = 0;
  41803. if (this._engine.getCaps().textureHalfFloatRender) {
  41804. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_HALF_FLOAT;
  41805. }
  41806. else {
  41807. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  41808. }
  41809. this._blurTexture1 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT", {
  41810. width: blurTextureWidth,
  41811. height: blurTextureHeight
  41812. }, this._scene, false, true, textureType);
  41813. this._blurTexture1.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41814. this._blurTexture1.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41815. this._blurTexture1.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  41816. this._blurTexture1.renderParticles = false;
  41817. this._blurTexture1.ignoreCameraViewport = true;
  41818. var blurTextureWidth2 = Math.floor(blurTextureWidth / 2);
  41819. var blurTextureHeight2 = Math.floor(blurTextureHeight / 2);
  41820. this._blurTexture2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT2", {
  41821. width: blurTextureWidth2,
  41822. height: blurTextureHeight2
  41823. }, this._scene, false, true, textureType);
  41824. this._blurTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41825. this._blurTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41826. this._blurTexture2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  41827. this._blurTexture2.renderParticles = false;
  41828. this._blurTexture2.ignoreCameraViewport = true;
  41829. this._textures = [this._blurTexture1, this._blurTexture2];
  41830. 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, {
  41831. width: blurTextureWidth,
  41832. height: blurTextureHeight
  41833. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41834. this._horizontalBlurPostprocess1.width = blurTextureWidth;
  41835. this._horizontalBlurPostprocess1.height = blurTextureHeight;
  41836. this._horizontalBlurPostprocess1.onApplyObservable.add(function (effect) {
  41837. effect.setTexture("textureSampler", _this._mainTexture);
  41838. });
  41839. 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, {
  41840. width: blurTextureWidth,
  41841. height: blurTextureHeight
  41842. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41843. 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, {
  41844. width: blurTextureWidth2,
  41845. height: blurTextureHeight2
  41846. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41847. this._horizontalBlurPostprocess2.width = blurTextureWidth2;
  41848. this._horizontalBlurPostprocess2.height = blurTextureHeight2;
  41849. this._horizontalBlurPostprocess2.onApplyObservable.add(function (effect) {
  41850. effect.setTexture("textureSampler", _this._blurTexture1);
  41851. });
  41852. 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, {
  41853. width: blurTextureWidth2,
  41854. height: blurTextureHeight2
  41855. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41856. this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  41857. this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1];
  41858. this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  41859. this._mainTexture.samples = this._options.mainTextureSamples;
  41860. this._mainTexture.onAfterUnbindObservable.add(function () {
  41861. var internalTexture = _this._blurTexture1.getInternalTexture();
  41862. if (internalTexture) {
  41863. _this._scene.postProcessManager.directRender(_this._postProcesses1, internalTexture, true);
  41864. internalTexture = _this._blurTexture2.getInternalTexture();
  41865. if (internalTexture) {
  41866. _this._scene.postProcessManager.directRender(_this._postProcesses2, internalTexture, true);
  41867. }
  41868. }
  41869. });
  41870. // Prevent autoClear.
  41871. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  41872. };
  41873. /**
  41874. * Checks for the readiness of the element composing the layer.
  41875. * @param subMesh the mesh to check for
  41876. * @param useInstances specify wether or not to use instances to render the mesh
  41877. * @param emissiveTexture the associated emissive texture used to generate the glow
  41878. * @return true if ready otherwise, false
  41879. */
  41880. GlowLayer.prototype.isReady = function (subMesh, useInstances) {
  41881. var material = subMesh.getMaterial();
  41882. var mesh = subMesh.getRenderingMesh();
  41883. if (!material || !mesh) {
  41884. return false;
  41885. }
  41886. var emissiveTexture = material.emissiveTexture;
  41887. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  41888. };
  41889. /**
  41890. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  41891. */
  41892. GlowLayer.prototype.needStencil = function () {
  41893. return false;
  41894. };
  41895. /**
  41896. * Returns true if the mesh can be rendered, otherwise false.
  41897. * @param mesh The mesh to render
  41898. * @param material The material used on the mesh
  41899. * @returns true if it can be rendered otherwise false
  41900. */
  41901. GlowLayer.prototype._canRenderMesh = function (mesh, material) {
  41902. return true;
  41903. };
  41904. /**
  41905. * Implementation specific of rendering the generating effect on the main canvas.
  41906. * @param effect The effect used to render through
  41907. */
  41908. GlowLayer.prototype._internalRender = function (effect) {
  41909. // Texture
  41910. effect.setTexture("textureSampler", this._blurTexture1);
  41911. effect.setTexture("textureSampler2", this._blurTexture2);
  41912. effect.setFloat("offset", this._intensity);
  41913. // Cache
  41914. var engine = this._engine;
  41915. var previousStencilBuffer = engine.getStencilBuffer();
  41916. // Draw order
  41917. engine.setStencilBuffer(false);
  41918. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, 6);
  41919. // Draw order
  41920. engine.setStencilBuffer(previousStencilBuffer);
  41921. };
  41922. /**
  41923. * Sets the required values for both the emissive texture and and the main color.
  41924. */
  41925. GlowLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  41926. var textureLevel = 1.0;
  41927. if (this.customEmissiveTextureSelector) {
  41928. this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(mesh, subMesh, material);
  41929. }
  41930. else {
  41931. if (material) {
  41932. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  41933. if (this._emissiveTextureAndColor.texture) {
  41934. textureLevel = this._emissiveTextureAndColor.texture.level;
  41935. }
  41936. }
  41937. else {
  41938. this._emissiveTextureAndColor.texture = null;
  41939. }
  41940. }
  41941. if (this.customEmissiveColorSelector) {
  41942. this.customEmissiveColorSelector(mesh, subMesh, material, this._emissiveTextureAndColor.color);
  41943. }
  41944. else {
  41945. if (material.emissiveColor) {
  41946. this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, material.alpha);
  41947. }
  41948. else {
  41949. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  41950. }
  41951. }
  41952. };
  41953. /**
  41954. * Returns true if the mesh should render, otherwise false.
  41955. * @param mesh The mesh to render
  41956. * @returns true if it should render otherwise false
  41957. */
  41958. GlowLayer.prototype._shouldRenderMesh = function (mesh) {
  41959. return this.hasMesh(mesh);
  41960. };
  41961. /**
  41962. * Adds specific effects defines.
  41963. * @param defines The defines to add specifics to.
  41964. */
  41965. GlowLayer.prototype._addCustomEffectDefines = function (defines) {
  41966. defines.push("#define GLOW");
  41967. };
  41968. /**
  41969. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  41970. * @param mesh The mesh to exclude from the glow layer
  41971. */
  41972. GlowLayer.prototype.addExcludedMesh = function (mesh) {
  41973. if (this._excludedMeshes.indexOf(mesh.uniqueId) === -1) {
  41974. this._excludedMeshes.push(mesh.uniqueId);
  41975. }
  41976. };
  41977. /**
  41978. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  41979. * @param mesh The mesh to remove
  41980. */
  41981. GlowLayer.prototype.removeExcludedMesh = function (mesh) {
  41982. var index = this._excludedMeshes.indexOf(mesh.uniqueId);
  41983. if (index !== -1) {
  41984. this._excludedMeshes.splice(index, 1);
  41985. }
  41986. };
  41987. /**
  41988. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  41989. * @param mesh The mesh to include in the glow layer
  41990. */
  41991. GlowLayer.prototype.addIncludedOnlyMesh = function (mesh) {
  41992. if (this._includedOnlyMeshes.indexOf(mesh.uniqueId) === -1) {
  41993. this._includedOnlyMeshes.push(mesh.uniqueId);
  41994. }
  41995. };
  41996. /**
  41997. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  41998. * @param mesh The mesh to remove
  41999. */
  42000. GlowLayer.prototype.removeIncludedOnlyMesh = function (mesh) {
  42001. var index = this._includedOnlyMeshes.indexOf(mesh.uniqueId);
  42002. if (index !== -1) {
  42003. this._includedOnlyMeshes.splice(index, 1);
  42004. }
  42005. };
  42006. /**
  42007. * Determine if a given mesh will be used in the glow layer
  42008. * @param mesh The mesh to test
  42009. * @returns true if the mesh will be highlighted by the current glow layer
  42010. */
  42011. GlowLayer.prototype.hasMesh = function (mesh) {
  42012. if (!_super.prototype.hasMesh.call(this, mesh)) {
  42013. return false;
  42014. }
  42015. // Included Mesh
  42016. if (this._includedOnlyMeshes.length) {
  42017. return this._includedOnlyMeshes.indexOf(mesh.uniqueId) !== -1;
  42018. }
  42019. // Excluded Mesh
  42020. if (this._excludedMeshes.length) {
  42021. return this._excludedMeshes.indexOf(mesh.uniqueId) === -1;
  42022. }
  42023. return true;
  42024. };
  42025. /**
  42026. * Free any resources and references associated to a mesh.
  42027. * Internal use
  42028. * @param mesh The mesh to free.
  42029. * @hidden
  42030. */
  42031. GlowLayer.prototype._disposeMesh = function (mesh) {
  42032. this.removeIncludedOnlyMesh(mesh);
  42033. this.removeExcludedMesh(mesh);
  42034. };
  42035. /**
  42036. * Gets the class name of the effect layer
  42037. * @returns the string with the class name of the effect layer
  42038. */
  42039. GlowLayer.prototype.getClassName = function () {
  42040. return "GlowLayer";
  42041. };
  42042. /**
  42043. * Serializes this glow layer
  42044. * @returns a serialized glow layer object
  42045. */
  42046. GlowLayer.prototype.serialize = function () {
  42047. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  42048. serializationObject.customType = "BABYLON.GlowLayer";
  42049. var index;
  42050. // Included meshes
  42051. serializationObject.includedMeshes = [];
  42052. if (this._includedOnlyMeshes.length) {
  42053. for (index = 0; index < this._includedOnlyMeshes.length; index++) {
  42054. var mesh = this._scene.getMeshByUniqueID(this._includedOnlyMeshes[index]);
  42055. if (mesh) {
  42056. serializationObject.includedMeshes.push(mesh.id);
  42057. }
  42058. }
  42059. }
  42060. // Excluded meshes
  42061. serializationObject.excludedMeshes = [];
  42062. if (this._excludedMeshes.length) {
  42063. for (index = 0; index < this._excludedMeshes.length; index++) {
  42064. var mesh = this._scene.getMeshByUniqueID(this._excludedMeshes[index]);
  42065. if (mesh) {
  42066. serializationObject.excludedMeshes.push(mesh.id);
  42067. }
  42068. }
  42069. }
  42070. return serializationObject;
  42071. };
  42072. /**
  42073. * Creates a Glow Layer from parsed glow layer data
  42074. * @param parsedGlowLayer defines glow layer data
  42075. * @param scene defines the current scene
  42076. * @param rootUrl defines the root URL containing the glow layer information
  42077. * @returns a parsed Glow Layer
  42078. */
  42079. GlowLayer.Parse = function (parsedGlowLayer, scene, rootUrl) {
  42080. var gl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new GlowLayer(parsedGlowLayer.name, scene, parsedGlowLayer.options); }, parsedGlowLayer, scene, rootUrl);
  42081. var index;
  42082. // Excluded meshes
  42083. for (index = 0; index < parsedGlowLayer.excludedMeshes.length; index++) {
  42084. var mesh = scene.getMeshByID(parsedGlowLayer.excludedMeshes[index]);
  42085. if (mesh) {
  42086. gl.addExcludedMesh(mesh);
  42087. }
  42088. }
  42089. // Included meshes
  42090. for (index = 0; index < parsedGlowLayer.includedMeshes.length; index++) {
  42091. var mesh = scene.getMeshByID(parsedGlowLayer.includedMeshes[index]);
  42092. if (mesh) {
  42093. gl.addIncludedOnlyMesh(mesh);
  42094. }
  42095. }
  42096. return gl;
  42097. };
  42098. /**
  42099. * Effect Name of the layer.
  42100. */
  42101. GlowLayer.EffectName = "GlowLayer";
  42102. /**
  42103. * The default blur kernel size used for the glow.
  42104. */
  42105. GlowLayer.DefaultBlurKernelSize = 32;
  42106. /**
  42107. * The default texture size ratio used for the glow.
  42108. */
  42109. GlowLayer.DefaultTextureRatio = 0.5;
  42110. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42112. ], GlowLayer.prototype, "blurKernelSize", null);
  42113. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42114. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42115. ], GlowLayer.prototype, "intensity", null);
  42116. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42117. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  42118. ], GlowLayer.prototype, "_options", void 0);
  42119. return GlowLayer;
  42120. }(_effectLayer__WEBPACK_IMPORTED_MODULE_9__["EffectLayer"]));
  42121. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.GlowLayer"] = GlowLayer;
  42122. /***/ }),
  42123. /***/ "./Layers/highlightLayer.ts":
  42124. /*!**********************************!*\
  42125. !*** ./Layers/highlightLayer.ts ***!
  42126. \**********************************/
  42127. /*! exports provided: HighlightLayer */
  42128. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42129. "use strict";
  42130. __webpack_require__.r(__webpack_exports__);
  42131. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return HighlightLayer; });
  42132. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  42133. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  42134. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  42135. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  42136. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42137. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42138. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42139. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42140. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  42141. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  42142. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  42143. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  42144. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42145. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  42146. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42147. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  42148. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  42149. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  42150. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  42151. /* harmony import */ var _Shaders_glowBlurPostProcess_fragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/glowBlurPostProcess.fragment */ "./Shaders/glowBlurPostProcess.fragment.ts");
  42152. _abstractScene__WEBPACK_IMPORTED_MODULE_13__["AbstractScene"].prototype.getHighlightLayerByName = function (name) {
  42153. for (var index = 0; index < this.effectLayers.length; index++) {
  42154. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === HighlightLayer.EffectName) {
  42155. return this.effectLayers[index];
  42156. }
  42157. }
  42158. return null;
  42159. };
  42160. /**
  42161. * Special Glow Blur post process only blurring the alpha channel
  42162. * It enforces keeping the most luminous color in the color channel.
  42163. */
  42164. var GlowBlurPostProcess = /** @class */ (function (_super) {
  42165. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowBlurPostProcess, _super);
  42166. function GlowBlurPostProcess(name, direction, kernel, options, camera, samplingMode, engine, reusable) {
  42167. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE; }
  42168. var _this = _super.call(this, name, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, options, camera, samplingMode, engine, reusable) || this;
  42169. _this.direction = direction;
  42170. _this.kernel = kernel;
  42171. _this.onApplyObservable.add(function (effect) {
  42172. effect.setFloat2("screenSize", _this.width, _this.height);
  42173. effect.setVector2("direction", _this.direction);
  42174. effect.setFloat("blurWidth", _this.kernel);
  42175. });
  42176. return _this;
  42177. }
  42178. return GlowBlurPostProcess;
  42179. }(_PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__["PostProcess"]));
  42180. /**
  42181. * The highlight layer Helps adding a glow effect around a mesh.
  42182. *
  42183. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  42184. * glowy meshes to your scene.
  42185. *
  42186. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  42187. */
  42188. var HighlightLayer = /** @class */ (function (_super) {
  42189. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightLayer, _super);
  42190. /**
  42191. * Instantiates a new highlight Layer and references it to the scene..
  42192. * @param name The name of the layer
  42193. * @param scene The scene to use the layer in
  42194. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  42195. */
  42196. function HighlightLayer(name, scene, options) {
  42197. var _this = _super.call(this, name, scene) || this;
  42198. _this.name = name;
  42199. /**
  42200. * Specifies whether or not the inner glow is ACTIVE in the layer.
  42201. */
  42202. _this.innerGlow = true;
  42203. /**
  42204. * Specifies whether or not the outer glow is ACTIVE in the layer.
  42205. */
  42206. _this.outerGlow = true;
  42207. /**
  42208. * An event triggered when the highlight layer is being blurred.
  42209. */
  42210. _this.onBeforeBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  42211. /**
  42212. * An event triggered when the highlight layer has been blurred.
  42213. */
  42214. _this.onAfterBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  42215. _this._instanceGlowingMeshStencilReference = HighlightLayer.GlowingMeshStencilReference++;
  42216. _this._meshes = {};
  42217. _this._excludedMeshes = {};
  42218. _this.neutralColor = HighlightLayer.NeutralColor;
  42219. // Warn on stencil
  42220. if (!_this._engine.isStencilEnable) {
  42221. _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 }");
  42222. }
  42223. // Adapt options
  42224. _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);
  42225. // Initialize the layer
  42226. _this._init({
  42227. alphaBlendingMode: _this._options.alphaBlendingMode,
  42228. camera: _this._options.camera,
  42229. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  42230. mainTextureRatio: _this._options.mainTextureRatio,
  42231. renderingGroupId: _this._options.renderingGroupId
  42232. });
  42233. // Do not render as long as no meshes have been added
  42234. _this._shouldRender = false;
  42235. return _this;
  42236. }
  42237. Object.defineProperty(HighlightLayer.prototype, "blurHorizontalSize", {
  42238. /**
  42239. * Gets the horizontal size of the blur.
  42240. */
  42241. get: function () {
  42242. return this._horizontalBlurPostprocess.kernel;
  42243. },
  42244. /**
  42245. * Specifies the horizontal size of the blur.
  42246. */
  42247. set: function (value) {
  42248. this._horizontalBlurPostprocess.kernel = value;
  42249. },
  42250. enumerable: true,
  42251. configurable: true
  42252. });
  42253. Object.defineProperty(HighlightLayer.prototype, "blurVerticalSize", {
  42254. /**
  42255. * Gets the vertical size of the blur.
  42256. */
  42257. get: function () {
  42258. return this._verticalBlurPostprocess.kernel;
  42259. },
  42260. /**
  42261. * Specifies the vertical size of the blur.
  42262. */
  42263. set: function (value) {
  42264. this._verticalBlurPostprocess.kernel = value;
  42265. },
  42266. enumerable: true,
  42267. configurable: true
  42268. });
  42269. /**
  42270. * Get the effect name of the layer.
  42271. * @return The effect name
  42272. */
  42273. HighlightLayer.prototype.getEffectName = function () {
  42274. return HighlightLayer.EffectName;
  42275. };
  42276. /**
  42277. * Create the merge effect. This is the shader use to blit the information back
  42278. * to the main canvas at the end of the scene rendering.
  42279. */
  42280. HighlightLayer.prototype._createMergeEffect = function () {
  42281. // Effect
  42282. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? "#define STROKE \n" : undefined);
  42283. };
  42284. /**
  42285. * Creates the render target textures and post processes used in the highlight layer.
  42286. */
  42287. HighlightLayer.prototype._createTextureAndPostProcesses = function () {
  42288. var _this = this;
  42289. var blurTextureWidth = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio;
  42290. var blurTextureHeight = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio;
  42291. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  42292. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  42293. var textureType = 0;
  42294. if (this._engine.getCaps().textureHalfFloatRender) {
  42295. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_HALF_FLOAT;
  42296. }
  42297. else {
  42298. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  42299. }
  42300. this._blurTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerBlurRTT", {
  42301. width: blurTextureWidth,
  42302. height: blurTextureHeight
  42303. }, this._scene, false, true, textureType);
  42304. this._blurTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  42305. this._blurTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  42306. this._blurTexture.anisotropicFilteringLevel = 16;
  42307. this._blurTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].TRILINEAR_SAMPLINGMODE);
  42308. this._blurTexture.renderParticles = false;
  42309. this._blurTexture.ignoreCameraViewport = true;
  42310. this._textures = [this._blurTexture];
  42311. if (this._options.alphaBlendingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].ALPHA_COMBINE) {
  42312. 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());
  42313. this._downSamplePostprocess.onApplyObservable.add(function (effect) {
  42314. effect.setTexture("textureSampler", _this._mainTexture);
  42315. });
  42316. 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());
  42317. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  42318. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  42319. });
  42320. 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());
  42321. this._verticalBlurPostprocess.onApplyObservable.add(function (effect) {
  42322. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  42323. });
  42324. this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  42325. }
  42326. else {
  42327. 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, {
  42328. width: blurTextureWidth,
  42329. height: blurTextureHeight
  42330. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42331. this._horizontalBlurPostprocess.width = blurTextureWidth;
  42332. this._horizontalBlurPostprocess.height = blurTextureHeight;
  42333. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  42334. effect.setTexture("textureSampler", _this._mainTexture);
  42335. });
  42336. 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, {
  42337. width: blurTextureWidth,
  42338. height: blurTextureHeight
  42339. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42340. this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  42341. }
  42342. this._mainTexture.onAfterUnbindObservable.add(function () {
  42343. _this.onBeforeBlurObservable.notifyObservers(_this);
  42344. var internalTexture = _this._blurTexture.getInternalTexture();
  42345. if (internalTexture) {
  42346. _this._scene.postProcessManager.directRender(_this._postProcesses, internalTexture, true);
  42347. }
  42348. _this.onAfterBlurObservable.notifyObservers(_this);
  42349. });
  42350. // Prevent autoClear.
  42351. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  42352. };
  42353. /**
  42354. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  42355. */
  42356. HighlightLayer.prototype.needStencil = function () {
  42357. return true;
  42358. };
  42359. /**
  42360. * Checks for the readiness of the element composing the layer.
  42361. * @param subMesh the mesh to check for
  42362. * @param useInstances specify wether or not to use instances to render the mesh
  42363. * @param emissiveTexture the associated emissive texture used to generate the glow
  42364. * @return true if ready otherwise, false
  42365. */
  42366. HighlightLayer.prototype.isReady = function (subMesh, useInstances) {
  42367. var material = subMesh.getMaterial();
  42368. var mesh = subMesh.getRenderingMesh();
  42369. if (!material || !mesh || !this._meshes) {
  42370. return false;
  42371. }
  42372. var emissiveTexture = null;
  42373. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  42374. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  42375. emissiveTexture = material.emissiveTexture;
  42376. }
  42377. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  42378. };
  42379. /**
  42380. * Implementation specific of rendering the generating effect on the main canvas.
  42381. * @param effect The effect used to render through
  42382. */
  42383. HighlightLayer.prototype._internalRender = function (effect) {
  42384. // Texture
  42385. effect.setTexture("textureSampler", this._blurTexture);
  42386. // Cache
  42387. var engine = this._engine;
  42388. var previousStencilBuffer = engine.getStencilBuffer();
  42389. var previousStencilFunction = engine.getStencilFunction();
  42390. var previousStencilMask = engine.getStencilMask();
  42391. var previousStencilOperationPass = engine.getStencilOperationPass();
  42392. var previousStencilOperationFail = engine.getStencilOperationFail();
  42393. var previousStencilOperationDepthFail = engine.getStencilOperationDepthFail();
  42394. var previousStencilReference = engine.getStencilFunctionReference();
  42395. // Stencil operations
  42396. engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].REPLACE);
  42397. engine.setStencilOperationFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  42398. engine.setStencilOperationDepthFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  42399. // Draw order
  42400. engine.setStencilMask(0x00);
  42401. engine.setStencilBuffer(true);
  42402. engine.setStencilFunctionReference(this._instanceGlowingMeshStencilReference);
  42403. // 2 passes inner outer
  42404. if (this.outerGlow) {
  42405. effect.setFloat("offset", 0);
  42406. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].NOTEQUAL);
  42407. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  42408. }
  42409. if (this.innerGlow) {
  42410. effect.setFloat("offset", 1);
  42411. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].EQUAL);
  42412. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  42413. }
  42414. // Restore Cache
  42415. engine.setStencilFunction(previousStencilFunction);
  42416. engine.setStencilMask(previousStencilMask);
  42417. engine.setStencilBuffer(previousStencilBuffer);
  42418. engine.setStencilOperationPass(previousStencilOperationPass);
  42419. engine.setStencilOperationFail(previousStencilOperationFail);
  42420. engine.setStencilOperationDepthFail(previousStencilOperationDepthFail);
  42421. engine.setStencilFunctionReference(previousStencilReference);
  42422. };
  42423. /**
  42424. * Returns true if the layer contains information to display, otherwise false.
  42425. */
  42426. HighlightLayer.prototype.shouldRender = function () {
  42427. if (_super.prototype.shouldRender.call(this)) {
  42428. return this._meshes ? true : false;
  42429. }
  42430. return false;
  42431. };
  42432. /**
  42433. * Returns true if the mesh should render, otherwise false.
  42434. * @param mesh The mesh to render
  42435. * @returns true if it should render otherwise false
  42436. */
  42437. HighlightLayer.prototype._shouldRenderMesh = function (mesh) {
  42438. // Excluded Mesh
  42439. if (this._excludedMeshes && this._excludedMeshes[mesh.uniqueId]) {
  42440. return false;
  42441. }
  42442. if (!_super.prototype.hasMesh.call(this, mesh)) {
  42443. return false;
  42444. }
  42445. return true;
  42446. };
  42447. /**
  42448. * Sets the required values for both the emissive texture and and the main color.
  42449. */
  42450. HighlightLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  42451. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  42452. if (highlightLayerMesh) {
  42453. this._emissiveTextureAndColor.color.set(highlightLayerMesh.color.r, highlightLayerMesh.color.g, highlightLayerMesh.color.b, 1.0);
  42454. }
  42455. else {
  42456. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  42457. }
  42458. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  42459. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  42460. this._emissiveTextureAndColor.color.set(1.0, 1.0, 1.0, 1.0);
  42461. }
  42462. else {
  42463. this._emissiveTextureAndColor.texture = null;
  42464. }
  42465. };
  42466. /**
  42467. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  42468. * @param mesh The mesh to exclude from the highlight layer
  42469. */
  42470. HighlightLayer.prototype.addExcludedMesh = function (mesh) {
  42471. if (!this._excludedMeshes) {
  42472. return;
  42473. }
  42474. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  42475. if (!meshExcluded) {
  42476. this._excludedMeshes[mesh.uniqueId] = {
  42477. mesh: mesh,
  42478. beforeBind: mesh.onBeforeBindObservable.add(function (mesh) {
  42479. mesh.getEngine().setStencilBuffer(false);
  42480. }),
  42481. afterRender: mesh.onAfterRenderObservable.add(function (mesh) {
  42482. mesh.getEngine().setStencilBuffer(true);
  42483. }),
  42484. };
  42485. }
  42486. };
  42487. /**
  42488. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  42489. * @param mesh The mesh to highlight
  42490. */
  42491. HighlightLayer.prototype.removeExcludedMesh = function (mesh) {
  42492. if (!this._excludedMeshes) {
  42493. return;
  42494. }
  42495. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  42496. if (meshExcluded) {
  42497. if (meshExcluded.beforeBind) {
  42498. mesh.onBeforeBindObservable.remove(meshExcluded.beforeBind);
  42499. }
  42500. if (meshExcluded.afterRender) {
  42501. mesh.onAfterRenderObservable.remove(meshExcluded.afterRender);
  42502. }
  42503. }
  42504. this._excludedMeshes[mesh.uniqueId] = null;
  42505. };
  42506. /**
  42507. * Determine if a given mesh will be highlighted by the current HighlightLayer
  42508. * @param mesh mesh to test
  42509. * @returns true if the mesh will be highlighted by the current HighlightLayer
  42510. */
  42511. HighlightLayer.prototype.hasMesh = function (mesh) {
  42512. if (!this._meshes) {
  42513. return false;
  42514. }
  42515. if (!_super.prototype.hasMesh.call(this, mesh)) {
  42516. return false;
  42517. }
  42518. return this._meshes[mesh.uniqueId] !== undefined && this._meshes[mesh.uniqueId] !== null;
  42519. };
  42520. /**
  42521. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  42522. * @param mesh The mesh to highlight
  42523. * @param color The color of the highlight
  42524. * @param glowEmissiveOnly Extract the glow from the emissive texture
  42525. */
  42526. HighlightLayer.prototype.addMesh = function (mesh, color, glowEmissiveOnly) {
  42527. var _this = this;
  42528. if (glowEmissiveOnly === void 0) { glowEmissiveOnly = false; }
  42529. if (!this._meshes) {
  42530. return;
  42531. }
  42532. var meshHighlight = this._meshes[mesh.uniqueId];
  42533. if (meshHighlight) {
  42534. meshHighlight.color = color;
  42535. }
  42536. else {
  42537. this._meshes[mesh.uniqueId] = {
  42538. mesh: mesh,
  42539. color: color,
  42540. // Lambda required for capture due to Observable this context
  42541. observerHighlight: mesh.onBeforeBindObservable.add(function (mesh) {
  42542. if (_this._excludedMeshes && _this._excludedMeshes[mesh.uniqueId]) {
  42543. _this._defaultStencilReference(mesh);
  42544. }
  42545. else {
  42546. mesh.getScene().getEngine().setStencilFunctionReference(_this._instanceGlowingMeshStencilReference);
  42547. }
  42548. }),
  42549. observerDefault: mesh.onAfterRenderObservable.add(this._defaultStencilReference),
  42550. glowEmissiveOnly: glowEmissiveOnly
  42551. };
  42552. mesh.onDisposeObservable.add(function () {
  42553. _this._disposeMesh(mesh);
  42554. });
  42555. }
  42556. this._shouldRender = true;
  42557. };
  42558. /**
  42559. * Remove a mesh from the highlight layer in order to make it stop glowing.
  42560. * @param mesh The mesh to highlight
  42561. */
  42562. HighlightLayer.prototype.removeMesh = function (mesh) {
  42563. if (!this._meshes) {
  42564. return;
  42565. }
  42566. var meshHighlight = this._meshes[mesh.uniqueId];
  42567. if (meshHighlight) {
  42568. if (meshHighlight.observerHighlight) {
  42569. mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  42570. }
  42571. if (meshHighlight.observerDefault) {
  42572. mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  42573. }
  42574. delete this._meshes[mesh.uniqueId];
  42575. }
  42576. this._shouldRender = false;
  42577. for (var meshHighlightToCheck in this._meshes) {
  42578. if (this._meshes[meshHighlightToCheck]) {
  42579. this._shouldRender = true;
  42580. break;
  42581. }
  42582. }
  42583. };
  42584. /**
  42585. * Force the stencil to the normal expected value for none glowing parts
  42586. */
  42587. HighlightLayer.prototype._defaultStencilReference = function (mesh) {
  42588. mesh.getScene().getEngine().setStencilFunctionReference(HighlightLayer.NormalMeshStencilReference);
  42589. };
  42590. /**
  42591. * Free any resources and references associated to a mesh.
  42592. * Internal use
  42593. * @param mesh The mesh to free.
  42594. * @hidden
  42595. */
  42596. HighlightLayer.prototype._disposeMesh = function (mesh) {
  42597. this.removeMesh(mesh);
  42598. this.removeExcludedMesh(mesh);
  42599. };
  42600. /**
  42601. * Dispose the highlight layer and free resources.
  42602. */
  42603. HighlightLayer.prototype.dispose = function () {
  42604. if (this._meshes) {
  42605. // Clean mesh references
  42606. for (var id in this._meshes) {
  42607. var meshHighlight = this._meshes[id];
  42608. if (meshHighlight && meshHighlight.mesh) {
  42609. if (meshHighlight.observerHighlight) {
  42610. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  42611. }
  42612. if (meshHighlight.observerDefault) {
  42613. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  42614. }
  42615. }
  42616. }
  42617. this._meshes = null;
  42618. }
  42619. if (this._excludedMeshes) {
  42620. for (var id in this._excludedMeshes) {
  42621. var meshHighlight = this._excludedMeshes[id];
  42622. if (meshHighlight) {
  42623. if (meshHighlight.beforeBind) {
  42624. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.beforeBind);
  42625. }
  42626. if (meshHighlight.afterRender) {
  42627. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.afterRender);
  42628. }
  42629. }
  42630. }
  42631. this._excludedMeshes = null;
  42632. }
  42633. _super.prototype.dispose.call(this);
  42634. };
  42635. /**
  42636. * Gets the class name of the effect layer
  42637. * @returns the string with the class name of the effect layer
  42638. */
  42639. HighlightLayer.prototype.getClassName = function () {
  42640. return "HighlightLayer";
  42641. };
  42642. /**
  42643. * Serializes this Highlight layer
  42644. * @returns a serialized Highlight layer object
  42645. */
  42646. HighlightLayer.prototype.serialize = function () {
  42647. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  42648. serializationObject.customType = "BABYLON.HighlightLayer";
  42649. // Highlighted meshes
  42650. serializationObject.meshes = [];
  42651. if (this._meshes) {
  42652. for (var m in this._meshes) {
  42653. var mesh = this._meshes[m];
  42654. if (mesh) {
  42655. serializationObject.meshes.push({
  42656. glowEmissiveOnly: mesh.glowEmissiveOnly,
  42657. color: mesh.color.asArray(),
  42658. meshId: mesh.mesh.id
  42659. });
  42660. }
  42661. }
  42662. }
  42663. // Excluded meshes
  42664. serializationObject.excludedMeshes = [];
  42665. if (this._excludedMeshes) {
  42666. for (var e in this._excludedMeshes) {
  42667. var excludedMesh = this._excludedMeshes[e];
  42668. if (excludedMesh) {
  42669. serializationObject.excludedMeshes.push(excludedMesh.mesh.id);
  42670. }
  42671. }
  42672. }
  42673. return serializationObject;
  42674. };
  42675. /**
  42676. * Creates a Highlight layer from parsed Highlight layer data
  42677. * @param parsedHightlightLayer defines the Highlight layer data
  42678. * @param scene defines the current scene
  42679. * @param rootUrl defines the root URL containing the Highlight layer information
  42680. * @returns a parsed Highlight layer
  42681. */
  42682. HighlightLayer.Parse = function (parsedHightlightLayer, scene, rootUrl) {
  42683. var hl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new HighlightLayer(parsedHightlightLayer.name, scene, parsedHightlightLayer.options); }, parsedHightlightLayer, scene, rootUrl);
  42684. var index;
  42685. // Excluded meshes
  42686. for (index = 0; index < parsedHightlightLayer.excludedMeshes.length; index++) {
  42687. var mesh = scene.getMeshByID(parsedHightlightLayer.excludedMeshes[index]);
  42688. if (mesh) {
  42689. hl.addExcludedMesh(mesh);
  42690. }
  42691. }
  42692. // Included meshes
  42693. for (index = 0; index < parsedHightlightLayer.meshes.length; index++) {
  42694. var highlightedMesh = parsedHightlightLayer.meshes[index];
  42695. var mesh = scene.getMeshByID(highlightedMesh.meshId);
  42696. if (mesh) {
  42697. hl.addMesh(mesh, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromArray(highlightedMesh.color), highlightedMesh.glowEmissiveOnly);
  42698. }
  42699. }
  42700. return hl;
  42701. };
  42702. /**
  42703. * Effect Name of the highlight layer.
  42704. */
  42705. HighlightLayer.EffectName = "HighlightLayer";
  42706. /**
  42707. * The neutral color used during the preparation of the glow effect.
  42708. * This is black by default as the blend operation is a blend operation.
  42709. */
  42710. HighlightLayer.NeutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  42711. /**
  42712. * Stencil value used for glowing meshes.
  42713. */
  42714. HighlightLayer.GlowingMeshStencilReference = 0x02;
  42715. /**
  42716. * Stencil value used for the other meshes in the scene.
  42717. */
  42718. HighlightLayer.NormalMeshStencilReference = 0x01;
  42719. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42720. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42721. ], HighlightLayer.prototype, "innerGlow", void 0);
  42722. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42723. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42724. ], HighlightLayer.prototype, "outerGlow", void 0);
  42725. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42726. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42727. ], HighlightLayer.prototype, "blurHorizontalSize", null);
  42728. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42729. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42730. ], HighlightLayer.prototype, "blurVerticalSize", null);
  42731. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42732. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  42733. ], HighlightLayer.prototype, "_options", void 0);
  42734. return HighlightLayer;
  42735. }(_effectLayer__WEBPACK_IMPORTED_MODULE_12__["EffectLayer"]));
  42736. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__["_TypeStore"].RegisteredTypes["BABYLON.HighlightLayer"] = HighlightLayer;
  42737. /***/ }),
  42738. /***/ "./Layers/index.ts":
  42739. /*!*************************!*\
  42740. !*** ./Layers/index.ts ***!
  42741. \*************************/
  42742. /*! exports provided: EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent */
  42743. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42744. "use strict";
  42745. __webpack_require__.r(__webpack_exports__);
  42746. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _effectLayer__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  42748. /* harmony import */ var _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  42749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__["EffectLayerSceneComponent"]; });
  42750. /* harmony import */ var _glowLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glowLayer */ "./Layers/glowLayer.ts");
  42751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _glowLayer__WEBPACK_IMPORTED_MODULE_2__["GlowLayer"]; });
  42752. /* harmony import */ var _highlightLayer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./highlightLayer */ "./Layers/highlightLayer.ts");
  42753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _highlightLayer__WEBPACK_IMPORTED_MODULE_3__["HighlightLayer"]; });
  42754. /* harmony import */ var _layer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./layer */ "./Layers/layer.ts");
  42755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _layer__WEBPACK_IMPORTED_MODULE_4__["Layer"]; });
  42756. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  42757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__["LayerSceneComponent"]; });
  42758. /***/ }),
  42759. /***/ "./Layers/layer.ts":
  42760. /*!*************************!*\
  42761. !*** ./Layers/layer.ts ***!
  42762. \*************************/
  42763. /*! exports provided: Layer */
  42764. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42765. "use strict";
  42766. __webpack_require__.r(__webpack_exports__);
  42767. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return Layer; });
  42768. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  42769. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42770. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  42771. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42772. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42773. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42774. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  42775. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  42776. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42777. /* harmony import */ var _Shaders_layer_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/layer.fragment */ "./Shaders/layer.fragment.ts");
  42778. /* harmony import */ var _Shaders_layer_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/layer.vertex */ "./Shaders/layer.vertex.ts");
  42779. /**
  42780. * This represents a full screen 2d layer.
  42781. * This can be useful to display a picture in the background of your scene for instance.
  42782. * @see https://www.babylonjs-playground.com/#08A2BS#1
  42783. */
  42784. var Layer = /** @class */ (function () {
  42785. /**
  42786. * Instantiates a new layer.
  42787. * This represents a full screen 2d layer.
  42788. * This can be useful to display a picture in the background of your scene for instance.
  42789. * @see https://www.babylonjs-playground.com/#08A2BS#1
  42790. * @param name Define the name of the layer in the scene
  42791. * @param imgUrl Define the url of the texture to display in the layer
  42792. * @param scene Define the scene the layer belongs to
  42793. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  42794. * @param color Defines a color for the layer
  42795. */
  42796. function Layer(
  42797. /**
  42798. * Define the name of the layer.
  42799. */
  42800. name, imgUrl, scene, isBackground, color) {
  42801. this.name = name;
  42802. /**
  42803. * Define the scale of the layer in order to zoom in out of the texture.
  42804. */
  42805. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1, 1);
  42806. /**
  42807. * Define an offset for the layer in order to shift the texture.
  42808. */
  42809. this.offset = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 0);
  42810. /**
  42811. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  42812. */
  42813. this.alphaBlendingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  42814. /**
  42815. * Define a mask to restrict the layer to only some of the scene cameras.
  42816. */
  42817. this.layerMask = 0x0FFFFFFF;
  42818. /**
  42819. * Define the list of render target the layer is visible into.
  42820. */
  42821. this.renderTargetTextures = [];
  42822. /**
  42823. * Define if the layer is only used in renderTarget or if it also
  42824. * renders in the main frame buffer of the canvas.
  42825. */
  42826. this.renderOnlyInRenderTargetTextures = false;
  42827. this._vertexBuffers = {};
  42828. /**
  42829. * An event triggered when the layer is disposed.
  42830. */
  42831. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  42832. /**
  42833. * An event triggered before rendering the scene
  42834. */
  42835. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  42836. /**
  42837. * An event triggered after rendering the scene
  42838. */
  42839. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  42840. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"](imgUrl, scene, true) : null;
  42841. this.isBackground = isBackground === undefined ? true : isBackground;
  42842. this.color = color === undefined ? new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1, 1, 1, 1) : color;
  42843. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene);
  42844. var layerComponent = this._scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_LAYER);
  42845. if (!layerComponent) {
  42846. layerComponent = new _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__["LayerSceneComponent"](this._scene);
  42847. this._scene._addComponent(layerComponent);
  42848. }
  42849. this._scene.layers.push(this);
  42850. var engine = this._scene.getEngine();
  42851. // VBO
  42852. var vertices = [];
  42853. vertices.push(1, 1);
  42854. vertices.push(-1, 1);
  42855. vertices.push(-1, -1);
  42856. vertices.push(1, -1);
  42857. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"](engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, false, false, 2);
  42858. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = vertexBuffer;
  42859. this._createIndexBuffer();
  42860. // Effects
  42861. this._effect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "");
  42862. this._alphaTestEffect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "#define ALPHATEST");
  42863. }
  42864. Object.defineProperty(Layer.prototype, "onDispose", {
  42865. /**
  42866. * Back compatibility with callback before the onDisposeObservable existed.
  42867. * The set callback will be triggered when the layer has been disposed.
  42868. */
  42869. set: function (callback) {
  42870. if (this._onDisposeObserver) {
  42871. this.onDisposeObservable.remove(this._onDisposeObserver);
  42872. }
  42873. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  42874. },
  42875. enumerable: true,
  42876. configurable: true
  42877. });
  42878. Object.defineProperty(Layer.prototype, "onBeforeRender", {
  42879. /**
  42880. * Back compatibility with callback before the onBeforeRenderObservable existed.
  42881. * The set callback will be triggered just before rendering the layer.
  42882. */
  42883. set: function (callback) {
  42884. if (this._onBeforeRenderObserver) {
  42885. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  42886. }
  42887. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  42888. },
  42889. enumerable: true,
  42890. configurable: true
  42891. });
  42892. Object.defineProperty(Layer.prototype, "onAfterRender", {
  42893. /**
  42894. * Back compatibility with callback before the onAfterRenderObservable existed.
  42895. * The set callback will be triggered just after rendering the layer.
  42896. */
  42897. set: function (callback) {
  42898. if (this._onAfterRenderObserver) {
  42899. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  42900. }
  42901. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  42902. },
  42903. enumerable: true,
  42904. configurable: true
  42905. });
  42906. Layer.prototype._createIndexBuffer = function () {
  42907. var engine = this._scene.getEngine();
  42908. // Indices
  42909. var indices = [];
  42910. indices.push(0);
  42911. indices.push(1);
  42912. indices.push(2);
  42913. indices.push(0);
  42914. indices.push(2);
  42915. indices.push(3);
  42916. this._indexBuffer = engine.createIndexBuffer(indices);
  42917. };
  42918. /** @hidden */
  42919. Layer.prototype._rebuild = function () {
  42920. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  42921. if (vb) {
  42922. vb._rebuild();
  42923. }
  42924. this._createIndexBuffer();
  42925. };
  42926. /**
  42927. * Renders the layer in the scene.
  42928. */
  42929. Layer.prototype.render = function () {
  42930. var currentEffect = this.alphaTest ? this._alphaTestEffect : this._effect;
  42931. // Check
  42932. if (!currentEffect.isReady() || !this.texture || !this.texture.isReady()) {
  42933. return;
  42934. }
  42935. var engine = this._scene.getEngine();
  42936. this.onBeforeRenderObservable.notifyObservers(this);
  42937. // Render
  42938. engine.enableEffect(currentEffect);
  42939. engine.setState(false);
  42940. // Texture
  42941. currentEffect.setTexture("textureSampler", this.texture);
  42942. currentEffect.setMatrix("textureMatrix", this.texture.getTextureMatrix());
  42943. // Color
  42944. currentEffect.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a);
  42945. // Scale / offset
  42946. currentEffect.setVector2("offset", this.offset);
  42947. currentEffect.setVector2("scale", this.scale);
  42948. // VBOs
  42949. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  42950. // Draw order
  42951. if (!this.alphaTest) {
  42952. engine.setAlphaMode(this.alphaBlendingMode);
  42953. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  42954. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  42955. }
  42956. else {
  42957. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  42958. }
  42959. this.onAfterRenderObservable.notifyObservers(this);
  42960. };
  42961. /**
  42962. * Disposes and releases the associated ressources.
  42963. */
  42964. Layer.prototype.dispose = function () {
  42965. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  42966. if (vertexBuffer) {
  42967. vertexBuffer.dispose();
  42968. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  42969. }
  42970. if (this._indexBuffer) {
  42971. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  42972. this._indexBuffer = null;
  42973. }
  42974. if (this.texture) {
  42975. this.texture.dispose();
  42976. this.texture = null;
  42977. }
  42978. // Clean RTT list
  42979. this.renderTargetTextures = [];
  42980. // Remove from scene
  42981. var index = this._scene.layers.indexOf(this);
  42982. this._scene.layers.splice(index, 1);
  42983. // Callback
  42984. this.onDisposeObservable.notifyObservers(this);
  42985. this.onDisposeObservable.clear();
  42986. this.onAfterRenderObservable.clear();
  42987. this.onBeforeRenderObservable.clear();
  42988. };
  42989. return Layer;
  42990. }());
  42991. /***/ }),
  42992. /***/ "./Layers/layerSceneComponent.ts":
  42993. /*!***************************************!*\
  42994. !*** ./Layers/layerSceneComponent.ts ***!
  42995. \***************************************/
  42996. /*! exports provided: LayerSceneComponent */
  42997. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42998. "use strict";
  42999. __webpack_require__.r(__webpack_exports__);
  43000. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return LayerSceneComponent; });
  43001. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  43002. /**
  43003. * Defines the layer scene component responsible to manage any layers
  43004. * in a given scene.
  43005. */
  43006. var LayerSceneComponent = /** @class */ (function () {
  43007. /**
  43008. * Creates a new instance of the component for the given scene
  43009. * @param scene Defines the scene to register the component in
  43010. */
  43011. function LayerSceneComponent(scene) {
  43012. /**
  43013. * The component name helpfull to identify the component in the list of scene components.
  43014. */
  43015. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_LAYER;
  43016. this.scene = scene;
  43017. this._engine = scene.getEngine();
  43018. scene.layers = new Array();
  43019. }
  43020. /**
  43021. * Registers the component in a given scene
  43022. */
  43023. LayerSceneComponent.prototype.register = function () {
  43024. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground);
  43025. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForeground);
  43026. this.scene._beforeRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground);
  43027. this.scene._afterRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForeground);
  43028. };
  43029. /**
  43030. * Rebuilds the elements related to this component in case of
  43031. * context lost for instance.
  43032. */
  43033. LayerSceneComponent.prototype.rebuild = function () {
  43034. var layers = this.scene.layers;
  43035. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  43036. var layer = layers_1[_i];
  43037. layer._rebuild();
  43038. }
  43039. };
  43040. /**
  43041. * Disposes the component and the associated ressources.
  43042. */
  43043. LayerSceneComponent.prototype.dispose = function () {
  43044. var layers = this.scene.layers;
  43045. while (layers.length) {
  43046. layers[0].dispose();
  43047. }
  43048. };
  43049. LayerSceneComponent.prototype._draw = function (predicate) {
  43050. var layers = this.scene.layers;
  43051. if (layers.length) {
  43052. this._engine.setDepthBuffer(false);
  43053. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  43054. var layer = layers_2[_i];
  43055. if (predicate(layer)) {
  43056. layer.render();
  43057. }
  43058. }
  43059. this._engine.setDepthBuffer(true);
  43060. }
  43061. };
  43062. LayerSceneComponent.prototype._drawCameraPredicate = function (layer, isBackground, cameraLayerMask) {
  43063. return !layer.renderOnlyInRenderTargetTextures &&
  43064. layer.isBackground === isBackground &&
  43065. ((layer.layerMask & cameraLayerMask) !== 0);
  43066. };
  43067. LayerSceneComponent.prototype._drawCameraBackground = function (camera) {
  43068. var _this = this;
  43069. this._draw(function (layer) {
  43070. return _this._drawCameraPredicate(layer, true, camera.layerMask);
  43071. });
  43072. };
  43073. LayerSceneComponent.prototype._drawCameraForeground = function (camera) {
  43074. var _this = this;
  43075. this._draw(function (layer) {
  43076. return _this._drawCameraPredicate(layer, false, camera.layerMask);
  43077. });
  43078. };
  43079. LayerSceneComponent.prototype._drawRenderTargetPredicate = function (layer, isBackground, cameraLayerMask, renderTargetTexture) {
  43080. return (layer.renderTargetTextures.length > 0) &&
  43081. layer.isBackground === isBackground &&
  43082. (layer.renderTargetTextures.indexOf(renderTargetTexture) > -1) &&
  43083. ((layer.layerMask & cameraLayerMask) !== 0);
  43084. };
  43085. LayerSceneComponent.prototype._drawRenderTargetBackground = function (renderTarget) {
  43086. var _this = this;
  43087. this._draw(function (layer) {
  43088. return _this._drawRenderTargetPredicate(layer, true, _this.scene.activeCamera.layerMask, renderTarget);
  43089. });
  43090. };
  43091. LayerSceneComponent.prototype._drawRenderTargetForeground = function (renderTarget) {
  43092. var _this = this;
  43093. this._draw(function (layer) {
  43094. return _this._drawRenderTargetPredicate(layer, false, _this.scene.activeCamera.layerMask, renderTarget);
  43095. });
  43096. };
  43097. return LayerSceneComponent;
  43098. }());
  43099. /***/ }),
  43100. /***/ "./Legacy/legacy.ts":
  43101. /*!**************************!*\
  43102. !*** ./Legacy/legacy.ts ***!
  43103. \**************************/
  43104. /*! 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 */
  43105. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43106. "use strict";
  43107. __webpack_require__.r(__webpack_exports__);
  43108. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  43109. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/index */ "./Debug/index.ts");
  43110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  43111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeepAssets"]; });
  43112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetContainer"]; });
  43113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Node"]; });
  43114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scene"]; });
  43115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"]; });
  43116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Stage"]; });
  43117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  43118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionEvent"]; });
  43119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionManager"]; });
  43120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Condition"]; });
  43121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueCondition"]; });
  43122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PredicateCondition"]; });
  43123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StateCondition"]; });
  43124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SwitchBooleanAction"]; });
  43125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetStateAction"]; });
  43126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetValueAction"]; });
  43127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IncrementValueAction"]; });
  43128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlayAnimationAction"]; });
  43129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopAnimationAction"]; });
  43130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DoNothingAction"]; });
  43131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CombineAction"]; });
  43132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExecuteCodeAction"]; });
  43133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetParentAction"]; });
  43134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaySoundAction"]; });
  43135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopSoundAction"]; });
  43136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InterpolateValueAction"]; });
  43137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  43138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animation"]; });
  43139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetedAnimation"]; });
  43140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationGroup"]; });
  43141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationPropertiesOverride"]; });
  43142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"]; });
  43143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleEase"]; });
  43144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackEase"]; });
  43145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BounceEase"]; });
  43146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubicEase"]; });
  43147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ElasticEase"]; });
  43148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]; });
  43149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PowerEase"]; });
  43150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuadraticEase"]; });
  43151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuarticEase"]; });
  43152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuinticEase"]; });
  43153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SineEase"]; });
  43154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurveEase"]; });
  43155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RuntimeAnimation"]; });
  43156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationEvent"]; });
  43157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationKeyInterpolation"]; });
  43158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationRange"]; });
  43159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  43160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioEngine"]; });
  43161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioSceneComponent"]; });
  43162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sound"]; });
  43163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SoundTrack"]; });
  43164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WeightedSound"]; });
  43165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  43166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneIKController"]; });
  43167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneLookController"]; });
  43168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Skeleton"]; });
  43169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]; });
  43170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputsManager"]; });
  43171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Camera"]; });
  43172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetCamera"]; });
  43173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCamera"]; });
  43174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraInputsManager"]; });
  43175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TouchCamera"]; });
  43176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCamera"]; });
  43177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraInputsManager"]; });
  43178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeviceOrientationCamera"]; });
  43179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCamera"]; });
  43180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraInputsManager"]; });
  43181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCamera"]; });
  43182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcFollowCamera"]; });
  43183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadCamera"]; });
  43184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniversalCamera"]; });
  43185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoysticksCamera"]; });
  43186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  43187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultCollisionCoordinator"]; });
  43188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PickingInfo"]; });
  43189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IntersectionInfo"]; });
  43190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  43191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingInfo"]; });
  43192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingSphere"]; });
  43193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ray"]; });
  43194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  43195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneAxesViewer"]; });
  43196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DebugLayer"]; });
  43197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsViewer"]; });
  43198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RayHelper"]; });
  43199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SkeletonViewer"]; });
  43200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  43201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancingAttributeInfo"]; });
  43202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthTextureCreationOptions"]; });
  43203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineCapabilities"]; });
  43204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Engine"]; });
  43205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineStore"]; });
  43206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngineOptions"]; });
  43207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngine"]; });
  43208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  43209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  43210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  43211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"]; });
  43212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoBase"]; });
  43213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoPre"]; });
  43214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"]; });
  43215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardEventTypes"]; });
  43216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardInfo"]; });
  43217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  43218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  43219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  43220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  43221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  43222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  43223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  43224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  43225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  43226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  43227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StickValues"]; });
  43228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gamepad"]; });
  43229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericPad"]; });
  43230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadManager"]; });
  43231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadSystemSceneComponent"]; });
  43232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Button"]; });
  43233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Dpad"]; });
  43234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Pad"]; });
  43235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  43236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisScaleGizmo"]; });
  43237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxGizmo"]; });
  43238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gizmo"]; });
  43239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GizmoManager"]; });
  43240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneRotationGizmo"]; });
  43241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionGizmo"]; });
  43242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RotationGizmo"]; });
  43243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScaleGizmo"]; });
  43244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LightGizmo"]; });
  43245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  43246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhotoDome"]; });
  43247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceSceneHelpersToBundle"]; });
  43248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoDome"]; });
  43249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  43250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneInstrumentation"]; });
  43251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TimeToken"]; });
  43252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  43253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayerSceneComponent"]; });
  43254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GlowLayer"]; });
  43255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightLayer"]; });
  43256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Layer"]; });
  43257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LayerSceneComponent"]; });
  43258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  43259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystem"]; });
  43260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystemSceneComponent"]; });
  43261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  43262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowLight"]; });
  43263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DirectionalLight"]; });
  43264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]; });
  43265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointLight"]; });
  43266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpotLight"]; });
  43267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  43268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderProgressEvent"]; });
  43269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"]; });
  43270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderFlags"]; });
  43271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCurves"]; });
  43272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectFallbacks"]; });
  43273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectCreationOptions"]; });
  43274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Effect"]; });
  43275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FresnelParameters"]; });
  43276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfigurationDefines"]; });
  43277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfiguration"]; });
  43278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Material"]; });
  43279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialDefines"]; });
  43280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialHelper"]; });
  43281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiMaterial"]; });
  43282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PushMaterial"]; });
  43283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShaderMaterial"]; });
  43284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterialDefines"]; });
  43285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterial"]; });
  43286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  43287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTexture"]; });
  43288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTexture"]; });
  43289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InternalTexture"]; });
  43290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DummyInternalTextureTracker"]; });
  43291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MirrorTexture"]; });
  43292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiRenderTarget"]; });
  43293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetTexture"]; });
  43294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Texture"]; });
  43295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniformBuffer"]; });
  43296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialFlags"]; });
  43297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  43298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToGammaSpace"]; });
  43299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]; });
  43300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; });
  43301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3"]; });
  43302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color4"]; });
  43303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2"]; });
  43304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3"]; });
  43305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector4"]; });
  43306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Size"]; });
  43307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]; });
  43308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix"]; });
  43309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Plane"]; });
  43310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Viewport"]; });
  43311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Frustum"]; });
  43312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Space"]; });
  43313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Axis"]; });
  43314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurve"]; });
  43315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Orientation"]; });
  43316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Angle"]; });
  43317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Arc2"]; });
  43318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path2"]; });
  43319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path3D"]; });
  43320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Curve3"]; });
  43321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]; });
  43322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalTextureVertex"]; });
  43323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tmp"]; });
  43324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]; });
  43325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalHarmonics"]; });
  43326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  43327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Buffer"]; });
  43328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"]; });
  43329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CSG"]; });
  43330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Geometry"]; });
  43331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundMesh"]; });
  43332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedMesh"]; });
  43333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesMesh"]; });
  43334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedLinesMesh"]; });
  43335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshLODLevel"]; });
  43336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_CreationDataStorage"]; });
  43337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_InstancesBatch"]; });
  43338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Mesh"]; });
  43339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexData"]; });
  43340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshBuilder"]; });
  43341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationSettings"]; });
  43342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationQueue"]; });
  43343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationType"]; });
  43344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplicationQueueSceneComponent"]; });
  43345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Polygon"]; });
  43346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonMeshBuilder"]; });
  43347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSubMesh"]; });
  43348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubMesh"]; });
  43349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TransformNode"]; });
  43350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  43351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereBuilder"]; });
  43352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderBuilder"]; });
  43353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesBuilder"]; });
  43354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneBuilder"]; });
  43355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  43356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTargetManager"]; });
  43357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  43358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  43359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GPUParticleSystem"]; });
  43360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Particle"]; });
  43361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleHelper"]; });
  43362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystem"]; });
  43363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_IDoNeedToBeInTheBuild"]; });
  43364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystemSet"]; });
  43365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticle"]; });
  43366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ModelShape"]; });
  43367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthSortedParticle"]; });
  43368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticleSystem"]; });
  43369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitterType"]; });
  43370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitter"]; });
  43371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  43372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngineSceneComponent"]; });
  43373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsHelper"]; });
  43374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialExplosionEvent"]; });
  43375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsGravitationalFieldEvent"]; });
  43376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftEvent"]; });
  43377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsVortexEvent"]; });
  43378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialImpulseFalloff"]; });
  43379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftMode"]; });
  43380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"]; });
  43381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsJoint"]; });
  43382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DistanceJoint"]; });
  43383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotorEnabledJoint"]; });
  43384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HingeJoint"]; });
  43385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Hinge2Joint"]; });
  43386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  43387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlackAndWhitePostProcess"]; });
  43388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomEffect"]; });
  43389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomMergePostProcess"]; });
  43390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlurPostProcess"]; });
  43391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ChromaticAberrationPostProcess"]; });
  43392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleOfConfusionPostProcess"]; });
  43393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCorrectionPostProcess"]; });
  43394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConvolutionPostProcess"]; });
  43395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldBlurPostProcess"]; });
  43396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffectBlurLevel"]; });
  43397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffect"]; });
  43398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcessOptions"]; });
  43399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcess"]; });
  43400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayPassPostProcess"]; });
  43401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExtractHighlightsPostProcess"]; });
  43402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilterPostProcess"]; });
  43403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FxaaPostProcess"]; });
  43404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GrainPostProcess"]; });
  43405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightsPostProcess"]; });
  43406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingPostProcess"]; });
  43407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotionBlurPostProcess"]; });
  43408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassPostProcess"]; });
  43409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassCubePostProcess"]; });
  43410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcess"]; });
  43411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessManager"]; });
  43412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionPostProcess"]; });
  43413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SharpenPostProcess"]; });
  43414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicInterlacePostProcess"]; });
  43415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemappingOperator"]; });
  43416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemapPostProcess"]; });
  43417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumetricLightScatteringPostProcess"]; });
  43418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDistortionCorrectionPostProcess"]; });
  43419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  43420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  43421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRenderer"]; });
  43422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRendererSceneComponent"]; });
  43423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EdgesRenderer"]; });
  43424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LineEdgesRenderer"]; });
  43425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRenderer"]; });
  43426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRendererSceneComponent"]; });
  43427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OutlineRenderer"]; });
  43428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"]; });
  43429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroupInfo"]; });
  43430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingManager"]; });
  43431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"]; });
  43432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  43433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteManager"]; });
  43434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteSceneComponent"]; });
  43435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  43436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DepthCullingState"]; });
  43437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_StencilState"]; });
  43438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  43439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetTaskState"]; });
  43440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractAssetTask"]; });
  43441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsProgressEvent"]; });
  43442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshAssetTask"]; });
  43443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextFileAssetTask"]; });
  43444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BinaryFileAssetTask"]; });
  43445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageAssetTask"]; });
  43446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureAssetTask"]; });
  43447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTextureAssetTask"]; });
  43448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTextureAssetTask"]; });
  43449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsManager"]; });
  43450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DDSTools"]; });
  43451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["expandToProperty"]; });
  43452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serialize"]; });
  43453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsTexture"]; });
  43454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor3"]; });
  43455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsFresnelParameters"]; });
  43456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector2"]; });
  43457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector3"]; });
  43458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMeshReference"]; });
  43459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColorCurves"]; });
  43460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor4"]; });
  43461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsImageProcessingConfiguration"]; });
  43462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsQuaternion"]; });
  43463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsCameraReference"]; });
  43464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SerializationHelper"]; });
  43465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Deferred"]; });
  43466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"]; });
  43467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInput"]; });
  43468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"]; });
  43469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EventState"]; });
  43470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observer"]; });
  43471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiObserver"]; });
  43472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observable"]; });
  43473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerformanceMonitor"]; });
  43474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RollingAverage"]; });
  43475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PromisePolyfill"]; });
  43476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimization"]; });
  43477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureOptimization"]; });
  43478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HardwareScalingOptimization"]; });
  43479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowsOptimization"]; });
  43480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessesOptimization"]; });
  43481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlaresOptimization"]; });
  43482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomOptimization"]; });
  43483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticlesOptimization"]; });
  43484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetsOptimization"]; });
  43485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MergeMeshesOptimization"]; });
  43486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizerOptions"]; });
  43487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizer"]; });
  43488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneSerializer"]; });
  43489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArray"]; });
  43490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"]; });
  43491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StringDictionary"]; });
  43492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tags"]; });
  43493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureTools"]; });
  43494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TGATools"]; });
  43495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradient"]; });
  43496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3Gradient"]; });
  43497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FactorGradient"]; });
  43498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LoadFileError"]; });
  43499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RetryStrategy"]; });
  43500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tools"]; });
  43501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]; });
  43502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["className"]; });
  43503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AsyncLoop"]; });
  43504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoRecorder"]; });
  43505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"]; });
  43506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"]; });
  43507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WorkerPool"]; });
  43508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Logger"]; });
  43509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"]; });
  43510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInputStore"]; });
  43511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"]; });
  43512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PivotTools"]; });
  43513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"]; });
  43514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScreenshotTools"]; });
  43515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  43516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  43517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  43518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  43519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FadeInOutBehavior"]; });
  43520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiPointerScaleBehavior"]; });
  43521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]; });
  43522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SixDofDragBehavior"]; });
  43523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  43524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  43525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  43526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  43527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  43528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  43529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  43530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  43531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  43532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  43533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  43534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  43535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  43536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  43537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphFreeCamera"]; });
  43538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphGamepadCamera"]; });
  43539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphUniversalCamera"]; });
  43540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicArcRotateCamera"]; });
  43541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicFreeCamera"]; });
  43542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicGamepadCamera"]; });
  43543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicUniversalCamera"]; });
  43544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  43545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationArcRotateCamera"]; });
  43546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationFreeCamera"]; });
  43547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationGamepadCamera"]; });
  43548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRExperienceHelper"]; });
  43549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRFreeCamera"]; });
  43550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  43551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIButton"]; });
  43552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIOptions"]; });
  43553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUI"]; });
  43554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRState"]; });
  43555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRExperienceHelper"]; });
  43556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRController"]; });
  43557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRInput"]; });
  43558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRManagedOutputCanvas"]; });
  43559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRSessionManager"]; });
  43560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  43561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeBlock"]; });
  43562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeSceneComponent"]; });
  43563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  43564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceTransformFeedbackToBundle"]; });
  43565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  43566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGeneratorSceneComponent"]; });
  43567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  43568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  43569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  43570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseSimpleMaterial"]; });
  43571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"]; });
  43572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMetallicRoughnessMaterial"]; });
  43573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRSpecularGlossinessMaterial"]; });
  43574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradingTexture"]; });
  43575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DynamicTexture"]; });
  43576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTexture"]; });
  43577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawCubeTexture"]; });
  43578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture"]; });
  43579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture3D"]; });
  43580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionTexture"]; });
  43581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoTexture"]; });
  43582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  43583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DiscBuilder"]; });
  43584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"]; });
  43585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusBuilder"]; });
  43586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusKnotBuilder"]; });
  43587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonBuilder"]; });
  43588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShapeBuilder"]; });
  43589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LatheBuilder"]; });
  43590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundBuilder"]; });
  43591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TubeBuilder"]; });
  43592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolyhedronBuilder"]; });
  43593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IcoSphereBuilder"]; });
  43594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DecalBuilder"]; });
  43595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  43596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConeParticleEmitter"]; });
  43597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderParticleEmitter"]; });
  43598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderDirectedParticleEmitter"]; });
  43599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericParticleEmitter"]; });
  43600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointParticleEmitter"]; });
  43601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereParticleEmitter"]; });
  43602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereDirectedParticleEmitter"]; });
  43603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  43604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AmmoJSPlugin"]; });
  43605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OimoJSPlugin"]; });
  43606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderEffect"]; });
  43607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipeline"]; });
  43608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManager"]; });
  43609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManagerSceneComponent"]; });
  43610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  43611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRTools"]; });
  43612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"]; });
  43613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  43614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_ENVTextureLoader"]; });
  43615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_KTXTextureLoader"]; });
  43616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TGATextureLoader"]; });
  43617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  43618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NoiseProceduralTexture"]; });
  43619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTextureSceneComponent"]; });
  43620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  43621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  43622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  43623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  43624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  43625. /**
  43626. * Legacy support, defining window.BABYLON (global variable).
  43627. *
  43628. * This is the entry point for the UMD module.
  43629. * The entry point for a future ESM package should be index.ts
  43630. */
  43631. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  43632. if (typeof globalObject !== "undefined") {
  43633. globalObject.BABYLON = BABYLON;
  43634. globalObject.BABYLON = globalObject.BABYLON || {};
  43635. var BABYLON = globalObject.BABYLON;
  43636. BABYLON.Debug = BABYLON.Debug || {};
  43637. var keys = [];
  43638. for (var key in _Debug_index__WEBPACK_IMPORTED_MODULE_1__) {
  43639. BABYLON.Debug[key] = _Debug_index__WEBPACK_IMPORTED_MODULE_1__[key];
  43640. keys.push(key);
  43641. }
  43642. for (var key in _index__WEBPACK_IMPORTED_MODULE_0__) {
  43643. // Prevent Reassignment.
  43644. if (keys.indexOf(key) > -1) {
  43645. continue;
  43646. }
  43647. BABYLON[key] = _index__WEBPACK_IMPORTED_MODULE_0__[key];
  43648. }
  43649. }
  43650. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  43651. /***/ }),
  43652. /***/ "./LensFlares/index.ts":
  43653. /*!*****************************!*\
  43654. !*** ./LensFlares/index.ts ***!
  43655. \*****************************/
  43656. /*! exports provided: LensFlare, LensFlareSystem, LensFlareSystemSceneComponent */
  43657. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43658. "use strict";
  43659. __webpack_require__.r(__webpack_exports__);
  43660. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  43661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _lensFlare__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  43662. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  43663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__["LensFlareSystem"]; });
  43664. /* harmony import */ var _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lensFlareSystemSceneComponent */ "./LensFlares/lensFlareSystemSceneComponent.ts");
  43665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__["LensFlareSystemSceneComponent"]; });
  43666. /***/ }),
  43667. /***/ "./LensFlares/lensFlare.ts":
  43668. /*!*********************************!*\
  43669. !*** ./LensFlares/lensFlare.ts ***!
  43670. \*********************************/
  43671. /*! exports provided: LensFlare */
  43672. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43673. "use strict";
  43674. __webpack_require__.r(__webpack_exports__);
  43675. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return LensFlare; });
  43676. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43677. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43678. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43679. /**
  43680. * This represents one of the lens effect in a `lensFlareSystem`.
  43681. * It controls one of the indiviual texture used in the effect.
  43682. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43683. */
  43684. var LensFlare = /** @class */ (function () {
  43685. /**
  43686. * Instantiates a new Lens Flare.
  43687. * This represents one of the lens effect in a `lensFlareSystem`.
  43688. * It controls one of the indiviual texture used in the effect.
  43689. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43690. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  43691. * @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.
  43692. * @param color Define the lens color
  43693. * @param imgUrl Define the lens texture url
  43694. * @param system Define the `lensFlareSystem` this flare is part of
  43695. */
  43696. function LensFlare(
  43697. /**
  43698. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  43699. */
  43700. size,
  43701. /**
  43702. * 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.
  43703. */
  43704. position, color, imgUrl, system) {
  43705. this.size = size;
  43706. this.position = position;
  43707. /**
  43708. * Define the alpha mode to render this particular lens.
  43709. */
  43710. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_ONEONE;
  43711. this.color = color || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](1, 1, 1);
  43712. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](imgUrl, system.getScene(), true) : null;
  43713. this._system = system;
  43714. system.lensFlares.push(this);
  43715. }
  43716. /**
  43717. * Creates a new Lens Flare.
  43718. * This represents one of the lens effect in a `lensFlareSystem`.
  43719. * It controls one of the indiviual texture used in the effect.
  43720. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43721. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  43722. * @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.
  43723. * @param color Define the lens color
  43724. * @param imgUrl Define the lens texture url
  43725. * @param system Define the `lensFlareSystem` this flare is part of
  43726. * @returns The newly created Lens Flare
  43727. */
  43728. LensFlare.AddFlare = function (size, position, color, imgUrl, system) {
  43729. return new LensFlare(size, position, color, imgUrl, system);
  43730. };
  43731. /**
  43732. * Dispose and release the lens flare with its associated resources.
  43733. */
  43734. LensFlare.prototype.dispose = function () {
  43735. if (this.texture) {
  43736. this.texture.dispose();
  43737. }
  43738. // Remove from scene
  43739. var index = this._system.lensFlares.indexOf(this);
  43740. this._system.lensFlares.splice(index, 1);
  43741. };
  43742. return LensFlare;
  43743. }());
  43744. /***/ }),
  43745. /***/ "./LensFlares/lensFlareSystem.ts":
  43746. /*!***************************************!*\
  43747. !*** ./LensFlares/lensFlareSystem.ts ***!
  43748. \***************************************/
  43749. /*! exports provided: LensFlareSystem */
  43750. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43751. "use strict";
  43752. __webpack_require__.r(__webpack_exports__);
  43753. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return LensFlareSystem; });
  43754. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  43755. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43756. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  43757. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  43758. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  43759. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  43760. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  43761. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  43762. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43763. /* harmony import */ var _Shaders_lensFlare_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/lensFlare.fragment */ "./Shaders/lensFlare.fragment.ts");
  43764. /* harmony import */ var _Shaders_lensFlare_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/lensFlare.vertex */ "./Shaders/lensFlare.vertex.ts");
  43765. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  43766. /**
  43767. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  43768. * It is usually composed of several `lensFlare`.
  43769. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43770. */
  43771. var LensFlareSystem = /** @class */ (function () {
  43772. /**
  43773. * Instantiates a lens flare system.
  43774. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  43775. * It is usually composed of several `lensFlare`.
  43776. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43777. * @param name Define the name of the lens flare system in the scene
  43778. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  43779. * @param scene Define the scene the lens flare system belongs to
  43780. */
  43781. function LensFlareSystem(
  43782. /**
  43783. * Define the name of the lens flare system
  43784. */
  43785. name, emitter, scene) {
  43786. this.name = name;
  43787. /**
  43788. * List of lens flares used in this system.
  43789. */
  43790. this.lensFlares = new Array();
  43791. /**
  43792. * Define a limit from the border the lens flare can be visible.
  43793. */
  43794. this.borderLimit = 300;
  43795. /**
  43796. * Define a viewport border we do not want to see the lens flare in.
  43797. */
  43798. this.viewportBorder = 0;
  43799. /**
  43800. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  43801. */
  43802. this.layerMask = 0x0FFFFFFF;
  43803. this._vertexBuffers = {};
  43804. this._isEnabled = true;
  43805. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  43806. LensFlareSystem._SceneComponentInitialization(this._scene);
  43807. this._emitter = emitter;
  43808. this.id = name;
  43809. scene.lensFlareSystems.push(this);
  43810. this.meshesSelectionPredicate = function (m) { return (scene.activeCamera && m.material && m.isVisible && m.isEnabled() && m.isBlocker && ((m.layerMask & scene.activeCamera.layerMask) != 0)); };
  43811. var engine = scene.getEngine();
  43812. // VBO
  43813. var vertices = [];
  43814. vertices.push(1, 1);
  43815. vertices.push(-1, 1);
  43816. vertices.push(-1, -1);
  43817. vertices.push(1, -1);
  43818. 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);
  43819. // Indices
  43820. var indices = [];
  43821. indices.push(0);
  43822. indices.push(1);
  43823. indices.push(2);
  43824. indices.push(0);
  43825. indices.push(2);
  43826. indices.push(3);
  43827. this._indexBuffer = engine.createIndexBuffer(indices);
  43828. // Effects
  43829. this._effect = engine.createEffect("lensFlare", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["color", "viewportMatrix"], ["textureSampler"], "");
  43830. }
  43831. Object.defineProperty(LensFlareSystem.prototype, "isEnabled", {
  43832. /**
  43833. * Define if the lens flare system is enabled.
  43834. */
  43835. get: function () {
  43836. return this._isEnabled;
  43837. },
  43838. set: function (value) {
  43839. this._isEnabled = value;
  43840. },
  43841. enumerable: true,
  43842. configurable: true
  43843. });
  43844. /**
  43845. * Get the scene the effects belongs to.
  43846. * @returns the scene holding the lens flare system
  43847. */
  43848. LensFlareSystem.prototype.getScene = function () {
  43849. return this._scene;
  43850. };
  43851. /**
  43852. * Get the emitter of the lens flare system.
  43853. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  43854. * @returns the emitter of the lens flare system
  43855. */
  43856. LensFlareSystem.prototype.getEmitter = function () {
  43857. return this._emitter;
  43858. };
  43859. /**
  43860. * Set the emitter of the lens flare system.
  43861. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  43862. * @param newEmitter Define the new emitter of the system
  43863. */
  43864. LensFlareSystem.prototype.setEmitter = function (newEmitter) {
  43865. this._emitter = newEmitter;
  43866. };
  43867. /**
  43868. * Get the lens flare system emitter position.
  43869. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  43870. * @returns the position
  43871. */
  43872. LensFlareSystem.prototype.getEmitterPosition = function () {
  43873. return this._emitter.getAbsolutePosition ? this._emitter.getAbsolutePosition() : this._emitter.position;
  43874. };
  43875. /**
  43876. * @hidden
  43877. */
  43878. LensFlareSystem.prototype.computeEffectivePosition = function (globalViewport) {
  43879. var position = this.getEmitterPosition();
  43880. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), this._scene.getTransformMatrix(), globalViewport);
  43881. this._positionX = position.x;
  43882. this._positionY = position.y;
  43883. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(this.getEmitterPosition(), this._scene.getViewMatrix());
  43884. if (this.viewportBorder > 0) {
  43885. globalViewport.x -= this.viewportBorder;
  43886. globalViewport.y -= this.viewportBorder;
  43887. globalViewport.width += this.viewportBorder * 2;
  43888. globalViewport.height += this.viewportBorder * 2;
  43889. position.x += this.viewportBorder;
  43890. position.y += this.viewportBorder;
  43891. this._positionX += this.viewportBorder;
  43892. this._positionY += this.viewportBorder;
  43893. }
  43894. if (position.z > 0) {
  43895. if ((this._positionX > globalViewport.x) && (this._positionX < globalViewport.x + globalViewport.width)) {
  43896. if ((this._positionY > globalViewport.y) && (this._positionY < globalViewport.y + globalViewport.height)) {
  43897. return true;
  43898. }
  43899. }
  43900. return true;
  43901. }
  43902. return false;
  43903. };
  43904. /** @hidden */
  43905. LensFlareSystem.prototype._isVisible = function () {
  43906. if (!this._isEnabled || !this._scene.activeCamera) {
  43907. return false;
  43908. }
  43909. var emitterPosition = this.getEmitterPosition();
  43910. var direction = emitterPosition.subtract(this._scene.activeCamera.globalPosition);
  43911. var distance = direction.length();
  43912. direction.normalize();
  43913. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](this._scene.activeCamera.globalPosition, direction);
  43914. var pickInfo = this._scene.pickWithRay(ray, this.meshesSelectionPredicate, true);
  43915. return !pickInfo || !pickInfo.hit || pickInfo.distance > distance;
  43916. };
  43917. /**
  43918. * @hidden
  43919. */
  43920. LensFlareSystem.prototype.render = function () {
  43921. if (!this._effect.isReady() || !this._scene.activeCamera) {
  43922. return false;
  43923. }
  43924. var engine = this._scene.getEngine();
  43925. var viewport = this._scene.activeCamera.viewport;
  43926. var globalViewport = viewport.toGlobal(engine.getRenderWidth(true), engine.getRenderHeight(true));
  43927. // Position
  43928. if (!this.computeEffectivePosition(globalViewport)) {
  43929. return false;
  43930. }
  43931. // Visibility
  43932. if (!this._isVisible()) {
  43933. return false;
  43934. }
  43935. // Intensity
  43936. var awayX;
  43937. var awayY;
  43938. if (this._positionX < this.borderLimit + globalViewport.x) {
  43939. awayX = this.borderLimit + globalViewport.x - this._positionX;
  43940. }
  43941. else if (this._positionX > globalViewport.x + globalViewport.width - this.borderLimit) {
  43942. awayX = this._positionX - globalViewport.x - globalViewport.width + this.borderLimit;
  43943. }
  43944. else {
  43945. awayX = 0;
  43946. }
  43947. if (this._positionY < this.borderLimit + globalViewport.y) {
  43948. awayY = this.borderLimit + globalViewport.y - this._positionY;
  43949. }
  43950. else if (this._positionY > globalViewport.y + globalViewport.height - this.borderLimit) {
  43951. awayY = this._positionY - globalViewport.y - globalViewport.height + this.borderLimit;
  43952. }
  43953. else {
  43954. awayY = 0;
  43955. }
  43956. var away = (awayX > awayY) ? awayX : awayY;
  43957. away -= this.viewportBorder;
  43958. if (away > this.borderLimit) {
  43959. away = this.borderLimit;
  43960. }
  43961. var intensity = 1.0 - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Clamp(away / this.borderLimit, 0, 1);
  43962. if (intensity < 0) {
  43963. return false;
  43964. }
  43965. if (intensity > 1.0) {
  43966. intensity = 1.0;
  43967. }
  43968. if (this.viewportBorder > 0) {
  43969. globalViewport.x += this.viewportBorder;
  43970. globalViewport.y += this.viewportBorder;
  43971. globalViewport.width -= this.viewportBorder * 2;
  43972. globalViewport.height -= this.viewportBorder * 2;
  43973. this._positionX -= this.viewportBorder;
  43974. this._positionY -= this.viewportBorder;
  43975. }
  43976. // Position
  43977. var centerX = globalViewport.x + globalViewport.width / 2;
  43978. var centerY = globalViewport.y + globalViewport.height / 2;
  43979. var distX = centerX - this._positionX;
  43980. var distY = centerY - this._positionY;
  43981. // Effects
  43982. engine.enableEffect(this._effect);
  43983. engine.setState(false);
  43984. engine.setDepthBuffer(false);
  43985. // VBOs
  43986. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  43987. // Flares
  43988. for (var index = 0; index < this.lensFlares.length; index++) {
  43989. var flare = this.lensFlares[index];
  43990. engine.setAlphaMode(flare.alphaMode);
  43991. var x = centerX - (distX * flare.position);
  43992. var y = centerY - (distY * flare.position);
  43993. var cw = flare.size;
  43994. var ch = flare.size * engine.getAspectRatio(this._scene.activeCamera, true);
  43995. var cx = 2 * (x / (globalViewport.width + globalViewport.x * 2)) - 1.0;
  43996. var cy = 1.0 - 2 * (y / (globalViewport.height + globalViewport.y * 2));
  43997. 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);
  43998. this._effect.setMatrix("viewportMatrix", viewportMatrix);
  43999. // Texture
  44000. this._effect.setTexture("textureSampler", flare.texture);
  44001. // Color
  44002. this._effect.setFloat4("color", flare.color.r * intensity, flare.color.g * intensity, flare.color.b * intensity, 1.0);
  44003. // Draw order
  44004. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  44005. }
  44006. engine.setDepthBuffer(true);
  44007. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  44008. return true;
  44009. };
  44010. /**
  44011. * Dispose and release the lens flare with its associated resources.
  44012. */
  44013. LensFlareSystem.prototype.dispose = function () {
  44014. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  44015. if (vertexBuffer) {
  44016. vertexBuffer.dispose();
  44017. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind] = null;
  44018. }
  44019. if (this._indexBuffer) {
  44020. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  44021. this._indexBuffer = null;
  44022. }
  44023. while (this.lensFlares.length) {
  44024. this.lensFlares[0].dispose();
  44025. }
  44026. // Remove from scene
  44027. var index = this._scene.lensFlareSystems.indexOf(this);
  44028. this._scene.lensFlareSystems.splice(index, 1);
  44029. };
  44030. /**
  44031. * Parse a lens flare system from a JSON repressentation
  44032. * @param parsedLensFlareSystem Define the JSON to parse
  44033. * @param scene Define the scene the parsed system should be instantiated in
  44034. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  44035. * @returns the parsed system
  44036. */
  44037. LensFlareSystem.Parse = function (parsedLensFlareSystem, scene, rootUrl) {
  44038. var emitter = scene.getLastEntryByID(parsedLensFlareSystem.emitterId);
  44039. var name = parsedLensFlareSystem.name || "lensFlareSystem#" + parsedLensFlareSystem.emitterId;
  44040. var lensFlareSystem = new LensFlareSystem(name, emitter, scene);
  44041. lensFlareSystem.id = parsedLensFlareSystem.id || name;
  44042. lensFlareSystem.borderLimit = parsedLensFlareSystem.borderLimit;
  44043. for (var index = 0; index < parsedLensFlareSystem.flares.length; index++) {
  44044. var parsedFlare = parsedLensFlareSystem.flares[index];
  44045. _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);
  44046. }
  44047. return lensFlareSystem;
  44048. };
  44049. /**
  44050. * Serialize the current Lens Flare System into a JSON representation.
  44051. * @returns the serialized JSON
  44052. */
  44053. LensFlareSystem.prototype.serialize = function () {
  44054. var serializationObject = {};
  44055. serializationObject.id = this.id;
  44056. serializationObject.name = this.name;
  44057. serializationObject.emitterId = this.getEmitter().id;
  44058. serializationObject.borderLimit = this.borderLimit;
  44059. serializationObject.flares = [];
  44060. for (var index = 0; index < this.lensFlares.length; index++) {
  44061. var flare = this.lensFlares[index];
  44062. serializationObject.flares.push({
  44063. size: flare.size,
  44064. position: flare.position,
  44065. color: flare.color.asArray(),
  44066. textureName: _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(flare.texture ? flare.texture.name : "")
  44067. });
  44068. }
  44069. return serializationObject;
  44070. };
  44071. /** @hidden */
  44072. LensFlareSystem._SceneComponentInitialization = function (_) {
  44073. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("LensFlareSystemSceneComponent");
  44074. };
  44075. return LensFlareSystem;
  44076. }());
  44077. /***/ }),
  44078. /***/ "./LensFlares/lensFlareSystemSceneComponent.ts":
  44079. /*!*****************************************************!*\
  44080. !*** ./LensFlares/lensFlareSystemSceneComponent.ts ***!
  44081. \*****************************************************/
  44082. /*! exports provided: LensFlareSystemSceneComponent */
  44083. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44084. "use strict";
  44085. __webpack_require__.r(__webpack_exports__);
  44086. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return LensFlareSystemSceneComponent; });
  44087. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  44088. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  44089. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  44090. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  44091. // Adds the parser to the scene parsers.
  44092. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM, function (parsedData, scene, container, rootUrl) {
  44093. // Lens flares
  44094. if (parsedData.lensFlareSystems !== undefined && parsedData.lensFlareSystems !== null) {
  44095. if (!container.lensFlareSystems) {
  44096. container.lensFlareSystems = new Array();
  44097. }
  44098. for (var index = 0, cache = parsedData.lensFlareSystems.length; index < cache; index++) {
  44099. var parsedLensFlareSystem = parsedData.lensFlareSystems[index];
  44100. var lf = _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"].Parse(parsedLensFlareSystem, scene, rootUrl);
  44101. container.lensFlareSystems.push(lf);
  44102. }
  44103. }
  44104. });
  44105. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByName = function (name) {
  44106. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  44107. if (this.lensFlareSystems[index].name === name) {
  44108. return this.lensFlareSystems[index];
  44109. }
  44110. }
  44111. return null;
  44112. };
  44113. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByID = function (id) {
  44114. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  44115. if (this.lensFlareSystems[index].id === id) {
  44116. return this.lensFlareSystems[index];
  44117. }
  44118. }
  44119. return null;
  44120. };
  44121. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.removeLensFlareSystem = function (toRemove) {
  44122. var index = this.lensFlareSystems.indexOf(toRemove);
  44123. if (index !== -1) {
  44124. this.lensFlareSystems.splice(index, 1);
  44125. }
  44126. return index;
  44127. };
  44128. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.addLensFlareSystem = function (newLensFlareSystem) {
  44129. this.lensFlareSystems.push(newLensFlareSystem);
  44130. };
  44131. /**
  44132. * Defines the lens flare scene component responsible to manage any lens flares
  44133. * in a given scene.
  44134. */
  44135. var LensFlareSystemSceneComponent = /** @class */ (function () {
  44136. /**
  44137. * Creates a new instance of the component for the given scene
  44138. * @param scene Defines the scene to register the component in
  44139. */
  44140. function LensFlareSystemSceneComponent(scene) {
  44141. /**
  44142. * The component name helpfull to identify the component in the list of scene components.
  44143. */
  44144. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM;
  44145. this.scene = scene;
  44146. scene.lensFlareSystems = new Array();
  44147. }
  44148. /**
  44149. * Registers the component in a given scene
  44150. */
  44151. LensFlareSystemSceneComponent.prototype.register = function () {
  44152. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw);
  44153. };
  44154. /**
  44155. * Rebuilds the elements related to this component in case of
  44156. * context lost for instance.
  44157. */
  44158. LensFlareSystemSceneComponent.prototype.rebuild = function () {
  44159. // Nothing to do for lens flare
  44160. };
  44161. /**
  44162. * Adds all the element from the container to the scene
  44163. * @param container the container holding the elements
  44164. */
  44165. LensFlareSystemSceneComponent.prototype.addFromContainer = function (container) {
  44166. var _this = this;
  44167. if (!container.lensFlareSystems) {
  44168. return;
  44169. }
  44170. container.lensFlareSystems.forEach(function (o) {
  44171. _this.scene.addLensFlareSystem(o);
  44172. });
  44173. };
  44174. /**
  44175. * Removes all the elements in the container from the scene
  44176. * @param container contains the elements to remove
  44177. */
  44178. LensFlareSystemSceneComponent.prototype.removeFromContainer = function (container) {
  44179. var _this = this;
  44180. if (!container.lensFlareSystems) {
  44181. return;
  44182. }
  44183. container.lensFlareSystems.forEach(function (o) {
  44184. _this.scene.removeLensFlareSystem(o);
  44185. });
  44186. };
  44187. /**
  44188. * Serializes the component data to the specified json object
  44189. * @param serializationObject The object to serialize to
  44190. */
  44191. LensFlareSystemSceneComponent.prototype.serialize = function (serializationObject) {
  44192. // Lens flares
  44193. serializationObject.lensFlareSystems = [];
  44194. var lensFlareSystems = this.scene.lensFlareSystems;
  44195. for (var _i = 0, lensFlareSystems_1 = lensFlareSystems; _i < lensFlareSystems_1.length; _i++) {
  44196. var lensFlareSystem = lensFlareSystems_1[_i];
  44197. serializationObject.lensFlareSystems.push(lensFlareSystem.serialize());
  44198. }
  44199. };
  44200. /**
  44201. * Disposes the component and the associated ressources.
  44202. */
  44203. LensFlareSystemSceneComponent.prototype.dispose = function () {
  44204. var lensFlareSystems = this.scene.lensFlareSystems;
  44205. while (lensFlareSystems.length) {
  44206. lensFlareSystems[0].dispose();
  44207. }
  44208. };
  44209. LensFlareSystemSceneComponent.prototype._draw = function (camera) {
  44210. // Lens flares
  44211. if (this.scene.lensFlaresEnabled) {
  44212. var lensFlareSystems = this.scene.lensFlareSystems;
  44213. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  44214. for (var _i = 0, lensFlareSystems_2 = lensFlareSystems; _i < lensFlareSystems_2.length; _i++) {
  44215. var lensFlareSystem = lensFlareSystems_2[_i];
  44216. if ((camera.layerMask & lensFlareSystem.layerMask) !== 0) {
  44217. lensFlareSystem.render();
  44218. }
  44219. }
  44220. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  44221. }
  44222. };
  44223. return LensFlareSystemSceneComponent;
  44224. }());
  44225. _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"]._SceneComponentInitialization = function (scene) {
  44226. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM);
  44227. if (!component) {
  44228. component = new LensFlareSystemSceneComponent(scene);
  44229. scene._addComponent(component);
  44230. }
  44231. };
  44232. /***/ }),
  44233. /***/ "./Lights/Shadows/index.ts":
  44234. /*!*********************************!*\
  44235. !*** ./Lights/Shadows/index.ts ***!
  44236. \*********************************/
  44237. /*! exports provided: ShadowGenerator, ShadowGeneratorSceneComponent */
  44238. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44239. "use strict";
  44240. __webpack_require__.r(__webpack_exports__);
  44241. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  44242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  44243. /* harmony import */ var _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowGeneratorSceneComponent */ "./Lights/Shadows/shadowGeneratorSceneComponent.ts");
  44244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__["ShadowGeneratorSceneComponent"]; });
  44245. /***/ }),
  44246. /***/ "./Lights/Shadows/shadowGenerator.ts":
  44247. /*!*******************************************!*\
  44248. !*** ./Lights/Shadows/shadowGenerator.ts ***!
  44249. \*******************************************/
  44250. /*! exports provided: ShadowGenerator */
  44251. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44252. "use strict";
  44253. __webpack_require__.r(__webpack_exports__);
  44254. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return ShadowGenerator; });
  44255. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  44256. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  44257. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  44258. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  44259. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  44260. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  44261. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  44262. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  44263. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  44264. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  44265. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  44266. /* harmony import */ var _Shaders_shadowMap_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Shaders/shadowMap.fragment */ "./Shaders/shadowMap.fragment.ts");
  44267. /* harmony import */ var _Shaders_shadowMap_vertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Shaders/shadowMap.vertex */ "./Shaders/shadowMap.vertex.ts");
  44268. /* harmony import */ var _Shaders_depthBoxBlur_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Shaders/depthBoxBlur.fragment */ "./Shaders/depthBoxBlur.fragment.ts");
  44269. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  44270. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  44271. /**
  44272. * Default implementation IShadowGenerator.
  44273. * This is the main object responsible of generating shadows in the framework.
  44274. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44275. */
  44276. var ShadowGenerator = /** @class */ (function () {
  44277. /**
  44278. * Creates a ShadowGenerator object.
  44279. * A ShadowGenerator is the required tool to use the shadows.
  44280. * Each light casting shadows needs to use its own ShadowGenerator.
  44281. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  44282. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44283. * @param light The light object generating the shadows.
  44284. * @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.
  44285. */
  44286. function ShadowGenerator(mapSize, light, usefulFloatFirst) {
  44287. /**
  44288. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  44289. */
  44290. this.onBeforeShadowMapRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_14__["Observable"]();
  44291. this._bias = 0.00005;
  44292. this._normalBias = 0;
  44293. this._blurBoxOffset = 1;
  44294. this._blurScale = 2;
  44295. this._blurKernel = 1;
  44296. this._useKernelBlur = false;
  44297. this._filter = ShadowGenerator.FILTER_NONE;
  44298. this._filteringQuality = ShadowGenerator.QUALITY_HIGH;
  44299. this._contactHardeningLightSizeUVRatio = 0.1;
  44300. this._darkness = 0;
  44301. this._transparencyShadow = false;
  44302. /**
  44303. * Controls the extent to which the shadows fade out at the edge of the frustum
  44304. * Used only by directionals and spots
  44305. */
  44306. this.frustumEdgeFalloff = 0;
  44307. /**
  44308. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44309. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44310. * It might on the other hand introduce peter panning.
  44311. */
  44312. this.forceBackFacesOnly = false;
  44313. this._lightDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  44314. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  44315. this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  44316. this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  44317. this._cachedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  44318. this._cachedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  44319. this._currentFaceIndex = 0;
  44320. this._currentFaceIndexCache = 0;
  44321. this._defaultTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  44322. this._mapSize = mapSize;
  44323. this._light = light;
  44324. this._scene = light.getScene();
  44325. light._shadowGenerator = this;
  44326. ShadowGenerator._SceneComponentInitialization(this._scene);
  44327. // Texture type fallback from float to int if not supported.
  44328. var caps = this._scene.getEngine().getCaps();
  44329. if (!usefulFloatFirst) {
  44330. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  44331. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  44332. }
  44333. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  44334. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  44335. }
  44336. else {
  44337. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  44338. }
  44339. }
  44340. else {
  44341. if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  44342. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  44343. }
  44344. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  44345. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  44346. }
  44347. else {
  44348. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  44349. }
  44350. }
  44351. this._initializeGenerator();
  44352. this._applyFilterValues();
  44353. }
  44354. Object.defineProperty(ShadowGenerator.prototype, "bias", {
  44355. /**
  44356. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44357. */
  44358. get: function () {
  44359. return this._bias;
  44360. },
  44361. /**
  44362. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44363. */
  44364. set: function (bias) {
  44365. this._bias = bias;
  44366. },
  44367. enumerable: true,
  44368. configurable: true
  44369. });
  44370. Object.defineProperty(ShadowGenerator.prototype, "normalBias", {
  44371. /**
  44372. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44373. */
  44374. get: function () {
  44375. return this._normalBias;
  44376. },
  44377. /**
  44378. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44379. */
  44380. set: function (normalBias) {
  44381. this._normalBias = normalBias;
  44382. },
  44383. enumerable: true,
  44384. configurable: true
  44385. });
  44386. Object.defineProperty(ShadowGenerator.prototype, "blurBoxOffset", {
  44387. /**
  44388. * Gets the blur box offset: offset applied during the blur pass.
  44389. * Only useful if useKernelBlur = false
  44390. */
  44391. get: function () {
  44392. return this._blurBoxOffset;
  44393. },
  44394. /**
  44395. * Sets the blur box offset: offset applied during the blur pass.
  44396. * Only useful if useKernelBlur = false
  44397. */
  44398. set: function (value) {
  44399. if (this._blurBoxOffset === value) {
  44400. return;
  44401. }
  44402. this._blurBoxOffset = value;
  44403. this._disposeBlurPostProcesses();
  44404. },
  44405. enumerable: true,
  44406. configurable: true
  44407. });
  44408. Object.defineProperty(ShadowGenerator.prototype, "blurScale", {
  44409. /**
  44410. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  44411. * 2 means half of the size.
  44412. */
  44413. get: function () {
  44414. return this._blurScale;
  44415. },
  44416. /**
  44417. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  44418. * 2 means half of the size.
  44419. */
  44420. set: function (value) {
  44421. if (this._blurScale === value) {
  44422. return;
  44423. }
  44424. this._blurScale = value;
  44425. this._disposeBlurPostProcesses();
  44426. },
  44427. enumerable: true,
  44428. configurable: true
  44429. });
  44430. Object.defineProperty(ShadowGenerator.prototype, "blurKernel", {
  44431. /**
  44432. * Gets the blur kernel: kernel size of the blur pass.
  44433. * Only useful if useKernelBlur = true
  44434. */
  44435. get: function () {
  44436. return this._blurKernel;
  44437. },
  44438. /**
  44439. * Sets the blur kernel: kernel size of the blur pass.
  44440. * Only useful if useKernelBlur = true
  44441. */
  44442. set: function (value) {
  44443. if (this._blurKernel === value) {
  44444. return;
  44445. }
  44446. this._blurKernel = value;
  44447. this._disposeBlurPostProcesses();
  44448. },
  44449. enumerable: true,
  44450. configurable: true
  44451. });
  44452. Object.defineProperty(ShadowGenerator.prototype, "useKernelBlur", {
  44453. /**
  44454. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  44455. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44456. */
  44457. get: function () {
  44458. return this._useKernelBlur;
  44459. },
  44460. /**
  44461. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  44462. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44463. */
  44464. set: function (value) {
  44465. if (this._useKernelBlur === value) {
  44466. return;
  44467. }
  44468. this._useKernelBlur = value;
  44469. this._disposeBlurPostProcesses();
  44470. },
  44471. enumerable: true,
  44472. configurable: true
  44473. });
  44474. Object.defineProperty(ShadowGenerator.prototype, "depthScale", {
  44475. /**
  44476. * Gets the depth scale used in ESM mode.
  44477. */
  44478. get: function () {
  44479. return this._depthScale !== undefined ? this._depthScale : this._light.getDepthScale();
  44480. },
  44481. /**
  44482. * Sets the depth scale used in ESM mode.
  44483. * This can override the scale stored on the light.
  44484. */
  44485. set: function (value) {
  44486. this._depthScale = value;
  44487. },
  44488. enumerable: true,
  44489. configurable: true
  44490. });
  44491. Object.defineProperty(ShadowGenerator.prototype, "filter", {
  44492. /**
  44493. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  44494. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44495. */
  44496. get: function () {
  44497. return this._filter;
  44498. },
  44499. /**
  44500. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  44501. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44502. */
  44503. set: function (value) {
  44504. // Blurring the cubemap is going to be too expensive. Reverting to unblurred version
  44505. if (this._light.needCube()) {
  44506. if (value === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  44507. this.useExponentialShadowMap = true;
  44508. return;
  44509. }
  44510. else if (value === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  44511. this.useCloseExponentialShadowMap = true;
  44512. return;
  44513. }
  44514. // PCF on cubemap would also be expensive
  44515. else if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  44516. this.usePoissonSampling = true;
  44517. return;
  44518. }
  44519. }
  44520. // Weblg1 fallback for PCF.
  44521. if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  44522. if (this._scene.getEngine().webGLVersion === 1) {
  44523. this.usePoissonSampling = true;
  44524. return;
  44525. }
  44526. }
  44527. if (this._filter === value) {
  44528. return;
  44529. }
  44530. this._filter = value;
  44531. this._disposeBlurPostProcesses();
  44532. this._applyFilterValues();
  44533. this._light._markMeshesAsLightDirty();
  44534. },
  44535. enumerable: true,
  44536. configurable: true
  44537. });
  44538. Object.defineProperty(ShadowGenerator.prototype, "usePoissonSampling", {
  44539. /**
  44540. * Gets if the current filter is set to Poisson Sampling.
  44541. */
  44542. get: function () {
  44543. return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING;
  44544. },
  44545. /**
  44546. * Sets the current filter to Poisson Sampling.
  44547. */
  44548. set: function (value) {
  44549. if (!value && this.filter !== ShadowGenerator.FILTER_POISSONSAMPLING) {
  44550. return;
  44551. }
  44552. this.filter = (value ? ShadowGenerator.FILTER_POISSONSAMPLING : ShadowGenerator.FILTER_NONE);
  44553. },
  44554. enumerable: true,
  44555. configurable: true
  44556. });
  44557. Object.defineProperty(ShadowGenerator.prototype, "useExponentialShadowMap", {
  44558. /**
  44559. * Gets if the current filter is set to ESM.
  44560. */
  44561. get: function () {
  44562. return this.filter === ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP;
  44563. },
  44564. /**
  44565. * Sets the current filter is to ESM.
  44566. */
  44567. set: function (value) {
  44568. if (!value && this.filter !== ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP) {
  44569. return;
  44570. }
  44571. this.filter = (value ? ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  44572. },
  44573. enumerable: true,
  44574. configurable: true
  44575. });
  44576. Object.defineProperty(ShadowGenerator.prototype, "useBlurExponentialShadowMap", {
  44577. /**
  44578. * Gets if the current filter is set to filtered ESM.
  44579. */
  44580. get: function () {
  44581. return this.filter === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP;
  44582. },
  44583. /**
  44584. * Gets if the current filter is set to filtered ESM.
  44585. */
  44586. set: function (value) {
  44587. if (!value && this.filter !== ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  44588. return;
  44589. }
  44590. this.filter = (value ? ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  44591. },
  44592. enumerable: true,
  44593. configurable: true
  44594. });
  44595. Object.defineProperty(ShadowGenerator.prototype, "useCloseExponentialShadowMap", {
  44596. /**
  44597. * Gets if the current filter is set to "close ESM" (using the inverse of the
  44598. * exponential to prevent steep falloff artifacts).
  44599. */
  44600. get: function () {
  44601. return this.filter === ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP;
  44602. },
  44603. /**
  44604. * Sets the current filter to "close ESM" (using the inverse of the
  44605. * exponential to prevent steep falloff artifacts).
  44606. */
  44607. set: function (value) {
  44608. if (!value && this.filter !== ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP) {
  44609. return;
  44610. }
  44611. this.filter = (value ? ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  44612. },
  44613. enumerable: true,
  44614. configurable: true
  44615. });
  44616. Object.defineProperty(ShadowGenerator.prototype, "useBlurCloseExponentialShadowMap", {
  44617. /**
  44618. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  44619. * exponential to prevent steep falloff artifacts).
  44620. */
  44621. get: function () {
  44622. return this.filter === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
  44623. },
  44624. /**
  44625. * Sets the current filter to filtered "close ESM" (using the inverse of the
  44626. * exponential to prevent steep falloff artifacts).
  44627. */
  44628. set: function (value) {
  44629. if (!value && this.filter !== ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  44630. return;
  44631. }
  44632. this.filter = (value ? ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  44633. },
  44634. enumerable: true,
  44635. configurable: true
  44636. });
  44637. Object.defineProperty(ShadowGenerator.prototype, "usePercentageCloserFiltering", {
  44638. /**
  44639. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  44640. */
  44641. get: function () {
  44642. return this.filter === ShadowGenerator.FILTER_PCF;
  44643. },
  44644. /**
  44645. * Sets the current filter to "PCF" (percentage closer filtering).
  44646. */
  44647. set: function (value) {
  44648. if (!value && this.filter !== ShadowGenerator.FILTER_PCF) {
  44649. return;
  44650. }
  44651. this.filter = (value ? ShadowGenerator.FILTER_PCF : ShadowGenerator.FILTER_NONE);
  44652. },
  44653. enumerable: true,
  44654. configurable: true
  44655. });
  44656. Object.defineProperty(ShadowGenerator.prototype, "filteringQuality", {
  44657. /**
  44658. * Gets the PCF or PCSS Quality.
  44659. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44660. */
  44661. get: function () {
  44662. return this._filteringQuality;
  44663. },
  44664. /**
  44665. * Sets the PCF or PCSS Quality.
  44666. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44667. */
  44668. set: function (filteringQuality) {
  44669. this._filteringQuality = filteringQuality;
  44670. },
  44671. enumerable: true,
  44672. configurable: true
  44673. });
  44674. Object.defineProperty(ShadowGenerator.prototype, "useContactHardeningShadow", {
  44675. /**
  44676. * Gets if the current filter is set to "PCSS" (contact hardening).
  44677. */
  44678. get: function () {
  44679. return this.filter === ShadowGenerator.FILTER_PCSS;
  44680. },
  44681. /**
  44682. * Sets the current filter to "PCSS" (contact hardening).
  44683. */
  44684. set: function (value) {
  44685. if (!value && this.filter !== ShadowGenerator.FILTER_PCSS) {
  44686. return;
  44687. }
  44688. this.filter = (value ? ShadowGenerator.FILTER_PCSS : ShadowGenerator.FILTER_NONE);
  44689. },
  44690. enumerable: true,
  44691. configurable: true
  44692. });
  44693. Object.defineProperty(ShadowGenerator.prototype, "contactHardeningLightSizeUVRatio", {
  44694. /**
  44695. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44696. * Using a ratio helps keeping shape stability independently of the map size.
  44697. *
  44698. * It does not account for the light projection as it was having too much
  44699. * instability during the light setup or during light position changes.
  44700. *
  44701. * Only valid if useContactHardeningShadow is true.
  44702. */
  44703. get: function () {
  44704. return this._contactHardeningLightSizeUVRatio;
  44705. },
  44706. /**
  44707. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44708. * Using a ratio helps keeping shape stability independently of the map size.
  44709. *
  44710. * It does not account for the light projection as it was having too much
  44711. * instability during the light setup or during light position changes.
  44712. *
  44713. * Only valid if useContactHardeningShadow is true.
  44714. */
  44715. set: function (contactHardeningLightSizeUVRatio) {
  44716. this._contactHardeningLightSizeUVRatio = contactHardeningLightSizeUVRatio;
  44717. },
  44718. enumerable: true,
  44719. configurable: true
  44720. });
  44721. /**
  44722. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44723. * 0 means strongest and 1 would means no shadow.
  44724. * @returns the darkness.
  44725. */
  44726. ShadowGenerator.prototype.getDarkness = function () {
  44727. return this._darkness;
  44728. };
  44729. /**
  44730. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44731. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44732. * @returns the shadow generator allowing fluent coding.
  44733. */
  44734. ShadowGenerator.prototype.setDarkness = function (darkness) {
  44735. if (darkness >= 1.0) {
  44736. this._darkness = 1.0;
  44737. }
  44738. else if (darkness <= 0.0) {
  44739. this._darkness = 0.0;
  44740. }
  44741. else {
  44742. this._darkness = darkness;
  44743. }
  44744. return this;
  44745. };
  44746. /**
  44747. * Sets the ability to have transparent shadow (boolean).
  44748. * @param transparent True if transparent else False
  44749. * @returns the shadow generator allowing fluent coding
  44750. */
  44751. ShadowGenerator.prototype.setTransparencyShadow = function (transparent) {
  44752. this._transparencyShadow = transparent;
  44753. return this;
  44754. };
  44755. /**
  44756. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44757. * @returns The render target texture if present otherwise, null
  44758. */
  44759. ShadowGenerator.prototype.getShadowMap = function () {
  44760. return this._shadowMap;
  44761. };
  44762. /**
  44763. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44764. * @returns The render target texture if the shadow map is present otherwise, null
  44765. */
  44766. ShadowGenerator.prototype.getShadowMapForRendering = function () {
  44767. if (this._shadowMap2) {
  44768. return this._shadowMap2;
  44769. }
  44770. return this._shadowMap;
  44771. };
  44772. /**
  44773. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44774. * @param mesh Mesh to add
  44775. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44776. * @returns the Shadow Generator itself
  44777. */
  44778. ShadowGenerator.prototype.addShadowCaster = function (mesh, includeDescendants) {
  44779. if (includeDescendants === void 0) { includeDescendants = true; }
  44780. var _a;
  44781. if (!this._shadowMap) {
  44782. return this;
  44783. }
  44784. if (!this._shadowMap.renderList) {
  44785. this._shadowMap.renderList = [];
  44786. }
  44787. this._shadowMap.renderList.push(mesh);
  44788. if (includeDescendants) {
  44789. (_a = this._shadowMap.renderList).push.apply(_a, mesh.getChildMeshes());
  44790. }
  44791. return this;
  44792. };
  44793. /**
  44794. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44795. * @param mesh Mesh to remove
  44796. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44797. * @returns the Shadow Generator itself
  44798. */
  44799. ShadowGenerator.prototype.removeShadowCaster = function (mesh, includeDescendants) {
  44800. if (includeDescendants === void 0) { includeDescendants = true; }
  44801. if (!this._shadowMap || !this._shadowMap.renderList) {
  44802. return this;
  44803. }
  44804. var index = this._shadowMap.renderList.indexOf(mesh);
  44805. if (index !== -1) {
  44806. this._shadowMap.renderList.splice(index, 1);
  44807. }
  44808. if (includeDescendants) {
  44809. for (var _i = 0, _a = mesh.getChildren(); _i < _a.length; _i++) {
  44810. var child = _a[_i];
  44811. this.removeShadowCaster(child);
  44812. }
  44813. }
  44814. return this;
  44815. };
  44816. /**
  44817. * Returns the associated light object.
  44818. * @returns the light generating the shadow
  44819. */
  44820. ShadowGenerator.prototype.getLight = function () {
  44821. return this._light;
  44822. };
  44823. ShadowGenerator.prototype._initializeGenerator = function () {
  44824. this._light._markMeshesAsLightDirty();
  44825. this._initializeShadowMap();
  44826. };
  44827. ShadowGenerator.prototype._initializeShadowMap = function () {
  44828. var _this = this;
  44829. // Render target
  44830. var engine = this._scene.getEngine();
  44831. if (engine.webGLVersion > 1) {
  44832. 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);
  44833. this._shadowMap.createDepthStencilTexture(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].LESS, true);
  44834. }
  44835. else {
  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());
  44837. }
  44838. this._shadowMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44839. this._shadowMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44840. this._shadowMap.anisotropicFilteringLevel = 1;
  44841. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  44842. this._shadowMap.renderParticles = false;
  44843. this._shadowMap.ignoreCameraViewport = true;
  44844. // Record Face Index before render.
  44845. this._shadowMap.onBeforeRenderObservable.add(function (faceIndex) {
  44846. _this._currentFaceIndex = faceIndex;
  44847. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  44848. engine.setColorWrite(false);
  44849. }
  44850. });
  44851. // Custom render function.
  44852. this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this);
  44853. // Blur if required afer render.
  44854. this._shadowMap.onAfterUnbindObservable.add(function () {
  44855. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  44856. engine.setColorWrite(true);
  44857. }
  44858. if (!_this.useBlurExponentialShadowMap && !_this.useBlurCloseExponentialShadowMap) {
  44859. return;
  44860. }
  44861. var shadowMap = _this.getShadowMapForRendering();
  44862. if (shadowMap) {
  44863. _this._scene.postProcessManager.directRender(_this._blurPostProcesses, shadowMap.getInternalTexture(), true);
  44864. }
  44865. });
  44866. // Clear according to the chosen filter.
  44867. var clearZero = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](0, 0, 0, 0);
  44868. var clearOne = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  44869. this._shadowMap.onClearObservable.add(function (engine) {
  44870. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  44871. engine.clear(clearOne, false, true, false);
  44872. }
  44873. else if (_this.useExponentialShadowMap || _this.useBlurExponentialShadowMap) {
  44874. engine.clear(clearZero, true, true, false);
  44875. }
  44876. else {
  44877. engine.clear(clearOne, true, true, false);
  44878. }
  44879. });
  44880. };
  44881. ShadowGenerator.prototype._initializeBlurRTTAndPostProcesses = function () {
  44882. var _this = this;
  44883. var engine = this._scene.getEngine();
  44884. var targetSize = this._mapSize / this.blurScale;
  44885. if (!this.useKernelBlur || this.blurScale !== 1.0) {
  44886. this._shadowMap2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"](this._light.name + "_shadowMap2", targetSize, this._scene, false, true, this._textureType);
  44887. this._shadowMap2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44888. this._shadowMap2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44889. this._shadowMap2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  44890. }
  44891. if (this.useKernelBlur) {
  44892. 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);
  44893. this._kernelBlurXPostprocess.width = targetSize;
  44894. this._kernelBlurXPostprocess.height = targetSize;
  44895. this._kernelBlurXPostprocess.onApplyObservable.add(function (effect) {
  44896. effect.setTexture("textureSampler", _this._shadowMap);
  44897. });
  44898. 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);
  44899. this._kernelBlurXPostprocess.autoClear = false;
  44900. this._kernelBlurYPostprocess.autoClear = false;
  44901. if (this._textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  44902. this._kernelBlurXPostprocess.packedFloat = true;
  44903. this._kernelBlurYPostprocess.packedFloat = true;
  44904. }
  44905. this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess];
  44906. }
  44907. else {
  44908. 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);
  44909. this._boxBlurPostprocess.onApplyObservable.add(function (effect) {
  44910. effect.setFloat2("screenSize", targetSize, targetSize);
  44911. effect.setTexture("textureSampler", _this._shadowMap);
  44912. });
  44913. this._boxBlurPostprocess.autoClear = false;
  44914. this._blurPostProcesses = [this._boxBlurPostprocess];
  44915. }
  44916. };
  44917. ShadowGenerator.prototype._renderForShadowMap = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  44918. var index;
  44919. var engine = this._scene.getEngine();
  44920. if (depthOnlySubMeshes.length) {
  44921. engine.setColorWrite(false);
  44922. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  44923. this._renderSubMeshForShadowMap(depthOnlySubMeshes.data[index]);
  44924. }
  44925. engine.setColorWrite(true);
  44926. }
  44927. for (index = 0; index < opaqueSubMeshes.length; index++) {
  44928. this._renderSubMeshForShadowMap(opaqueSubMeshes.data[index]);
  44929. }
  44930. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  44931. this._renderSubMeshForShadowMap(alphaTestSubMeshes.data[index]);
  44932. }
  44933. if (this._transparencyShadow) {
  44934. for (index = 0; index < transparentSubMeshes.length; index++) {
  44935. this._renderSubMeshForShadowMap(transparentSubMeshes.data[index]);
  44936. }
  44937. }
  44938. };
  44939. ShadowGenerator.prototype._renderSubMeshForShadowMap = function (subMesh) {
  44940. var _this = this;
  44941. var mesh = subMesh.getRenderingMesh();
  44942. var scene = this._scene;
  44943. var engine = scene.getEngine();
  44944. var material = subMesh.getMaterial();
  44945. if (!material || subMesh.verticesCount === 0) {
  44946. return;
  44947. }
  44948. // Culling
  44949. engine.setState(material.backFaceCulling);
  44950. // Managing instances
  44951. var batch = mesh._getInstancesRenderList(subMesh._id);
  44952. if (batch.mustReturn) {
  44953. return;
  44954. }
  44955. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  44956. if (this.isReady(subMesh, hardwareInstancedRendering)) {
  44957. engine.enableEffect(this._effect);
  44958. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  44959. this._effect.setFloat3("biasAndScale", this.bias, this.normalBias, this.depthScale);
  44960. this._effect.setMatrix("viewProjection", this.getTransformMatrix());
  44961. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  44962. this._effect.setVector3("lightData", this._cachedDirection);
  44963. }
  44964. else {
  44965. this._effect.setVector3("lightData", this._cachedPosition);
  44966. }
  44967. if (scene.activeCamera) {
  44968. this._effect.setFloat2("depthValues", this.getLight().getDepthMinZ(scene.activeCamera), this.getLight().getDepthMinZ(scene.activeCamera) + this.getLight().getDepthMaxZ(scene.activeCamera));
  44969. }
  44970. // Alpha test
  44971. if (material && material.needAlphaTesting()) {
  44972. var alphaTexture = material.getAlphaTestTexture();
  44973. if (alphaTexture) {
  44974. this._effect.setTexture("diffuseSampler", alphaTexture);
  44975. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix() || this._defaultTextureMatrix);
  44976. }
  44977. }
  44978. // Bones
  44979. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  44980. var skeleton = mesh.skeleton;
  44981. if (skeleton.isUsingTextureForMatrices) {
  44982. var boneTexture = skeleton.getTransformMatrixTexture();
  44983. if (!boneTexture) {
  44984. return;
  44985. }
  44986. this._effect.setTexture("boneSampler", boneTexture);
  44987. this._effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  44988. }
  44989. else {
  44990. this._effect.setMatrices("mBones", skeleton.getTransformMatrices((mesh)));
  44991. }
  44992. }
  44993. // Morph targets
  44994. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effect);
  44995. if (this.forceBackFacesOnly) {
  44996. engine.setState(true, 0, false, true);
  44997. }
  44998. // Observable
  44999. this.onBeforeShadowMapRenderObservable.notifyObservers(this._effect);
  45000. // Draw
  45001. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  45002. if (this.forceBackFacesOnly) {
  45003. engine.setState(true, 0, false, false);
  45004. }
  45005. }
  45006. else {
  45007. // Need to reset refresh rate of the shadowMap
  45008. if (this._shadowMap) {
  45009. this._shadowMap.resetRefreshCounter();
  45010. }
  45011. }
  45012. };
  45013. ShadowGenerator.prototype._applyFilterValues = function () {
  45014. if (!this._shadowMap) {
  45015. return;
  45016. }
  45017. if (this.filter === ShadowGenerator.FILTER_NONE || this.filter === ShadowGenerator.FILTER_PCSS) {
  45018. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].NEAREST_SAMPLINGMODE);
  45019. }
  45020. else {
  45021. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  45022. }
  45023. };
  45024. /**
  45025. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  45026. * @param onCompiled Callback triggered at the and of the effects compilation
  45027. * @param options Sets of optional options forcing the compilation with different modes
  45028. */
  45029. ShadowGenerator.prototype.forceCompilation = function (onCompiled, options) {
  45030. var _this = this;
  45031. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ useInstances: false }, options);
  45032. var shadowMap = this.getShadowMap();
  45033. if (!shadowMap) {
  45034. if (onCompiled) {
  45035. onCompiled(this);
  45036. }
  45037. return;
  45038. }
  45039. var renderList = shadowMap.renderList;
  45040. if (!renderList) {
  45041. if (onCompiled) {
  45042. onCompiled(this);
  45043. }
  45044. return;
  45045. }
  45046. var subMeshes = new Array();
  45047. for (var _i = 0, renderList_1 = renderList; _i < renderList_1.length; _i++) {
  45048. var mesh = renderList_1[_i];
  45049. subMeshes.push.apply(subMeshes, mesh.subMeshes);
  45050. }
  45051. if (subMeshes.length === 0) {
  45052. if (onCompiled) {
  45053. onCompiled(this);
  45054. }
  45055. return;
  45056. }
  45057. var currentIndex = 0;
  45058. var checkReady = function () {
  45059. if (!_this._scene || !_this._scene.getEngine()) {
  45060. return;
  45061. }
  45062. while (_this.isReady(subMeshes[currentIndex], localOptions.useInstances)) {
  45063. currentIndex++;
  45064. if (currentIndex >= subMeshes.length) {
  45065. if (onCompiled) {
  45066. onCompiled(_this);
  45067. }
  45068. return;
  45069. }
  45070. }
  45071. setTimeout(checkReady, 16);
  45072. };
  45073. checkReady();
  45074. };
  45075. /**
  45076. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  45077. * @param options Sets of optional options forcing the compilation with different modes
  45078. * @returns A promise that resolves when the compilation completes
  45079. */
  45080. ShadowGenerator.prototype.forceCompilationAsync = function (options) {
  45081. var _this = this;
  45082. return new Promise(function (resolve) {
  45083. _this.forceCompilation(function () {
  45084. resolve();
  45085. }, options);
  45086. });
  45087. };
  45088. /**
  45089. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  45090. * @param subMesh The submesh we want to render in the shadow map
  45091. * @param useInstances Defines wether will draw in the map using instances
  45092. * @returns true if ready otherwise, false
  45093. */
  45094. ShadowGenerator.prototype.isReady = function (subMesh, useInstances) {
  45095. var defines = [];
  45096. if (this._textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  45097. defines.push("#define FLOAT");
  45098. }
  45099. if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  45100. defines.push("#define ESM");
  45101. }
  45102. else if (this.usePercentageCloserFiltering || this.useContactHardeningShadow) {
  45103. defines.push("#define DEPTHTEXTURE");
  45104. }
  45105. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind];
  45106. var mesh = subMesh.getMesh();
  45107. var material = subMesh.getMaterial();
  45108. // Normal bias.
  45109. if (this.normalBias && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  45110. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  45111. defines.push("#define NORMAL");
  45112. if (mesh.nonUniformScaling) {
  45113. defines.push("#define NONUNIFORMSCALING");
  45114. }
  45115. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  45116. defines.push("#define DIRECTIONINLIGHTDATA");
  45117. }
  45118. }
  45119. // Alpha test
  45120. if (material && material.needAlphaTesting()) {
  45121. var alphaTexture = material.getAlphaTestTexture();
  45122. if (alphaTexture) {
  45123. defines.push("#define ALPHATEST");
  45124. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  45125. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  45126. defines.push("#define UV1");
  45127. }
  45128. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  45129. if (alphaTexture.coordinatesIndex === 1) {
  45130. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  45131. defines.push("#define UV2");
  45132. }
  45133. }
  45134. }
  45135. }
  45136. // Bones
  45137. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  45138. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  45139. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  45140. if (mesh.numBoneInfluencers > 4) {
  45141. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  45142. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind);
  45143. }
  45144. var skeleton = mesh.skeleton;
  45145. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  45146. if (skeleton.isUsingTextureForMatrices) {
  45147. defines.push("#define BONETEXTURE");
  45148. }
  45149. else {
  45150. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  45151. }
  45152. }
  45153. else {
  45154. defines.push("#define NUM_BONE_INFLUENCERS 0");
  45155. }
  45156. // Morph targets
  45157. var manager = mesh.morphTargetManager;
  45158. var morphInfluencers = 0;
  45159. if (manager) {
  45160. if (manager.numInfluencers > 0) {
  45161. defines.push("#define MORPHTARGETS");
  45162. morphInfluencers = manager.numInfluencers;
  45163. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  45164. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  45165. }
  45166. }
  45167. // Instances
  45168. if (useInstances) {
  45169. defines.push("#define INSTANCES");
  45170. attribs.push("world0");
  45171. attribs.push("world1");
  45172. attribs.push("world2");
  45173. attribs.push("world3");
  45174. }
  45175. if (this.customShaderOptions) {
  45176. if (this.customShaderOptions.defines) {
  45177. for (var _i = 0, _a = this.customShaderOptions.defines; _i < _a.length; _i++) {
  45178. var define = _a[_i];
  45179. if (defines.indexOf(define) === -1) {
  45180. defines.push(define);
  45181. }
  45182. }
  45183. }
  45184. }
  45185. // Get correct effect
  45186. var join = defines.join("\n");
  45187. if (this._cachedDefines !== join) {
  45188. this._cachedDefines = join;
  45189. var shaderName = "shadowMap";
  45190. var uniforms = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightData", "depthValues", "biasAndScale", "morphTargetInfluences", "boneTextureWidth"];
  45191. var samplers = ["diffuseSampler", "boneSampler"];
  45192. // Custom shader?
  45193. if (this.customShaderOptions) {
  45194. shaderName = this.customShaderOptions.shaderName;
  45195. if (this.customShaderOptions.attributes) {
  45196. for (var _b = 0, _c = this.customShaderOptions.attributes; _b < _c.length; _b++) {
  45197. var attrib = _c[_b];
  45198. if (attribs.indexOf(attrib) === -1) {
  45199. attribs.push(attrib);
  45200. }
  45201. }
  45202. }
  45203. if (this.customShaderOptions.uniforms) {
  45204. for (var _d = 0, _e = this.customShaderOptions.uniforms; _d < _e.length; _d++) {
  45205. var uniform = _e[_d];
  45206. if (uniforms.indexOf(uniform) === -1) {
  45207. uniforms.push(uniform);
  45208. }
  45209. }
  45210. }
  45211. if (this.customShaderOptions.samplers) {
  45212. for (var _f = 0, _g = this.customShaderOptions.samplers; _f < _g.length; _f++) {
  45213. var sampler = _g[_f];
  45214. if (samplers.indexOf(sampler) === -1) {
  45215. samplers.push(sampler);
  45216. }
  45217. }
  45218. }
  45219. }
  45220. this._effect = this._scene.getEngine().createEffect(shaderName, attribs, uniforms, samplers, join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  45221. }
  45222. if (!this._effect.isReady()) {
  45223. return false;
  45224. }
  45225. if (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  45226. if (!this._blurPostProcesses || !this._blurPostProcesses.length) {
  45227. this._initializeBlurRTTAndPostProcesses();
  45228. }
  45229. }
  45230. if (this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady()) {
  45231. return false;
  45232. }
  45233. if (this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady()) {
  45234. return false;
  45235. }
  45236. if (this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady()) {
  45237. return false;
  45238. }
  45239. return true;
  45240. };
  45241. /**
  45242. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  45243. * @param defines Defines of the material we want to update
  45244. * @param lightIndex Index of the light in the enabled light list of the material
  45245. */
  45246. ShadowGenerator.prototype.prepareDefines = function (defines, lightIndex) {
  45247. var scene = this._scene;
  45248. var light = this._light;
  45249. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  45250. return;
  45251. }
  45252. defines["SHADOW" + lightIndex] = true;
  45253. if (this.useContactHardeningShadow) {
  45254. defines["SHADOWPCSS" + lightIndex] = true;
  45255. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  45256. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  45257. }
  45258. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  45259. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  45260. }
  45261. // else default to high.
  45262. }
  45263. if (this.usePercentageCloserFiltering) {
  45264. defines["SHADOWPCF" + lightIndex] = true;
  45265. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  45266. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  45267. }
  45268. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  45269. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  45270. }
  45271. // else default to high.
  45272. }
  45273. else if (this.usePoissonSampling) {
  45274. defines["SHADOWPOISSON" + lightIndex] = true;
  45275. }
  45276. else if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  45277. defines["SHADOWESM" + lightIndex] = true;
  45278. }
  45279. else if (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  45280. defines["SHADOWCLOSEESM" + lightIndex] = true;
  45281. }
  45282. if (light.needCube()) {
  45283. defines["SHADOWCUBE" + lightIndex] = true;
  45284. }
  45285. };
  45286. /**
  45287. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  45288. * defined in the generator but impacting the effect).
  45289. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  45290. * @param effect The effect we are binfing the information for
  45291. */
  45292. ShadowGenerator.prototype.bindShadowLight = function (lightIndex, effect) {
  45293. var light = this._light;
  45294. var scene = this._scene;
  45295. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  45296. return;
  45297. }
  45298. var camera = scene.activeCamera;
  45299. if (!camera) {
  45300. return;
  45301. }
  45302. var shadowMap = this.getShadowMap();
  45303. if (!shadowMap) {
  45304. return;
  45305. }
  45306. if (!light.needCube()) {
  45307. effect.setMatrix("lightMatrix" + lightIndex, this.getTransformMatrix());
  45308. }
  45309. // Only PCF uses depth stencil texture.
  45310. if (this._filter === ShadowGenerator.FILTER_PCF) {
  45311. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  45312. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), shadowMap.getSize().width, 1 / shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  45313. }
  45314. else if (this._filter === ShadowGenerator.FILTER_PCSS) {
  45315. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  45316. effect.setTexture("depthSampler" + lightIndex, this.getShadowMapForRendering());
  45317. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / shadowMap.getSize().width, this._contactHardeningLightSizeUVRatio * shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  45318. }
  45319. else {
  45320. effect.setTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  45321. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / shadowMap.getSize().width, this.depthScale, this.frustumEdgeFalloff, lightIndex);
  45322. }
  45323. light._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(camera), this.getLight().getDepthMinZ(camera) + this.getLight().getDepthMaxZ(camera), lightIndex);
  45324. };
  45325. /**
  45326. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  45327. * (eq to shadow prjection matrix * light transform matrix)
  45328. * @returns The transform matrix used to create the shadow map
  45329. */
  45330. ShadowGenerator.prototype.getTransformMatrix = function () {
  45331. var scene = this._scene;
  45332. if (this._currentRenderID === scene.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex) {
  45333. return this._transformMatrix;
  45334. }
  45335. this._currentRenderID = scene.getRenderId();
  45336. this._currentFaceIndexCache = this._currentFaceIndex;
  45337. var lightPosition = this._light.position;
  45338. if (this._light.computeTransformedInformation()) {
  45339. lightPosition = this._light.transformedPosition;
  45340. }
  45341. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection);
  45342. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this._lightDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up())) === 1.0) {
  45343. this._lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light
  45344. }
  45345. if (this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
  45346. this._cachedPosition.copyFrom(lightPosition);
  45347. this._cachedDirection.copyFrom(this._lightDirection);
  45348. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].LookAtLHToRef(lightPosition, lightPosition.add(this._lightDirection), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up(), this._viewMatrix);
  45349. var shadowMap = this.getShadowMap();
  45350. if (shadowMap) {
  45351. var renderList = shadowMap.renderList;
  45352. if (renderList) {
  45353. this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, renderList);
  45354. }
  45355. }
  45356. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  45357. }
  45358. return this._transformMatrix;
  45359. };
  45360. /**
  45361. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  45362. * Cube and 2D textures for instance.
  45363. */
  45364. ShadowGenerator.prototype.recreateShadowMap = function () {
  45365. var shadowMap = this._shadowMap;
  45366. if (!shadowMap) {
  45367. return;
  45368. }
  45369. // Track render list.
  45370. var renderList = shadowMap.renderList;
  45371. // Clean up existing data.
  45372. this._disposeRTTandPostProcesses();
  45373. // Reinitializes.
  45374. this._initializeGenerator();
  45375. // Reaffect the filter to ensure a correct fallback if necessary.
  45376. this.filter = this.filter;
  45377. // Reaffect the filter.
  45378. this._applyFilterValues();
  45379. // Reaffect Render List.
  45380. this._shadowMap.renderList = renderList;
  45381. };
  45382. ShadowGenerator.prototype._disposeBlurPostProcesses = function () {
  45383. if (this._shadowMap2) {
  45384. this._shadowMap2.dispose();
  45385. this._shadowMap2 = null;
  45386. }
  45387. if (this._boxBlurPostprocess) {
  45388. this._boxBlurPostprocess.dispose();
  45389. this._boxBlurPostprocess = null;
  45390. }
  45391. if (this._kernelBlurXPostprocess) {
  45392. this._kernelBlurXPostprocess.dispose();
  45393. this._kernelBlurXPostprocess = null;
  45394. }
  45395. if (this._kernelBlurYPostprocess) {
  45396. this._kernelBlurYPostprocess.dispose();
  45397. this._kernelBlurYPostprocess = null;
  45398. }
  45399. this._blurPostProcesses = [];
  45400. };
  45401. ShadowGenerator.prototype._disposeRTTandPostProcesses = function () {
  45402. if (this._shadowMap) {
  45403. this._shadowMap.dispose();
  45404. this._shadowMap = null;
  45405. }
  45406. this._disposeBlurPostProcesses();
  45407. };
  45408. /**
  45409. * Disposes the ShadowGenerator.
  45410. * Returns nothing.
  45411. */
  45412. ShadowGenerator.prototype.dispose = function () {
  45413. this._disposeRTTandPostProcesses();
  45414. if (this._light) {
  45415. this._light._shadowGenerator = null;
  45416. this._light._markMeshesAsLightDirty();
  45417. }
  45418. };
  45419. /**
  45420. * Serializes the shadow generator setup to a json object.
  45421. * @returns The serialized JSON object
  45422. */
  45423. ShadowGenerator.prototype.serialize = function () {
  45424. var serializationObject = {};
  45425. var shadowMap = this.getShadowMap();
  45426. if (!shadowMap) {
  45427. return serializationObject;
  45428. }
  45429. serializationObject.lightId = this._light.id;
  45430. serializationObject.mapSize = shadowMap.getRenderSize();
  45431. serializationObject.useExponentialShadowMap = this.useExponentialShadowMap;
  45432. serializationObject.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap;
  45433. serializationObject.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  45434. serializationObject.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  45435. serializationObject.usePoissonSampling = this.usePoissonSampling;
  45436. serializationObject.forceBackFacesOnly = this.forceBackFacesOnly;
  45437. serializationObject.depthScale = this.depthScale;
  45438. serializationObject.darkness = this.getDarkness();
  45439. serializationObject.blurBoxOffset = this.blurBoxOffset;
  45440. serializationObject.blurKernel = this.blurKernel;
  45441. serializationObject.blurScale = this.blurScale;
  45442. serializationObject.useKernelBlur = this.useKernelBlur;
  45443. serializationObject.transparencyShadow = this._transparencyShadow;
  45444. serializationObject.frustumEdgeFalloff = this.frustumEdgeFalloff;
  45445. serializationObject.bias = this.bias;
  45446. serializationObject.normalBias = this.normalBias;
  45447. serializationObject.usePercentageCloserFiltering = this.usePercentageCloserFiltering;
  45448. serializationObject.useContactHardeningShadow = this.useContactHardeningShadow;
  45449. serializationObject.filteringQuality = this.filteringQuality;
  45450. serializationObject.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio;
  45451. serializationObject.renderList = [];
  45452. if (shadowMap.renderList) {
  45453. for (var meshIndex = 0; meshIndex < shadowMap.renderList.length; meshIndex++) {
  45454. var mesh = shadowMap.renderList[meshIndex];
  45455. serializationObject.renderList.push(mesh.id);
  45456. }
  45457. }
  45458. return serializationObject;
  45459. };
  45460. /**
  45461. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  45462. * @param parsedShadowGenerator The JSON object to parse
  45463. * @param scene The scene to create the shadow map for
  45464. * @returns The parsed shadow generator
  45465. */
  45466. ShadowGenerator.Parse = function (parsedShadowGenerator, scene) {
  45467. var light = scene.getLightByID(parsedShadowGenerator.lightId);
  45468. var shadowGenerator = new ShadowGenerator(parsedShadowGenerator.mapSize, light);
  45469. var shadowMap = shadowGenerator.getShadowMap();
  45470. for (var meshIndex = 0; meshIndex < parsedShadowGenerator.renderList.length; meshIndex++) {
  45471. var meshes = scene.getMeshesByID(parsedShadowGenerator.renderList[meshIndex]);
  45472. meshes.forEach(function (mesh) {
  45473. if (!shadowMap) {
  45474. return;
  45475. }
  45476. if (!shadowMap.renderList) {
  45477. shadowMap.renderList = [];
  45478. }
  45479. shadowMap.renderList.push(mesh);
  45480. });
  45481. }
  45482. if (parsedShadowGenerator.usePoissonSampling) {
  45483. shadowGenerator.usePoissonSampling = true;
  45484. }
  45485. else if (parsedShadowGenerator.useExponentialShadowMap) {
  45486. shadowGenerator.useExponentialShadowMap = true;
  45487. }
  45488. else if (parsedShadowGenerator.useBlurExponentialShadowMap) {
  45489. shadowGenerator.useBlurExponentialShadowMap = true;
  45490. }
  45491. else if (parsedShadowGenerator.useCloseExponentialShadowMap) {
  45492. shadowGenerator.useCloseExponentialShadowMap = true;
  45493. }
  45494. else if (parsedShadowGenerator.useBlurCloseExponentialShadowMap) {
  45495. shadowGenerator.useBlurCloseExponentialShadowMap = true;
  45496. }
  45497. else if (parsedShadowGenerator.usePercentageCloserFiltering) {
  45498. shadowGenerator.usePercentageCloserFiltering = true;
  45499. }
  45500. else if (parsedShadowGenerator.useContactHardeningShadow) {
  45501. shadowGenerator.useContactHardeningShadow = true;
  45502. }
  45503. if (parsedShadowGenerator.filteringQuality) {
  45504. shadowGenerator.filteringQuality = parsedShadowGenerator.filteringQuality;
  45505. }
  45506. if (parsedShadowGenerator.contactHardeningLightSizeUVRatio) {
  45507. shadowGenerator.contactHardeningLightSizeUVRatio = parsedShadowGenerator.contactHardeningLightSizeUVRatio;
  45508. }
  45509. // Backward compat
  45510. else if (parsedShadowGenerator.useVarianceShadowMap) {
  45511. shadowGenerator.useExponentialShadowMap = true;
  45512. }
  45513. else if (parsedShadowGenerator.useBlurVarianceShadowMap) {
  45514. shadowGenerator.useBlurExponentialShadowMap = true;
  45515. }
  45516. if (parsedShadowGenerator.depthScale) {
  45517. shadowGenerator.depthScale = parsedShadowGenerator.depthScale;
  45518. }
  45519. if (parsedShadowGenerator.blurScale) {
  45520. shadowGenerator.blurScale = parsedShadowGenerator.blurScale;
  45521. }
  45522. if (parsedShadowGenerator.blurBoxOffset) {
  45523. shadowGenerator.blurBoxOffset = parsedShadowGenerator.blurBoxOffset;
  45524. }
  45525. if (parsedShadowGenerator.useKernelBlur) {
  45526. shadowGenerator.useKernelBlur = parsedShadowGenerator.useKernelBlur;
  45527. }
  45528. if (parsedShadowGenerator.blurKernel) {
  45529. shadowGenerator.blurKernel = parsedShadowGenerator.blurKernel;
  45530. }
  45531. if (parsedShadowGenerator.bias !== undefined) {
  45532. shadowGenerator.bias = parsedShadowGenerator.bias;
  45533. }
  45534. if (parsedShadowGenerator.normalBias !== undefined) {
  45535. shadowGenerator.normalBias = parsedShadowGenerator.normalBias;
  45536. }
  45537. if (parsedShadowGenerator.frustumEdgeFalloff !== undefined) {
  45538. shadowGenerator.frustumEdgeFalloff = parsedShadowGenerator.frustumEdgeFalloff;
  45539. }
  45540. if (parsedShadowGenerator.darkness) {
  45541. shadowGenerator.setDarkness(parsedShadowGenerator.darkness);
  45542. }
  45543. if (parsedShadowGenerator.transparencyShadow) {
  45544. shadowGenerator.setTransparencyShadow(true);
  45545. }
  45546. shadowGenerator.forceBackFacesOnly = parsedShadowGenerator.forceBackFacesOnly;
  45547. return shadowGenerator;
  45548. };
  45549. /**
  45550. * Shadow generator mode None: no filtering applied.
  45551. */
  45552. ShadowGenerator.FILTER_NONE = 0;
  45553. /**
  45554. * Shadow generator mode ESM: Exponential Shadow Mapping.
  45555. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  45556. */
  45557. ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP = 1;
  45558. /**
  45559. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  45560. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  45561. */
  45562. ShadowGenerator.FILTER_POISSONSAMPLING = 2;
  45563. /**
  45564. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  45565. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  45566. */
  45567. ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP = 3;
  45568. /**
  45569. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  45570. * edge artifacts on steep falloff.
  45571. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  45572. */
  45573. ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4;
  45574. /**
  45575. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  45576. * edge artifacts on steep falloff.
  45577. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  45578. */
  45579. ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5;
  45580. /**
  45581. * Shadow generator mode PCF: Percentage Closer Filtering
  45582. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  45583. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  45584. */
  45585. ShadowGenerator.FILTER_PCF = 6;
  45586. /**
  45587. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  45588. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  45589. * Contact Hardening
  45590. */
  45591. ShadowGenerator.FILTER_PCSS = 7;
  45592. /**
  45593. * Reserved for PCF and PCSS
  45594. * Highest Quality.
  45595. *
  45596. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  45597. *
  45598. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  45599. */
  45600. ShadowGenerator.QUALITY_HIGH = 0;
  45601. /**
  45602. * Reserved for PCF and PCSS
  45603. * Good tradeoff for quality/perf cross devices
  45604. *
  45605. * Execute PCF on a 3*3 kernel.
  45606. *
  45607. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  45608. */
  45609. ShadowGenerator.QUALITY_MEDIUM = 1;
  45610. /**
  45611. * Reserved for PCF and PCSS
  45612. * The lowest quality but the fastest.
  45613. *
  45614. * Execute PCF on a 1*1 kernel.
  45615. *
  45616. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  45617. */
  45618. ShadowGenerator.QUALITY_LOW = 2;
  45619. /** @hidden */
  45620. ShadowGenerator._SceneComponentInitialization = function (_) {
  45621. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__["_DevTools"].WarnImport("ShadowGeneratorSceneComponent");
  45622. };
  45623. return ShadowGenerator;
  45624. }());
  45625. /***/ }),
  45626. /***/ "./Lights/Shadows/shadowGeneratorSceneComponent.ts":
  45627. /*!*********************************************************!*\
  45628. !*** ./Lights/Shadows/shadowGeneratorSceneComponent.ts ***!
  45629. \*********************************************************/
  45630. /*! exports provided: ShadowGeneratorSceneComponent */
  45631. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45632. "use strict";
  45633. __webpack_require__.r(__webpack_exports__);
  45634. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return ShadowGeneratorSceneComponent; });
  45635. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  45636. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  45637. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  45638. // Adds the parser to the scene parsers.
  45639. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR, function (parsedData, scene) {
  45640. // Shadows
  45641. if (parsedData.shadowGenerators !== undefined && parsedData.shadowGenerators !== null) {
  45642. for (var index = 0, cache = parsedData.shadowGenerators.length; index < cache; index++) {
  45643. var parsedShadowGenerator = parsedData.shadowGenerators[index];
  45644. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"].Parse(parsedShadowGenerator, scene);
  45645. // SG would be available on their associated lights
  45646. }
  45647. }
  45648. });
  45649. /**
  45650. * Defines the shadow generator component responsible to manage any shadow generators
  45651. * in a given scene.
  45652. */
  45653. var ShadowGeneratorSceneComponent = /** @class */ (function () {
  45654. /**
  45655. * Creates a new instance of the component for the given scene
  45656. * @param scene Defines the scene to register the component in
  45657. */
  45658. function ShadowGeneratorSceneComponent(scene) {
  45659. /**
  45660. * The component name helpfull to identify the component in the list of scene components.
  45661. */
  45662. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR;
  45663. this.scene = scene;
  45664. }
  45665. /**
  45666. * Registers the component in a given scene
  45667. */
  45668. ShadowGeneratorSceneComponent.prototype.register = function () {
  45669. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets);
  45670. };
  45671. /**
  45672. * Rebuilds the elements related to this component in case of
  45673. * context lost for instance.
  45674. */
  45675. ShadowGeneratorSceneComponent.prototype.rebuild = function () {
  45676. // Nothing To Do Here.
  45677. };
  45678. /**
  45679. * Serializes the component data to the specified json object
  45680. * @param serializationObject The object to serialize to
  45681. */
  45682. ShadowGeneratorSceneComponent.prototype.serialize = function (serializationObject) {
  45683. // Shadows
  45684. serializationObject.shadowGenerators = [];
  45685. var lights = this.scene.lights;
  45686. for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) {
  45687. var light = lights_1[_i];
  45688. var shadowGenerator = light.getShadowGenerator();
  45689. if (shadowGenerator) {
  45690. serializationObject.shadowGenerators.push(shadowGenerator.serialize());
  45691. }
  45692. }
  45693. };
  45694. /**
  45695. * Adds all the element from the container to the scene
  45696. * @param container the container holding the elements
  45697. */
  45698. ShadowGeneratorSceneComponent.prototype.addFromContainer = function (container) {
  45699. // Nothing To Do Here. (directly attached to a light)
  45700. };
  45701. /**
  45702. * Removes all the elements in the container from the scene
  45703. * @param container contains the elements to remove
  45704. */
  45705. ShadowGeneratorSceneComponent.prototype.removeFromContainer = function (container) {
  45706. // Nothing To Do Here. (directly attached to a light)
  45707. };
  45708. /**
  45709. * Rebuilds the elements related to this component in case of
  45710. * context lost for instance.
  45711. */
  45712. ShadowGeneratorSceneComponent.prototype.dispose = function () {
  45713. // Nothing To Do Here.
  45714. };
  45715. ShadowGeneratorSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  45716. // Shadows
  45717. var scene = this.scene;
  45718. if (this.scene.shadowsEnabled) {
  45719. for (var lightIndex = 0; lightIndex < scene.lights.length; lightIndex++) {
  45720. var light = scene.lights[lightIndex];
  45721. var shadowGenerator = light.getShadowGenerator();
  45722. if (light.isEnabled() && light.shadowEnabled && shadowGenerator) {
  45723. var shadowMap = (shadowGenerator.getShadowMap());
  45724. if (scene.textures.indexOf(shadowMap) !== -1) {
  45725. renderTargets.push(shadowMap);
  45726. }
  45727. }
  45728. }
  45729. }
  45730. };
  45731. return ShadowGeneratorSceneComponent;
  45732. }());
  45733. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]._SceneComponentInitialization = function (scene) {
  45734. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR);
  45735. if (!component) {
  45736. component = new ShadowGeneratorSceneComponent(scene);
  45737. scene._addComponent(component);
  45738. }
  45739. };
  45740. /***/ }),
  45741. /***/ "./Lights/directionalLight.ts":
  45742. /*!************************************!*\
  45743. !*** ./Lights/directionalLight.ts ***!
  45744. \************************************/
  45745. /*! exports provided: DirectionalLight */
  45746. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45747. "use strict";
  45748. __webpack_require__.r(__webpack_exports__);
  45749. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return DirectionalLight; });
  45750. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45751. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  45752. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  45753. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  45754. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  45755. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  45756. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_1", function (name, scene) {
  45757. return function () { return new DirectionalLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  45758. });
  45759. /**
  45760. * A directional light is defined by a direction (what a surprise!).
  45761. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45762. * 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.
  45763. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45764. */
  45765. var DirectionalLight = /** @class */ (function (_super) {
  45766. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DirectionalLight, _super);
  45767. /**
  45768. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45769. * The directional light is emitted from everywhere in the given direction.
  45770. * It can cast shadows.
  45771. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45772. * @param name The friendly name of the light
  45773. * @param direction The direction of the light
  45774. * @param scene The scene the light belongs to
  45775. */
  45776. function DirectionalLight(name, direction, scene) {
  45777. var _this = _super.call(this, name, scene) || this;
  45778. _this._shadowFrustumSize = 0;
  45779. _this._shadowOrthoScale = 0.1;
  45780. /**
  45781. * Automatically compute the projection matrix to best fit (including all the casters)
  45782. * on each frame.
  45783. */
  45784. _this.autoUpdateExtends = true;
  45785. // Cache
  45786. _this._orthoLeft = Number.MAX_VALUE;
  45787. _this._orthoRight = Number.MIN_VALUE;
  45788. _this._orthoTop = Number.MIN_VALUE;
  45789. _this._orthoBottom = Number.MAX_VALUE;
  45790. _this.position = direction.scale(-1.0);
  45791. _this.direction = direction;
  45792. return _this;
  45793. }
  45794. Object.defineProperty(DirectionalLight.prototype, "shadowFrustumSize", {
  45795. /**
  45796. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45797. */
  45798. get: function () {
  45799. return this._shadowFrustumSize;
  45800. },
  45801. /**
  45802. * Specifies a fix frustum size for the shadow generation.
  45803. */
  45804. set: function (value) {
  45805. this._shadowFrustumSize = value;
  45806. this.forceProjectionMatrixCompute();
  45807. },
  45808. enumerable: true,
  45809. configurable: true
  45810. });
  45811. Object.defineProperty(DirectionalLight.prototype, "shadowOrthoScale", {
  45812. /**
  45813. * Gets the shadow projection scale against the optimal computed one.
  45814. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45815. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45816. */
  45817. get: function () {
  45818. return this._shadowOrthoScale;
  45819. },
  45820. /**
  45821. * Sets the shadow projection scale against the optimal computed one.
  45822. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45823. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45824. */
  45825. set: function (value) {
  45826. this._shadowOrthoScale = value;
  45827. this.forceProjectionMatrixCompute();
  45828. },
  45829. enumerable: true,
  45830. configurable: true
  45831. });
  45832. /**
  45833. * Returns the string "DirectionalLight".
  45834. * @return The class name
  45835. */
  45836. DirectionalLight.prototype.getClassName = function () {
  45837. return "DirectionalLight";
  45838. };
  45839. /**
  45840. * Returns the integer 1.
  45841. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45842. */
  45843. DirectionalLight.prototype.getTypeID = function () {
  45844. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT;
  45845. };
  45846. /**
  45847. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45848. * Returns the DirectionalLight Shadow projection matrix.
  45849. */
  45850. DirectionalLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  45851. if (this.shadowFrustumSize > 0) {
  45852. this._setDefaultFixedFrustumShadowProjectionMatrix(matrix);
  45853. }
  45854. else {
  45855. this._setDefaultAutoExtendShadowProjectionMatrix(matrix, viewMatrix, renderList);
  45856. }
  45857. };
  45858. /**
  45859. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45860. * Returns the DirectionalLight Shadow projection matrix.
  45861. */
  45862. DirectionalLight.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function (matrix) {
  45863. var activeCamera = this.getScene().activeCamera;
  45864. if (!activeCamera) {
  45865. return;
  45866. }
  45867. _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);
  45868. };
  45869. /**
  45870. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45871. * Returns the DirectionalLight Shadow projection matrix.
  45872. */
  45873. DirectionalLight.prototype._setDefaultAutoExtendShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  45874. var activeCamera = this.getScene().activeCamera;
  45875. if (!activeCamera) {
  45876. return;
  45877. }
  45878. // Check extends
  45879. if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
  45880. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  45881. this._orthoLeft = Number.MAX_VALUE;
  45882. this._orthoRight = Number.MIN_VALUE;
  45883. this._orthoTop = Number.MIN_VALUE;
  45884. this._orthoBottom = Number.MAX_VALUE;
  45885. for (var meshIndex = 0; meshIndex < renderList.length; meshIndex++) {
  45886. var mesh = renderList[meshIndex];
  45887. if (!mesh) {
  45888. continue;
  45889. }
  45890. var boundingInfo = mesh.getBoundingInfo();
  45891. var boundingBox = boundingInfo.boundingBox;
  45892. for (var index = 0; index < boundingBox.vectorsWorld.length; index++) {
  45893. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(boundingBox.vectorsWorld[index], viewMatrix, tempVector3);
  45894. if (tempVector3.x < this._orthoLeft) {
  45895. this._orthoLeft = tempVector3.x;
  45896. }
  45897. if (tempVector3.y < this._orthoBottom) {
  45898. this._orthoBottom = tempVector3.y;
  45899. }
  45900. if (tempVector3.x > this._orthoRight) {
  45901. this._orthoRight = tempVector3.x;
  45902. }
  45903. if (tempVector3.y > this._orthoTop) {
  45904. this._orthoTop = tempVector3.y;
  45905. }
  45906. }
  45907. }
  45908. }
  45909. var xOffset = this._orthoRight - this._orthoLeft;
  45910. var yOffset = this._orthoTop - this._orthoBottom;
  45911. _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);
  45912. };
  45913. DirectionalLight.prototype._buildUniformLayout = function () {
  45914. this._uniformBuffer.addUniform("vLightData", 4);
  45915. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  45916. this._uniformBuffer.addUniform("vLightSpecular", 3);
  45917. this._uniformBuffer.addUniform("shadowsInfo", 3);
  45918. this._uniformBuffer.addUniform("depthValues", 2);
  45919. this._uniformBuffer.create();
  45920. };
  45921. /**
  45922. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45923. * @param effect The effect to update
  45924. * @param lightIndex The index of the light in the effect to update
  45925. * @returns The directional light
  45926. */
  45927. DirectionalLight.prototype.transferToEffect = function (effect, lightIndex) {
  45928. if (this.computeTransformedInformation()) {
  45929. this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, lightIndex);
  45930. return this;
  45931. }
  45932. this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, lightIndex);
  45933. return this;
  45934. };
  45935. /**
  45936. * Gets the minZ used for shadow according to both the scene and the light.
  45937. *
  45938. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45939. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45940. * @param activeCamera The camera we are returning the min for
  45941. * @returns the depth min z
  45942. */
  45943. DirectionalLight.prototype.getDepthMinZ = function (activeCamera) {
  45944. return 1;
  45945. };
  45946. /**
  45947. * Gets the maxZ used for shadow according to both the scene and the light.
  45948. *
  45949. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45950. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45951. * @param activeCamera The camera we are returning the max for
  45952. * @returns the depth max z
  45953. */
  45954. DirectionalLight.prototype.getDepthMaxZ = function (activeCamera) {
  45955. return 1;
  45956. };
  45957. /**
  45958. * Prepares the list of defines specific to the light type.
  45959. * @param defines the list of defines
  45960. * @param lightIndex defines the index of the light for the effect
  45961. */
  45962. DirectionalLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  45963. defines["DIRLIGHT" + lightIndex] = true;
  45964. };
  45965. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45966. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45967. ], DirectionalLight.prototype, "shadowFrustumSize", null);
  45968. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45969. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45970. ], DirectionalLight.prototype, "shadowOrthoScale", null);
  45971. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45972. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45973. ], DirectionalLight.prototype, "autoUpdateExtends", void 0);
  45974. return DirectionalLight;
  45975. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  45976. /***/ }),
  45977. /***/ "./Lights/hemisphericLight.ts":
  45978. /*!************************************!*\
  45979. !*** ./Lights/hemisphericLight.ts ***!
  45980. \************************************/
  45981. /*! exports provided: HemisphericLight */
  45982. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45983. "use strict";
  45984. __webpack_require__.r(__webpack_exports__);
  45985. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return HemisphericLight; });
  45986. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45987. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  45988. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  45989. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  45990. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  45991. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_3", function (name, scene) {
  45992. return function () { return new HemisphericLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  45993. });
  45994. /**
  45995. * The HemisphericLight simulates the ambient environment light,
  45996. * so the passed direction is the light reflection direction, not the incoming direction.
  45997. */
  45998. var HemisphericLight = /** @class */ (function (_super) {
  45999. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HemisphericLight, _super);
  46000. /**
  46001. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  46002. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  46003. * The HemisphericLight can't cast shadows.
  46004. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46005. * @param name The friendly name of the light
  46006. * @param direction The direction of the light reflection
  46007. * @param scene The scene the light belongs to
  46008. */
  46009. function HemisphericLight(name, direction, scene) {
  46010. var _this = _super.call(this, name, scene) || this;
  46011. /**
  46012. * The groundColor is the light in the opposite direction to the one specified during creation.
  46013. * 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.
  46014. */
  46015. _this.groundColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.0, 0.0, 0.0);
  46016. _this.direction = direction || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  46017. return _this;
  46018. }
  46019. HemisphericLight.prototype._buildUniformLayout = function () {
  46020. this._uniformBuffer.addUniform("vLightData", 4);
  46021. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  46022. this._uniformBuffer.addUniform("vLightSpecular", 3);
  46023. this._uniformBuffer.addUniform("vLightGround", 3);
  46024. this._uniformBuffer.addUniform("shadowsInfo", 3);
  46025. this._uniformBuffer.addUniform("depthValues", 2);
  46026. this._uniformBuffer.create();
  46027. };
  46028. /**
  46029. * Returns the string "HemisphericLight".
  46030. * @return The class name
  46031. */
  46032. HemisphericLight.prototype.getClassName = function () {
  46033. return "HemisphericLight";
  46034. };
  46035. /**
  46036. * Sets the HemisphericLight direction towards the passed target (Vector3).
  46037. * Returns the updated direction.
  46038. * @param target The target the direction should point to
  46039. * @return The computed direction
  46040. */
  46041. HemisphericLight.prototype.setDirectionToTarget = function (target) {
  46042. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero()));
  46043. return this.direction;
  46044. };
  46045. /**
  46046. * Returns the shadow generator associated to the light.
  46047. * @returns Always null for hemispheric lights because it does not support shadows.
  46048. */
  46049. HemisphericLight.prototype.getShadowGenerator = function () {
  46050. return null;
  46051. };
  46052. /**
  46053. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  46054. * @param effect The effect to update
  46055. * @param lightIndex The index of the light in the effect to update
  46056. * @returns The hemispheric light
  46057. */
  46058. HemisphericLight.prototype.transferToEffect = function (effect, lightIndex) {
  46059. var normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  46060. this._uniformBuffer.updateFloat4("vLightData", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0.0, lightIndex);
  46061. this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), lightIndex);
  46062. return this;
  46063. };
  46064. /**
  46065. * Computes the world matrix of the node
  46066. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  46067. * @param useWasUpdatedFlag defines a reserved property
  46068. * @returns the world matrix
  46069. */
  46070. HemisphericLight.prototype.computeWorldMatrix = function () {
  46071. if (!this._worldMatrix) {
  46072. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  46073. }
  46074. return this._worldMatrix;
  46075. };
  46076. /**
  46077. * Returns the integer 3.
  46078. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46079. */
  46080. HemisphericLight.prototype.getTypeID = function () {
  46081. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_HEMISPHERICLIGHT;
  46082. };
  46083. /**
  46084. * Prepares the list of defines specific to the light type.
  46085. * @param defines the list of defines
  46086. * @param lightIndex defines the index of the light for the effect
  46087. */
  46088. HemisphericLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  46089. defines["HEMILIGHT" + lightIndex] = true;
  46090. };
  46091. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46092. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  46093. ], HemisphericLight.prototype, "groundColor", void 0);
  46094. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46095. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  46096. ], HemisphericLight.prototype, "direction", void 0);
  46097. return HemisphericLight;
  46098. }(_light__WEBPACK_IMPORTED_MODULE_4__["Light"]));
  46099. /***/ }),
  46100. /***/ "./Lights/index.ts":
  46101. /*!*************************!*\
  46102. !*** ./Lights/index.ts ***!
  46103. \*************************/
  46104. /*! exports provided: Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, ShadowGenerator, ShadowGeneratorSceneComponent */
  46105. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46106. "use strict";
  46107. __webpack_require__.r(__webpack_exports__);
  46108. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _light__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  46110. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _shadowLight__WEBPACK_IMPORTED_MODULE_1__["ShadowLight"]; });
  46112. /* harmony import */ var _Shadows_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Shadows/index */ "./Lights/Shadows/index.ts");
  46113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGenerator"]; });
  46114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGeneratorSceneComponent"]; });
  46115. /* harmony import */ var _directionalLight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./directionalLight */ "./Lights/directionalLight.ts");
  46116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _directionalLight__WEBPACK_IMPORTED_MODULE_3__["DirectionalLight"]; });
  46117. /* harmony import */ var _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hemisphericLight */ "./Lights/hemisphericLight.ts");
  46118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__["HemisphericLight"]; });
  46119. /* harmony import */ var _pointLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pointLight */ "./Lights/pointLight.ts");
  46120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _pointLight__WEBPACK_IMPORTED_MODULE_5__["PointLight"]; });
  46121. /* harmony import */ var _spotLight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./spotLight */ "./Lights/spotLight.ts");
  46122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _spotLight__WEBPACK_IMPORTED_MODULE_6__["SpotLight"]; });
  46123. /***/ }),
  46124. /***/ "./Lights/light.ts":
  46125. /*!*************************!*\
  46126. !*** ./Lights/light.ts ***!
  46127. \*************************/
  46128. /*! exports provided: Light */
  46129. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46130. "use strict";
  46131. __webpack_require__.r(__webpack_exports__);
  46132. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return Light; });
  46133. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46134. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46135. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46136. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46137. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  46138. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  46139. /**
  46140. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  46141. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  46142. * 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.
  46143. */
  46144. var Light = /** @class */ (function (_super) {
  46145. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Light, _super);
  46146. /**
  46147. * Creates a Light object in the scene.
  46148. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46149. * @param name The firendly name of the light
  46150. * @param scene The scene the light belongs too
  46151. */
  46152. function Light(name, scene) {
  46153. var _this = _super.call(this, name, scene) || this;
  46154. /**
  46155. * Diffuse gives the basic color to an object.
  46156. */
  46157. _this.diffuse = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  46158. /**
  46159. * Specular produces a highlight color on an object.
  46160. * Note: This is note affecting PBR materials.
  46161. */
  46162. _this.specular = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  46163. /**
  46164. * Defines the falloff type for this light. This lets overrriding how punctual light are
  46165. * falling off base on range or angle.
  46166. * This can be set to any values in Light.FALLOFF_x.
  46167. *
  46168. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  46169. * other types of materials.
  46170. */
  46171. _this.falloffType = Light.FALLOFF_DEFAULT;
  46172. /**
  46173. * Strength of the light.
  46174. * Note: By default it is define in the framework own unit.
  46175. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  46176. */
  46177. _this.intensity = 1.0;
  46178. _this._range = Number.MAX_VALUE;
  46179. _this._inverseSquaredRange = 0;
  46180. /**
  46181. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  46182. * of light.
  46183. */
  46184. _this._photometricScale = 1.0;
  46185. _this._intensityMode = Light.INTENSITYMODE_AUTOMATIC;
  46186. _this._radius = 0.00001;
  46187. /**
  46188. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  46189. * exceeding the number allowed of the materials.
  46190. */
  46191. _this.renderPriority = 0;
  46192. _this._shadowEnabled = true;
  46193. _this._excludeWithLayerMask = 0;
  46194. _this._includeOnlyWithLayerMask = 0;
  46195. _this._lightmapMode = 0;
  46196. /**
  46197. * @hidden Internal use only.
  46198. */
  46199. _this._excludedMeshesIds = new Array();
  46200. /**
  46201. * @hidden Internal use only.
  46202. */
  46203. _this._includedOnlyMeshesIds = new Array();
  46204. /** @hidden */
  46205. _this._isLight = true;
  46206. _this.getScene().addLight(_this);
  46207. _this._uniformBuffer = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__["UniformBuffer"](_this.getScene().getEngine());
  46208. _this._buildUniformLayout();
  46209. _this.includedOnlyMeshes = new Array();
  46210. _this.excludedMeshes = new Array();
  46211. _this._resyncMeshes();
  46212. return _this;
  46213. }
  46214. Object.defineProperty(Light.prototype, "range", {
  46215. /**
  46216. * Defines how far from the source the light is impacting in scene units.
  46217. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  46218. */
  46219. get: function () {
  46220. return this._range;
  46221. },
  46222. /**
  46223. * Defines how far from the source the light is impacting in scene units.
  46224. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  46225. */
  46226. set: function (value) {
  46227. this._range = value;
  46228. this._inverseSquaredRange = 1.0 / (this.range * this.range);
  46229. },
  46230. enumerable: true,
  46231. configurable: true
  46232. });
  46233. Object.defineProperty(Light.prototype, "intensityMode", {
  46234. /**
  46235. * Gets the photometric scale used to interpret the intensity.
  46236. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  46237. */
  46238. get: function () {
  46239. return this._intensityMode;
  46240. },
  46241. /**
  46242. * Sets the photometric scale used to interpret the intensity.
  46243. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  46244. */
  46245. set: function (value) {
  46246. this._intensityMode = value;
  46247. this._computePhotometricScale();
  46248. },
  46249. enumerable: true,
  46250. configurable: true
  46251. });
  46252. Object.defineProperty(Light.prototype, "radius", {
  46253. /**
  46254. * Gets the light radius used by PBR Materials to simulate soft area lights.
  46255. */
  46256. get: function () {
  46257. return this._radius;
  46258. },
  46259. /**
  46260. * sets the light radius used by PBR Materials to simulate soft area lights.
  46261. */
  46262. set: function (value) {
  46263. this._radius = value;
  46264. this._computePhotometricScale();
  46265. },
  46266. enumerable: true,
  46267. configurable: true
  46268. });
  46269. Object.defineProperty(Light.prototype, "shadowEnabled", {
  46270. /**
  46271. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  46272. * the current shadow generator.
  46273. */
  46274. get: function () {
  46275. return this._shadowEnabled;
  46276. },
  46277. /**
  46278. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  46279. * the current shadow generator.
  46280. */
  46281. set: function (value) {
  46282. if (this._shadowEnabled === value) {
  46283. return;
  46284. }
  46285. this._shadowEnabled = value;
  46286. this._markMeshesAsLightDirty();
  46287. },
  46288. enumerable: true,
  46289. configurable: true
  46290. });
  46291. Object.defineProperty(Light.prototype, "includedOnlyMeshes", {
  46292. /**
  46293. * Gets the only meshes impacted by this light.
  46294. */
  46295. get: function () {
  46296. return this._includedOnlyMeshes;
  46297. },
  46298. /**
  46299. * Sets the only meshes impacted by this light.
  46300. */
  46301. set: function (value) {
  46302. this._includedOnlyMeshes = value;
  46303. this._hookArrayForIncludedOnly(value);
  46304. },
  46305. enumerable: true,
  46306. configurable: true
  46307. });
  46308. Object.defineProperty(Light.prototype, "excludedMeshes", {
  46309. /**
  46310. * Gets the meshes not impacted by this light.
  46311. */
  46312. get: function () {
  46313. return this._excludedMeshes;
  46314. },
  46315. /**
  46316. * Sets the meshes not impacted by this light.
  46317. */
  46318. set: function (value) {
  46319. this._excludedMeshes = value;
  46320. this._hookArrayForExcluded(value);
  46321. },
  46322. enumerable: true,
  46323. configurable: true
  46324. });
  46325. Object.defineProperty(Light.prototype, "excludeWithLayerMask", {
  46326. /**
  46327. * Gets the layer id use to find what meshes are not impacted by the light.
  46328. * Inactive if 0
  46329. */
  46330. get: function () {
  46331. return this._excludeWithLayerMask;
  46332. },
  46333. /**
  46334. * Sets the layer id use to find what meshes are not impacted by the light.
  46335. * Inactive if 0
  46336. */
  46337. set: function (value) {
  46338. this._excludeWithLayerMask = value;
  46339. this._resyncMeshes();
  46340. },
  46341. enumerable: true,
  46342. configurable: true
  46343. });
  46344. Object.defineProperty(Light.prototype, "includeOnlyWithLayerMask", {
  46345. /**
  46346. * Gets the layer id use to find what meshes are impacted by the light.
  46347. * Inactive if 0
  46348. */
  46349. get: function () {
  46350. return this._includeOnlyWithLayerMask;
  46351. },
  46352. /**
  46353. * Sets the layer id use to find what meshes are impacted by the light.
  46354. * Inactive if 0
  46355. */
  46356. set: function (value) {
  46357. this._includeOnlyWithLayerMask = value;
  46358. this._resyncMeshes();
  46359. },
  46360. enumerable: true,
  46361. configurable: true
  46362. });
  46363. Object.defineProperty(Light.prototype, "lightmapMode", {
  46364. /**
  46365. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  46366. */
  46367. get: function () {
  46368. return this._lightmapMode;
  46369. },
  46370. /**
  46371. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  46372. */
  46373. set: function (value) {
  46374. if (this._lightmapMode === value) {
  46375. return;
  46376. }
  46377. this._lightmapMode = value;
  46378. this._markMeshesAsLightDirty();
  46379. },
  46380. enumerable: true,
  46381. configurable: true
  46382. });
  46383. /**
  46384. * Returns the string "Light".
  46385. * @returns the class name
  46386. */
  46387. Light.prototype.getClassName = function () {
  46388. return "Light";
  46389. };
  46390. /**
  46391. * Converts the light information to a readable string for debug purpose.
  46392. * @param fullDetails Supports for multiple levels of logging within scene loading
  46393. * @returns the human readable light info
  46394. */
  46395. Light.prototype.toString = function (fullDetails) {
  46396. var ret = "Name: " + this.name;
  46397. ret += ", type: " + (["Point", "Directional", "Spot", "Hemispheric"])[this.getTypeID()];
  46398. if (this.animations) {
  46399. for (var i = 0; i < this.animations.length; i++) {
  46400. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  46401. }
  46402. }
  46403. if (fullDetails) {
  46404. }
  46405. return ret;
  46406. };
  46407. /** @hidden */
  46408. Light.prototype._syncParentEnabledState = function () {
  46409. _super.prototype._syncParentEnabledState.call(this);
  46410. this._resyncMeshes();
  46411. };
  46412. /**
  46413. * Set the enabled state of this node.
  46414. * @param value - the new enabled state
  46415. */
  46416. Light.prototype.setEnabled = function (value) {
  46417. _super.prototype.setEnabled.call(this, value);
  46418. this._resyncMeshes();
  46419. };
  46420. /**
  46421. * Returns the Light associated shadow generator if any.
  46422. * @return the associated shadow generator.
  46423. */
  46424. Light.prototype.getShadowGenerator = function () {
  46425. return this._shadowGenerator;
  46426. };
  46427. /**
  46428. * Returns a Vector3, the absolute light position in the World.
  46429. * @returns the world space position of the light
  46430. */
  46431. Light.prototype.getAbsolutePosition = function () {
  46432. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46433. };
  46434. /**
  46435. * Specifies if the light will affect the passed mesh.
  46436. * @param mesh The mesh to test against the light
  46437. * @return true the mesh is affected otherwise, false.
  46438. */
  46439. Light.prototype.canAffectMesh = function (mesh) {
  46440. if (!mesh) {
  46441. return true;
  46442. }
  46443. if (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {
  46444. return false;
  46445. }
  46446. if (this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  46447. return false;
  46448. }
  46449. if (this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & mesh.layerMask) === 0) {
  46450. return false;
  46451. }
  46452. if (this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & mesh.layerMask) {
  46453. return false;
  46454. }
  46455. return true;
  46456. };
  46457. /**
  46458. * Sort function to order lights for rendering.
  46459. * @param a First Light object to compare to second.
  46460. * @param b Second Light object to compare first.
  46461. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  46462. */
  46463. Light.CompareLightsPriority = function (a, b) {
  46464. //shadow-casting lights have priority over non-shadow-casting lights
  46465. //the renderPrioirty is a secondary sort criterion
  46466. if (a.shadowEnabled !== b.shadowEnabled) {
  46467. return (b.shadowEnabled ? 1 : 0) - (a.shadowEnabled ? 1 : 0);
  46468. }
  46469. return b.renderPriority - a.renderPriority;
  46470. };
  46471. /**
  46472. * Releases resources associated with this node.
  46473. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46474. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46475. */
  46476. Light.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  46477. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  46478. if (this._shadowGenerator) {
  46479. this._shadowGenerator.dispose();
  46480. this._shadowGenerator = null;
  46481. }
  46482. // Animations
  46483. this.getScene().stopAnimation(this);
  46484. // Remove from meshes
  46485. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  46486. var mesh = _a[_i];
  46487. mesh._removeLightSource(this);
  46488. }
  46489. this._uniformBuffer.dispose();
  46490. // Remove from scene
  46491. this.getScene().removeLight(this);
  46492. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  46493. };
  46494. /**
  46495. * Returns the light type ID (integer).
  46496. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46497. */
  46498. Light.prototype.getTypeID = function () {
  46499. return 0;
  46500. };
  46501. /**
  46502. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  46503. * @returns the scaled intensity in intensity mode unit
  46504. */
  46505. Light.prototype.getScaledIntensity = function () {
  46506. return this._photometricScale * this.intensity;
  46507. };
  46508. /**
  46509. * Returns a new Light object, named "name", from the current one.
  46510. * @param name The name of the cloned light
  46511. * @returns the new created light
  46512. */
  46513. Light.prototype.clone = function (name) {
  46514. var constructor = Light.GetConstructorFromName(this.getTypeID(), name, this.getScene());
  46515. if (!constructor) {
  46516. return null;
  46517. }
  46518. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(constructor, this);
  46519. };
  46520. /**
  46521. * Serializes the current light into a Serialization object.
  46522. * @returns the serialized object.
  46523. */
  46524. Light.prototype.serialize = function () {
  46525. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  46526. // Type
  46527. serializationObject.type = this.getTypeID();
  46528. // Parent
  46529. if (this.parent) {
  46530. serializationObject.parentId = this.parent.id;
  46531. }
  46532. // Inclusion / exclusions
  46533. if (this.excludedMeshes.length > 0) {
  46534. serializationObject.excludedMeshesIds = [];
  46535. this.excludedMeshes.forEach(function (mesh) {
  46536. serializationObject.excludedMeshesIds.push(mesh.id);
  46537. });
  46538. }
  46539. if (this.includedOnlyMeshes.length > 0) {
  46540. serializationObject.includedOnlyMeshesIds = [];
  46541. this.includedOnlyMeshes.forEach(function (mesh) {
  46542. serializationObject.includedOnlyMeshesIds.push(mesh.id);
  46543. });
  46544. }
  46545. // Animations
  46546. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  46547. serializationObject.ranges = this.serializeAnimationRanges();
  46548. return serializationObject;
  46549. };
  46550. /**
  46551. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  46552. * This new light is named "name" and added to the passed scene.
  46553. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  46554. * @param name The friendly name of the light
  46555. * @param scene The scene the new light will belong to
  46556. * @returns the constructor function
  46557. */
  46558. Light.GetConstructorFromName = function (type, name, scene) {
  46559. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_3__["Node"].Construct("Light_Type_" + type, name, scene);
  46560. if (constructorFunc) {
  46561. return constructorFunc;
  46562. }
  46563. // Default to no light for none present once.
  46564. return null;
  46565. };
  46566. /**
  46567. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  46568. * @param parsedLight The JSON representation of the light
  46569. * @param scene The scene to create the parsed light in
  46570. * @returns the created light after parsing
  46571. */
  46572. Light.Parse = function (parsedLight, scene) {
  46573. var constructor = Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene);
  46574. if (!constructor) {
  46575. return null;
  46576. }
  46577. var light = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(constructor, parsedLight, scene);
  46578. // Inclusion / exclusions
  46579. if (parsedLight.excludedMeshesIds) {
  46580. light._excludedMeshesIds = parsedLight.excludedMeshesIds;
  46581. }
  46582. if (parsedLight.includedOnlyMeshesIds) {
  46583. light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
  46584. }
  46585. // Parent
  46586. if (parsedLight.parentId) {
  46587. light._waitingParentId = parsedLight.parentId;
  46588. }
  46589. // Animations
  46590. if (parsedLight.animations) {
  46591. for (var animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {
  46592. var parsedAnimation = parsedLight.animations[animationIndex];
  46593. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  46594. if (internalClass) {
  46595. light.animations.push(internalClass.Parse(parsedAnimation));
  46596. }
  46597. }
  46598. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].ParseAnimationRanges(light, parsedLight, scene);
  46599. }
  46600. if (parsedLight.autoAnimate) {
  46601. scene.beginAnimation(light, parsedLight.autoAnimateFrom, parsedLight.autoAnimateTo, parsedLight.autoAnimateLoop, parsedLight.autoAnimateSpeed || 1.0);
  46602. }
  46603. return light;
  46604. };
  46605. Light.prototype._hookArrayForExcluded = function (array) {
  46606. var _this = this;
  46607. var oldPush = array.push;
  46608. array.push = function () {
  46609. var items = [];
  46610. for (var _i = 0; _i < arguments.length; _i++) {
  46611. items[_i] = arguments[_i];
  46612. }
  46613. var result = oldPush.apply(array, items);
  46614. for (var _a = 0, items_1 = items; _a < items_1.length; _a++) {
  46615. var item = items_1[_a];
  46616. item._resyncLighSource(_this);
  46617. }
  46618. return result;
  46619. };
  46620. var oldSplice = array.splice;
  46621. array.splice = function (index, deleteCount) {
  46622. var deleted = oldSplice.apply(array, [index, deleteCount]);
  46623. for (var _i = 0, deleted_1 = deleted; _i < deleted_1.length; _i++) {
  46624. var item = deleted_1[_i];
  46625. item._resyncLighSource(_this);
  46626. }
  46627. return deleted;
  46628. };
  46629. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  46630. var item = array_1[_i];
  46631. item._resyncLighSource(this);
  46632. }
  46633. };
  46634. Light.prototype._hookArrayForIncludedOnly = function (array) {
  46635. var _this = this;
  46636. var oldPush = array.push;
  46637. array.push = function () {
  46638. var items = [];
  46639. for (var _i = 0; _i < arguments.length; _i++) {
  46640. items[_i] = arguments[_i];
  46641. }
  46642. var result = oldPush.apply(array, items);
  46643. _this._resyncMeshes();
  46644. return result;
  46645. };
  46646. var oldSplice = array.splice;
  46647. array.splice = function (index, deleteCount) {
  46648. var deleted = oldSplice.apply(array, [index, deleteCount]);
  46649. _this._resyncMeshes();
  46650. return deleted;
  46651. };
  46652. this._resyncMeshes();
  46653. };
  46654. Light.prototype._resyncMeshes = function () {
  46655. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  46656. var mesh = _a[_i];
  46657. mesh._resyncLighSource(this);
  46658. }
  46659. };
  46660. /**
  46661. * Forces the meshes to update their light related information in their rendering used effects
  46662. * @hidden Internal Use Only
  46663. */
  46664. Light.prototype._markMeshesAsLightDirty = function () {
  46665. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  46666. var mesh = _a[_i];
  46667. if (mesh._lightSources.indexOf(this) !== -1) {
  46668. mesh._markSubMeshesAsLightDirty();
  46669. }
  46670. }
  46671. };
  46672. /**
  46673. * Recomputes the cached photometric scale if needed.
  46674. */
  46675. Light.prototype._computePhotometricScale = function () {
  46676. this._photometricScale = this._getPhotometricScale();
  46677. this.getScene().resetCachedMaterial();
  46678. };
  46679. /**
  46680. * Returns the Photometric Scale according to the light type and intensity mode.
  46681. */
  46682. Light.prototype._getPhotometricScale = function () {
  46683. var photometricScale = 0.0;
  46684. var lightTypeID = this.getTypeID();
  46685. //get photometric mode
  46686. var photometricMode = this.intensityMode;
  46687. if (photometricMode === Light.INTENSITYMODE_AUTOMATIC) {
  46688. if (lightTypeID === Light.LIGHTTYPEID_DIRECTIONALLIGHT) {
  46689. photometricMode = Light.INTENSITYMODE_ILLUMINANCE;
  46690. }
  46691. else {
  46692. photometricMode = Light.INTENSITYMODE_LUMINOUSINTENSITY;
  46693. }
  46694. }
  46695. //compute photometric scale
  46696. switch (lightTypeID) {
  46697. case Light.LIGHTTYPEID_POINTLIGHT:
  46698. case Light.LIGHTTYPEID_SPOTLIGHT:
  46699. switch (photometricMode) {
  46700. case Light.INTENSITYMODE_LUMINOUSPOWER:
  46701. photometricScale = 1.0 / (4.0 * Math.PI);
  46702. break;
  46703. case Light.INTENSITYMODE_LUMINOUSINTENSITY:
  46704. photometricScale = 1.0;
  46705. break;
  46706. case Light.INTENSITYMODE_LUMINANCE:
  46707. photometricScale = this.radius * this.radius;
  46708. break;
  46709. }
  46710. break;
  46711. case Light.LIGHTTYPEID_DIRECTIONALLIGHT:
  46712. switch (photometricMode) {
  46713. case Light.INTENSITYMODE_ILLUMINANCE:
  46714. photometricScale = 1.0;
  46715. break;
  46716. case Light.INTENSITYMODE_LUMINANCE:
  46717. // When radius (and therefore solid angle) is non-zero a directional lights brightness can be specified via central (peak) luminance.
  46718. // For a directional light the 'radius' defines the angular radius (in radians) rather than world-space radius (e.g. in metres).
  46719. var apexAngleRadians = this.radius;
  46720. // Impose a minimum light angular size to avoid the light becoming an infinitely small angular light source (i.e. a dirac delta function).
  46721. apexAngleRadians = Math.max(apexAngleRadians, 0.001);
  46722. var solidAngle = 2.0 * Math.PI * (1.0 - Math.cos(apexAngleRadians));
  46723. photometricScale = solidAngle;
  46724. break;
  46725. }
  46726. break;
  46727. case Light.LIGHTTYPEID_HEMISPHERICLIGHT:
  46728. // No fall off in hemisperic light.
  46729. photometricScale = 1.0;
  46730. break;
  46731. }
  46732. return photometricScale;
  46733. };
  46734. /**
  46735. * Reorder the light in the scene according to their defined priority.
  46736. * @hidden Internal Use Only
  46737. */
  46738. Light.prototype._reorderLightsInScene = function () {
  46739. var scene = this.getScene();
  46740. if (this._renderPriority != 0) {
  46741. scene.requireLightSorting = true;
  46742. }
  46743. this.getScene().sortLightsByPriority();
  46744. };
  46745. /**
  46746. * Falloff Default: light is falling off following the material specification:
  46747. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  46748. */
  46749. Light.FALLOFF_DEFAULT = 0;
  46750. /**
  46751. * Falloff Physical: light is falling off following the inverse squared distance law.
  46752. */
  46753. Light.FALLOFF_PHYSICAL = 1;
  46754. /**
  46755. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  46756. * to enhance interoperability with other engines.
  46757. */
  46758. Light.FALLOFF_GLTF = 2;
  46759. /**
  46760. * Falloff Standard: light is falling off like in the standard material
  46761. * to enhance interoperability with other materials.
  46762. */
  46763. Light.FALLOFF_STANDARD = 3;
  46764. //lightmapMode Consts
  46765. /**
  46766. * If every light affecting the material is in this lightmapMode,
  46767. * material.lightmapTexture adds or multiplies
  46768. * (depends on material.useLightmapAsShadowmap)
  46769. * after every other light calculations.
  46770. */
  46771. Light.LIGHTMAP_DEFAULT = 0;
  46772. /**
  46773. * material.lightmapTexture as only diffuse lighting from this light
  46774. * adds only specular lighting from this light
  46775. * adds dynamic shadows
  46776. */
  46777. Light.LIGHTMAP_SPECULAR = 1;
  46778. /**
  46779. * material.lightmapTexture as only lighting
  46780. * no light calculation from this light
  46781. * only adds dynamic shadows from this light
  46782. */
  46783. Light.LIGHTMAP_SHADOWSONLY = 2;
  46784. // Intensity Mode Consts
  46785. /**
  46786. * Each light type uses the default quantity according to its type:
  46787. * point/spot lights use luminous intensity
  46788. * directional lights use illuminance
  46789. */
  46790. Light.INTENSITYMODE_AUTOMATIC = 0;
  46791. /**
  46792. * lumen (lm)
  46793. */
  46794. Light.INTENSITYMODE_LUMINOUSPOWER = 1;
  46795. /**
  46796. * candela (lm/sr)
  46797. */
  46798. Light.INTENSITYMODE_LUMINOUSINTENSITY = 2;
  46799. /**
  46800. * lux (lm/m^2)
  46801. */
  46802. Light.INTENSITYMODE_ILLUMINANCE = 3;
  46803. /**
  46804. * nit (cd/m^2)
  46805. */
  46806. Light.INTENSITYMODE_LUMINANCE = 4;
  46807. // Light types ids const.
  46808. /**
  46809. * Light type const id of the point light.
  46810. */
  46811. Light.LIGHTTYPEID_POINTLIGHT = 0;
  46812. /**
  46813. * Light type const id of the directional light.
  46814. */
  46815. Light.LIGHTTYPEID_DIRECTIONALLIGHT = 1;
  46816. /**
  46817. * Light type const id of the spot light.
  46818. */
  46819. Light.LIGHTTYPEID_SPOTLIGHT = 2;
  46820. /**
  46821. * Light type const id of the hemispheric light.
  46822. */
  46823. Light.LIGHTTYPEID_HEMISPHERICLIGHT = 3;
  46824. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  46826. ], Light.prototype, "diffuse", void 0);
  46827. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46828. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  46829. ], Light.prototype, "specular", void 0);
  46830. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46831. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46832. ], Light.prototype, "falloffType", void 0);
  46833. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46834. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46835. ], Light.prototype, "intensity", void 0);
  46836. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46837. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46838. ], Light.prototype, "range", null);
  46839. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46840. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46841. ], Light.prototype, "intensityMode", null);
  46842. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46843. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46844. ], Light.prototype, "radius", null);
  46845. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46846. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46847. ], Light.prototype, "_renderPriority", void 0);
  46848. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46849. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_reorderLightsInScene")
  46850. ], Light.prototype, "renderPriority", void 0);
  46851. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46852. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("shadowEnabled")
  46853. ], Light.prototype, "_shadowEnabled", void 0);
  46854. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46855. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("excludeWithLayerMask")
  46856. ], Light.prototype, "_excludeWithLayerMask", void 0);
  46857. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46858. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("includeOnlyWithLayerMask")
  46859. ], Light.prototype, "_includeOnlyWithLayerMask", void 0);
  46860. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46861. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("lightmapMode")
  46862. ], Light.prototype, "_lightmapMode", void 0);
  46863. return Light;
  46864. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  46865. /***/ }),
  46866. /***/ "./Lights/pointLight.ts":
  46867. /*!******************************!*\
  46868. !*** ./Lights/pointLight.ts ***!
  46869. \******************************/
  46870. /*! exports provided: PointLight */
  46871. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46872. "use strict";
  46873. __webpack_require__.r(__webpack_exports__);
  46874. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return PointLight; });
  46875. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46876. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46877. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46878. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46879. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46880. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46881. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_0", function (name, scene) {
  46882. return function () { return new PointLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  46883. });
  46884. /**
  46885. * A point light is a light defined by an unique point in world space.
  46886. * The light is emitted in every direction from this point.
  46887. * A good example of a point light is a standard light bulb.
  46888. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46889. */
  46890. var PointLight = /** @class */ (function (_super) {
  46891. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointLight, _super);
  46892. /**
  46893. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  46894. * A PointLight emits the light in every direction.
  46895. * It can cast shadows.
  46896. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  46897. * ```javascript
  46898. * var pointLight = new PointLight("pl", camera.position, scene);
  46899. * ```
  46900. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46901. * @param name The light friendly name
  46902. * @param position The position of the point light in the scene
  46903. * @param scene The scene the lights belongs to
  46904. */
  46905. function PointLight(name, position, scene) {
  46906. var _this = _super.call(this, name, scene) || this;
  46907. _this._shadowAngle = Math.PI / 2;
  46908. _this.position = position;
  46909. return _this;
  46910. }
  46911. Object.defineProperty(PointLight.prototype, "shadowAngle", {
  46912. /**
  46913. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46914. * This specifies what angle the shadow will use to be created.
  46915. *
  46916. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46917. */
  46918. get: function () {
  46919. return this._shadowAngle;
  46920. },
  46921. /**
  46922. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46923. * This specifies what angle the shadow will use to be created.
  46924. *
  46925. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46926. */
  46927. set: function (value) {
  46928. this._shadowAngle = value;
  46929. this.forceProjectionMatrixCompute();
  46930. },
  46931. enumerable: true,
  46932. configurable: true
  46933. });
  46934. Object.defineProperty(PointLight.prototype, "direction", {
  46935. /**
  46936. * Gets the direction if it has been set.
  46937. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46938. */
  46939. get: function () {
  46940. return this._direction;
  46941. },
  46942. /**
  46943. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46944. */
  46945. set: function (value) {
  46946. var previousNeedCube = this.needCube();
  46947. this._direction = value;
  46948. if (this.needCube() !== previousNeedCube && this._shadowGenerator) {
  46949. this._shadowGenerator.recreateShadowMap();
  46950. }
  46951. },
  46952. enumerable: true,
  46953. configurable: true
  46954. });
  46955. /**
  46956. * Returns the string "PointLight"
  46957. * @returns the class name
  46958. */
  46959. PointLight.prototype.getClassName = function () {
  46960. return "PointLight";
  46961. };
  46962. /**
  46963. * Returns the integer 0.
  46964. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46965. */
  46966. PointLight.prototype.getTypeID = function () {
  46967. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_POINTLIGHT;
  46968. };
  46969. /**
  46970. * Specifies wether or not the shadowmap should be a cube texture.
  46971. * @returns true if the shadowmap needs to be a cube texture.
  46972. */
  46973. PointLight.prototype.needCube = function () {
  46974. return !this.direction;
  46975. };
  46976. /**
  46977. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  46978. * @param faceIndex The index of the face we are computed the direction to generate shadow
  46979. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  46980. */
  46981. PointLight.prototype.getShadowDirection = function (faceIndex) {
  46982. if (this.direction) {
  46983. return _super.prototype.getShadowDirection.call(this, faceIndex);
  46984. }
  46985. else {
  46986. switch (faceIndex) {
  46987. case 0:
  46988. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1.0, 0.0, 0.0);
  46989. case 1:
  46990. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](-1.0, 0.0, 0.0);
  46991. case 2:
  46992. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, -1.0, 0.0);
  46993. case 3:
  46994. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 1.0, 0.0);
  46995. case 4:
  46996. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, 1.0);
  46997. case 5:
  46998. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, -1.0);
  46999. }
  47000. }
  47001. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47002. };
  47003. /**
  47004. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47005. * - fov = PI / 2
  47006. * - aspect ratio : 1.0
  47007. * - z-near and far equal to the active camera minZ and maxZ.
  47008. * Returns the PointLight.
  47009. */
  47010. PointLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47011. var activeCamera = this.getScene().activeCamera;
  47012. if (!activeCamera) {
  47013. return;
  47014. }
  47015. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(this.shadowAngle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  47016. };
  47017. PointLight.prototype._buildUniformLayout = function () {
  47018. this._uniformBuffer.addUniform("vLightData", 4);
  47019. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  47020. this._uniformBuffer.addUniform("vLightSpecular", 3);
  47021. this._uniformBuffer.addUniform("vLightFalloff", 4);
  47022. this._uniformBuffer.addUniform("shadowsInfo", 3);
  47023. this._uniformBuffer.addUniform("depthValues", 2);
  47024. this._uniformBuffer.create();
  47025. };
  47026. /**
  47027. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47028. * @param effect The effect to update
  47029. * @param lightIndex The index of the light in the effect to update
  47030. * @returns The point light
  47031. */
  47032. PointLight.prototype.transferToEffect = function (effect, lightIndex) {
  47033. if (this.computeTransformedInformation()) {
  47034. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0.0, lightIndex);
  47035. }
  47036. else {
  47037. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, lightIndex);
  47038. }
  47039. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, lightIndex);
  47040. return this;
  47041. };
  47042. /**
  47043. * Prepares the list of defines specific to the light type.
  47044. * @param defines the list of defines
  47045. * @param lightIndex defines the index of the light for the effect
  47046. */
  47047. PointLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  47048. defines["POINTLIGHT" + lightIndex] = true;
  47049. };
  47050. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47051. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47052. ], PointLight.prototype, "shadowAngle", null);
  47053. return PointLight;
  47054. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  47055. /***/ }),
  47056. /***/ "./Lights/shadowLight.ts":
  47057. /*!*******************************!*\
  47058. !*** ./Lights/shadowLight.ts ***!
  47059. \*******************************/
  47060. /*! exports provided: ShadowLight */
  47061. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47062. "use strict";
  47063. __webpack_require__.r(__webpack_exports__);
  47064. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return ShadowLight; });
  47065. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47066. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47067. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47068. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47069. /**
  47070. * Base implementation IShadowLight
  47071. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  47072. */
  47073. var ShadowLight = /** @class */ (function (_super) {
  47074. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowLight, _super);
  47075. function ShadowLight() {
  47076. var _this = _super !== null && _super.apply(this, arguments) || this;
  47077. _this._needProjectionMatrixCompute = true;
  47078. return _this;
  47079. }
  47080. ShadowLight.prototype._setPosition = function (value) {
  47081. this._position = value;
  47082. };
  47083. Object.defineProperty(ShadowLight.prototype, "position", {
  47084. /**
  47085. * Sets the position the shadow will be casted from. Also use as the light position for both
  47086. * point and spot lights.
  47087. */
  47088. get: function () {
  47089. return this._position;
  47090. },
  47091. /**
  47092. * Sets the position the shadow will be casted from. Also use as the light position for both
  47093. * point and spot lights.
  47094. */
  47095. set: function (value) {
  47096. this._setPosition(value);
  47097. },
  47098. enumerable: true,
  47099. configurable: true
  47100. });
  47101. ShadowLight.prototype._setDirection = function (value) {
  47102. this._direction = value;
  47103. };
  47104. Object.defineProperty(ShadowLight.prototype, "direction", {
  47105. /**
  47106. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  47107. * Also use as the light direction on spot and directional lights.
  47108. */
  47109. get: function () {
  47110. return this._direction;
  47111. },
  47112. /**
  47113. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  47114. * Also use as the light direction on spot and directional lights.
  47115. */
  47116. set: function (value) {
  47117. this._setDirection(value);
  47118. },
  47119. enumerable: true,
  47120. configurable: true
  47121. });
  47122. Object.defineProperty(ShadowLight.prototype, "shadowMinZ", {
  47123. /**
  47124. * Gets the shadow projection clipping minimum z value.
  47125. */
  47126. get: function () {
  47127. return this._shadowMinZ;
  47128. },
  47129. /**
  47130. * Sets the shadow projection clipping minimum z value.
  47131. */
  47132. set: function (value) {
  47133. this._shadowMinZ = value;
  47134. this.forceProjectionMatrixCompute();
  47135. },
  47136. enumerable: true,
  47137. configurable: true
  47138. });
  47139. Object.defineProperty(ShadowLight.prototype, "shadowMaxZ", {
  47140. /**
  47141. * Sets the shadow projection clipping maximum z value.
  47142. */
  47143. get: function () {
  47144. return this._shadowMaxZ;
  47145. },
  47146. /**
  47147. * Gets the shadow projection clipping maximum z value.
  47148. */
  47149. set: function (value) {
  47150. this._shadowMaxZ = value;
  47151. this.forceProjectionMatrixCompute();
  47152. },
  47153. enumerable: true,
  47154. configurable: true
  47155. });
  47156. /**
  47157. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  47158. * @returns true if the information has been computed, false if it does not need to (no parenting)
  47159. */
  47160. ShadowLight.prototype.computeTransformedInformation = function () {
  47161. if (this.parent && this.parent.getWorldMatrix) {
  47162. if (!this.transformedPosition) {
  47163. this.transformedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47164. }
  47165. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
  47166. // In case the direction is present.
  47167. if (this.direction) {
  47168. if (!this.transformedDirection) {
  47169. this.transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47170. }
  47171. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection);
  47172. }
  47173. return true;
  47174. }
  47175. return false;
  47176. };
  47177. /**
  47178. * Return the depth scale used for the shadow map.
  47179. * @returns the depth scale.
  47180. */
  47181. ShadowLight.prototype.getDepthScale = function () {
  47182. return 50.0;
  47183. };
  47184. /**
  47185. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  47186. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47187. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47188. */
  47189. ShadowLight.prototype.getShadowDirection = function (faceIndex) {
  47190. return this.transformedDirection ? this.transformedDirection : this.direction;
  47191. };
  47192. /**
  47193. * Returns the ShadowLight absolute position in the World.
  47194. * @returns the position vector in world space
  47195. */
  47196. ShadowLight.prototype.getAbsolutePosition = function () {
  47197. return this.transformedPosition ? this.transformedPosition : this.position;
  47198. };
  47199. /**
  47200. * Sets the ShadowLight direction toward the passed target.
  47201. * @param target The point to target in local space
  47202. * @returns the updated ShadowLight direction
  47203. */
  47204. ShadowLight.prototype.setDirectionToTarget = function (target) {
  47205. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(this.position));
  47206. return this.direction;
  47207. };
  47208. /**
  47209. * Returns the light rotation in euler definition.
  47210. * @returns the x y z rotation in local space.
  47211. */
  47212. ShadowLight.prototype.getRotation = function () {
  47213. this.direction.normalize();
  47214. var xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y);
  47215. var yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(xaxis, this.direction);
  47216. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].RotationFromAxis(xaxis, yaxis, this.direction);
  47217. };
  47218. /**
  47219. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  47220. * @returns true if a cube texture needs to be use
  47221. */
  47222. ShadowLight.prototype.needCube = function () {
  47223. return false;
  47224. };
  47225. /**
  47226. * Detects if the projection matrix requires to be recomputed this frame.
  47227. * @returns true if it requires to be recomputed otherwise, false.
  47228. */
  47229. ShadowLight.prototype.needProjectionMatrixCompute = function () {
  47230. return this._needProjectionMatrixCompute;
  47231. };
  47232. /**
  47233. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  47234. */
  47235. ShadowLight.prototype.forceProjectionMatrixCompute = function () {
  47236. this._needProjectionMatrixCompute = true;
  47237. };
  47238. /** @hidden */
  47239. ShadowLight.prototype._initCache = function () {
  47240. _super.prototype._initCache.call(this);
  47241. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47242. };
  47243. /** @hidden */
  47244. ShadowLight.prototype._isSynchronized = function () {
  47245. if (!this._cache.position.equals(this.position)) {
  47246. return false;
  47247. }
  47248. return true;
  47249. };
  47250. /**
  47251. * Computes the world matrix of the node
  47252. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  47253. * @returns the world matrix
  47254. */
  47255. ShadowLight.prototype.computeWorldMatrix = function (force) {
  47256. if (!force && this.isSynchronized()) {
  47257. this._currentRenderId = this.getScene().getRenderId();
  47258. return this._worldMatrix;
  47259. }
  47260. this._updateCache();
  47261. this._cache.position.copyFrom(this.position);
  47262. if (!this._worldMatrix) {
  47263. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  47264. }
  47265. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
  47266. if (this.parent && this.parent.getWorldMatrix) {
  47267. this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  47268. this._markSyncedWithParent();
  47269. }
  47270. // Cache the determinant
  47271. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  47272. return this._worldMatrix;
  47273. };
  47274. /**
  47275. * Gets the minZ used for shadow according to both the scene and the light.
  47276. * @param activeCamera The camera we are returning the min for
  47277. * @returns the depth min z
  47278. */
  47279. ShadowLight.prototype.getDepthMinZ = function (activeCamera) {
  47280. return this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ;
  47281. };
  47282. /**
  47283. * Gets the maxZ used for shadow according to both the scene and the light.
  47284. * @param activeCamera The camera we are returning the max for
  47285. * @returns the depth max z
  47286. */
  47287. ShadowLight.prototype.getDepthMaxZ = function (activeCamera) {
  47288. return this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;
  47289. };
  47290. /**
  47291. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  47292. * @param matrix The materix to updated with the projection information
  47293. * @param viewMatrix The transform matrix of the light
  47294. * @param renderList The list of mesh to render in the map
  47295. * @returns The current light
  47296. */
  47297. ShadowLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47298. if (this.customProjectionMatrixBuilder) {
  47299. this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
  47300. }
  47301. else {
  47302. this._setDefaultShadowProjectionMatrix(matrix, viewMatrix, renderList);
  47303. }
  47304. return this;
  47305. };
  47306. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47307. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  47308. ], ShadowLight.prototype, "position", null);
  47309. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47310. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  47311. ], ShadowLight.prototype, "direction", null);
  47312. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47313. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47314. ], ShadowLight.prototype, "shadowMinZ", null);
  47315. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47316. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47317. ], ShadowLight.prototype, "shadowMaxZ", null);
  47318. return ShadowLight;
  47319. }(_light__WEBPACK_IMPORTED_MODULE_3__["Light"]));
  47320. /***/ }),
  47321. /***/ "./Lights/spotLight.ts":
  47322. /*!*****************************!*\
  47323. !*** ./Lights/spotLight.ts ***!
  47324. \*****************************/
  47325. /*! exports provided: SpotLight */
  47326. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47327. "use strict";
  47328. __webpack_require__.r(__webpack_exports__);
  47329. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return SpotLight; });
  47330. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47331. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47332. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47333. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  47334. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47335. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  47336. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_2", function (name, scene) {
  47337. 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); };
  47338. });
  47339. /**
  47340. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47341. * These values define a cone of light starting from the position, emitting toward the direction.
  47342. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47343. * and the exponent defines the speed of the decay of the light with distance (reach).
  47344. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47345. */
  47346. var SpotLight = /** @class */ (function (_super) {
  47347. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpotLight, _super);
  47348. /**
  47349. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47350. * It can cast shadows.
  47351. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47352. * @param name The light friendly name
  47353. * @param position The position of the spot light in the scene
  47354. * @param direction The direction of the light in the scene
  47355. * @param angle The cone angle of the light in Radians
  47356. * @param exponent The light decay speed with the distance from the emission spot
  47357. * @param scene The scene the lights belongs to
  47358. */
  47359. function SpotLight(name, position, direction, angle, exponent, scene) {
  47360. var _this = _super.call(this, name, scene) || this;
  47361. _this._innerAngle = 0;
  47362. _this._projectionTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  47363. _this._projectionTextureLightNear = 1e-6;
  47364. _this._projectionTextureLightFar = 1000.0;
  47365. _this._projectionTextureUpDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  47366. _this._projectionTextureViewLightDirty = true;
  47367. _this._projectionTextureProjectionLightDirty = true;
  47368. _this._projectionTextureDirty = true;
  47369. _this._projectionTextureViewTargetVector = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47370. _this._projectionTextureViewLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  47371. _this._projectionTextureProjectionLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  47372. _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);
  47373. _this.position = position;
  47374. _this.direction = direction;
  47375. _this.angle = angle;
  47376. _this.exponent = exponent;
  47377. return _this;
  47378. }
  47379. Object.defineProperty(SpotLight.prototype, "angle", {
  47380. /**
  47381. * Gets the cone angle of the spot light in Radians.
  47382. */
  47383. get: function () {
  47384. return this._angle;
  47385. },
  47386. /**
  47387. * Sets the cone angle of the spot light in Radians.
  47388. */
  47389. set: function (value) {
  47390. this._angle = value;
  47391. this._cosHalfAngle = Math.cos(value * 0.5);
  47392. this._projectionTextureProjectionLightDirty = true;
  47393. this.forceProjectionMatrixCompute();
  47394. this._computeAngleValues();
  47395. },
  47396. enumerable: true,
  47397. configurable: true
  47398. });
  47399. Object.defineProperty(SpotLight.prototype, "innerAngle", {
  47400. /**
  47401. * Only used in gltf falloff mode, this defines the angle where
  47402. * the directional falloff will start before cutting at angle which could be seen
  47403. * as outer angle.
  47404. */
  47405. get: function () {
  47406. return this._innerAngle;
  47407. },
  47408. /**
  47409. * Only used in gltf falloff mode, this defines the angle where
  47410. * the directional falloff will start before cutting at angle which could be seen
  47411. * as outer angle.
  47412. */
  47413. set: function (value) {
  47414. this._innerAngle = value;
  47415. this._computeAngleValues();
  47416. },
  47417. enumerable: true,
  47418. configurable: true
  47419. });
  47420. Object.defineProperty(SpotLight.prototype, "shadowAngleScale", {
  47421. /**
  47422. * Allows scaling the angle of the light for shadow generation only.
  47423. */
  47424. get: function () {
  47425. return this._shadowAngleScale;
  47426. },
  47427. /**
  47428. * Allows scaling the angle of the light for shadow generation only.
  47429. */
  47430. set: function (value) {
  47431. this._shadowAngleScale = value;
  47432. this.forceProjectionMatrixCompute();
  47433. },
  47434. enumerable: true,
  47435. configurable: true
  47436. });
  47437. Object.defineProperty(SpotLight.prototype, "projectionTextureMatrix", {
  47438. /**
  47439. * Allows reading the projecton texture
  47440. */
  47441. get: function () {
  47442. return this._projectionTextureMatrix;
  47443. },
  47444. enumerable: true,
  47445. configurable: true
  47446. });
  47447. Object.defineProperty(SpotLight.prototype, "projectionTextureLightNear", {
  47448. /**
  47449. * Gets the near clip of the Spotlight for texture projection.
  47450. */
  47451. get: function () {
  47452. return this._projectionTextureLightNear;
  47453. },
  47454. /**
  47455. * Sets the near clip of the Spotlight for texture projection.
  47456. */
  47457. set: function (value) {
  47458. this._projectionTextureLightNear = value;
  47459. this._projectionTextureProjectionLightDirty = true;
  47460. },
  47461. enumerable: true,
  47462. configurable: true
  47463. });
  47464. Object.defineProperty(SpotLight.prototype, "projectionTextureLightFar", {
  47465. /**
  47466. * Gets the far clip of the Spotlight for texture projection.
  47467. */
  47468. get: function () {
  47469. return this._projectionTextureLightFar;
  47470. },
  47471. /**
  47472. * Sets the far clip of the Spotlight for texture projection.
  47473. */
  47474. set: function (value) {
  47475. this._projectionTextureLightFar = value;
  47476. this._projectionTextureProjectionLightDirty = true;
  47477. },
  47478. enumerable: true,
  47479. configurable: true
  47480. });
  47481. Object.defineProperty(SpotLight.prototype, "projectionTextureUpDirection", {
  47482. /**
  47483. * Gets the Up vector of the Spotlight for texture projection.
  47484. */
  47485. get: function () {
  47486. return this._projectionTextureUpDirection;
  47487. },
  47488. /**
  47489. * Sets the Up vector of the Spotlight for texture projection.
  47490. */
  47491. set: function (value) {
  47492. this._projectionTextureUpDirection = value;
  47493. this._projectionTextureProjectionLightDirty = true;
  47494. },
  47495. enumerable: true,
  47496. configurable: true
  47497. });
  47498. Object.defineProperty(SpotLight.prototype, "projectionTexture", {
  47499. /**
  47500. * Gets the projection texture of the light.
  47501. */
  47502. get: function () {
  47503. return this._projectionTexture;
  47504. },
  47505. /**
  47506. * Sets the projection texture of the light.
  47507. */
  47508. set: function (value) {
  47509. this._projectionTexture = value;
  47510. this._projectionTextureDirty = true;
  47511. },
  47512. enumerable: true,
  47513. configurable: true
  47514. });
  47515. /**
  47516. * Returns the string "SpotLight".
  47517. * @returns the class name
  47518. */
  47519. SpotLight.prototype.getClassName = function () {
  47520. return "SpotLight";
  47521. };
  47522. /**
  47523. * Returns the integer 2.
  47524. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47525. */
  47526. SpotLight.prototype.getTypeID = function () {
  47527. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_SPOTLIGHT;
  47528. };
  47529. /**
  47530. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47531. */
  47532. SpotLight.prototype._setDirection = function (value) {
  47533. _super.prototype._setDirection.call(this, value);
  47534. this._projectionTextureViewLightDirty = true;
  47535. };
  47536. /**
  47537. * Overrides the position setter to recompute the projection texture view light Matrix.
  47538. */
  47539. SpotLight.prototype._setPosition = function (value) {
  47540. _super.prototype._setPosition.call(this, value);
  47541. this._projectionTextureViewLightDirty = true;
  47542. };
  47543. /**
  47544. * 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.
  47545. * Returns the SpotLight.
  47546. */
  47547. SpotLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47548. var activeCamera = this.getScene().activeCamera;
  47549. if (!activeCamera) {
  47550. return;
  47551. }
  47552. this._shadowAngleScale = this._shadowAngleScale || 1;
  47553. var angle = this._shadowAngleScale * this._angle;
  47554. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(angle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  47555. };
  47556. SpotLight.prototype._computeProjectionTextureViewLightMatrix = function () {
  47557. this._projectionTextureViewLightDirty = false;
  47558. this._projectionTextureDirty = true;
  47559. this.position.addToRef(this.direction, this._projectionTextureViewTargetVector);
  47560. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].LookAtLHToRef(this.position, this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix);
  47561. };
  47562. SpotLight.prototype._computeProjectionTextureProjectionLightMatrix = function () {
  47563. this._projectionTextureProjectionLightDirty = false;
  47564. this._projectionTextureDirty = true;
  47565. var light_far = this.projectionTextureLightFar;
  47566. var light_near = this.projectionTextureLightNear;
  47567. var P = light_far / (light_far - light_near);
  47568. var Q = -P * light_near;
  47569. var S = 1.0 / Math.tan(this._angle / 2.0);
  47570. var A = 1.0;
  47571. _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);
  47572. };
  47573. /**
  47574. * Main function for light texture projection matrix computing.
  47575. */
  47576. SpotLight.prototype._computeProjectionTextureMatrix = function () {
  47577. this._projectionTextureDirty = false;
  47578. this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix);
  47579. this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix);
  47580. };
  47581. SpotLight.prototype._buildUniformLayout = function () {
  47582. this._uniformBuffer.addUniform("vLightData", 4);
  47583. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  47584. this._uniformBuffer.addUniform("vLightSpecular", 3);
  47585. this._uniformBuffer.addUniform("vLightDirection", 3);
  47586. this._uniformBuffer.addUniform("vLightFalloff", 4);
  47587. this._uniformBuffer.addUniform("shadowsInfo", 3);
  47588. this._uniformBuffer.addUniform("depthValues", 2);
  47589. this._uniformBuffer.create();
  47590. };
  47591. SpotLight.prototype._computeAngleValues = function () {
  47592. this._lightAngleScale = 1.0 / Math.max(0.001, (Math.cos(this._innerAngle * 0.5) - this._cosHalfAngle));
  47593. this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale;
  47594. };
  47595. /**
  47596. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47597. * @param effect The effect to update
  47598. * @param lightIndex The index of the light in the effect to update
  47599. * @returns The spot light
  47600. */
  47601. SpotLight.prototype.transferToEffect = function (effect, lightIndex) {
  47602. var normalizeDirection;
  47603. if (this.computeTransformedInformation()) {
  47604. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, lightIndex);
  47605. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.transformedDirection);
  47606. }
  47607. else {
  47608. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, lightIndex);
  47609. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  47610. }
  47611. this._uniformBuffer.updateFloat4("vLightDirection", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, this._cosHalfAngle, lightIndex);
  47612. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, lightIndex);
  47613. if (this.projectionTexture && this.projectionTexture.isReady()) {
  47614. if (this._projectionTextureViewLightDirty) {
  47615. this._computeProjectionTextureViewLightMatrix();
  47616. }
  47617. if (this._projectionTextureProjectionLightDirty) {
  47618. this._computeProjectionTextureProjectionLightMatrix();
  47619. }
  47620. if (this._projectionTextureDirty) {
  47621. this._computeProjectionTextureMatrix();
  47622. }
  47623. effect.setMatrix("textureProjectionMatrix" + lightIndex, this._projectionTextureMatrix);
  47624. effect.setTexture("projectionLightSampler" + lightIndex, this.projectionTexture);
  47625. }
  47626. return this;
  47627. };
  47628. /**
  47629. * Disposes the light and the associated resources.
  47630. */
  47631. SpotLight.prototype.dispose = function () {
  47632. _super.prototype.dispose.call(this);
  47633. if (this._projectionTexture) {
  47634. this._projectionTexture.dispose();
  47635. }
  47636. };
  47637. /**
  47638. * Prepares the list of defines specific to the light type.
  47639. * @param defines the list of defines
  47640. * @param lightIndex defines the index of the light for the effect
  47641. */
  47642. SpotLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  47643. defines["SPOTLIGHT" + lightIndex] = true;
  47644. defines["PROJECTEDLIGHTTEXTURE" + lightIndex] = this.projectionTexture ? true : false;
  47645. };
  47646. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47647. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47648. ], SpotLight.prototype, "angle", null);
  47649. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47650. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47651. ], SpotLight.prototype, "innerAngle", null);
  47652. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47653. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47654. ], SpotLight.prototype, "shadowAngleScale", null);
  47655. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47656. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47657. ], SpotLight.prototype, "exponent", void 0);
  47658. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47659. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47660. ], SpotLight.prototype, "projectionTextureLightNear", null);
  47661. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47662. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47663. ], SpotLight.prototype, "projectionTextureLightFar", null);
  47664. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47665. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47666. ], SpotLight.prototype, "projectionTextureUpDirection", null);
  47667. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47668. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("projectedLightTexture")
  47669. ], SpotLight.prototype, "_projectionTexture", void 0);
  47670. return SpotLight;
  47671. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  47672. /***/ }),
  47673. /***/ "./Loading/Plugins/babylonFileLoader.ts":
  47674. /*!**********************************************!*\
  47675. !*** ./Loading/Plugins/babylonFileLoader.ts ***!
  47676. \**********************************************/
  47677. /*! exports provided: _BabylonLoaderRegistered */
  47678. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47679. "use strict";
  47680. __webpack_require__.r(__webpack_exports__);
  47681. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _BabylonLoaderRegistered; });
  47682. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  47683. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  47684. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  47685. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  47686. /* harmony import */ var _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/geometry */ "./Meshes/geometry.ts");
  47687. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/transformNode */ "./Meshes/transformNode.ts");
  47688. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  47689. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  47690. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  47691. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  47692. /* harmony import */ var _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Animations/animationGroup */ "./Animations/animationGroup.ts");
  47693. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  47694. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  47695. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  47696. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  47697. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../assetContainer */ "./assetContainer.ts");
  47698. /* harmony import */ var _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Actions/actionManager */ "./Actions/actionManager.ts");
  47699. /* harmony import */ var _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Bones/skeleton */ "./Bones/skeleton.ts");
  47700. /* harmony import */ var _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Morph/morphTargetManager */ "./Morph/morphTargetManager.ts");
  47701. /* harmony import */ var _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Physics/Plugins/cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  47702. /* harmony import */ var _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Physics/Plugins/oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  47703. /* harmony import */ var _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Probes/reflectionProbe */ "./Probes/reflectionProbe.ts");
  47704. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  47705. /** @hidden */
  47706. var _BabylonLoaderRegistered = true;
  47707. var parseMaterialById = function (id, parsedData, scene, rootUrl) {
  47708. for (var index = 0, cache = parsedData.materials.length; index < cache; index++) {
  47709. var parsedMaterial = parsedData.materials[index];
  47710. if (parsedMaterial.id === id) {
  47711. return _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  47712. }
  47713. }
  47714. return null;
  47715. };
  47716. var isDescendantOf = function (mesh, names, hierarchyIds) {
  47717. for (var i in names) {
  47718. if (mesh.name === names[i]) {
  47719. hierarchyIds.push(mesh.id);
  47720. return true;
  47721. }
  47722. }
  47723. if (mesh.parentId && hierarchyIds.indexOf(mesh.parentId) !== -1) {
  47724. hierarchyIds.push(mesh.id);
  47725. return true;
  47726. }
  47727. return false;
  47728. };
  47729. var logOperation = function (operation, producer) {
  47730. return operation + " of " + (producer ? producer.file + " from " + producer.name + " version: " + producer.version + ", exporter version: " + producer.exporter_version : "unknown");
  47731. };
  47732. var loadAssetContainer = function (scene, data, rootUrl, onError, addToScene) {
  47733. if (addToScene === void 0) { addToScene = false; }
  47734. var container = new _assetContainer__WEBPACK_IMPORTED_MODULE_15__["AssetContainer"](scene);
  47735. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  47736. // when SceneLoader.debugLogging = true (default), or exception encountered.
  47737. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  47738. // and avoid problems with multiple concurrent .babylon loads.
  47739. var log = "importScene has failed JSON parse";
  47740. try {
  47741. var parsedData = JSON.parse(data);
  47742. log = "";
  47743. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  47744. var index;
  47745. var cache;
  47746. // Lights
  47747. if (parsedData.lights !== undefined && parsedData.lights !== null) {
  47748. for (index = 0, cache = parsedData.lights.length; index < cache; index++) {
  47749. var parsedLight = parsedData.lights[index];
  47750. var light = _Lights_light__WEBPACK_IMPORTED_MODULE_11__["Light"].Parse(parsedLight, scene);
  47751. if (light) {
  47752. container.lights.push(light);
  47753. log += (index === 0 ? "\n\tLights:" : "");
  47754. log += "\n\t\t" + light.toString(fullDetails);
  47755. }
  47756. }
  47757. }
  47758. // Reflection probes
  47759. if (parsedData.reflectionProbes !== undefined && parsedData.reflectionProbes !== null) {
  47760. for (index = 0, cache = parsedData.reflectionProbes.length; index < cache; index++) {
  47761. var parsedReflectionProbe = parsedData.reflectionProbes[index];
  47762. var reflectionProbe = _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_21__["ReflectionProbe"].Parse(parsedReflectionProbe, scene, rootUrl);
  47763. if (reflectionProbe) {
  47764. container.reflectionProbes.push(reflectionProbe);
  47765. log += (index === 0 ? "\n\tReflection Probes:" : "");
  47766. log += "\n\t\t" + reflectionProbe.toString(fullDetails);
  47767. }
  47768. }
  47769. }
  47770. // Animations
  47771. if (parsedData.animations !== undefined && parsedData.animations !== null) {
  47772. for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
  47773. var parsedAnimation = parsedData.animations[index];
  47774. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_22__["_TypeStore"].GetClass("BABYLON.Animation");
  47775. if (internalClass) {
  47776. var animation = internalClass.Parse(parsedAnimation);
  47777. scene.animations.push(animation);
  47778. container.animations.push(animation);
  47779. log += (index === 0 ? "\n\tAnimations:" : "");
  47780. log += "\n\t\t" + animation.toString(fullDetails);
  47781. }
  47782. }
  47783. }
  47784. // Materials
  47785. if (parsedData.materials !== undefined && parsedData.materials !== null) {
  47786. for (index = 0, cache = parsedData.materials.length; index < cache; index++) {
  47787. var parsedMaterial = parsedData.materials[index];
  47788. var mat = _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  47789. container.materials.push(mat);
  47790. log += (index === 0 ? "\n\tMaterials:" : "");
  47791. log += "\n\t\t" + mat.toString(fullDetails);
  47792. }
  47793. }
  47794. if (parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  47795. for (index = 0, cache = parsedData.multiMaterials.length; index < cache; index++) {
  47796. var parsedMultiMaterial = parsedData.multiMaterials[index];
  47797. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  47798. container.multiMaterials.push(mmat);
  47799. log += (index === 0 ? "\n\tMultiMaterials:" : "");
  47800. log += "\n\t\t" + mmat.toString(fullDetails);
  47801. }
  47802. }
  47803. // Morph targets
  47804. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  47805. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  47806. var managerData = _a[_i];
  47807. container.morphTargetManagers.push(_Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene));
  47808. }
  47809. }
  47810. // Skeletons
  47811. if (parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  47812. for (index = 0, cache = parsedData.skeletons.length; index < cache; index++) {
  47813. var parsedSkeleton = parsedData.skeletons[index];
  47814. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  47815. container.skeletons.push(skeleton);
  47816. log += (index === 0 ? "\n\tSkeletons:" : "");
  47817. log += "\n\t\t" + skeleton.toString(fullDetails);
  47818. }
  47819. }
  47820. // Geometries
  47821. var geometries = parsedData.geometries;
  47822. if (geometries !== undefined && geometries !== null) {
  47823. var addedGeometry = new Array();
  47824. // VertexData
  47825. var vertexData = geometries.vertexData;
  47826. if (vertexData !== undefined && vertexData !== null) {
  47827. for (index = 0, cache = vertexData.length; index < cache; index++) {
  47828. var parsedVertexData = vertexData[index];
  47829. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedVertexData, scene, rootUrl));
  47830. }
  47831. }
  47832. addedGeometry.forEach(function (g) {
  47833. if (g) {
  47834. container.geometries.push(g);
  47835. }
  47836. });
  47837. }
  47838. // Transform nodes
  47839. if (parsedData.transformNodes !== undefined && parsedData.transformNodes !== null) {
  47840. for (index = 0, cache = parsedData.transformNodes.length; index < cache; index++) {
  47841. var parsedTransformNode = parsedData.transformNodes[index];
  47842. var node = _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__["TransformNode"].Parse(parsedTransformNode, scene, rootUrl);
  47843. container.transformNodes.push(node);
  47844. }
  47845. }
  47846. // Meshes
  47847. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  47848. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  47849. var parsedMesh = parsedData.meshes[index];
  47850. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  47851. container.meshes.push(mesh);
  47852. log += (index === 0 ? "\n\tMeshes:" : "");
  47853. log += "\n\t\t" + mesh.toString(fullDetails);
  47854. }
  47855. }
  47856. // Cameras
  47857. if (parsedData.cameras !== undefined && parsedData.cameras !== null) {
  47858. for (index = 0, cache = parsedData.cameras.length; index < cache; index++) {
  47859. var parsedCamera = parsedData.cameras[index];
  47860. var camera = _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].Parse(parsedCamera, scene);
  47861. container.cameras.push(camera);
  47862. log += (index === 0 ? "\n\tCameras:" : "");
  47863. log += "\n\t\t" + camera.toString(fullDetails);
  47864. }
  47865. }
  47866. // Animation Groups
  47867. if (parsedData.animationGroups !== undefined && parsedData.animationGroups !== null) {
  47868. for (index = 0, cache = parsedData.animationGroups.length; index < cache; index++) {
  47869. var parsedAnimationGroup = parsedData.animationGroups[index];
  47870. var animationGroup = _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__["AnimationGroup"].Parse(parsedAnimationGroup, scene);
  47871. container.animationGroups.push(animationGroup);
  47872. log += (index === 0 ? "\n\tAnimationGroups:" : "");
  47873. log += "\n\t\t" + animationGroup.toString(fullDetails);
  47874. }
  47875. }
  47876. // Browsing all the graph to connect the dots
  47877. for (index = 0, cache = scene.cameras.length; index < cache; index++) {
  47878. var camera = scene.cameras[index];
  47879. if (camera._waitingParentId) {
  47880. camera.parent = scene.getLastEntryByID(camera._waitingParentId);
  47881. camera._waitingParentId = null;
  47882. }
  47883. }
  47884. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  47885. var light_1 = scene.lights[index];
  47886. if (light_1 && light_1._waitingParentId) {
  47887. light_1.parent = scene.getLastEntryByID(light_1._waitingParentId);
  47888. light_1._waitingParentId = null;
  47889. }
  47890. }
  47891. // Connect parents & children and parse actions
  47892. for (index = 0, cache = scene.transformNodes.length; index < cache; index++) {
  47893. var transformNode = scene.transformNodes[index];
  47894. if (transformNode._waitingParentId) {
  47895. transformNode.parent = scene.getLastEntryByID(transformNode._waitingParentId);
  47896. transformNode._waitingParentId = null;
  47897. }
  47898. }
  47899. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47900. var mesh = scene.meshes[index];
  47901. if (mesh._waitingParentId) {
  47902. mesh.parent = scene.getLastEntryByID(mesh._waitingParentId);
  47903. mesh._waitingParentId = null;
  47904. }
  47905. }
  47906. // freeze world matrix application
  47907. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47908. var currentMesh = scene.meshes[index];
  47909. if (currentMesh._waitingFreezeWorldMatrix) {
  47910. currentMesh.freezeWorldMatrix();
  47911. currentMesh._waitingFreezeWorldMatrix = null;
  47912. }
  47913. else {
  47914. currentMesh.computeWorldMatrix(true);
  47915. }
  47916. }
  47917. // Lights exclusions / inclusions
  47918. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  47919. var light_2 = scene.lights[index];
  47920. // Excluded check
  47921. if (light_2._excludedMeshesIds.length > 0) {
  47922. for (var excludedIndex = 0; excludedIndex < light_2._excludedMeshesIds.length; excludedIndex++) {
  47923. var excludedMesh = scene.getMeshByID(light_2._excludedMeshesIds[excludedIndex]);
  47924. if (excludedMesh) {
  47925. light_2.excludedMeshes.push(excludedMesh);
  47926. }
  47927. }
  47928. light_2._excludedMeshesIds = [];
  47929. }
  47930. // Included check
  47931. if (light_2._includedOnlyMeshesIds.length > 0) {
  47932. for (var includedOnlyIndex = 0; includedOnlyIndex < light_2._includedOnlyMeshesIds.length; includedOnlyIndex++) {
  47933. var includedOnlyMesh = scene.getMeshByID(light_2._includedOnlyMeshesIds[includedOnlyIndex]);
  47934. if (includedOnlyMesh) {
  47935. light_2.includedOnlyMeshes.push(includedOnlyMesh);
  47936. }
  47937. }
  47938. light_2._includedOnlyMeshesIds = [];
  47939. }
  47940. }
  47941. _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].Parse(parsedData, scene, container, rootUrl);
  47942. // Actions (scene) Done last as it can access other objects.
  47943. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47944. var mesh = scene.meshes[index];
  47945. if (mesh._waitingActions) {
  47946. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(mesh._waitingActions, mesh, scene);
  47947. mesh._waitingActions = null;
  47948. }
  47949. }
  47950. if (parsedData.actions !== undefined && parsedData.actions !== null) {
  47951. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(parsedData.actions, null, scene);
  47952. }
  47953. if (!addToScene) {
  47954. container.removeAllFromScene();
  47955. }
  47956. }
  47957. catch (err) {
  47958. var msg = logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + log;
  47959. if (onError) {
  47960. onError(msg, err);
  47961. }
  47962. else {
  47963. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  47964. throw err;
  47965. }
  47966. }
  47967. finally {
  47968. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  47969. _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 : ""));
  47970. }
  47971. }
  47972. return container;
  47973. };
  47974. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].RegisterPlugin({
  47975. name: "babylon.js",
  47976. extensions: ".babylon",
  47977. canDirectLoad: function (data) {
  47978. if (data.indexOf("babylon") !== -1) { // We consider that the producer string is filled
  47979. return true;
  47980. }
  47981. return false;
  47982. },
  47983. importMesh: function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons, onError) {
  47984. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  47985. // when SceneLoader.debugLogging = true (default), or exception encountered.
  47986. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  47987. // and avoid problems with multiple concurrent .babylon loads.
  47988. var log = "importMesh has failed JSON parse";
  47989. try {
  47990. var parsedData = JSON.parse(data);
  47991. log = "";
  47992. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  47993. if (!meshesNames) {
  47994. meshesNames = null;
  47995. }
  47996. else if (!Array.isArray(meshesNames)) {
  47997. meshesNames = [meshesNames];
  47998. }
  47999. var hierarchyIds = new Array();
  48000. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  48001. var loadedSkeletonsIds = [];
  48002. var loadedMaterialsIds = [];
  48003. var index;
  48004. var cache;
  48005. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  48006. var parsedMesh = parsedData.meshes[index];
  48007. if (meshesNames === null || isDescendantOf(parsedMesh, meshesNames, hierarchyIds)) {
  48008. if (meshesNames !== null) {
  48009. // Remove found mesh name from list.
  48010. delete meshesNames[meshesNames.indexOf(parsedMesh.name)];
  48011. }
  48012. //Geometry?
  48013. if (parsedMesh.geometryId !== undefined && parsedMesh.geometryId !== null) {
  48014. //does the file contain geometries?
  48015. if (parsedData.geometries !== undefined && parsedData.geometries !== null) {
  48016. //find the correct geometry and add it to the scene
  48017. var found = false;
  48018. ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach(function (geometryType) {
  48019. if (found === true || !parsedData.geometries[geometryType] || !(Array.isArray(parsedData.geometries[geometryType]))) {
  48020. return;
  48021. }
  48022. else {
  48023. parsedData.geometries[geometryType].forEach(function (parsedGeometryData) {
  48024. if (parsedGeometryData.id === parsedMesh.geometryId) {
  48025. switch (geometryType) {
  48026. case "vertexData":
  48027. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedGeometryData, scene, rootUrl);
  48028. break;
  48029. }
  48030. found = true;
  48031. }
  48032. });
  48033. }
  48034. });
  48035. if (found === false) {
  48036. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Geometry not found for mesh " + parsedMesh.id);
  48037. }
  48038. }
  48039. }
  48040. // Material ?
  48041. if (parsedMesh.materialId) {
  48042. var materialFound = (loadedMaterialsIds.indexOf(parsedMesh.materialId) !== -1);
  48043. if (materialFound === false && parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  48044. for (var multimatIndex = 0, multimatCache = parsedData.multiMaterials.length; multimatIndex < multimatCache; multimatIndex++) {
  48045. var parsedMultiMaterial = parsedData.multiMaterials[multimatIndex];
  48046. if (parsedMultiMaterial.id === parsedMesh.materialId) {
  48047. for (var matIndex = 0, matCache = parsedMultiMaterial.materials.length; matIndex < matCache; matIndex++) {
  48048. var subMatId = parsedMultiMaterial.materials[matIndex];
  48049. loadedMaterialsIds.push(subMatId);
  48050. var mat = parseMaterialById(subMatId, parsedData, scene, rootUrl);
  48051. if (mat) {
  48052. log += "\n\tMaterial " + mat.toString(fullDetails);
  48053. }
  48054. }
  48055. loadedMaterialsIds.push(parsedMultiMaterial.id);
  48056. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  48057. if (mmat) {
  48058. materialFound = true;
  48059. log += "\n\tMulti-Material " + mmat.toString(fullDetails);
  48060. }
  48061. break;
  48062. }
  48063. }
  48064. }
  48065. if (materialFound === false) {
  48066. loadedMaterialsIds.push(parsedMesh.materialId);
  48067. var mat = parseMaterialById(parsedMesh.materialId, parsedData, scene, rootUrl);
  48068. if (!mat) {
  48069. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Material not found for mesh " + parsedMesh.id);
  48070. }
  48071. else {
  48072. log += "\n\tMaterial " + mat.toString(fullDetails);
  48073. }
  48074. }
  48075. }
  48076. // Skeleton ?
  48077. if (parsedMesh.skeletonId > -1 && parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  48078. var skeletonAlreadyLoaded = (loadedSkeletonsIds.indexOf(parsedMesh.skeletonId) > -1);
  48079. if (skeletonAlreadyLoaded === false) {
  48080. for (var skeletonIndex = 0, skeletonCache = parsedData.skeletons.length; skeletonIndex < skeletonCache; skeletonIndex++) {
  48081. var parsedSkeleton = parsedData.skeletons[skeletonIndex];
  48082. if (parsedSkeleton.id === parsedMesh.skeletonId) {
  48083. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  48084. skeletons.push(skeleton);
  48085. loadedSkeletonsIds.push(parsedSkeleton.id);
  48086. log += "\n\tSkeleton " + skeleton.toString(fullDetails);
  48087. }
  48088. }
  48089. }
  48090. }
  48091. // Morph targets ?
  48092. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  48093. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  48094. var managerData = _a[_i];
  48095. _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene);
  48096. }
  48097. }
  48098. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  48099. meshes.push(mesh);
  48100. log += "\n\tMesh " + mesh.toString(fullDetails);
  48101. }
  48102. }
  48103. // Connecting parents
  48104. var currentMesh;
  48105. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48106. currentMesh = scene.meshes[index];
  48107. if (currentMesh._waitingParentId) {
  48108. currentMesh.parent = scene.getLastEntryByID(currentMesh._waitingParentId);
  48109. currentMesh._waitingParentId = null;
  48110. }
  48111. }
  48112. // freeze and compute world matrix application
  48113. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48114. currentMesh = scene.meshes[index];
  48115. if (currentMesh._waitingFreezeWorldMatrix) {
  48116. currentMesh.freezeWorldMatrix();
  48117. currentMesh._waitingFreezeWorldMatrix = null;
  48118. }
  48119. else {
  48120. currentMesh.computeWorldMatrix(true);
  48121. }
  48122. }
  48123. }
  48124. // Particles
  48125. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  48126. var parser = _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_12__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  48127. if (parser) {
  48128. for (index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  48129. var parsedParticleSystem = parsedData.particleSystems[index];
  48130. if (hierarchyIds.indexOf(parsedParticleSystem.emitterId) !== -1) {
  48131. particleSystems.push(parser(parsedParticleSystem, scene, rootUrl));
  48132. }
  48133. }
  48134. }
  48135. }
  48136. return true;
  48137. }
  48138. catch (err) {
  48139. var msg = logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + log;
  48140. if (onError) {
  48141. onError(msg, err);
  48142. }
  48143. else {
  48144. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  48145. throw err;
  48146. }
  48147. }
  48148. finally {
  48149. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  48150. _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 : ""));
  48151. }
  48152. }
  48153. return false;
  48154. },
  48155. load: function (scene, data, rootUrl, onError) {
  48156. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  48157. // when SceneLoader.debugLogging = true (default), or exception encountered.
  48158. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  48159. // and avoid problems with multiple concurrent .babylon loads.
  48160. var log = "importScene has failed JSON parse";
  48161. try {
  48162. var parsedData = JSON.parse(data);
  48163. log = "";
  48164. // Scene
  48165. if (parsedData.useDelayedTextureLoading !== undefined && parsedData.useDelayedTextureLoading !== null) {
  48166. scene.useDelayedTextureLoading = parsedData.useDelayedTextureLoading && !_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].ForceFullSceneLoadingForIncremental;
  48167. }
  48168. if (parsedData.autoClear !== undefined && parsedData.autoClear !== null) {
  48169. scene.autoClear = parsedData.autoClear;
  48170. }
  48171. if (parsedData.clearColor !== undefined && parsedData.clearColor !== null) {
  48172. scene.clearColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(parsedData.clearColor);
  48173. }
  48174. if (parsedData.ambientColor !== undefined && parsedData.ambientColor !== null) {
  48175. scene.ambientColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.ambientColor);
  48176. }
  48177. if (parsedData.gravity !== undefined && parsedData.gravity !== null) {
  48178. scene.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.gravity);
  48179. }
  48180. // Fog
  48181. if (parsedData.fogMode && parsedData.fogMode !== 0) {
  48182. scene.fogMode = parsedData.fogMode;
  48183. scene.fogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.fogColor);
  48184. scene.fogStart = parsedData.fogStart;
  48185. scene.fogEnd = parsedData.fogEnd;
  48186. scene.fogDensity = parsedData.fogDensity;
  48187. log += "\tFog mode for scene: ";
  48188. switch (scene.fogMode) {
  48189. // getters not compiling, so using hardcoded
  48190. case 1:
  48191. log += "exp\n";
  48192. break;
  48193. case 2:
  48194. log += "exp2\n";
  48195. break;
  48196. case 3:
  48197. log += "linear\n";
  48198. break;
  48199. }
  48200. }
  48201. //Physics
  48202. if (parsedData.physicsEnabled) {
  48203. var physicsPlugin;
  48204. if (parsedData.physicsEngine === "cannon") {
  48205. physicsPlugin = new _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__["CannonJSPlugin"]();
  48206. }
  48207. else if (parsedData.physicsEngine === "oimo") {
  48208. physicsPlugin = new _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__["OimoJSPlugin"]();
  48209. }
  48210. log = "\tPhysics engine " + (parsedData.physicsEngine ? parsedData.physicsEngine : "oimo") + " enabled\n";
  48211. //else - default engine, which is currently oimo
  48212. var physicsGravity = parsedData.physicsGravity ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.physicsGravity) : null;
  48213. scene.enablePhysics(physicsGravity, physicsPlugin);
  48214. }
  48215. // Metadata
  48216. if (parsedData.metadata !== undefined && parsedData.metadata !== null) {
  48217. scene.metadata = parsedData.metadata;
  48218. }
  48219. //collisions, if defined. otherwise, default is true
  48220. if (parsedData.collisionsEnabled !== undefined && parsedData.collisionsEnabled !== null) {
  48221. scene.collisionsEnabled = parsedData.collisionsEnabled;
  48222. }
  48223. var container = loadAssetContainer(scene, data, rootUrl, onError, true);
  48224. if (!container) {
  48225. return false;
  48226. }
  48227. if (parsedData.autoAnimate) {
  48228. scene.beginAnimation(scene, parsedData.autoAnimateFrom, parsedData.autoAnimateTo, parsedData.autoAnimateLoop, parsedData.autoAnimateSpeed || 1.0);
  48229. }
  48230. if (parsedData.activeCameraID !== undefined && parsedData.activeCameraID !== null) {
  48231. scene.setActiveCameraByID(parsedData.activeCameraID);
  48232. }
  48233. // Environment texture
  48234. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  48235. // PBR needed for both HDR texture (gamma space) & a sky box
  48236. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  48237. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  48238. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  48239. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__["HDRCubeTexture"](rootUrl + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  48240. if (parsedData.environmentTextureRotationY) {
  48241. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  48242. }
  48243. scene.environmentTexture = hdrTexture;
  48244. }
  48245. else {
  48246. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(rootUrl + parsedData.environmentTexture, scene);
  48247. if (parsedData.environmentTextureRotationY) {
  48248. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  48249. }
  48250. scene.environmentTexture = cubeTexture;
  48251. }
  48252. if (parsedData.createDefaultSkybox === true) {
  48253. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  48254. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  48255. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  48256. }
  48257. }
  48258. // Finish
  48259. return true;
  48260. }
  48261. catch (err) {
  48262. var msg = logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + log;
  48263. if (onError) {
  48264. onError(msg, err);
  48265. }
  48266. else {
  48267. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  48268. throw err;
  48269. }
  48270. }
  48271. finally {
  48272. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  48273. _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 : ""));
  48274. }
  48275. }
  48276. return false;
  48277. },
  48278. loadAssetContainer: function (scene, data, rootUrl, onError) {
  48279. var container = loadAssetContainer(scene, data, rootUrl, onError);
  48280. return container;
  48281. }
  48282. });
  48283. /***/ }),
  48284. /***/ "./Loading/Plugins/index.ts":
  48285. /*!**********************************!*\
  48286. !*** ./Loading/Plugins/index.ts ***!
  48287. \**********************************/
  48288. /*! exports provided: _BabylonLoaderRegistered */
  48289. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48290. "use strict";
  48291. __webpack_require__.r(__webpack_exports__);
  48292. /* harmony import */ var _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./babylonFileLoader */ "./Loading/Plugins/babylonFileLoader.ts");
  48293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  48294. /***/ }),
  48295. /***/ "./Loading/index.ts":
  48296. /*!**************************!*\
  48297. !*** ./Loading/index.ts ***!
  48298. \**************************/
  48299. /*! exports provided: DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, _BabylonLoaderRegistered */
  48300. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48301. "use strict";
  48302. __webpack_require__.r(__webpack_exports__);
  48303. /* harmony import */ var _loadingScreen__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./loadingScreen */ "./Loading/loadingScreen.ts");
  48304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _loadingScreen__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  48305. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Plugins/index */ "./Loading/Plugins/index.ts");
  48306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_1__["_BabylonLoaderRegistered"]; });
  48307. /* harmony import */ var _sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneLoader */ "./Loading/sceneLoader.ts");
  48308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoaderProgressEvent"]; });
  48309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"]; });
  48310. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  48311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__["SceneLoaderFlags"]; });
  48312. /***/ }),
  48313. /***/ "./Loading/loadingScreen.ts":
  48314. /*!**********************************!*\
  48315. !*** ./Loading/loadingScreen.ts ***!
  48316. \**********************************/
  48317. /*! exports provided: DefaultLoadingScreen */
  48318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48319. "use strict";
  48320. __webpack_require__.r(__webpack_exports__);
  48321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return DefaultLoadingScreen; });
  48322. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  48323. /**
  48324. * Class used for the default loading screen
  48325. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  48326. */
  48327. var DefaultLoadingScreen = /** @class */ (function () {
  48328. /**
  48329. * Creates a new default loading screen
  48330. * @param _renderingCanvas defines the canvas used to render the scene
  48331. * @param _loadingText defines the default text to display
  48332. * @param _loadingDivBackgroundColor defines the default background color
  48333. */
  48334. function DefaultLoadingScreen(_renderingCanvas, _loadingText, _loadingDivBackgroundColor) {
  48335. if (_loadingText === void 0) { _loadingText = ""; }
  48336. if (_loadingDivBackgroundColor === void 0) { _loadingDivBackgroundColor = "black"; }
  48337. var _this = this;
  48338. this._renderingCanvas = _renderingCanvas;
  48339. this._loadingText = _loadingText;
  48340. this._loadingDivBackgroundColor = _loadingDivBackgroundColor;
  48341. // Resize
  48342. this._resizeLoadingUI = function () {
  48343. var canvasRect = _this._renderingCanvas.getBoundingClientRect();
  48344. var canvasPositioning = window.getComputedStyle(_this._renderingCanvas).position;
  48345. if (!_this._loadingDiv) {
  48346. return;
  48347. }
  48348. _this._loadingDiv.style.position = (canvasPositioning === "fixed") ? "fixed" : "absolute";
  48349. _this._loadingDiv.style.left = canvasRect.left + "px";
  48350. _this._loadingDiv.style.top = canvasRect.top + "px";
  48351. _this._loadingDiv.style.width = canvasRect.width + "px";
  48352. _this._loadingDiv.style.height = canvasRect.height + "px";
  48353. };
  48354. }
  48355. /**
  48356. * Function called to display the loading screen
  48357. */
  48358. DefaultLoadingScreen.prototype.displayLoadingUI = function () {
  48359. if (this._loadingDiv) {
  48360. // Do not add a loading screen if there is already one
  48361. return;
  48362. }
  48363. this._loadingDiv = document.createElement("div");
  48364. this._loadingDiv.id = "babylonjsLoadingDiv";
  48365. this._loadingDiv.style.opacity = "0";
  48366. this._loadingDiv.style.transition = "opacity 1.5s ease";
  48367. this._loadingDiv.style.pointerEvents = "none";
  48368. // Loading text
  48369. this._loadingTextDiv = document.createElement("div");
  48370. this._loadingTextDiv.style.position = "absolute";
  48371. this._loadingTextDiv.style.left = "0";
  48372. this._loadingTextDiv.style.top = "50%";
  48373. this._loadingTextDiv.style.marginTop = "80px";
  48374. this._loadingTextDiv.style.width = "100%";
  48375. this._loadingTextDiv.style.height = "20px";
  48376. this._loadingTextDiv.style.fontFamily = "Arial";
  48377. this._loadingTextDiv.style.fontSize = "14px";
  48378. this._loadingTextDiv.style.color = "white";
  48379. this._loadingTextDiv.style.textAlign = "center";
  48380. this._loadingTextDiv.innerHTML = "Loading";
  48381. this._loadingDiv.appendChild(this._loadingTextDiv);
  48382. //set the predefined text
  48383. this._loadingTextDiv.innerHTML = this._loadingText;
  48384. // Generating keyframes
  48385. var style = document.createElement('style');
  48386. style.type = 'text/css';
  48387. 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 }";
  48388. style.innerHTML = keyFrames;
  48389. document.getElementsByTagName('head')[0].appendChild(style);
  48390. // Loading img
  48391. var imgBack = new Image();
  48392. 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";
  48393. imgBack.style.position = "absolute";
  48394. imgBack.style.left = "50%";
  48395. imgBack.style.top = "50%";
  48396. imgBack.style.marginLeft = "-60px";
  48397. imgBack.style.marginTop = "-60px";
  48398. imgBack.style.animation = "spin1 2s infinite ease-in-out";
  48399. imgBack.style.webkitAnimation = "spin1 2s infinite ease-in-out";
  48400. imgBack.style.transformOrigin = "50% 50%";
  48401. imgBack.style.webkitTransformOrigin = "50% 50%";
  48402. this._loadingDiv.appendChild(imgBack);
  48403. this._resizeLoadingUI();
  48404. window.addEventListener("resize", this._resizeLoadingUI);
  48405. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  48406. document.body.appendChild(this._loadingDiv);
  48407. this._loadingDiv.style.opacity = "1";
  48408. };
  48409. /**
  48410. * Function called to hide the loading screen
  48411. */
  48412. DefaultLoadingScreen.prototype.hideLoadingUI = function () {
  48413. var _this = this;
  48414. if (!this._loadingDiv) {
  48415. return;
  48416. }
  48417. var onTransitionEnd = function () {
  48418. if (!_this._loadingDiv) {
  48419. return;
  48420. }
  48421. if (_this._loadingDiv.parentElement) {
  48422. _this._loadingDiv.parentElement.removeChild(_this._loadingDiv);
  48423. }
  48424. window.removeEventListener("resize", _this._resizeLoadingUI);
  48425. _this._loadingDiv = null;
  48426. };
  48427. this._loadingDiv.style.opacity = "0";
  48428. this._loadingDiv.addEventListener("transitionend", onTransitionEnd);
  48429. };
  48430. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIText", {
  48431. get: function () {
  48432. return this._loadingText;
  48433. },
  48434. /**
  48435. * Gets or sets the text to display while loading
  48436. */
  48437. set: function (text) {
  48438. this._loadingText = text;
  48439. if (this._loadingTextDiv) {
  48440. this._loadingTextDiv.innerHTML = this._loadingText;
  48441. }
  48442. },
  48443. enumerable: true,
  48444. configurable: true
  48445. });
  48446. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIBackgroundColor", {
  48447. /**
  48448. * Gets or sets the color to use for the background
  48449. */
  48450. get: function () {
  48451. return this._loadingDivBackgroundColor;
  48452. },
  48453. set: function (color) {
  48454. this._loadingDivBackgroundColor = color;
  48455. if (!this._loadingDiv) {
  48456. return;
  48457. }
  48458. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  48459. },
  48460. enumerable: true,
  48461. configurable: true
  48462. });
  48463. return DefaultLoadingScreen;
  48464. }());
  48465. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].DefaultLoadingScreenFactory = function (canvas) { return new DefaultLoadingScreen(canvas); };
  48466. /***/ }),
  48467. /***/ "./Loading/sceneLoader.ts":
  48468. /*!********************************!*\
  48469. !*** ./Loading/sceneLoader.ts ***!
  48470. \********************************/
  48471. /*! exports provided: SceneLoaderProgressEvent, SceneLoader */
  48472. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48473. "use strict";
  48474. __webpack_require__.r(__webpack_exports__);
  48475. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return SceneLoaderProgressEvent; });
  48476. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return SceneLoader; });
  48477. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  48478. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  48479. /* harmony import */ var _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/filesInputStore */ "./Misc/filesInputStore.ts");
  48480. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  48481. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  48482. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  48483. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  48484. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  48485. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  48486. /**
  48487. * Class used to represent data loading progression
  48488. */
  48489. var SceneLoaderProgressEvent = /** @class */ (function () {
  48490. /**
  48491. * Create a new progress event
  48492. * @param lengthComputable defines if data length to load can be evaluated
  48493. * @param loaded defines the loaded data length
  48494. * @param total defines the data length to load
  48495. */
  48496. function SceneLoaderProgressEvent(
  48497. /** defines if data length to load can be evaluated */
  48498. lengthComputable,
  48499. /** defines the loaded data length */
  48500. loaded,
  48501. /** defines the data length to load */
  48502. total) {
  48503. this.lengthComputable = lengthComputable;
  48504. this.loaded = loaded;
  48505. this.total = total;
  48506. }
  48507. /**
  48508. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  48509. * @param event defines the source event
  48510. * @returns a new SceneLoaderProgressEvent
  48511. */
  48512. SceneLoaderProgressEvent.FromProgressEvent = function (event) {
  48513. return new SceneLoaderProgressEvent(event.lengthComputable, event.loaded, event.total);
  48514. };
  48515. return SceneLoaderProgressEvent;
  48516. }());
  48517. /**
  48518. * Class used to load scene from various file formats using registered plugins
  48519. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  48520. */
  48521. var SceneLoader = /** @class */ (function () {
  48522. function SceneLoader() {
  48523. }
  48524. Object.defineProperty(SceneLoader, "ForceFullSceneLoadingForIncremental", {
  48525. /**
  48526. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48527. */
  48528. get: function () {
  48529. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental;
  48530. },
  48531. set: function (value) {
  48532. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental = value;
  48533. },
  48534. enumerable: true,
  48535. configurable: true
  48536. });
  48537. Object.defineProperty(SceneLoader, "ShowLoadingScreen", {
  48538. /**
  48539. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48540. */
  48541. get: function () {
  48542. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen;
  48543. },
  48544. set: function (value) {
  48545. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen = value;
  48546. },
  48547. enumerable: true,
  48548. configurable: true
  48549. });
  48550. Object.defineProperty(SceneLoader, "loggingLevel", {
  48551. /**
  48552. * Defines the current logging level (while loading the scene)
  48553. * @ignorenaming
  48554. */
  48555. get: function () {
  48556. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel;
  48557. },
  48558. set: function (value) {
  48559. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel = value;
  48560. },
  48561. enumerable: true,
  48562. configurable: true
  48563. });
  48564. Object.defineProperty(SceneLoader, "CleanBoneMatrixWeights", {
  48565. /**
  48566. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48567. */
  48568. get: function () {
  48569. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights;
  48570. },
  48571. set: function (value) {
  48572. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights = value;
  48573. },
  48574. enumerable: true,
  48575. configurable: true
  48576. });
  48577. SceneLoader._getDefaultPlugin = function () {
  48578. return SceneLoader._registeredPlugins[".babylon"];
  48579. };
  48580. SceneLoader._getPluginForExtension = function (extension) {
  48581. var registeredPlugin = SceneLoader._registeredPlugins[extension];
  48582. if (registeredPlugin) {
  48583. return registeredPlugin;
  48584. }
  48585. _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");
  48586. return SceneLoader._getDefaultPlugin();
  48587. };
  48588. SceneLoader._getPluginForDirectLoad = function (data) {
  48589. for (var extension in SceneLoader._registeredPlugins) {
  48590. var plugin = SceneLoader._registeredPlugins[extension].plugin;
  48591. if (plugin.canDirectLoad && plugin.canDirectLoad(data)) {
  48592. return SceneLoader._registeredPlugins[extension];
  48593. }
  48594. }
  48595. return SceneLoader._getDefaultPlugin();
  48596. };
  48597. SceneLoader._getPluginForFilename = function (sceneFilename) {
  48598. var queryStringPosition = sceneFilename.indexOf("?");
  48599. if (queryStringPosition !== -1) {
  48600. sceneFilename = sceneFilename.substring(0, queryStringPosition);
  48601. }
  48602. var dotPosition = sceneFilename.lastIndexOf(".");
  48603. var extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
  48604. return SceneLoader._getPluginForExtension(extension);
  48605. };
  48606. // use babylon file loader directly if sceneFilename is prefixed with "data:"
  48607. SceneLoader._getDirectLoad = function (sceneFilename) {
  48608. if (sceneFilename.substr(0, 5) === "data:") {
  48609. return sceneFilename.substr(5);
  48610. }
  48611. return null;
  48612. };
  48613. SceneLoader._loadData = function (fileInfo, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
  48614. var directLoad = SceneLoader._getDirectLoad(fileInfo.name);
  48615. var registeredPlugin = pluginExtension ? SceneLoader._getPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._getPluginForDirectLoad(fileInfo.name) : SceneLoader._getPluginForFilename(fileInfo.name));
  48616. var plugin;
  48617. if (registeredPlugin.plugin.createPlugin) {
  48618. plugin = registeredPlugin.plugin.createPlugin();
  48619. }
  48620. else {
  48621. plugin = registeredPlugin.plugin;
  48622. }
  48623. if (!plugin) {
  48624. 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.";
  48625. }
  48626. var useArrayBuffer = registeredPlugin.isBinary;
  48627. var offlineProvider;
  48628. SceneLoader.OnPluginActivatedObservable.notifyObservers(plugin);
  48629. var dataCallback = function (data, responseURL) {
  48630. if (scene.isDisposed) {
  48631. onError("Scene has been disposed");
  48632. return;
  48633. }
  48634. scene.offlineProvider = offlineProvider;
  48635. onSuccess(plugin, data, responseURL);
  48636. };
  48637. var request = null;
  48638. var pluginDisposed = false;
  48639. var onDisposeObservable = plugin.onDisposeObservable;
  48640. if (onDisposeObservable) {
  48641. onDisposeObservable.add(function () {
  48642. pluginDisposed = true;
  48643. if (request) {
  48644. request.abort();
  48645. request = null;
  48646. }
  48647. onDispose();
  48648. });
  48649. }
  48650. var manifestChecked = function () {
  48651. if (pluginDisposed) {
  48652. return;
  48653. }
  48654. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(fileInfo.url, dataCallback, onProgress ? function (event) {
  48655. onProgress(SceneLoaderProgressEvent.FromProgressEvent(event));
  48656. } : undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  48657. onError("Failed to load scene." + (exception ? " " + exception.message : ""), exception);
  48658. });
  48659. };
  48660. if (directLoad) {
  48661. dataCallback(directLoad);
  48662. return plugin;
  48663. }
  48664. var file = fileInfo.file || _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad[fileInfo.name.toLowerCase()];
  48665. if (fileInfo.rootUrl.indexOf("file:") === -1 || (fileInfo.rootUrl.indexOf("file:") !== -1 && !file)) {
  48666. var engine = scene.getEngine();
  48667. var canUseOfflineSupport = engine.enableOfflineSupport;
  48668. if (canUseOfflineSupport) {
  48669. // Also check for exceptions
  48670. var exceptionFound = false;
  48671. for (var _i = 0, _a = scene.disableOfflineSupportExceptionRules; _i < _a.length; _i++) {
  48672. var regex = _a[_i];
  48673. if (regex.test(fileInfo.url)) {
  48674. exceptionFound = true;
  48675. break;
  48676. }
  48677. }
  48678. canUseOfflineSupport = !exceptionFound;
  48679. }
  48680. if (canUseOfflineSupport && _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory) {
  48681. // Checking if a manifest file has been set for this scene and if offline mode has been requested
  48682. offlineProvider = _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory(fileInfo.url, manifestChecked, engine.disableManifestCheck);
  48683. }
  48684. else {
  48685. manifestChecked();
  48686. }
  48687. }
  48688. // Loading file from disk via input file or drag'n'drop
  48689. else {
  48690. if (file) {
  48691. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ReadFile(file, dataCallback, onProgress, useArrayBuffer);
  48692. }
  48693. else {
  48694. onError("Unable to find file named " + fileInfo.name);
  48695. }
  48696. }
  48697. return plugin;
  48698. };
  48699. SceneLoader._getFileInfo = function (rootUrl, sceneFilename) {
  48700. var url;
  48701. var name;
  48702. var file = null;
  48703. if (!sceneFilename) {
  48704. url = rootUrl;
  48705. name = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(rootUrl);
  48706. rootUrl = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFolderPath(rootUrl);
  48707. }
  48708. else if (sceneFilename.name) {
  48709. var sceneFile = sceneFilename;
  48710. url = rootUrl + sceneFile.name;
  48711. name = sceneFile.name;
  48712. file = sceneFile;
  48713. }
  48714. else {
  48715. var filename = sceneFilename;
  48716. if (filename.substr(0, 1) === "/") {
  48717. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Wrong sceneFilename parameter");
  48718. return null;
  48719. }
  48720. url = rootUrl + filename;
  48721. name = filename;
  48722. }
  48723. return {
  48724. url: url,
  48725. rootUrl: rootUrl,
  48726. name: name,
  48727. file: file
  48728. };
  48729. };
  48730. // Public functions
  48731. /**
  48732. * Gets a plugin that can load the given extension
  48733. * @param extension defines the extension to load
  48734. * @returns a plugin or null if none works
  48735. */
  48736. SceneLoader.GetPluginForExtension = function (extension) {
  48737. return SceneLoader._getPluginForExtension(extension).plugin;
  48738. };
  48739. /**
  48740. * Gets a boolean indicating that the given extension can be loaded
  48741. * @param extension defines the extension to load
  48742. * @returns true if the extension is supported
  48743. */
  48744. SceneLoader.IsPluginForExtensionAvailable = function (extension) {
  48745. return !!SceneLoader._registeredPlugins[extension];
  48746. };
  48747. /**
  48748. * Adds a new plugin to the list of registered plugins
  48749. * @param plugin defines the plugin to add
  48750. */
  48751. SceneLoader.RegisterPlugin = function (plugin) {
  48752. if (typeof plugin.extensions === "string") {
  48753. var extension = plugin.extensions;
  48754. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  48755. plugin: plugin,
  48756. isBinary: false
  48757. };
  48758. }
  48759. else {
  48760. var extensions = plugin.extensions;
  48761. Object.keys(extensions).forEach(function (extension) {
  48762. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  48763. plugin: plugin,
  48764. isBinary: extensions[extension].isBinary
  48765. };
  48766. });
  48767. }
  48768. };
  48769. /**
  48770. * Import meshes into a scene
  48771. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48772. * @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)
  48773. * @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)
  48774. * @param scene the instance of BABYLON.Scene to append to
  48775. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48776. * @param onProgress a callback with a progress event for each file being loaded
  48777. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48778. * @param pluginExtension the extension used to determine the plugin
  48779. * @returns The loaded plugin
  48780. */
  48781. SceneLoader.ImportMesh = function (meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  48782. if (sceneFilename === void 0) { sceneFilename = ""; }
  48783. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48784. if (onSuccess === void 0) { onSuccess = null; }
  48785. if (onProgress === void 0) { onProgress = null; }
  48786. if (onError === void 0) { onError = null; }
  48787. if (pluginExtension === void 0) { pluginExtension = null; }
  48788. if (!scene) {
  48789. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to import mesh to");
  48790. return null;
  48791. }
  48792. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  48793. if (!fileInfo) {
  48794. return null;
  48795. }
  48796. var loadingToken = {};
  48797. scene._addPendingData(loadingToken);
  48798. var disposeHandler = function () {
  48799. scene._removePendingData(loadingToken);
  48800. };
  48801. var errorHandler = function (message, exception) {
  48802. var errorMessage = "Unable to import meshes from " + fileInfo.url + ": " + message;
  48803. if (onError) {
  48804. onError(scene, errorMessage, exception);
  48805. }
  48806. else {
  48807. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  48808. // should the exception be thrown?
  48809. }
  48810. disposeHandler();
  48811. };
  48812. var progressHandler = onProgress ? function (event) {
  48813. try {
  48814. onProgress(event);
  48815. }
  48816. catch (e) {
  48817. errorHandler("Error in onProgress callback", e);
  48818. }
  48819. } : undefined;
  48820. var successHandler = function (meshes, particleSystems, skeletons, animationGroups) {
  48821. scene.importedMeshesFiles.push(fileInfo.url);
  48822. if (onSuccess) {
  48823. try {
  48824. onSuccess(meshes, particleSystems, skeletons, animationGroups);
  48825. }
  48826. catch (e) {
  48827. errorHandler("Error in onSuccess callback", e);
  48828. }
  48829. }
  48830. scene._removePendingData(loadingToken);
  48831. };
  48832. return SceneLoader._loadData(fileInfo, scene, function (plugin, data, responseURL) {
  48833. if (plugin.rewriteRootURL) {
  48834. fileInfo.rootUrl = plugin.rewriteRootURL(fileInfo.rootUrl, responseURL);
  48835. }
  48836. if (plugin.importMesh) {
  48837. var syncedPlugin = plugin;
  48838. var meshes = new Array();
  48839. var particleSystems = new Array();
  48840. var skeletons = new Array();
  48841. if (!syncedPlugin.importMesh(meshNames, scene, data, fileInfo.rootUrl, meshes, particleSystems, skeletons, errorHandler)) {
  48842. return;
  48843. }
  48844. scene.loadingPluginName = plugin.name;
  48845. successHandler(meshes, particleSystems, skeletons, []);
  48846. }
  48847. else {
  48848. var asyncedPlugin = plugin;
  48849. asyncedPlugin.importMeshAsync(meshNames, scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (result) {
  48850. scene.loadingPluginName = plugin.name;
  48851. successHandler(result.meshes, result.particleSystems, result.skeletons, result.animationGroups);
  48852. }).catch(function (error) {
  48853. errorHandler(error.message, error);
  48854. });
  48855. }
  48856. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  48857. };
  48858. /**
  48859. * Import meshes into a scene
  48860. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48861. * @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)
  48862. * @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)
  48863. * @param scene the instance of BABYLON.Scene to append to
  48864. * @param onProgress a callback with a progress event for each file being loaded
  48865. * @param pluginExtension the extension used to determine the plugin
  48866. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48867. */
  48868. SceneLoader.ImportMeshAsync = function (meshNames, rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  48869. if (sceneFilename === void 0) { sceneFilename = ""; }
  48870. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48871. if (onProgress === void 0) { onProgress = null; }
  48872. if (pluginExtension === void 0) { pluginExtension = null; }
  48873. return new Promise(function (resolve, reject) {
  48874. SceneLoader.ImportMesh(meshNames, rootUrl, sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  48875. resolve({
  48876. meshes: meshes,
  48877. particleSystems: particleSystems,
  48878. skeletons: skeletons,
  48879. animationGroups: animationGroups
  48880. });
  48881. }, onProgress, function (scene, message, exception) {
  48882. reject(exception || new Error(message));
  48883. }, pluginExtension);
  48884. });
  48885. };
  48886. /**
  48887. * Load a scene
  48888. * @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)
  48889. * @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)
  48890. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48891. * @param onSuccess a callback with the scene when import succeeds
  48892. * @param onProgress a callback with a progress event for each file being loaded
  48893. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48894. * @param pluginExtension the extension used to determine the plugin
  48895. * @returns The loaded plugin
  48896. */
  48897. SceneLoader.Load = function (rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension) {
  48898. if (sceneFilename === void 0) { sceneFilename = ""; }
  48899. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  48900. if (onSuccess === void 0) { onSuccess = null; }
  48901. if (onProgress === void 0) { onProgress = null; }
  48902. if (onError === void 0) { onError = null; }
  48903. if (pluginExtension === void 0) { pluginExtension = null; }
  48904. if (!engine) {
  48905. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("No engine available");
  48906. return null;
  48907. }
  48908. return SceneLoader.Append(rootUrl, sceneFilename, new _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"](engine), onSuccess, onProgress, onError, pluginExtension);
  48909. };
  48910. /**
  48911. * Load a scene
  48912. * @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)
  48913. * @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)
  48914. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48915. * @param onProgress a callback with a progress event for each file being loaded
  48916. * @param pluginExtension the extension used to determine the plugin
  48917. * @returns The loaded scene
  48918. */
  48919. SceneLoader.LoadAsync = function (rootUrl, sceneFilename, engine, onProgress, pluginExtension) {
  48920. if (sceneFilename === void 0) { sceneFilename = ""; }
  48921. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  48922. if (onProgress === void 0) { onProgress = null; }
  48923. if (pluginExtension === void 0) { pluginExtension = null; }
  48924. return new Promise(function (resolve, reject) {
  48925. SceneLoader.Load(rootUrl, sceneFilename, engine, function (scene) {
  48926. resolve(scene);
  48927. }, onProgress, function (scene, message, exception) {
  48928. reject(exception || new Error(message));
  48929. }, pluginExtension);
  48930. });
  48931. };
  48932. /**
  48933. * Append a scene
  48934. * @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)
  48935. * @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)
  48936. * @param scene is the instance of BABYLON.Scene to append to
  48937. * @param onSuccess a callback with the scene when import succeeds
  48938. * @param onProgress a callback with a progress event for each file being loaded
  48939. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48940. * @param pluginExtension the extension used to determine the plugin
  48941. * @returns The loaded plugin
  48942. */
  48943. SceneLoader.Append = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  48944. if (sceneFilename === void 0) { sceneFilename = ""; }
  48945. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48946. if (onSuccess === void 0) { onSuccess = null; }
  48947. if (onProgress === void 0) { onProgress = null; }
  48948. if (onError === void 0) { onError = null; }
  48949. if (pluginExtension === void 0) { pluginExtension = null; }
  48950. if (!scene) {
  48951. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to append to");
  48952. return null;
  48953. }
  48954. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  48955. if (!fileInfo) {
  48956. return null;
  48957. }
  48958. if (SceneLoader.ShowLoadingScreen) {
  48959. scene.getEngine().displayLoadingUI();
  48960. }
  48961. var loadingToken = {};
  48962. scene._addPendingData(loadingToken);
  48963. var disposeHandler = function () {
  48964. scene._removePendingData(loadingToken);
  48965. scene.getEngine().hideLoadingUI();
  48966. };
  48967. var errorHandler = function (message, exception) {
  48968. var errorMessage = "Unable to load from " + fileInfo.url + (message ? ": " + message : "");
  48969. if (onError) {
  48970. onError(scene, errorMessage, exception);
  48971. }
  48972. else {
  48973. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  48974. // should the exception be thrown?
  48975. }
  48976. disposeHandler();
  48977. };
  48978. var progressHandler = onProgress ? function (event) {
  48979. try {
  48980. onProgress(event);
  48981. }
  48982. catch (e) {
  48983. errorHandler("Error in onProgress callback", e);
  48984. }
  48985. } : undefined;
  48986. var successHandler = function () {
  48987. if (onSuccess) {
  48988. try {
  48989. onSuccess(scene);
  48990. }
  48991. catch (e) {
  48992. errorHandler("Error in onSuccess callback", e);
  48993. }
  48994. }
  48995. scene._removePendingData(loadingToken);
  48996. };
  48997. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  48998. if (plugin.load) {
  48999. var syncedPlugin = plugin;
  49000. if (!syncedPlugin.load(scene, data, fileInfo.rootUrl, errorHandler)) {
  49001. return;
  49002. }
  49003. scene.loadingPluginName = plugin.name;
  49004. successHandler();
  49005. }
  49006. else {
  49007. var asyncedPlugin = plugin;
  49008. asyncedPlugin.loadAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function () {
  49009. scene.loadingPluginName = plugin.name;
  49010. successHandler();
  49011. }).catch(function (error) {
  49012. errorHandler(error.message, error);
  49013. });
  49014. }
  49015. if (SceneLoader.ShowLoadingScreen) {
  49016. scene.executeWhenReady(function () {
  49017. scene.getEngine().hideLoadingUI();
  49018. });
  49019. }
  49020. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  49021. };
  49022. /**
  49023. * Append a scene
  49024. * @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)
  49025. * @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)
  49026. * @param scene is the instance of BABYLON.Scene to append to
  49027. * @param onProgress a callback with a progress event for each file being loaded
  49028. * @param pluginExtension the extension used to determine the plugin
  49029. * @returns The given scene
  49030. */
  49031. SceneLoader.AppendAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  49032. if (sceneFilename === void 0) { sceneFilename = ""; }
  49033. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49034. if (onProgress === void 0) { onProgress = null; }
  49035. if (pluginExtension === void 0) { pluginExtension = null; }
  49036. return new Promise(function (resolve, reject) {
  49037. SceneLoader.Append(rootUrl, sceneFilename, scene, function (scene) {
  49038. resolve(scene);
  49039. }, onProgress, function (scene, message, exception) {
  49040. reject(exception || new Error(message));
  49041. }, pluginExtension);
  49042. });
  49043. };
  49044. /**
  49045. * Load a scene into an asset container
  49046. * @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)
  49047. * @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)
  49048. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49049. * @param onSuccess a callback with the scene when import succeeds
  49050. * @param onProgress a callback with a progress event for each file being loaded
  49051. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49052. * @param pluginExtension the extension used to determine the plugin
  49053. * @returns The loaded plugin
  49054. */
  49055. SceneLoader.LoadAssetContainer = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  49056. if (sceneFilename === void 0) { sceneFilename = ""; }
  49057. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49058. if (onSuccess === void 0) { onSuccess = null; }
  49059. if (onProgress === void 0) { onProgress = null; }
  49060. if (onError === void 0) { onError = null; }
  49061. if (pluginExtension === void 0) { pluginExtension = null; }
  49062. if (!scene) {
  49063. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to load asset container to");
  49064. return null;
  49065. }
  49066. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  49067. if (!fileInfo) {
  49068. return null;
  49069. }
  49070. var loadingToken = {};
  49071. scene._addPendingData(loadingToken);
  49072. var disposeHandler = function () {
  49073. scene._removePendingData(loadingToken);
  49074. };
  49075. var errorHandler = function (message, exception) {
  49076. var errorMessage = "Unable to load assets from " + fileInfo.url + (message ? ": " + message : "");
  49077. if (onError) {
  49078. onError(scene, errorMessage, exception);
  49079. }
  49080. else {
  49081. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  49082. // should the exception be thrown?
  49083. }
  49084. disposeHandler();
  49085. };
  49086. var progressHandler = onProgress ? function (event) {
  49087. try {
  49088. onProgress(event);
  49089. }
  49090. catch (e) {
  49091. errorHandler("Error in onProgress callback", e);
  49092. }
  49093. } : undefined;
  49094. var successHandler = function (assets) {
  49095. if (onSuccess) {
  49096. try {
  49097. onSuccess(assets);
  49098. }
  49099. catch (e) {
  49100. errorHandler("Error in onSuccess callback", e);
  49101. }
  49102. }
  49103. scene._removePendingData(loadingToken);
  49104. };
  49105. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  49106. if (plugin.loadAssetContainer) {
  49107. var syncedPlugin = plugin;
  49108. var assetContainer = syncedPlugin.loadAssetContainer(scene, data, fileInfo.rootUrl, errorHandler);
  49109. if (!assetContainer) {
  49110. return;
  49111. }
  49112. scene.loadingPluginName = plugin.name;
  49113. successHandler(assetContainer);
  49114. }
  49115. else if (plugin.loadAssetContainerAsync) {
  49116. var asyncedPlugin = plugin;
  49117. asyncedPlugin.loadAssetContainerAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (assetContainer) {
  49118. scene.loadingPluginName = plugin.name;
  49119. successHandler(assetContainer);
  49120. }).catch(function (error) {
  49121. errorHandler(error.message, error);
  49122. });
  49123. }
  49124. else {
  49125. errorHandler("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.");
  49126. }
  49127. if (SceneLoader.ShowLoadingScreen) {
  49128. scene.executeWhenReady(function () {
  49129. scene.getEngine().hideLoadingUI();
  49130. });
  49131. }
  49132. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  49133. };
  49134. /**
  49135. * Load a scene into an asset container
  49136. * @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)
  49137. * @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)
  49138. * @param scene is the instance of Scene to append to
  49139. * @param onProgress a callback with a progress event for each file being loaded
  49140. * @param pluginExtension the extension used to determine the plugin
  49141. * @returns The loaded asset container
  49142. */
  49143. SceneLoader.LoadAssetContainerAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  49144. if (sceneFilename === void 0) { sceneFilename = ""; }
  49145. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49146. if (onProgress === void 0) { onProgress = null; }
  49147. if (pluginExtension === void 0) { pluginExtension = null; }
  49148. return new Promise(function (resolve, reject) {
  49149. SceneLoader.LoadAssetContainer(rootUrl, sceneFilename, scene, function (assetContainer) {
  49150. resolve(assetContainer);
  49151. }, onProgress, function (scene, message, exception) {
  49152. reject(exception || new Error(message));
  49153. }, pluginExtension);
  49154. });
  49155. };
  49156. /**
  49157. * No logging while loading
  49158. */
  49159. SceneLoader.NO_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_NO_LOGGING;
  49160. /**
  49161. * Minimal logging while loading
  49162. */
  49163. SceneLoader.MINIMAL_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_MINIMAL_LOGGING;
  49164. /**
  49165. * Summary logging while loading
  49166. */
  49167. SceneLoader.SUMMARY_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_SUMMARY_LOGGING;
  49168. /**
  49169. * Detailled logging while loading
  49170. */
  49171. SceneLoader.DETAILED_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_DETAILED_LOGGING;
  49172. // Members
  49173. /**
  49174. * Event raised when a plugin is used to load a scene
  49175. */
  49176. SceneLoader.OnPluginActivatedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  49177. SceneLoader._registeredPlugins = {};
  49178. return SceneLoader;
  49179. }());
  49180. /***/ }),
  49181. /***/ "./Loading/sceneLoaderFlags.ts":
  49182. /*!*************************************!*\
  49183. !*** ./Loading/sceneLoaderFlags.ts ***!
  49184. \*************************************/
  49185. /*! exports provided: SceneLoaderFlags */
  49186. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49187. "use strict";
  49188. __webpack_require__.r(__webpack_exports__);
  49189. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return SceneLoaderFlags; });
  49190. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  49191. /**
  49192. * Class used to represent data loading progression
  49193. */
  49194. var SceneLoaderFlags = /** @class */ (function () {
  49195. function SceneLoaderFlags() {
  49196. }
  49197. Object.defineProperty(SceneLoaderFlags, "ForceFullSceneLoadingForIncremental", {
  49198. /**
  49199. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49200. */
  49201. get: function () {
  49202. return SceneLoaderFlags._ForceFullSceneLoadingForIncremental;
  49203. },
  49204. set: function (value) {
  49205. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = value;
  49206. },
  49207. enumerable: true,
  49208. configurable: true
  49209. });
  49210. Object.defineProperty(SceneLoaderFlags, "ShowLoadingScreen", {
  49211. /**
  49212. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49213. */
  49214. get: function () {
  49215. return SceneLoaderFlags._ShowLoadingScreen;
  49216. },
  49217. set: function (value) {
  49218. SceneLoaderFlags._ShowLoadingScreen = value;
  49219. },
  49220. enumerable: true,
  49221. configurable: true
  49222. });
  49223. Object.defineProperty(SceneLoaderFlags, "loggingLevel", {
  49224. /**
  49225. * Defines the current logging level (while loading the scene)
  49226. * @ignorenaming
  49227. */
  49228. get: function () {
  49229. return SceneLoaderFlags._loggingLevel;
  49230. },
  49231. set: function (value) {
  49232. SceneLoaderFlags._loggingLevel = value;
  49233. },
  49234. enumerable: true,
  49235. configurable: true
  49236. });
  49237. Object.defineProperty(SceneLoaderFlags, "CleanBoneMatrixWeights", {
  49238. /**
  49239. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49240. */
  49241. get: function () {
  49242. return SceneLoaderFlags._CleanBoneMatrixWeights;
  49243. },
  49244. set: function (value) {
  49245. SceneLoaderFlags._CleanBoneMatrixWeights = value;
  49246. },
  49247. enumerable: true,
  49248. configurable: true
  49249. });
  49250. // Flags
  49251. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = false;
  49252. SceneLoaderFlags._ShowLoadingScreen = true;
  49253. SceneLoaderFlags._CleanBoneMatrixWeights = false;
  49254. SceneLoaderFlags._loggingLevel = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].SCENELOADER_NO_LOGGING;
  49255. return SceneLoaderFlags;
  49256. }());
  49257. /***/ }),
  49258. /***/ "./Materials/Background/backgroundMaterial.ts":
  49259. /*!****************************************************!*\
  49260. !*** ./Materials/Background/backgroundMaterial.ts ***!
  49261. \****************************************************/
  49262. /*! exports provided: BackgroundMaterial */
  49263. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49264. "use strict";
  49265. __webpack_require__.r(__webpack_exports__);
  49266. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return BackgroundMaterial; });
  49267. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  49268. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  49269. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  49270. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  49271. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  49272. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  49273. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  49274. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  49275. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  49276. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  49277. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  49278. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  49279. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  49280. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  49281. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  49282. /* harmony import */ var _Shaders_background_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Shaders/background.fragment */ "./Shaders/background.fragment.ts");
  49283. /* harmony import */ var _Shaders_background_vertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/background.vertex */ "./Shaders/background.vertex.ts");
  49284. /**
  49285. * Background material defines definition.
  49286. * @hidden Mainly internal Use
  49287. */
  49288. var BackgroundMaterialDefines = /** @class */ (function (_super) {
  49289. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterialDefines, _super);
  49290. /**
  49291. * Constructor of the defines.
  49292. */
  49293. function BackgroundMaterialDefines() {
  49294. var _this = _super.call(this) || this;
  49295. /**
  49296. * True if the diffuse texture is in use.
  49297. */
  49298. _this.DIFFUSE = false;
  49299. /**
  49300. * The direct UV channel to use.
  49301. */
  49302. _this.DIFFUSEDIRECTUV = 0;
  49303. /**
  49304. * True if the diffuse texture is in gamma space.
  49305. */
  49306. _this.GAMMADIFFUSE = false;
  49307. /**
  49308. * True if the diffuse texture has opacity in the alpha channel.
  49309. */
  49310. _this.DIFFUSEHASALPHA = false;
  49311. /**
  49312. * True if you want the material to fade to transparent at grazing angle.
  49313. */
  49314. _this.OPACITYFRESNEL = false;
  49315. /**
  49316. * True if an extra blur needs to be added in the reflection.
  49317. */
  49318. _this.REFLECTIONBLUR = false;
  49319. /**
  49320. * True if you want the material to fade to reflection at grazing angle.
  49321. */
  49322. _this.REFLECTIONFRESNEL = false;
  49323. /**
  49324. * True if you want the material to falloff as far as you move away from the scene center.
  49325. */
  49326. _this.REFLECTIONFALLOFF = false;
  49327. /**
  49328. * False if the current Webgl implementation does not support the texture lod extension.
  49329. */
  49330. _this.TEXTURELODSUPPORT = false;
  49331. /**
  49332. * True to ensure the data are premultiplied.
  49333. */
  49334. _this.PREMULTIPLYALPHA = false;
  49335. /**
  49336. * True if the texture contains cooked RGB values and not gray scaled multipliers.
  49337. */
  49338. _this.USERGBCOLOR = false;
  49339. /**
  49340. * True if highlight and shadow levels have been specified. It can help ensuring the main perceived color
  49341. * stays aligned with the desired configuration.
  49342. */
  49343. _this.USEHIGHLIGHTANDSHADOWCOLORS = false;
  49344. /**
  49345. * True to add noise in order to reduce the banding effect.
  49346. */
  49347. _this.NOISE = false;
  49348. /**
  49349. * is the reflection texture in BGR color scheme?
  49350. * Mainly used to solve a bug in ios10 video tag
  49351. */
  49352. _this.REFLECTIONBGR = false;
  49353. _this.IMAGEPROCESSING = false;
  49354. _this.VIGNETTE = false;
  49355. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  49356. _this.VIGNETTEBLENDMODEOPAQUE = false;
  49357. _this.TONEMAPPING = false;
  49358. _this.TONEMAPPING_ACES = false;
  49359. _this.CONTRAST = false;
  49360. _this.COLORCURVES = false;
  49361. _this.COLORGRADING = false;
  49362. _this.COLORGRADING3D = false;
  49363. _this.SAMPLER3DGREENDEPTH = false;
  49364. _this.SAMPLER3DBGRMAP = false;
  49365. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  49366. _this.EXPOSURE = false;
  49367. // Reflection.
  49368. _this.REFLECTION = false;
  49369. _this.REFLECTIONMAP_3D = false;
  49370. _this.REFLECTIONMAP_SPHERICAL = false;
  49371. _this.REFLECTIONMAP_PLANAR = false;
  49372. _this.REFLECTIONMAP_CUBIC = false;
  49373. _this.REFLECTIONMAP_PROJECTION = false;
  49374. _this.REFLECTIONMAP_SKYBOX = false;
  49375. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  49376. _this.REFLECTIONMAP_EXPLICIT = false;
  49377. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  49378. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  49379. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  49380. _this.INVERTCUBICMAP = false;
  49381. _this.REFLECTIONMAP_OPPOSITEZ = false;
  49382. _this.LODINREFLECTIONALPHA = false;
  49383. _this.GAMMAREFLECTION = false;
  49384. _this.RGBDREFLECTION = false;
  49385. _this.EQUIRECTANGULAR_RELFECTION_FOV = false;
  49386. // Default BJS.
  49387. _this.MAINUV1 = false;
  49388. _this.MAINUV2 = false;
  49389. _this.UV1 = false;
  49390. _this.UV2 = false;
  49391. _this.CLIPPLANE = false;
  49392. _this.CLIPPLANE2 = false;
  49393. _this.CLIPPLANE3 = false;
  49394. _this.CLIPPLANE4 = false;
  49395. _this.POINTSIZE = false;
  49396. _this.FOG = false;
  49397. _this.NORMAL = false;
  49398. _this.NUM_BONE_INFLUENCERS = 0;
  49399. _this.BonesPerMesh = 0;
  49400. _this.INSTANCES = false;
  49401. _this.SHADOWFLOAT = false;
  49402. _this.rebuild();
  49403. return _this;
  49404. }
  49405. return BackgroundMaterialDefines;
  49406. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  49407. /**
  49408. * Background material used to create an efficient environement around your scene.
  49409. */
  49410. var BackgroundMaterial = /** @class */ (function (_super) {
  49411. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterial, _super);
  49412. /**
  49413. * Instantiates a Background Material in the given scene
  49414. * @param name The friendly name of the material
  49415. * @param scene The scene to add the material to
  49416. */
  49417. function BackgroundMaterial(name, scene) {
  49418. var _this = _super.call(this, name, scene) || this;
  49419. /**
  49420. * Key light Color (multiply against the environement texture)
  49421. */
  49422. _this.primaryColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  49423. _this._primaryColorShadowLevel = 0;
  49424. _this._primaryColorHighlightLevel = 0;
  49425. /**
  49426. * Reflection Texture used in the material.
  49427. * Should be author in a specific way for the best result (refer to the documentation).
  49428. */
  49429. _this.reflectionTexture = null;
  49430. /**
  49431. * Reflection Texture level of blur.
  49432. *
  49433. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49434. * texture twice.
  49435. */
  49436. _this.reflectionBlur = 0;
  49437. /**
  49438. * Diffuse Texture used in the material.
  49439. * Should be author in a specific way for the best result (refer to the documentation).
  49440. */
  49441. _this.diffuseTexture = null;
  49442. _this._shadowLights = null;
  49443. /**
  49444. * Specify the list of lights casting shadow on the material.
  49445. * All scene shadow lights will be included if null.
  49446. */
  49447. _this.shadowLights = null;
  49448. /**
  49449. * Helps adjusting the shadow to a softer level if required.
  49450. * 0 means black shadows and 1 means no shadows.
  49451. */
  49452. _this.shadowLevel = 0;
  49453. /**
  49454. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49455. * It is usually zero but might be interesting to modify according to your setup.
  49456. */
  49457. _this.sceneCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  49458. /**
  49459. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49460. * This helps ensuring a nice transition when the camera goes under the ground.
  49461. */
  49462. _this.opacityFresnel = true;
  49463. /**
  49464. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49465. * This helps adding a mirror texture on the ground.
  49466. */
  49467. _this.reflectionFresnel = false;
  49468. /**
  49469. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49470. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49471. */
  49472. _this.reflectionFalloffDistance = 0.0;
  49473. /**
  49474. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49475. */
  49476. _this.reflectionAmount = 1.0;
  49477. /**
  49478. * This specifies the weight of the reflection at grazing angle.
  49479. */
  49480. _this.reflectionReflectance0 = 0.05;
  49481. /**
  49482. * This specifies the weight of the reflection at a perpendicular point of view.
  49483. */
  49484. _this.reflectionReflectance90 = 0.5;
  49485. /**
  49486. * Helps to directly use the maps channels instead of their level.
  49487. */
  49488. _this.useRGBColor = true;
  49489. /**
  49490. * This helps reducing the banding effect that could occur on the background.
  49491. */
  49492. _this.enableNoise = false;
  49493. _this._fovMultiplier = 1.0;
  49494. /**
  49495. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49496. */
  49497. _this.useEquirectangularFOV = false;
  49498. _this._maxSimultaneousLights = 4;
  49499. /**
  49500. * Number of Simultaneous lights allowed on the material.
  49501. */
  49502. _this.maxSimultaneousLights = 4;
  49503. /**
  49504. * Keep track of the image processing observer to allow dispose and replace.
  49505. */
  49506. _this._imageProcessingObserver = null;
  49507. /**
  49508. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49509. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49510. */
  49511. _this.switchToBGR = false;
  49512. // Temp values kept as cache in the material.
  49513. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  49514. _this._reflectionControls = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector4"].Zero();
  49515. _this._white = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  49516. _this._primaryShadowColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  49517. _this._primaryHighlightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  49518. // Setup the default processing configuration to the scene.
  49519. _this._attachImageProcessingConfiguration(null);
  49520. _this.getRenderTargetTextures = function () {
  49521. _this._renderTargets.reset();
  49522. if (_this._diffuseTexture && _this._diffuseTexture.isRenderTarget) {
  49523. _this._renderTargets.push(_this._diffuseTexture);
  49524. }
  49525. if (_this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  49526. _this._renderTargets.push(_this._reflectionTexture);
  49527. }
  49528. return _this._renderTargets;
  49529. };
  49530. return _this;
  49531. }
  49532. Object.defineProperty(BackgroundMaterial.prototype, "_perceptualColor", {
  49533. /**
  49534. * Experimental Internal Use Only.
  49535. *
  49536. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49537. * This acts as a helper to set the primary color to a more "human friendly" value.
  49538. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49539. * output color as close as possible from the chosen value.
  49540. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49541. * part of lighting setup.)
  49542. */
  49543. get: function () {
  49544. return this.__perceptualColor;
  49545. },
  49546. set: function (value) {
  49547. this.__perceptualColor = value;
  49548. this._computePrimaryColorFromPerceptualColor();
  49549. this._markAllSubMeshesAsLightsDirty();
  49550. },
  49551. enumerable: true,
  49552. configurable: true
  49553. });
  49554. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorShadowLevel", {
  49555. /**
  49556. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49557. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49558. */
  49559. get: function () {
  49560. return this._primaryColorShadowLevel;
  49561. },
  49562. set: function (value) {
  49563. this._primaryColorShadowLevel = value;
  49564. this._computePrimaryColors();
  49565. this._markAllSubMeshesAsLightsDirty();
  49566. },
  49567. enumerable: true,
  49568. configurable: true
  49569. });
  49570. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorHighlightLevel", {
  49571. /**
  49572. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49573. * The primary color is used at the level chosen to define what the white area would look.
  49574. */
  49575. get: function () {
  49576. return this._primaryColorHighlightLevel;
  49577. },
  49578. set: function (value) {
  49579. this._primaryColorHighlightLevel = value;
  49580. this._computePrimaryColors();
  49581. this._markAllSubMeshesAsLightsDirty();
  49582. },
  49583. enumerable: true,
  49584. configurable: true
  49585. });
  49586. Object.defineProperty(BackgroundMaterial.prototype, "reflectionStandardFresnelWeight", {
  49587. /**
  49588. * Sets the reflection reflectance fresnel values according to the default standard
  49589. * empirically know to work well :-)
  49590. */
  49591. set: function (value) {
  49592. var reflectionWeight = value;
  49593. if (reflectionWeight < 0.5) {
  49594. reflectionWeight = reflectionWeight * 2.0;
  49595. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 * reflectionWeight;
  49596. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 * reflectionWeight;
  49597. }
  49598. else {
  49599. reflectionWeight = reflectionWeight * 2.0 - 1.0;
  49600. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 + (1.0 - BackgroundMaterial.StandardReflectance0) * reflectionWeight;
  49601. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 + (1.0 - BackgroundMaterial.StandardReflectance90) * reflectionWeight;
  49602. }
  49603. },
  49604. enumerable: true,
  49605. configurable: true
  49606. });
  49607. Object.defineProperty(BackgroundMaterial.prototype, "fovMultiplier", {
  49608. /**
  49609. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49610. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49611. * Recommended to be keep at 1.0 except for special cases.
  49612. */
  49613. get: function () {
  49614. return this._fovMultiplier;
  49615. },
  49616. set: function (value) {
  49617. if (isNaN(value)) {
  49618. value = 1.0;
  49619. }
  49620. this._fovMultiplier = Math.max(0.0, Math.min(2.0, value));
  49621. },
  49622. enumerable: true,
  49623. configurable: true
  49624. });
  49625. /**
  49626. * Attaches a new image processing configuration to the PBR Material.
  49627. * @param configuration (if null the scene configuration will be use)
  49628. */
  49629. BackgroundMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  49630. var _this = this;
  49631. if (configuration === this._imageProcessingConfiguration) {
  49632. return;
  49633. }
  49634. // Detaches observer.
  49635. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  49636. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  49637. }
  49638. // Pick the scene configuration if needed.
  49639. if (!configuration) {
  49640. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  49641. }
  49642. else {
  49643. this._imageProcessingConfiguration = configuration;
  49644. }
  49645. // Attaches observer.
  49646. if (this._imageProcessingConfiguration) {
  49647. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  49648. _this._computePrimaryColorFromPerceptualColor();
  49649. _this._markAllSubMeshesAsImageProcessingDirty();
  49650. });
  49651. }
  49652. };
  49653. Object.defineProperty(BackgroundMaterial.prototype, "imageProcessingConfiguration", {
  49654. /**
  49655. * Gets the image processing configuration used either in this material.
  49656. */
  49657. get: function () {
  49658. return this._imageProcessingConfiguration;
  49659. },
  49660. /**
  49661. * Sets the Default image processing configuration used either in the this material.
  49662. *
  49663. * If sets to null, the scene one is in use.
  49664. */
  49665. set: function (value) {
  49666. this._attachImageProcessingConfiguration(value);
  49667. // Ensure the effect will be rebuilt.
  49668. this._markAllSubMeshesAsTexturesDirty();
  49669. },
  49670. enumerable: true,
  49671. configurable: true
  49672. });
  49673. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurvesEnabled", {
  49674. /**
  49675. * Gets wether the color curves effect is enabled.
  49676. */
  49677. get: function () {
  49678. return this.imageProcessingConfiguration.colorCurvesEnabled;
  49679. },
  49680. /**
  49681. * Sets wether the color curves effect is enabled.
  49682. */
  49683. set: function (value) {
  49684. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  49685. },
  49686. enumerable: true,
  49687. configurable: true
  49688. });
  49689. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingEnabled", {
  49690. /**
  49691. * Gets wether the color grading effect is enabled.
  49692. */
  49693. get: function () {
  49694. return this.imageProcessingConfiguration.colorGradingEnabled;
  49695. },
  49696. /**
  49697. * Gets wether the color grading effect is enabled.
  49698. */
  49699. set: function (value) {
  49700. this.imageProcessingConfiguration.colorGradingEnabled = value;
  49701. },
  49702. enumerable: true,
  49703. configurable: true
  49704. });
  49705. Object.defineProperty(BackgroundMaterial.prototype, "cameraToneMappingEnabled", {
  49706. /**
  49707. * Gets wether tonemapping is enabled or not.
  49708. */
  49709. get: function () {
  49710. return this._imageProcessingConfiguration.toneMappingEnabled;
  49711. },
  49712. /**
  49713. * Sets wether tonemapping is enabled or not
  49714. */
  49715. set: function (value) {
  49716. this._imageProcessingConfiguration.toneMappingEnabled = value;
  49717. },
  49718. enumerable: true,
  49719. configurable: true
  49720. });
  49721. Object.defineProperty(BackgroundMaterial.prototype, "cameraExposure", {
  49722. /**
  49723. * The camera exposure used on this material.
  49724. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49725. * This corresponds to a photographic exposure.
  49726. */
  49727. get: function () {
  49728. return this._imageProcessingConfiguration.exposure;
  49729. },
  49730. /**
  49731. * The camera exposure used on this material.
  49732. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49733. * This corresponds to a photographic exposure.
  49734. */
  49735. set: function (value) {
  49736. this._imageProcessingConfiguration.exposure = value;
  49737. },
  49738. enumerable: true,
  49739. configurable: true
  49740. });
  49741. Object.defineProperty(BackgroundMaterial.prototype, "cameraContrast", {
  49742. /**
  49743. * Gets The camera contrast used on this material.
  49744. */
  49745. get: function () {
  49746. return this._imageProcessingConfiguration.contrast;
  49747. },
  49748. /**
  49749. * Sets The camera contrast used on this material.
  49750. */
  49751. set: function (value) {
  49752. this._imageProcessingConfiguration.contrast = value;
  49753. },
  49754. enumerable: true,
  49755. configurable: true
  49756. });
  49757. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingTexture", {
  49758. /**
  49759. * Gets the Color Grading 2D Lookup Texture.
  49760. */
  49761. get: function () {
  49762. return this._imageProcessingConfiguration.colorGradingTexture;
  49763. },
  49764. /**
  49765. * Sets the Color Grading 2D Lookup Texture.
  49766. */
  49767. set: function (value) {
  49768. this.imageProcessingConfiguration.colorGradingTexture = value;
  49769. },
  49770. enumerable: true,
  49771. configurable: true
  49772. });
  49773. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurves", {
  49774. /**
  49775. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49776. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49777. * 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;
  49778. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49779. */
  49780. get: function () {
  49781. return this.imageProcessingConfiguration.colorCurves;
  49782. },
  49783. /**
  49784. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49785. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49786. * 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;
  49787. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49788. */
  49789. set: function (value) {
  49790. this.imageProcessingConfiguration.colorCurves = value;
  49791. },
  49792. enumerable: true,
  49793. configurable: true
  49794. });
  49795. Object.defineProperty(BackgroundMaterial.prototype, "hasRenderTargetTextures", {
  49796. /**
  49797. * Gets a boolean indicating that current material needs to register RTT
  49798. */
  49799. get: function () {
  49800. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  49801. return true;
  49802. }
  49803. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  49804. return true;
  49805. }
  49806. return false;
  49807. },
  49808. enumerable: true,
  49809. configurable: true
  49810. });
  49811. /**
  49812. * The entire material has been created in order to prevent overdraw.
  49813. * @returns false
  49814. */
  49815. BackgroundMaterial.prototype.needAlphaTesting = function () {
  49816. return true;
  49817. };
  49818. /**
  49819. * The entire material has been created in order to prevent overdraw.
  49820. * @returns true if blending is enable
  49821. */
  49822. BackgroundMaterial.prototype.needAlphaBlending = function () {
  49823. return ((this.alpha < 0) || (this._diffuseTexture != null && this._diffuseTexture.hasAlpha));
  49824. };
  49825. /**
  49826. * Checks wether the material is ready to be rendered for a given mesh.
  49827. * @param mesh The mesh to render
  49828. * @param subMesh The submesh to check against
  49829. * @param useInstances Specify wether or not the material is used with instances
  49830. * @returns true if all the dependencies are ready (Textures, Effects...)
  49831. */
  49832. BackgroundMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  49833. var _this = this;
  49834. if (useInstances === void 0) { useInstances = false; }
  49835. if (subMesh.effect && this.isFrozen) {
  49836. if (this._wasPreviouslyReady) {
  49837. return true;
  49838. }
  49839. }
  49840. if (!subMesh._materialDefines) {
  49841. subMesh._materialDefines = new BackgroundMaterialDefines();
  49842. }
  49843. var scene = this.getScene();
  49844. var defines = subMesh._materialDefines;
  49845. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  49846. if (defines._renderId === scene.getRenderId()) {
  49847. return true;
  49848. }
  49849. }
  49850. var engine = scene.getEngine();
  49851. // Lights
  49852. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights);
  49853. defines._needNormals = true;
  49854. // Textures
  49855. if (defines._areTexturesDirty) {
  49856. defines._needUVs = false;
  49857. if (scene.texturesEnabled) {
  49858. if (scene.getEngine().getCaps().textureLOD) {
  49859. defines.TEXTURELODSUPPORT = true;
  49860. }
  49861. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  49862. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  49863. return false;
  49864. }
  49865. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  49866. defines.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha;
  49867. defines.GAMMADIFFUSE = this._diffuseTexture.gammaSpace;
  49868. defines.OPACITYFRESNEL = this._opacityFresnel;
  49869. }
  49870. else {
  49871. defines.DIFFUSE = false;
  49872. defines.DIFFUSEHASALPHA = false;
  49873. defines.GAMMADIFFUSE = false;
  49874. defines.OPACITYFRESNEL = false;
  49875. }
  49876. var reflectionTexture = this._reflectionTexture;
  49877. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  49878. if (!reflectionTexture.isReadyOrNotBlocking()) {
  49879. return false;
  49880. }
  49881. defines.REFLECTION = true;
  49882. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  49883. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  49884. defines.REFLECTIONBLUR = this._reflectionBlur > 0;
  49885. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  49886. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  49887. defines.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV;
  49888. defines.REFLECTIONBGR = this.switchToBGR;
  49889. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE) {
  49890. defines.INVERTCUBICMAP = true;
  49891. }
  49892. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  49893. switch (reflectionTexture.coordinatesMode) {
  49894. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  49895. defines.REFLECTIONMAP_EXPLICIT = true;
  49896. break;
  49897. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  49898. defines.REFLECTIONMAP_PLANAR = true;
  49899. break;
  49900. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  49901. defines.REFLECTIONMAP_PROJECTION = true;
  49902. break;
  49903. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  49904. defines.REFLECTIONMAP_SKYBOX = true;
  49905. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  49906. break;
  49907. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  49908. defines.REFLECTIONMAP_SPHERICAL = true;
  49909. break;
  49910. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  49911. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  49912. break;
  49913. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  49914. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  49915. break;
  49916. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  49917. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  49918. break;
  49919. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  49920. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  49921. default:
  49922. defines.REFLECTIONMAP_CUBIC = true;
  49923. break;
  49924. }
  49925. if (this.reflectionFresnel) {
  49926. defines.REFLECTIONFRESNEL = true;
  49927. defines.REFLECTIONFALLOFF = this.reflectionFalloffDistance > 0;
  49928. this._reflectionControls.x = this.reflectionAmount;
  49929. this._reflectionControls.y = this.reflectionReflectance0;
  49930. this._reflectionControls.z = this.reflectionReflectance90;
  49931. this._reflectionControls.w = 1 / this.reflectionFalloffDistance;
  49932. }
  49933. else {
  49934. defines.REFLECTIONFRESNEL = false;
  49935. defines.REFLECTIONFALLOFF = false;
  49936. }
  49937. }
  49938. else {
  49939. defines.REFLECTION = false;
  49940. defines.REFLECTIONFRESNEL = false;
  49941. defines.REFLECTIONFALLOFF = false;
  49942. defines.REFLECTIONBLUR = false;
  49943. defines.REFLECTIONMAP_3D = false;
  49944. defines.REFLECTIONMAP_SPHERICAL = false;
  49945. defines.REFLECTIONMAP_PLANAR = false;
  49946. defines.REFLECTIONMAP_CUBIC = false;
  49947. defines.REFLECTIONMAP_PROJECTION = false;
  49948. defines.REFLECTIONMAP_SKYBOX = false;
  49949. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  49950. defines.REFLECTIONMAP_EXPLICIT = false;
  49951. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  49952. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  49953. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  49954. defines.INVERTCUBICMAP = false;
  49955. defines.REFLECTIONMAP_OPPOSITEZ = false;
  49956. defines.LODINREFLECTIONALPHA = false;
  49957. defines.GAMMAREFLECTION = false;
  49958. defines.RGBDREFLECTION = false;
  49959. }
  49960. }
  49961. 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);
  49962. defines.USERGBCOLOR = this._useRGBColor;
  49963. defines.NOISE = this._enableNoise;
  49964. }
  49965. if (defines._areLightsDirty) {
  49966. defines.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (this._primaryColorShadowLevel !== 0 || this._primaryColorHighlightLevel !== 0);
  49967. }
  49968. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  49969. if (!this._imageProcessingConfiguration.isReady()) {
  49970. return false;
  49971. }
  49972. this._imageProcessingConfiguration.prepareDefines(defines);
  49973. }
  49974. // Misc.
  49975. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  49976. // Values that need to be evaluated on every frame
  49977. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  49978. // Attribs
  49979. if (_Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, false, true, false)) {
  49980. if (mesh) {
  49981. if (!scene.getEngine().getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  49982. mesh.createNormals(true);
  49983. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn("BackgroundMaterial: Normals have been created for the mesh: " + mesh.name);
  49984. }
  49985. }
  49986. }
  49987. // Get correct effect
  49988. if (defines.isDirty) {
  49989. defines.markAsProcessed();
  49990. scene.resetCachedMaterial();
  49991. // Fallbacks
  49992. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  49993. if (defines.FOG) {
  49994. fallbacks.addFallback(0, "FOG");
  49995. }
  49996. if (defines.POINTSIZE) {
  49997. fallbacks.addFallback(1, "POINTSIZE");
  49998. }
  49999. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  50000. if (defines.NUM_BONE_INFLUENCERS > 0) {
  50001. fallbacks.addCPUSkinningFallback(0, mesh);
  50002. }
  50003. //Attributes
  50004. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  50005. if (defines.NORMAL) {
  50006. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  50007. }
  50008. if (defines.UV1) {
  50009. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  50010. }
  50011. if (defines.UV2) {
  50012. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  50013. }
  50014. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  50015. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  50016. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
  50017. "vFogInfos", "vFogColor", "pointSize",
  50018. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "mBones",
  50019. "vPrimaryColor", "vPrimaryColorShadow",
  50020. "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos", "fFovMultiplier",
  50021. "shadowLevel", "alpha",
  50022. "vBackgroundCenter", "vReflectionControl",
  50023. "vDiffuseInfos", "diffuseMatrix",
  50024. ];
  50025. var samplers = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"];
  50026. var uniformBuffers = ["Material", "Scene"];
  50027. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"]) {
  50028. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  50029. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  50030. }
  50031. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareUniformsAndSamplersList({
  50032. uniformsNames: uniforms,
  50033. uniformBuffersNames: uniformBuffers,
  50034. samplers: samplers,
  50035. defines: defines,
  50036. maxSimultaneousLights: this._maxSimultaneousLights
  50037. });
  50038. var onCompiled = function (effect) {
  50039. if (_this.onCompiled) {
  50040. _this.onCompiled(effect);
  50041. }
  50042. _this.bindSceneUniformBuffer(effect, scene.getSceneUniformBuffer());
  50043. };
  50044. var join = defines.toString();
  50045. subMesh.setEffect(scene.getEngine().createEffect("background", {
  50046. attributes: attribs,
  50047. uniformsNames: uniforms,
  50048. uniformBuffersNames: uniformBuffers,
  50049. samplers: samplers,
  50050. defines: join,
  50051. fallbacks: fallbacks,
  50052. onCompiled: onCompiled,
  50053. onError: this.onError,
  50054. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights }
  50055. }, engine), defines);
  50056. this.buildUniformLayout();
  50057. }
  50058. if (!subMesh.effect || !subMesh.effect.isReady()) {
  50059. return false;
  50060. }
  50061. defines._renderId = scene.getRenderId();
  50062. this._wasPreviouslyReady = true;
  50063. return true;
  50064. };
  50065. /**
  50066. * Compute the primary color according to the chosen perceptual color.
  50067. */
  50068. BackgroundMaterial.prototype._computePrimaryColorFromPerceptualColor = function () {
  50069. if (!this.__perceptualColor) {
  50070. return;
  50071. }
  50072. this._primaryColor.copyFrom(this.__perceptualColor);
  50073. // Revert gamma space.
  50074. this._primaryColor.toLinearSpaceToRef(this._primaryColor);
  50075. // Revert image processing configuration.
  50076. if (this._imageProcessingConfiguration) {
  50077. // Revert Exposure.
  50078. this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor);
  50079. }
  50080. this._computePrimaryColors();
  50081. };
  50082. /**
  50083. * Compute the highlights and shadow colors according to their chosen levels.
  50084. */
  50085. BackgroundMaterial.prototype._computePrimaryColors = function () {
  50086. if (this._primaryColorShadowLevel === 0 && this._primaryColorHighlightLevel === 0) {
  50087. return;
  50088. }
  50089. // Find the highlight color based on the configuration.
  50090. this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor);
  50091. this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor);
  50092. // Find the shadow color based on the configuration.
  50093. this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor);
  50094. this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor);
  50095. this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor);
  50096. };
  50097. /**
  50098. * Build the uniform buffer used in the material.
  50099. */
  50100. BackgroundMaterial.prototype.buildUniformLayout = function () {
  50101. // Order is important !
  50102. this._uniformBuffer.addUniform("vPrimaryColor", 4);
  50103. this._uniformBuffer.addUniform("vPrimaryColorShadow", 4);
  50104. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  50105. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  50106. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  50107. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  50108. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  50109. this._uniformBuffer.addUniform("fFovMultiplier", 1);
  50110. this._uniformBuffer.addUniform("pointSize", 1);
  50111. this._uniformBuffer.addUniform("shadowLevel", 1);
  50112. this._uniformBuffer.addUniform("alpha", 1);
  50113. this._uniformBuffer.addUniform("vBackgroundCenter", 3);
  50114. this._uniformBuffer.addUniform("vReflectionControl", 4);
  50115. this._uniformBuffer.create();
  50116. };
  50117. /**
  50118. * Unbind the material.
  50119. */
  50120. BackgroundMaterial.prototype.unbind = function () {
  50121. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  50122. this._uniformBuffer.setTexture("diffuseSampler", null);
  50123. }
  50124. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  50125. this._uniformBuffer.setTexture("reflectionSampler", null);
  50126. }
  50127. _super.prototype.unbind.call(this);
  50128. };
  50129. /**
  50130. * Bind only the world matrix to the material.
  50131. * @param world The world matrix to bind.
  50132. */
  50133. BackgroundMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  50134. this._activeEffect.setMatrix("world", world);
  50135. };
  50136. /**
  50137. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50138. * @param world The world matrix to bind.
  50139. * @param subMesh The submesh to bind for.
  50140. */
  50141. BackgroundMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  50142. var scene = this.getScene();
  50143. var defines = subMesh._materialDefines;
  50144. if (!defines) {
  50145. return;
  50146. }
  50147. var effect = subMesh.effect;
  50148. if (!effect) {
  50149. return;
  50150. }
  50151. this._activeEffect = effect;
  50152. // Matrices
  50153. this.bindOnlyWorldMatrix(world);
  50154. // Bones
  50155. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  50156. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  50157. if (mustRebind) {
  50158. this._uniformBuffer.bindToEffect(effect, "Material");
  50159. this.bindViewProjection(effect);
  50160. var reflectionTexture = this._reflectionTexture;
  50161. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  50162. // Texture uniforms
  50163. if (scene.texturesEnabled) {
  50164. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50165. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  50166. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  50167. }
  50168. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50169. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  50170. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, this._reflectionBlur);
  50171. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  50172. }
  50173. }
  50174. if (this.shadowLevel > 0) {
  50175. this._uniformBuffer.updateFloat("shadowLevel", this.shadowLevel);
  50176. }
  50177. this._uniformBuffer.updateFloat("alpha", this.alpha);
  50178. // Point size
  50179. if (this.pointsCloud) {
  50180. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  50181. }
  50182. if (defines.USEHIGHLIGHTANDSHADOWCOLORS) {
  50183. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryHighlightColor, 1.0);
  50184. this._uniformBuffer.updateColor4("vPrimaryColorShadow", this._primaryShadowColor, 1.0);
  50185. }
  50186. else {
  50187. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryColor, 1.0);
  50188. }
  50189. }
  50190. this._uniformBuffer.updateFloat("fFovMultiplier", this._fovMultiplier);
  50191. // Textures
  50192. if (scene.texturesEnabled) {
  50193. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50194. this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture);
  50195. }
  50196. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50197. if (defines.REFLECTIONBLUR && defines.TEXTURELODSUPPORT) {
  50198. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  50199. }
  50200. else if (!defines.REFLECTIONBLUR) {
  50201. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  50202. }
  50203. else {
  50204. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  50205. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  50206. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  50207. }
  50208. if (defines.REFLECTIONFRESNEL) {
  50209. this._uniformBuffer.updateFloat3("vBackgroundCenter", this.sceneCenter.x, this.sceneCenter.y, this.sceneCenter.z);
  50210. this._uniformBuffer.updateFloat4("vReflectionControl", this._reflectionControls.x, this._reflectionControls.y, this._reflectionControls.z, this._reflectionControls.w);
  50211. }
  50212. }
  50213. }
  50214. // Clip plane
  50215. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  50216. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindEyePosition(effect, scene);
  50217. }
  50218. if (mustRebind || !this.isFrozen) {
  50219. if (scene.lightsEnabled) {
  50220. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, false);
  50221. }
  50222. // View
  50223. this.bindView(effect);
  50224. // Fog
  50225. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  50226. // image processing
  50227. if (this._imageProcessingConfiguration) {
  50228. this._imageProcessingConfiguration.bind(this._activeEffect);
  50229. }
  50230. }
  50231. this._uniformBuffer.update();
  50232. this._afterBind(mesh, this._activeEffect);
  50233. };
  50234. /**
  50235. * Dispose the material.
  50236. * @param forceDisposeEffect Force disposal of the associated effect.
  50237. * @param forceDisposeTextures Force disposal of the associated textures.
  50238. */
  50239. BackgroundMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  50240. if (forceDisposeEffect === void 0) { forceDisposeEffect = false; }
  50241. if (forceDisposeTextures === void 0) { forceDisposeTextures = false; }
  50242. if (forceDisposeTextures) {
  50243. if (this.diffuseTexture) {
  50244. this.diffuseTexture.dispose();
  50245. }
  50246. if (this.reflectionTexture) {
  50247. this.reflectionTexture.dispose();
  50248. }
  50249. }
  50250. this._renderTargets.dispose();
  50251. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  50252. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  50253. }
  50254. _super.prototype.dispose.call(this, forceDisposeEffect);
  50255. };
  50256. /**
  50257. * Clones the material.
  50258. * @param name The cloned name.
  50259. * @returns The cloned material.
  50260. */
  50261. BackgroundMaterial.prototype.clone = function (name) {
  50262. var _this = this;
  50263. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new BackgroundMaterial(name, _this.getScene()); }, this);
  50264. };
  50265. /**
  50266. * Serializes the current material to its JSON representation.
  50267. * @returns The JSON representation.
  50268. */
  50269. BackgroundMaterial.prototype.serialize = function () {
  50270. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  50271. serializationObject.customType = "BABYLON.BackgroundMaterial";
  50272. return serializationObject;
  50273. };
  50274. /**
  50275. * Gets the class name of the material
  50276. * @returns "BackgroundMaterial"
  50277. */
  50278. BackgroundMaterial.prototype.getClassName = function () {
  50279. return "BackgroundMaterial";
  50280. };
  50281. /**
  50282. * Parse a JSON input to create back a background material.
  50283. * @param source The JSON data to parse
  50284. * @param scene The scene to create the parsed material in
  50285. * @param rootUrl The root url of the assets the material depends upon
  50286. * @returns the instantiated BackgroundMaterial.
  50287. */
  50288. BackgroundMaterial.Parse = function (source, scene, rootUrl) {
  50289. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new BackgroundMaterial(source.name, scene); }, source, scene, rootUrl);
  50290. };
  50291. /**
  50292. * Standard reflectance value at parallel view angle.
  50293. */
  50294. BackgroundMaterial.StandardReflectance0 = 0.05;
  50295. /**
  50296. * Standard reflectance value at grazing angle.
  50297. */
  50298. BackgroundMaterial.StandardReflectance90 = 0.5;
  50299. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50300. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  50301. ], BackgroundMaterial.prototype, "_primaryColor", void 0);
  50302. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50303. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  50304. ], BackgroundMaterial.prototype, "primaryColor", void 0);
  50305. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50306. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  50307. ], BackgroundMaterial.prototype, "__perceptualColor", void 0);
  50308. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50309. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50310. ], BackgroundMaterial.prototype, "_primaryColorShadowLevel", void 0);
  50311. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50312. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50313. ], BackgroundMaterial.prototype, "_primaryColorHighlightLevel", void 0);
  50314. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50315. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  50316. ], BackgroundMaterial.prototype, "primaryColorHighlightLevel", null);
  50317. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50318. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  50319. ], BackgroundMaterial.prototype, "_reflectionTexture", void 0);
  50320. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50321. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50322. ], BackgroundMaterial.prototype, "reflectionTexture", void 0);
  50323. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50324. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50325. ], BackgroundMaterial.prototype, "_reflectionBlur", void 0);
  50326. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50327. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50328. ], BackgroundMaterial.prototype, "reflectionBlur", void 0);
  50329. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50330. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  50331. ], BackgroundMaterial.prototype, "_diffuseTexture", void 0);
  50332. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50333. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50334. ], BackgroundMaterial.prototype, "diffuseTexture", void 0);
  50335. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50336. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50337. ], BackgroundMaterial.prototype, "shadowLights", void 0);
  50338. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50339. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50340. ], BackgroundMaterial.prototype, "_shadowLevel", void 0);
  50341. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50342. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50343. ], BackgroundMaterial.prototype, "shadowLevel", void 0);
  50344. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50345. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  50346. ], BackgroundMaterial.prototype, "_sceneCenter", void 0);
  50347. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50348. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50349. ], BackgroundMaterial.prototype, "sceneCenter", void 0);
  50350. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50351. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50352. ], BackgroundMaterial.prototype, "_opacityFresnel", void 0);
  50353. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50354. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50355. ], BackgroundMaterial.prototype, "opacityFresnel", void 0);
  50356. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50357. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50358. ], BackgroundMaterial.prototype, "_reflectionFresnel", void 0);
  50359. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50360. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50361. ], BackgroundMaterial.prototype, "reflectionFresnel", void 0);
  50362. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50363. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50364. ], BackgroundMaterial.prototype, "_reflectionFalloffDistance", void 0);
  50365. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50366. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50367. ], BackgroundMaterial.prototype, "reflectionFalloffDistance", void 0);
  50368. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50369. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50370. ], BackgroundMaterial.prototype, "_reflectionAmount", void 0);
  50371. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50372. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50373. ], BackgroundMaterial.prototype, "reflectionAmount", void 0);
  50374. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50375. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50376. ], BackgroundMaterial.prototype, "_reflectionReflectance0", void 0);
  50377. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50378. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50379. ], BackgroundMaterial.prototype, "reflectionReflectance0", void 0);
  50380. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50381. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50382. ], BackgroundMaterial.prototype, "_reflectionReflectance90", void 0);
  50383. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50384. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50385. ], BackgroundMaterial.prototype, "reflectionReflectance90", void 0);
  50386. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50387. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50388. ], BackgroundMaterial.prototype, "_useRGBColor", void 0);
  50389. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50390. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50391. ], BackgroundMaterial.prototype, "useRGBColor", void 0);
  50392. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50393. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50394. ], BackgroundMaterial.prototype, "_enableNoise", void 0);
  50395. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50396. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50397. ], BackgroundMaterial.prototype, "enableNoise", void 0);
  50398. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50399. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50400. ], BackgroundMaterial.prototype, "_maxSimultaneousLights", void 0);
  50401. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50402. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50403. ], BackgroundMaterial.prototype, "maxSimultaneousLights", void 0);
  50404. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50405. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  50406. ], BackgroundMaterial.prototype, "_imageProcessingConfiguration", void 0);
  50407. return BackgroundMaterial;
  50408. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  50409. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__["_TypeStore"].RegisteredTypes["BABYLON.BackgroundMaterial"] = BackgroundMaterial;
  50410. /***/ }),
  50411. /***/ "./Materials/Background/index.ts":
  50412. /*!***************************************!*\
  50413. !*** ./Materials/Background/index.ts ***!
  50414. \***************************************/
  50415. /*! exports provided: BackgroundMaterial */
  50416. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50417. "use strict";
  50418. __webpack_require__.r(__webpack_exports__);
  50419. /* harmony import */ var _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  50420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  50421. /***/ }),
  50422. /***/ "./Materials/PBR/index.ts":
  50423. /*!********************************!*\
  50424. !*** ./Materials/PBR/index.ts ***!
  50425. \********************************/
  50426. /*! exports provided: PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial */
  50427. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50428. "use strict";
  50429. __webpack_require__.r(__webpack_exports__);
  50430. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  50431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  50432. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  50433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__["PBRBaseSimpleMaterial"]; });
  50434. /* harmony import */ var _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  50435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRMaterial"]; });
  50436. /* harmony import */ var _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrMetallicRoughnessMaterial */ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts");
  50437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRMetallicRoughnessMaterial"]; });
  50438. /* harmony import */ var _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrSpecularGlossinessMaterial */ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts");
  50439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRSpecularGlossinessMaterial"]; });
  50440. /***/ }),
  50441. /***/ "./Materials/PBR/pbrBaseMaterial.ts":
  50442. /*!******************************************!*\
  50443. !*** ./Materials/PBR/pbrBaseMaterial.ts ***!
  50444. \******************************************/
  50445. /*! exports provided: PBRBaseMaterial */
  50446. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50447. "use strict";
  50448. __webpack_require__.r(__webpack_exports__);
  50449. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return PBRBaseMaterial; });
  50450. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  50451. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  50452. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  50453. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  50454. /* harmony import */ var _Misc_textureTools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/textureTools */ "./Misc/textureTools.ts");
  50455. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  50456. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  50457. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  50458. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  50459. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  50460. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  50461. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  50462. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  50463. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  50464. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  50465. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  50466. /* harmony import */ var _Shaders_pbr_fragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/pbr.fragment */ "./Shaders/pbr.fragment.ts");
  50467. /* harmony import */ var _Shaders_pbr_vertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Shaders/pbr.vertex */ "./Shaders/pbr.vertex.ts");
  50468. /**
  50469. * Manages the defines for the PBR Material.
  50470. * @hiddenChildren
  50471. */
  50472. var PBRMaterialDefines = /** @class */ (function (_super) {
  50473. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterialDefines, _super);
  50474. /**
  50475. * Initializes the PBR Material defines.
  50476. */
  50477. function PBRMaterialDefines() {
  50478. var _this = _super.call(this) || this;
  50479. _this.PBR = true;
  50480. _this.MAINUV1 = false;
  50481. _this.MAINUV2 = false;
  50482. _this.UV1 = false;
  50483. _this.UV2 = false;
  50484. _this.ALBEDO = false;
  50485. _this.ALBEDODIRECTUV = 0;
  50486. _this.VERTEXCOLOR = false;
  50487. _this.AMBIENT = false;
  50488. _this.AMBIENTDIRECTUV = 0;
  50489. _this.AMBIENTINGRAYSCALE = false;
  50490. _this.OPACITY = false;
  50491. _this.VERTEXALPHA = false;
  50492. _this.OPACITYDIRECTUV = 0;
  50493. _this.OPACITYRGB = false;
  50494. _this.ALPHATEST = false;
  50495. _this.DEPTHPREPASS = false;
  50496. _this.ALPHABLEND = false;
  50497. _this.ALPHAFROMALBEDO = false;
  50498. _this.ALPHATESTVALUE = "0.5";
  50499. _this.SPECULAROVERALPHA = false;
  50500. _this.RADIANCEOVERALPHA = false;
  50501. _this.ALPHAFRESNEL = false;
  50502. _this.LINEARALPHAFRESNEL = false;
  50503. _this.PREMULTIPLYALPHA = false;
  50504. _this.EMISSIVE = false;
  50505. _this.EMISSIVEDIRECTUV = 0;
  50506. _this.REFLECTIVITY = false;
  50507. _this.REFLECTIVITYDIRECTUV = 0;
  50508. _this.SPECULARTERM = false;
  50509. _this.MICROSURFACEFROMREFLECTIVITYMAP = false;
  50510. _this.MICROSURFACEAUTOMATIC = false;
  50511. _this.LODBASEDMICROSFURACE = false;
  50512. _this.MICROSURFACEMAP = false;
  50513. _this.MICROSURFACEMAPDIRECTUV = 0;
  50514. _this.METALLICWORKFLOW = false;
  50515. _this.ROUGHNESSSTOREINMETALMAPALPHA = false;
  50516. _this.ROUGHNESSSTOREINMETALMAPGREEN = false;
  50517. _this.METALLNESSSTOREINMETALMAPBLUE = false;
  50518. _this.AOSTOREINMETALMAPRED = false;
  50519. _this.ENVIRONMENTBRDF = false;
  50520. _this.NORMAL = false;
  50521. _this.TANGENT = false;
  50522. _this.BUMP = false;
  50523. _this.BUMPDIRECTUV = 0;
  50524. _this.OBJECTSPACE_NORMALMAP = false;
  50525. _this.PARALLAX = false;
  50526. _this.PARALLAXOCCLUSION = false;
  50527. _this.NORMALXYSCALE = true;
  50528. _this.LIGHTMAP = false;
  50529. _this.LIGHTMAPDIRECTUV = 0;
  50530. _this.USELIGHTMAPASSHADOWMAP = false;
  50531. _this.GAMMALIGHTMAP = false;
  50532. _this.REFLECTION = false;
  50533. _this.REFLECTIONMAP_3D = false;
  50534. _this.REFLECTIONMAP_SPHERICAL = false;
  50535. _this.REFLECTIONMAP_PLANAR = false;
  50536. _this.REFLECTIONMAP_CUBIC = false;
  50537. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  50538. _this.REFLECTIONMAP_PROJECTION = false;
  50539. _this.REFLECTIONMAP_SKYBOX = false;
  50540. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  50541. _this.REFLECTIONMAP_EXPLICIT = false;
  50542. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  50543. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  50544. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  50545. _this.INVERTCUBICMAP = false;
  50546. _this.USESPHERICALFROMREFLECTIONMAP = false;
  50547. _this.USESPHERICALINVERTEX = false;
  50548. _this.REFLECTIONMAP_OPPOSITEZ = false;
  50549. _this.LODINREFLECTIONALPHA = false;
  50550. _this.GAMMAREFLECTION = false;
  50551. _this.RGBDREFLECTION = false;
  50552. _this.RADIANCEOCCLUSION = false;
  50553. _this.HORIZONOCCLUSION = false;
  50554. _this.REFRACTION = false;
  50555. _this.REFRACTIONMAP_3D = false;
  50556. _this.REFRACTIONMAP_OPPOSITEZ = false;
  50557. _this.LODINREFRACTIONALPHA = false;
  50558. _this.GAMMAREFRACTION = false;
  50559. _this.RGBDREFRACTION = false;
  50560. _this.LINKREFRACTIONTOTRANSPARENCY = false;
  50561. _this.INSTANCES = false;
  50562. _this.NUM_BONE_INFLUENCERS = 0;
  50563. _this.BonesPerMesh = 0;
  50564. _this.BONETEXTURE = false;
  50565. _this.NONUNIFORMSCALING = false;
  50566. _this.MORPHTARGETS = false;
  50567. _this.MORPHTARGETS_NORMAL = false;
  50568. _this.MORPHTARGETS_TANGENT = false;
  50569. _this.NUM_MORPH_INFLUENCERS = 0;
  50570. _this.IMAGEPROCESSING = false;
  50571. _this.VIGNETTE = false;
  50572. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  50573. _this.VIGNETTEBLENDMODEOPAQUE = false;
  50574. _this.TONEMAPPING = false;
  50575. _this.TONEMAPPING_ACES = false;
  50576. _this.CONTRAST = false;
  50577. _this.COLORCURVES = false;
  50578. _this.COLORGRADING = false;
  50579. _this.COLORGRADING3D = false;
  50580. _this.SAMPLER3DGREENDEPTH = false;
  50581. _this.SAMPLER3DBGRMAP = false;
  50582. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  50583. _this.EXPOSURE = false;
  50584. _this.USEPHYSICALLIGHTFALLOFF = false;
  50585. _this.USEGLTFLIGHTFALLOFF = false;
  50586. _this.TWOSIDEDLIGHTING = false;
  50587. _this.SHADOWFLOAT = false;
  50588. _this.CLIPPLANE = false;
  50589. _this.CLIPPLANE2 = false;
  50590. _this.CLIPPLANE3 = false;
  50591. _this.CLIPPLANE4 = false;
  50592. _this.POINTSIZE = false;
  50593. _this.FOG = false;
  50594. _this.LOGARITHMICDEPTH = false;
  50595. _this.FORCENORMALFORWARD = false;
  50596. _this.SPECULARAA = false;
  50597. _this.UNLIT = false;
  50598. _this.rebuild();
  50599. return _this;
  50600. }
  50601. /**
  50602. * Resets the PBR Material defines.
  50603. */
  50604. PBRMaterialDefines.prototype.reset = function () {
  50605. _super.prototype.reset.call(this);
  50606. this.ALPHATESTVALUE = "0.5";
  50607. this.PBR = true;
  50608. };
  50609. return PBRMaterialDefines;
  50610. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_10__["MaterialDefines"]));
  50611. /**
  50612. * The Physically based material base class of BJS.
  50613. *
  50614. * This offers the main features of a standard PBR material.
  50615. * For more information, please refer to the documentation :
  50616. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  50617. */
  50618. var PBRBaseMaterial = /** @class */ (function (_super) {
  50619. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseMaterial, _super);
  50620. /**
  50621. * Instantiates a new PBRMaterial instance.
  50622. *
  50623. * @param name The material name
  50624. * @param scene The scene the material will be use in.
  50625. */
  50626. function PBRBaseMaterial(name, scene) {
  50627. var _this = _super.call(this, name, scene) || this;
  50628. /**
  50629. * Intensity of the direct lights e.g. the four lights available in your scene.
  50630. * This impacts both the direct diffuse and specular highlights.
  50631. */
  50632. _this._directIntensity = 1.0;
  50633. /**
  50634. * Intensity of the emissive part of the material.
  50635. * This helps controlling the emissive effect without modifying the emissive color.
  50636. */
  50637. _this._emissiveIntensity = 1.0;
  50638. /**
  50639. * Intensity of the environment e.g. how much the environment will light the object
  50640. * either through harmonics for rough material or through the refelction for shiny ones.
  50641. */
  50642. _this._environmentIntensity = 1.0;
  50643. /**
  50644. * This is a special control allowing the reduction of the specular highlights coming from the
  50645. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50646. */
  50647. _this._specularIntensity = 1.0;
  50648. /**
  50649. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50650. */
  50651. _this._lightingInfos = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](_this._directIntensity, _this._emissiveIntensity, _this._environmentIntensity, _this._specularIntensity);
  50652. /**
  50653. * Debug Control allowing disabling the bump map on this material.
  50654. */
  50655. _this._disableBumpMap = false;
  50656. /**
  50657. * AKA Occlusion Texture Intensity in other nomenclature.
  50658. */
  50659. _this._ambientTextureStrength = 1.0;
  50660. /**
  50661. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50662. * 1 means it completely occludes it
  50663. * 0 mean it has no impact
  50664. */
  50665. _this._ambientTextureImpactOnAnalyticalLights = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  50666. /**
  50667. * The color of a material in ambient lighting.
  50668. */
  50669. _this._ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  50670. /**
  50671. * AKA Diffuse Color in other nomenclature.
  50672. */
  50673. _this._albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  50674. /**
  50675. * AKA Specular Color in other nomenclature.
  50676. */
  50677. _this._reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  50678. /**
  50679. * The color applied when light is reflected from a material.
  50680. */
  50681. _this._reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  50682. /**
  50683. * The color applied when light is emitted from a material.
  50684. */
  50685. _this._emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  50686. /**
  50687. * AKA Glossiness in other nomenclature.
  50688. */
  50689. _this._microSurface = 0.9;
  50690. /**
  50691. * source material index of refraction (IOR)' / 'destination material IOR.
  50692. */
  50693. _this._indexOfRefraction = 0.66;
  50694. /**
  50695. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50696. */
  50697. _this._invertRefractionY = false;
  50698. /**
  50699. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50700. * Materials half opaque for instance using refraction could benefit from this control.
  50701. */
  50702. _this._linkRefractionWithTransparency = false;
  50703. /**
  50704. * Specifies that the material will use the light map as a show map.
  50705. */
  50706. _this._useLightmapAsShadowmap = false;
  50707. /**
  50708. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50709. * makes the reflect vector face the model (under horizon).
  50710. */
  50711. _this._useHorizonOcclusion = true;
  50712. /**
  50713. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50714. * too much the area relying on ambient texture to define their ambient occlusion.
  50715. */
  50716. _this._useRadianceOcclusion = true;
  50717. /**
  50718. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50719. */
  50720. _this._useAlphaFromAlbedoTexture = false;
  50721. /**
  50722. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50723. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50724. */
  50725. _this._useSpecularOverAlpha = true;
  50726. /**
  50727. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50728. */
  50729. _this._useMicroSurfaceFromReflectivityMapAlpha = false;
  50730. /**
  50731. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50732. */
  50733. _this._useRoughnessFromMetallicTextureAlpha = true;
  50734. /**
  50735. * Specifies if the metallic texture contains the roughness information in its green channel.
  50736. */
  50737. _this._useRoughnessFromMetallicTextureGreen = false;
  50738. /**
  50739. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50740. */
  50741. _this._useMetallnessFromMetallicTextureBlue = false;
  50742. /**
  50743. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50744. */
  50745. _this._useAmbientOcclusionFromMetallicTextureRed = false;
  50746. /**
  50747. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50748. */
  50749. _this._useAmbientInGrayScale = false;
  50750. /**
  50751. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50752. * The material will try to infer what glossiness each pixel should be.
  50753. */
  50754. _this._useAutoMicroSurfaceFromReflectivityMap = false;
  50755. /**
  50756. * Defines the falloff type used in this material.
  50757. * It by default is Physical.
  50758. */
  50759. _this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL;
  50760. /**
  50761. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50762. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50763. */
  50764. _this._useRadianceOverAlpha = true;
  50765. /**
  50766. * Allows using an object space normal map (instead of tangent space).
  50767. */
  50768. _this._useObjectSpaceNormalMap = false;
  50769. /**
  50770. * Allows using the bump map in parallax mode.
  50771. */
  50772. _this._useParallax = false;
  50773. /**
  50774. * Allows using the bump map in parallax occlusion mode.
  50775. */
  50776. _this._useParallaxOcclusion = false;
  50777. /**
  50778. * Controls the scale bias of the parallax mode.
  50779. */
  50780. _this._parallaxScaleBias = 0.05;
  50781. /**
  50782. * If sets to true, disables all the lights affecting the material.
  50783. */
  50784. _this._disableLighting = false;
  50785. /**
  50786. * Number of Simultaneous lights allowed on the material.
  50787. */
  50788. _this._maxSimultaneousLights = 4;
  50789. /**
  50790. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50791. */
  50792. _this._invertNormalMapX = false;
  50793. /**
  50794. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50795. */
  50796. _this._invertNormalMapY = false;
  50797. /**
  50798. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50799. */
  50800. _this._twoSidedLighting = false;
  50801. /**
  50802. * Defines the alpha limits in alpha test mode.
  50803. */
  50804. _this._alphaCutOff = 0.4;
  50805. /**
  50806. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50807. */
  50808. _this._forceAlphaTest = false;
  50809. /**
  50810. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50811. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50812. */
  50813. _this._useAlphaFresnel = false;
  50814. /**
  50815. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50816. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50817. */
  50818. _this._useLinearAlphaFresnel = false;
  50819. /**
  50820. * The transparency mode of the material.
  50821. */
  50822. _this._transparencyMode = null;
  50823. /**
  50824. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50825. * from cos thetav and roughness:
  50826. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50827. */
  50828. _this._environmentBRDFTexture = null;
  50829. /**
  50830. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50831. */
  50832. _this._forceIrradianceInFragment = false;
  50833. /**
  50834. * Force normal to face away from face.
  50835. */
  50836. _this._forceNormalForward = false;
  50837. /**
  50838. * Enables specular anti aliasing in the PBR shader.
  50839. * It will both interacts on the Geometry for analytical and IBL lighting.
  50840. * It also prefilter the roughness map based on the bump values.
  50841. */
  50842. _this._enableSpecularAntiAliasing = false;
  50843. /**
  50844. * Stores the available render targets.
  50845. */
  50846. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__["SmartArray"](16);
  50847. /**
  50848. * Sets the global ambient color for the material used in lighting calculations.
  50849. */
  50850. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  50851. /**
  50852. * If set to true, no lighting calculations will be applied.
  50853. */
  50854. _this._unlit = false;
  50855. // Setup the default processing configuration to the scene.
  50856. _this._attachImageProcessingConfiguration(null);
  50857. _this.getRenderTargetTextures = function () {
  50858. _this._renderTargets.reset();
  50859. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  50860. _this._renderTargets.push(_this._reflectionTexture);
  50861. }
  50862. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  50863. _this._renderTargets.push(_this._refractionTexture);
  50864. }
  50865. return _this._renderTargets;
  50866. };
  50867. _this._environmentBRDFTexture = _Misc_textureTools__WEBPACK_IMPORTED_MODULE_4__["TextureTools"].GetEnvironmentBRDFTexture(scene);
  50868. return _this;
  50869. }
  50870. /**
  50871. * Attaches a new image processing configuration to the PBR Material.
  50872. * @param configuration
  50873. */
  50874. PBRBaseMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  50875. var _this = this;
  50876. if (configuration === this._imageProcessingConfiguration) {
  50877. return;
  50878. }
  50879. // Detaches observer.
  50880. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  50881. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  50882. }
  50883. // Pick the scene configuration if needed.
  50884. if (!configuration) {
  50885. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  50886. }
  50887. else {
  50888. this._imageProcessingConfiguration = configuration;
  50889. }
  50890. // Attaches observer.
  50891. if (this._imageProcessingConfiguration) {
  50892. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  50893. _this._markAllSubMeshesAsImageProcessingDirty();
  50894. });
  50895. }
  50896. };
  50897. Object.defineProperty(PBRBaseMaterial.prototype, "hasRenderTargetTextures", {
  50898. /**
  50899. * Gets a boolean indicating that current material needs to register RTT
  50900. */
  50901. get: function () {
  50902. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  50903. return true;
  50904. }
  50905. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  50906. return true;
  50907. }
  50908. return false;
  50909. },
  50910. enumerable: true,
  50911. configurable: true
  50912. });
  50913. /**
  50914. * Gets the name of the material class.
  50915. */
  50916. PBRBaseMaterial.prototype.getClassName = function () {
  50917. return "PBRBaseMaterial";
  50918. };
  50919. Object.defineProperty(PBRBaseMaterial.prototype, "useLogarithmicDepth", {
  50920. /**
  50921. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50922. */
  50923. get: function () {
  50924. return this._useLogarithmicDepth;
  50925. },
  50926. /**
  50927. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50928. */
  50929. set: function (value) {
  50930. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  50931. },
  50932. enumerable: true,
  50933. configurable: true
  50934. });
  50935. Object.defineProperty(PBRBaseMaterial.prototype, "transparencyMode", {
  50936. /**
  50937. * Gets the current transparency mode.
  50938. */
  50939. get: function () {
  50940. return this._transparencyMode;
  50941. },
  50942. /**
  50943. * Sets the transparency mode of the material.
  50944. *
  50945. * | Value | Type | Description |
  50946. * | ----- | ----------------------------------- | ----------- |
  50947. * | 0 | OPAQUE | |
  50948. * | 1 | ALPHATEST | |
  50949. * | 2 | ALPHABLEND | |
  50950. * | 3 | ALPHATESTANDBLEND | |
  50951. *
  50952. */
  50953. set: function (value) {
  50954. if (this._transparencyMode === value) {
  50955. return;
  50956. }
  50957. this._transparencyMode = value;
  50958. this._forceAlphaTest = (value === PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND);
  50959. this._markAllSubMeshesAsTexturesAndMiscDirty();
  50960. },
  50961. enumerable: true,
  50962. configurable: true
  50963. });
  50964. Object.defineProperty(PBRBaseMaterial.prototype, "_disableAlphaBlending", {
  50965. /**
  50966. * Returns true if alpha blending should be disabled.
  50967. */
  50968. get: function () {
  50969. return (this._linkRefractionWithTransparency ||
  50970. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_OPAQUE ||
  50971. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  50972. },
  50973. enumerable: true,
  50974. configurable: true
  50975. });
  50976. /**
  50977. * Specifies whether or not this material should be rendered in alpha blend mode.
  50978. */
  50979. PBRBaseMaterial.prototype.needAlphaBlending = function () {
  50980. if (this._disableAlphaBlending) {
  50981. return false;
  50982. }
  50983. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromAlbedoTexture();
  50984. };
  50985. /**
  50986. * Specifies if the mesh will require alpha blending.
  50987. * @param mesh - BJS mesh.
  50988. */
  50989. PBRBaseMaterial.prototype.needAlphaBlendingForMesh = function (mesh) {
  50990. if (this._disableAlphaBlending) {
  50991. return false;
  50992. }
  50993. return _super.prototype.needAlphaBlendingForMesh.call(this, mesh);
  50994. };
  50995. /**
  50996. * Specifies whether or not this material should be rendered in alpha test mode.
  50997. */
  50998. PBRBaseMaterial.prototype.needAlphaTesting = function () {
  50999. if (this._forceAlphaTest) {
  51000. return true;
  51001. }
  51002. if (this._linkRefractionWithTransparency) {
  51003. return false;
  51004. }
  51005. return this._albedoTexture != null && this._albedoTexture.hasAlpha && (this._transparencyMode == null || this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  51006. };
  51007. /**
  51008. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51009. */
  51010. PBRBaseMaterial.prototype._shouldUseAlphaFromAlbedoTexture = function () {
  51011. return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE;
  51012. };
  51013. /**
  51014. * Gets the texture used for the alpha test.
  51015. */
  51016. PBRBaseMaterial.prototype.getAlphaTestTexture = function () {
  51017. return this._albedoTexture;
  51018. };
  51019. /**
  51020. * Specifies that the submesh is ready to be used.
  51021. * @param mesh - BJS mesh.
  51022. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51023. * @param useInstances - Specifies that instances should be used.
  51024. * @returns - boolean indicating that the submesh is ready or not.
  51025. */
  51026. PBRBaseMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  51027. if (subMesh.effect && this.isFrozen) {
  51028. if (this._wasPreviouslyReady) {
  51029. return true;
  51030. }
  51031. }
  51032. if (!subMesh._materialDefines) {
  51033. subMesh._materialDefines = new PBRMaterialDefines();
  51034. }
  51035. var defines = subMesh._materialDefines;
  51036. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  51037. if (defines._renderId === this.getScene().getRenderId()) {
  51038. return true;
  51039. }
  51040. }
  51041. var scene = this.getScene();
  51042. var engine = scene.getEngine();
  51043. if (defines._areTexturesDirty) {
  51044. if (scene.texturesEnabled) {
  51045. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51046. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  51047. return false;
  51048. }
  51049. }
  51050. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  51051. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  51052. return false;
  51053. }
  51054. }
  51055. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  51056. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  51057. return false;
  51058. }
  51059. }
  51060. var reflectionTexture = this._getReflectionTexture();
  51061. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51062. if (!reflectionTexture.isReadyOrNotBlocking()) {
  51063. return false;
  51064. }
  51065. }
  51066. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  51067. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  51068. return false;
  51069. }
  51070. }
  51071. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  51072. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  51073. return false;
  51074. }
  51075. }
  51076. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  51077. if (this._metallicTexture) {
  51078. if (!this._metallicTexture.isReadyOrNotBlocking()) {
  51079. return false;
  51080. }
  51081. }
  51082. else if (this._reflectivityTexture) {
  51083. if (!this._reflectivityTexture.isReadyOrNotBlocking()) {
  51084. return false;
  51085. }
  51086. }
  51087. if (this._microSurfaceTexture) {
  51088. if (!this._microSurfaceTexture.isReadyOrNotBlocking()) {
  51089. return false;
  51090. }
  51091. }
  51092. }
  51093. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  51094. // Bump texture cannot be not blocking.
  51095. if (!this._bumpTexture.isReady()) {
  51096. return false;
  51097. }
  51098. }
  51099. var refractionTexture = this._getRefractionTexture();
  51100. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  51101. if (!refractionTexture.isReadyOrNotBlocking()) {
  51102. return false;
  51103. }
  51104. }
  51105. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51106. // This is blocking.
  51107. if (!this._environmentBRDFTexture.isReady()) {
  51108. return false;
  51109. }
  51110. }
  51111. }
  51112. }
  51113. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  51114. if (!this._imageProcessingConfiguration.isReady()) {
  51115. return false;
  51116. }
  51117. }
  51118. if (!engine.getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  51119. mesh.createNormals(true);
  51120. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("PBRMaterial: Normals have been created for the mesh: " + mesh.name);
  51121. }
  51122. var previousEffect = subMesh.effect;
  51123. var effect = this._prepareEffect(mesh, defines, this.onCompiled, this.onError, useInstances);
  51124. if (effect) {
  51125. // Use previous effect while new one is compiling
  51126. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  51127. effect = previousEffect;
  51128. defines.markAsUnprocessed();
  51129. }
  51130. else {
  51131. scene.resetCachedMaterial();
  51132. subMesh.setEffect(effect, defines);
  51133. this.buildUniformLayout();
  51134. }
  51135. }
  51136. if (!subMesh.effect || !subMesh.effect.isReady()) {
  51137. return false;
  51138. }
  51139. defines._renderId = scene.getRenderId();
  51140. this._wasPreviouslyReady = true;
  51141. return true;
  51142. };
  51143. /**
  51144. * Specifies if the material uses metallic roughness workflow.
  51145. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51146. */
  51147. PBRBaseMaterial.prototype.isMetallicWorkflow = function () {
  51148. if (this._metallic != null || this._roughness != null || this._metallicTexture) {
  51149. return true;
  51150. }
  51151. return false;
  51152. };
  51153. PBRBaseMaterial.prototype._prepareEffect = function (mesh, defines, onCompiled, onError, useInstances, useClipPlane) {
  51154. if (onCompiled === void 0) { onCompiled = null; }
  51155. if (onError === void 0) { onError = null; }
  51156. if (useInstances === void 0) { useInstances = null; }
  51157. if (useClipPlane === void 0) { useClipPlane = null; }
  51158. this._prepareDefines(mesh, defines, useInstances, useClipPlane);
  51159. if (!defines.isDirty) {
  51160. return null;
  51161. }
  51162. defines.markAsProcessed();
  51163. var scene = this.getScene();
  51164. var engine = scene.getEngine();
  51165. // Fallbacks
  51166. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["EffectFallbacks"]();
  51167. var fallbackRank = 0;
  51168. if (defines.USESPHERICALINVERTEX) {
  51169. fallbacks.addFallback(fallbackRank++, "USESPHERICALINVERTEX");
  51170. }
  51171. if (defines.FOG) {
  51172. fallbacks.addFallback(fallbackRank, "FOG");
  51173. }
  51174. if (defines.SPECULARAA) {
  51175. fallbacks.addFallback(fallbackRank, "SPECULARAA");
  51176. }
  51177. if (defines.POINTSIZE) {
  51178. fallbacks.addFallback(fallbackRank, "POINTSIZE");
  51179. }
  51180. if (defines.LOGARITHMICDEPTH) {
  51181. fallbacks.addFallback(fallbackRank, "LOGARITHMICDEPTH");
  51182. }
  51183. if (defines.PARALLAX) {
  51184. fallbacks.addFallback(fallbackRank, "PARALLAX");
  51185. }
  51186. if (defines.PARALLAXOCCLUSION) {
  51187. fallbacks.addFallback(fallbackRank++, "PARALLAXOCCLUSION");
  51188. }
  51189. if (defines.ENVIRONMENTBRDF) {
  51190. fallbacks.addFallback(fallbackRank++, "ENVIRONMENTBRDF");
  51191. }
  51192. if (defines.TANGENT) {
  51193. fallbacks.addFallback(fallbackRank++, "TANGENT");
  51194. }
  51195. if (defines.BUMP) {
  51196. fallbacks.addFallback(fallbackRank++, "BUMP");
  51197. }
  51198. fallbackRank = _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights, fallbackRank++);
  51199. if (defines.SPECULARTERM) {
  51200. fallbacks.addFallback(fallbackRank++, "SPECULARTERM");
  51201. }
  51202. if (defines.USESPHERICALFROMREFLECTIONMAP) {
  51203. fallbacks.addFallback(fallbackRank++, "USESPHERICALFROMREFLECTIONMAP");
  51204. }
  51205. if (defines.LIGHTMAP) {
  51206. fallbacks.addFallback(fallbackRank++, "LIGHTMAP");
  51207. }
  51208. if (defines.NORMAL) {
  51209. fallbacks.addFallback(fallbackRank++, "NORMAL");
  51210. }
  51211. if (defines.AMBIENT) {
  51212. fallbacks.addFallback(fallbackRank++, "AMBIENT");
  51213. }
  51214. if (defines.EMISSIVE) {
  51215. fallbacks.addFallback(fallbackRank++, "EMISSIVE");
  51216. }
  51217. if (defines.VERTEXCOLOR) {
  51218. fallbacks.addFallback(fallbackRank++, "VERTEXCOLOR");
  51219. }
  51220. if (defines.NUM_BONE_INFLUENCERS > 0) {
  51221. fallbacks.addCPUSkinningFallback(fallbackRank++, mesh);
  51222. }
  51223. if (defines.MORPHTARGETS) {
  51224. fallbacks.addFallback(fallbackRank++, "MORPHTARGETS");
  51225. }
  51226. //Attributes
  51227. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  51228. if (defines.NORMAL) {
  51229. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  51230. }
  51231. if (defines.TANGENT) {
  51232. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind);
  51233. }
  51234. if (defines.UV1) {
  51235. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  51236. }
  51237. if (defines.UV2) {
  51238. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  51239. }
  51240. if (defines.VERTEXCOLOR) {
  51241. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  51242. }
  51243. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  51244. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  51245. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  51246. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vAlbedoColor", "vReflectivityColor", "vEmissiveColor", "vReflectionColor",
  51247. "vFogInfos", "vFogColor", "pointSize",
  51248. "vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vReflectionPosition", "vReflectionSize", "vEmissiveInfos", "vReflectivityInfos",
  51249. "vMicroSurfaceSamplerInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  51250. "mBones",
  51251. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "normalMatrix", "microSurfaceSamplerMatrix", "bumpMatrix", "lightmapMatrix", "refractionMatrix",
  51252. "vLightingIntensity",
  51253. "logarithmicDepthConstant",
  51254. "vSphericalX", "vSphericalY", "vSphericalZ",
  51255. "vSphericalXX", "vSphericalYY", "vSphericalZZ",
  51256. "vSphericalXY", "vSphericalYZ", "vSphericalZX",
  51257. "vReflectionMicrosurfaceInfos", "vRefractionMicrosurfaceInfos",
  51258. "vTangentSpaceParams", "boneTextureWidth"
  51259. ];
  51260. var samplers = ["albedoSampler", "reflectivitySampler", "ambientSampler", "emissiveSampler",
  51261. "bumpSampler", "lightmapSampler", "opacitySampler",
  51262. "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh",
  51263. "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh",
  51264. "microSurfaceSampler", "environmentBrdfSampler", "boneSampler"];
  51265. var uniformBuffers = ["Material", "Scene"];
  51266. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__["ImageProcessingConfiguration"]) {
  51267. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  51268. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  51269. }
  51270. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareUniformsAndSamplersList({
  51271. uniformsNames: uniforms,
  51272. uniformBuffersNames: uniformBuffers,
  51273. samplers: samplers,
  51274. defines: defines,
  51275. maxSimultaneousLights: this._maxSimultaneousLights
  51276. });
  51277. var join = defines.toString();
  51278. return engine.createEffect("pbr", {
  51279. attributes: attribs,
  51280. uniformsNames: uniforms,
  51281. uniformBuffersNames: uniformBuffers,
  51282. samplers: samplers,
  51283. defines: join,
  51284. fallbacks: fallbacks,
  51285. onCompiled: onCompiled,
  51286. onError: onError,
  51287. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  51288. }, engine);
  51289. };
  51290. PBRBaseMaterial.prototype._prepareDefines = function (mesh, defines, useInstances, useClipPlane) {
  51291. if (useInstances === void 0) { useInstances = null; }
  51292. if (useClipPlane === void 0) { useClipPlane = null; }
  51293. var scene = this.getScene();
  51294. var engine = scene.getEngine();
  51295. // Lights
  51296. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  51297. defines._needNormals = true;
  51298. // Textures
  51299. defines.METALLICWORKFLOW = this.isMetallicWorkflow();
  51300. if (defines._areTexturesDirty) {
  51301. defines._needUVs = false;
  51302. if (scene.texturesEnabled) {
  51303. if (scene.getEngine().getCaps().textureLOD) {
  51304. defines.LODBASEDMICROSFURACE = true;
  51305. }
  51306. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51307. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._albedoTexture, defines, "ALBEDO");
  51308. }
  51309. else {
  51310. defines.ALBEDO = false;
  51311. }
  51312. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  51313. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  51314. defines.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale;
  51315. }
  51316. else {
  51317. defines.AMBIENT = false;
  51318. }
  51319. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  51320. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  51321. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  51322. }
  51323. else {
  51324. defines.OPACITY = false;
  51325. }
  51326. var reflectionTexture = this._getReflectionTexture();
  51327. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51328. defines.REFLECTION = true;
  51329. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  51330. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  51331. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  51332. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  51333. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].INVCUBIC_MODE) {
  51334. defines.INVERTCUBICMAP = true;
  51335. }
  51336. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  51337. defines.REFLECTIONMAP_CUBIC = false;
  51338. defines.REFLECTIONMAP_EXPLICIT = false;
  51339. defines.REFLECTIONMAP_PLANAR = false;
  51340. defines.REFLECTIONMAP_PROJECTION = false;
  51341. defines.REFLECTIONMAP_SKYBOX = false;
  51342. defines.REFLECTIONMAP_SPHERICAL = false;
  51343. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  51344. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  51345. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  51346. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  51347. switch (reflectionTexture.coordinatesMode) {
  51348. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].EXPLICIT_MODE:
  51349. defines.REFLECTIONMAP_EXPLICIT = true;
  51350. break;
  51351. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].PLANAR_MODE:
  51352. defines.REFLECTIONMAP_PLANAR = true;
  51353. break;
  51354. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].PROJECTION_MODE:
  51355. defines.REFLECTIONMAP_PROJECTION = true;
  51356. break;
  51357. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].SKYBOX_MODE:
  51358. defines.REFLECTIONMAP_SKYBOX = true;
  51359. break;
  51360. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].SPHERICAL_MODE:
  51361. defines.REFLECTIONMAP_SPHERICAL = true;
  51362. break;
  51363. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].EQUIRECTANGULAR_MODE:
  51364. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  51365. break;
  51366. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  51367. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  51368. break;
  51369. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  51370. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  51371. break;
  51372. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].CUBIC_MODE:
  51373. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].INVCUBIC_MODE:
  51374. default:
  51375. defines.REFLECTIONMAP_CUBIC = true;
  51376. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = reflectionTexture.boundingBoxSize ? true : false;
  51377. break;
  51378. }
  51379. if (reflectionTexture.coordinatesMode !== _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].SKYBOX_MODE) {
  51380. if (reflectionTexture.sphericalPolynomial) {
  51381. defines.USESPHERICALFROMREFLECTIONMAP = true;
  51382. if (this._forceIrradianceInFragment || scene.getEngine().getCaps().maxVaryingVectors <= 8) {
  51383. defines.USESPHERICALINVERTEX = false;
  51384. }
  51385. else {
  51386. defines.USESPHERICALINVERTEX = true;
  51387. }
  51388. }
  51389. }
  51390. else {
  51391. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  51392. }
  51393. }
  51394. else {
  51395. defines.REFLECTION = false;
  51396. defines.REFLECTIONMAP_3D = false;
  51397. defines.REFLECTIONMAP_SPHERICAL = false;
  51398. defines.REFLECTIONMAP_PLANAR = false;
  51399. defines.REFLECTIONMAP_CUBIC = false;
  51400. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  51401. defines.REFLECTIONMAP_PROJECTION = false;
  51402. defines.REFLECTIONMAP_SKYBOX = false;
  51403. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  51404. defines.REFLECTIONMAP_EXPLICIT = false;
  51405. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  51406. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  51407. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  51408. defines.INVERTCUBICMAP = false;
  51409. defines.USESPHERICALFROMREFLECTIONMAP = false;
  51410. defines.USESPHERICALINVERTEX = false;
  51411. defines.REFLECTIONMAP_OPPOSITEZ = false;
  51412. defines.LODINREFLECTIONALPHA = false;
  51413. defines.GAMMAREFLECTION = false;
  51414. defines.RGBDREFLECTION = false;
  51415. }
  51416. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  51417. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  51418. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  51419. defines.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace;
  51420. }
  51421. else {
  51422. defines.LIGHTMAP = false;
  51423. }
  51424. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  51425. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  51426. }
  51427. else {
  51428. defines.EMISSIVE = false;
  51429. }
  51430. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  51431. if (this._metallicTexture) {
  51432. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._metallicTexture, defines, "REFLECTIVITY");
  51433. defines.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha;
  51434. defines.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen;
  51435. defines.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue;
  51436. defines.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed;
  51437. }
  51438. else if (this._reflectivityTexture) {
  51439. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._reflectivityTexture, defines, "REFLECTIVITY");
  51440. defines.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha;
  51441. defines.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap;
  51442. }
  51443. else {
  51444. defines.REFLECTIVITY = false;
  51445. }
  51446. if (this._microSurfaceTexture) {
  51447. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._microSurfaceTexture, defines, "MICROSURFACEMAP");
  51448. }
  51449. else {
  51450. defines.MICROSURFACEMAP = false;
  51451. }
  51452. }
  51453. else {
  51454. defines.REFLECTIVITY = false;
  51455. defines.MICROSURFACEMAP = false;
  51456. }
  51457. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  51458. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  51459. if (this._useParallax && this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51460. defines.PARALLAX = true;
  51461. defines.PARALLAXOCCLUSION = !!this._useParallaxOcclusion;
  51462. }
  51463. else {
  51464. defines.PARALLAX = false;
  51465. }
  51466. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  51467. }
  51468. else {
  51469. defines.BUMP = false;
  51470. }
  51471. var refractionTexture = this._getRefractionTexture();
  51472. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  51473. defines.REFRACTION = true;
  51474. defines.REFRACTIONMAP_3D = refractionTexture.isCube;
  51475. defines.GAMMAREFRACTION = refractionTexture.gammaSpace;
  51476. defines.RGBDREFRACTION = refractionTexture.isRGBD;
  51477. defines.REFRACTIONMAP_OPPOSITEZ = refractionTexture.invertZ;
  51478. defines.LODINREFRACTIONALPHA = refractionTexture.lodLevelInAlpha;
  51479. if (this._linkRefractionWithTransparency) {
  51480. defines.LINKREFRACTIONTOTRANSPARENCY = true;
  51481. }
  51482. }
  51483. else {
  51484. defines.REFRACTION = false;
  51485. }
  51486. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51487. defines.ENVIRONMENTBRDF = true;
  51488. }
  51489. else {
  51490. defines.ENVIRONMENTBRDF = false;
  51491. }
  51492. if (this._shouldUseAlphaFromAlbedoTexture()) {
  51493. defines.ALPHAFROMALBEDO = true;
  51494. }
  51495. else {
  51496. defines.ALPHAFROMALBEDO = false;
  51497. }
  51498. }
  51499. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  51500. if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_STANDARD) {
  51501. defines.USEPHYSICALLIGHTFALLOFF = false;
  51502. defines.USEGLTFLIGHTFALLOFF = false;
  51503. }
  51504. else if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF) {
  51505. defines.USEPHYSICALLIGHTFALLOFF = false;
  51506. defines.USEGLTFLIGHTFALLOFF = true;
  51507. }
  51508. else {
  51509. defines.USEPHYSICALLIGHTFALLOFF = true;
  51510. defines.USEGLTFLIGHTFALLOFF = false;
  51511. }
  51512. defines.RADIANCEOVERALPHA = this._useRadianceOverAlpha;
  51513. if (!this.backFaceCulling && this._twoSidedLighting) {
  51514. defines.TWOSIDEDLIGHTING = true;
  51515. }
  51516. else {
  51517. defines.TWOSIDEDLIGHTING = false;
  51518. }
  51519. defines.ALPHATESTVALUE = "" + this._alphaCutOff + (this._alphaCutOff % 1 === 0 ? "." : "");
  51520. 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);
  51521. defines.ALPHABLEND = this.needAlphaBlendingForMesh(mesh);
  51522. defines.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel;
  51523. defines.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel;
  51524. defines.SPECULARAA = scene.getEngine().getCaps().standardDerivatives && this._enableSpecularAntiAliasing;
  51525. }
  51526. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  51527. this._imageProcessingConfiguration.prepareDefines(defines);
  51528. }
  51529. defines.FORCENORMALFORWARD = this._forceNormalForward;
  51530. defines.RADIANCEOCCLUSION = this._useRadianceOcclusion;
  51531. defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
  51532. // Misc.
  51533. if (defines._areMiscDirty) {
  51534. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, defines);
  51535. defines.UNLIT = this._unlit || ((this.pointsCloud || this.wireframe) && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind));
  51536. }
  51537. // Values that need to be evaluated on every frame
  51538. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, useClipPlane);
  51539. // Attribs
  51540. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE);
  51541. };
  51542. /**
  51543. * Force shader compilation
  51544. */
  51545. PBRBaseMaterial.prototype.forceCompilation = function (mesh, onCompiled, options) {
  51546. var _this = this;
  51547. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  51548. var defines = new PBRMaterialDefines();
  51549. var effect = this._prepareEffect(mesh, defines, undefined, undefined, undefined, localOptions.clipPlane);
  51550. if (effect.isReady()) {
  51551. if (onCompiled) {
  51552. onCompiled(this);
  51553. }
  51554. }
  51555. else {
  51556. effect.onCompileObservable.add(function () {
  51557. if (onCompiled) {
  51558. onCompiled(_this);
  51559. }
  51560. });
  51561. }
  51562. };
  51563. /**
  51564. * Initializes the uniform buffer layout for the shader.
  51565. */
  51566. PBRBaseMaterial.prototype.buildUniformLayout = function () {
  51567. // Order is important !
  51568. this._uniformBuffer.addUniform("vAlbedoInfos", 2);
  51569. this._uniformBuffer.addUniform("vAmbientInfos", 4);
  51570. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  51571. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  51572. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  51573. this._uniformBuffer.addUniform("vReflectivityInfos", 3);
  51574. this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos", 2);
  51575. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  51576. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  51577. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  51578. this._uniformBuffer.addUniform("vReflectionSize", 3);
  51579. this._uniformBuffer.addUniform("vBumpInfos", 3);
  51580. this._uniformBuffer.addUniform("albedoMatrix", 16);
  51581. this._uniformBuffer.addUniform("ambientMatrix", 16);
  51582. this._uniformBuffer.addUniform("opacityMatrix", 16);
  51583. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  51584. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  51585. this._uniformBuffer.addUniform("reflectivityMatrix", 16);
  51586. this._uniformBuffer.addUniform("microSurfaceSamplerMatrix", 16);
  51587. this._uniformBuffer.addUniform("bumpMatrix", 16);
  51588. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  51589. this._uniformBuffer.addUniform("refractionMatrix", 16);
  51590. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  51591. this._uniformBuffer.addUniform("vReflectionColor", 3);
  51592. this._uniformBuffer.addUniform("vAlbedoColor", 4);
  51593. this._uniformBuffer.addUniform("vLightingIntensity", 4);
  51594. this._uniformBuffer.addUniform("vRefractionMicrosurfaceInfos", 3);
  51595. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  51596. this._uniformBuffer.addUniform("vReflectivityColor", 4);
  51597. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  51598. this._uniformBuffer.addUniform("pointSize", 1);
  51599. this._uniformBuffer.create();
  51600. };
  51601. /**
  51602. * Unbinds the textures.
  51603. */
  51604. PBRBaseMaterial.prototype.unbind = function () {
  51605. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  51606. this._uniformBuffer.setTexture("reflectionSampler", null);
  51607. }
  51608. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  51609. this._uniformBuffer.setTexture("refractionSampler", null);
  51610. }
  51611. _super.prototype.unbind.call(this);
  51612. };
  51613. /**
  51614. * Binds the submesh data.
  51615. * @param world - The world matrix.
  51616. * @param mesh - The BJS mesh.
  51617. * @param subMesh - A submesh of the BJS mesh.
  51618. */
  51619. PBRBaseMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  51620. var scene = this.getScene();
  51621. var defines = subMesh._materialDefines;
  51622. if (!defines) {
  51623. return;
  51624. }
  51625. var effect = subMesh.effect;
  51626. if (!effect) {
  51627. return;
  51628. }
  51629. this._activeEffect = effect;
  51630. // Matrices
  51631. this.bindOnlyWorldMatrix(world);
  51632. // Normal Matrix
  51633. if (defines.OBJECTSPACE_NORMALMAP) {
  51634. world.toNormalMatrix(this._normalMatrix);
  51635. this.bindOnlyNormalMatrix(this._normalMatrix);
  51636. }
  51637. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  51638. // Bones
  51639. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  51640. var reflectionTexture = null;
  51641. if (mustRebind) {
  51642. this._uniformBuffer.bindToEffect(effect, "Material");
  51643. this.bindViewProjection(effect);
  51644. reflectionTexture = this._getReflectionTexture();
  51645. var refractionTexture = this._getRefractionTexture();
  51646. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  51647. // Texture uniforms
  51648. if (scene.texturesEnabled) {
  51649. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51650. this._uniformBuffer.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level);
  51651. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._albedoTexture, this._uniformBuffer, "albedo");
  51652. }
  51653. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  51654. this._uniformBuffer.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights);
  51655. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  51656. }
  51657. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  51658. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  51659. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  51660. }
  51661. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51662. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  51663. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, 0);
  51664. if (reflectionTexture.boundingBoxSize) {
  51665. var cubeTexture = reflectionTexture;
  51666. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  51667. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  51668. }
  51669. var polynomials = reflectionTexture.sphericalPolynomial;
  51670. if (defines.USESPHERICALFROMREFLECTIONMAP && polynomials) {
  51671. this._activeEffect.setFloat3("vSphericalX", polynomials.x.x, polynomials.x.y, polynomials.x.z);
  51672. this._activeEffect.setFloat3("vSphericalY", polynomials.y.x, polynomials.y.y, polynomials.y.z);
  51673. this._activeEffect.setFloat3("vSphericalZ", polynomials.z.x, polynomials.z.y, polynomials.z.z);
  51674. this._activeEffect.setFloat3("vSphericalXX_ZZ", polynomials.xx.x - polynomials.zz.x, polynomials.xx.y - polynomials.zz.y, polynomials.xx.z - polynomials.zz.z);
  51675. this._activeEffect.setFloat3("vSphericalYY_ZZ", polynomials.yy.x - polynomials.zz.x, polynomials.yy.y - polynomials.zz.y, polynomials.yy.z - polynomials.zz.z);
  51676. this._activeEffect.setFloat3("vSphericalZZ", polynomials.zz.x, polynomials.zz.y, polynomials.zz.z);
  51677. this._activeEffect.setFloat3("vSphericalXY", polynomials.xy.x, polynomials.xy.y, polynomials.xy.z);
  51678. this._activeEffect.setFloat3("vSphericalYZ", polynomials.yz.x, polynomials.yz.y, polynomials.yz.z);
  51679. this._activeEffect.setFloat3("vSphericalZX", polynomials.zx.x, polynomials.zx.y, polynomials.zx.z);
  51680. }
  51681. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  51682. }
  51683. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  51684. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  51685. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  51686. }
  51687. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  51688. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  51689. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  51690. }
  51691. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  51692. if (this._metallicTexture) {
  51693. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength);
  51694. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._metallicTexture, this._uniformBuffer, "reflectivity");
  51695. }
  51696. else if (this._reflectivityTexture) {
  51697. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1.0);
  51698. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._reflectivityTexture, this._uniformBuffer, "reflectivity");
  51699. }
  51700. if (this._microSurfaceTexture) {
  51701. this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level);
  51702. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._microSurfaceTexture, this._uniformBuffer, "microSurfaceSampler");
  51703. }
  51704. }
  51705. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  51706. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias);
  51707. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  51708. if (scene._mirroredCameraPosition) {
  51709. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  51710. }
  51711. else {
  51712. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  51713. }
  51714. }
  51715. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  51716. this._uniformBuffer.updateMatrix("refractionMatrix", refractionTexture.getReflectionTextureMatrix());
  51717. var depth = 1.0;
  51718. if (!refractionTexture.isCube) {
  51719. if (refractionTexture.depth) {
  51720. depth = refractionTexture.depth;
  51721. }
  51722. }
  51723. this._uniformBuffer.updateFloat4("vRefractionInfos", refractionTexture.level, this._indexOfRefraction, depth, this._invertRefractionY ? -1 : 1);
  51724. this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos", refractionTexture.getSize().width, refractionTexture.lodGenerationScale, refractionTexture.lodGenerationOffset);
  51725. }
  51726. }
  51727. // Point size
  51728. if (this.pointsCloud) {
  51729. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  51730. }
  51731. // Colors
  51732. if (defines.METALLICWORKFLOW) {
  51733. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].r = (this._metallic === undefined || this._metallic === null) ? 1 : this._metallic;
  51734. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].g = (this._roughness === undefined || this._roughness === null) ? 1 : this._roughness;
  51735. this._uniformBuffer.updateColor4("vReflectivityColor", _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0], 0);
  51736. }
  51737. else {
  51738. this._uniformBuffer.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
  51739. }
  51740. this._uniformBuffer.updateColor3("vEmissiveColor", _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled ? this._emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"].BlackReadOnly);
  51741. this._uniformBuffer.updateColor3("vReflectionColor", this._reflectionColor);
  51742. this._uniformBuffer.updateColor4("vAlbedoColor", this._albedoColor, this.alpha * mesh.visibility);
  51743. // Misc
  51744. this._lightingInfos.x = this._directIntensity;
  51745. this._lightingInfos.y = this._emissiveIntensity;
  51746. this._lightingInfos.z = this._environmentIntensity;
  51747. this._lightingInfos.w = this._specularIntensity;
  51748. this._uniformBuffer.updateVector4("vLightingIntensity", this._lightingInfos);
  51749. }
  51750. // Textures
  51751. if (scene.texturesEnabled) {
  51752. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51753. this._uniformBuffer.setTexture("albedoSampler", this._albedoTexture);
  51754. }
  51755. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  51756. this._uniformBuffer.setTexture("ambientSampler", this._ambientTexture);
  51757. }
  51758. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  51759. this._uniformBuffer.setTexture("opacitySampler", this._opacityTexture);
  51760. }
  51761. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51762. if (defines.LODBASEDMICROSFURACE) {
  51763. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  51764. }
  51765. else {
  51766. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  51767. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  51768. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  51769. }
  51770. }
  51771. if (defines.ENVIRONMENTBRDF) {
  51772. this._uniformBuffer.setTexture("environmentBrdfSampler", this._environmentBRDFTexture);
  51773. }
  51774. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  51775. if (defines.LODBASEDMICROSFURACE) {
  51776. this._uniformBuffer.setTexture("refractionSampler", refractionTexture);
  51777. }
  51778. else {
  51779. this._uniformBuffer.setTexture("refractionSampler", refractionTexture._lodTextureMid || refractionTexture);
  51780. this._uniformBuffer.setTexture("refractionSamplerLow", refractionTexture._lodTextureLow || refractionTexture);
  51781. this._uniformBuffer.setTexture("refractionSamplerHigh", refractionTexture._lodTextureHigh || refractionTexture);
  51782. }
  51783. }
  51784. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  51785. this._uniformBuffer.setTexture("emissiveSampler", this._emissiveTexture);
  51786. }
  51787. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  51788. this._uniformBuffer.setTexture("lightmapSampler", this._lightmapTexture);
  51789. }
  51790. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  51791. if (this._metallicTexture) {
  51792. this._uniformBuffer.setTexture("reflectivitySampler", this._metallicTexture);
  51793. }
  51794. else if (this._reflectivityTexture) {
  51795. this._uniformBuffer.setTexture("reflectivitySampler", this._reflectivityTexture);
  51796. }
  51797. if (this._microSurfaceTexture) {
  51798. this._uniformBuffer.setTexture("microSurfaceSampler", this._microSurfaceTexture);
  51799. }
  51800. }
  51801. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  51802. this._uniformBuffer.setTexture("bumpSampler", this._bumpTexture);
  51803. }
  51804. }
  51805. // Clip plane
  51806. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  51807. // Colors
  51808. scene.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor);
  51809. var eyePosition = scene._forcedViewPosition ? scene._forcedViewPosition : (scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  51810. var invertNormal = (scene.useRightHandedSystem === (scene._mirroredCameraPosition != null));
  51811. effect.setFloat4("vEyePosition", eyePosition.x, eyePosition.y, eyePosition.z, invertNormal ? -1 : 1);
  51812. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  51813. }
  51814. if (mustRebind || !this.isFrozen) {
  51815. // Lights
  51816. if (scene.lightsEnabled && !this._disableLighting) {
  51817. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, this._lightFalloff !== PBRBaseMaterial.LIGHTFALLOFF_STANDARD);
  51818. }
  51819. // View
  51820. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].FOGMODE_NONE || reflectionTexture) {
  51821. this.bindView(effect);
  51822. }
  51823. // Fog
  51824. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  51825. // Morph targets
  51826. if (defines.NUM_MORPH_INFLUENCERS) {
  51827. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindMorphTargetParameters(mesh, this._activeEffect);
  51828. }
  51829. // image processing
  51830. this._imageProcessingConfiguration.bind(this._activeEffect);
  51831. // Log. depth
  51832. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindLogDepth(defines, this._activeEffect, scene);
  51833. }
  51834. this._uniformBuffer.update();
  51835. this._afterBind(mesh, this._activeEffect);
  51836. };
  51837. /**
  51838. * Returns the animatable textures.
  51839. * @returns - Array of animatable textures.
  51840. */
  51841. PBRBaseMaterial.prototype.getAnimatables = function () {
  51842. var results = [];
  51843. if (this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0) {
  51844. results.push(this._albedoTexture);
  51845. }
  51846. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  51847. results.push(this._ambientTexture);
  51848. }
  51849. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  51850. results.push(this._opacityTexture);
  51851. }
  51852. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  51853. results.push(this._reflectionTexture);
  51854. }
  51855. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  51856. results.push(this._emissiveTexture);
  51857. }
  51858. if (this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0) {
  51859. results.push(this._metallicTexture);
  51860. }
  51861. else if (this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0) {
  51862. results.push(this._reflectivityTexture);
  51863. }
  51864. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  51865. results.push(this._bumpTexture);
  51866. }
  51867. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  51868. results.push(this._lightmapTexture);
  51869. }
  51870. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  51871. results.push(this._refractionTexture);
  51872. }
  51873. return results;
  51874. };
  51875. /**
  51876. * Returns the texture used for reflections.
  51877. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51878. */
  51879. PBRBaseMaterial.prototype._getReflectionTexture = function () {
  51880. if (this._reflectionTexture) {
  51881. return this._reflectionTexture;
  51882. }
  51883. return this.getScene().environmentTexture;
  51884. };
  51885. /**
  51886. * Returns the texture used for refraction or null if none is used.
  51887. * @returns - Refection texture if present. If no refraction texture and refraction
  51888. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51889. */
  51890. PBRBaseMaterial.prototype._getRefractionTexture = function () {
  51891. if (this._refractionTexture) {
  51892. return this._refractionTexture;
  51893. }
  51894. if (this._linkRefractionWithTransparency) {
  51895. return this.getScene().environmentTexture;
  51896. }
  51897. return null;
  51898. };
  51899. /**
  51900. * Disposes the resources of the material.
  51901. * @param forceDisposeEffect - Forces the disposal of effects.
  51902. * @param forceDisposeTextures - Forces the disposal of all textures.
  51903. */
  51904. PBRBaseMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  51905. if (forceDisposeTextures) {
  51906. if (this._albedoTexture) {
  51907. this._albedoTexture.dispose();
  51908. }
  51909. if (this._ambientTexture) {
  51910. this._ambientTexture.dispose();
  51911. }
  51912. if (this._opacityTexture) {
  51913. this._opacityTexture.dispose();
  51914. }
  51915. if (this._reflectionTexture) {
  51916. this._reflectionTexture.dispose();
  51917. }
  51918. if (this._environmentBRDFTexture && this.getScene()._environmentBRDFTexture !== this._environmentBRDFTexture) {
  51919. this._environmentBRDFTexture.dispose();
  51920. }
  51921. if (this._emissiveTexture) {
  51922. this._emissiveTexture.dispose();
  51923. }
  51924. if (this._metallicTexture) {
  51925. this._metallicTexture.dispose();
  51926. }
  51927. if (this._reflectivityTexture) {
  51928. this._reflectivityTexture.dispose();
  51929. }
  51930. if (this._bumpTexture) {
  51931. this._bumpTexture.dispose();
  51932. }
  51933. if (this._lightmapTexture) {
  51934. this._lightmapTexture.dispose();
  51935. }
  51936. if (this._refractionTexture) {
  51937. this._refractionTexture.dispose();
  51938. }
  51939. }
  51940. this._renderTargets.dispose();
  51941. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  51942. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  51943. }
  51944. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  51945. };
  51946. /**
  51947. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51948. */
  51949. PBRBaseMaterial.PBRMATERIAL_OPAQUE = 0;
  51950. /**
  51951. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51952. */
  51953. PBRBaseMaterial.PBRMATERIAL_ALPHATEST = 1;
  51954. /**
  51955. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51956. */
  51957. PBRBaseMaterial.PBRMATERIAL_ALPHABLEND = 2;
  51958. /**
  51959. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51960. * They are also discarded below the alpha cutoff threshold to improve performances.
  51961. */
  51962. PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND = 3;
  51963. /**
  51964. * Defines the default value of how much AO map is occluding the analytical lights
  51965. * (point spot...).
  51966. */
  51967. PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 1;
  51968. /**
  51969. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51970. */
  51971. PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL = 0;
  51972. /**
  51973. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51974. * to enhance interoperability with other engines.
  51975. */
  51976. PBRBaseMaterial.LIGHTFALLOFF_GLTF = 1;
  51977. /**
  51978. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51979. * to enhance interoperability with other materials.
  51980. */
  51981. PBRBaseMaterial.LIGHTFALLOFF_STANDARD = 2;
  51982. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51983. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  51984. ], PBRBaseMaterial.prototype, "_imageProcessingConfiguration", void 0);
  51985. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51986. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51987. ], PBRBaseMaterial.prototype, "useLogarithmicDepth", null);
  51988. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51989. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51990. ], PBRBaseMaterial.prototype, "transparencyMode", null);
  51991. return PBRBaseMaterial;
  51992. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_11__["PushMaterial"]));
  51993. /***/ }),
  51994. /***/ "./Materials/PBR/pbrBaseSimpleMaterial.ts":
  51995. /*!************************************************!*\
  51996. !*** ./Materials/PBR/pbrBaseSimpleMaterial.ts ***!
  51997. \************************************************/
  51998. /*! exports provided: PBRBaseSimpleMaterial */
  51999. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52000. "use strict";
  52001. __webpack_require__.r(__webpack_exports__);
  52002. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return PBRBaseSimpleMaterial; });
  52003. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52004. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  52005. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  52006. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  52007. /**
  52008. * The Physically based simple base material of BJS.
  52009. *
  52010. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52011. * It is used as the base class for both the specGloss and metalRough conventions.
  52012. */
  52013. var PBRBaseSimpleMaterial = /** @class */ (function (_super) {
  52014. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseSimpleMaterial, _super);
  52015. /**
  52016. * Instantiates a new PBRMaterial instance.
  52017. *
  52018. * @param name The material name
  52019. * @param scene The scene the material will be use in.
  52020. */
  52021. function PBRBaseSimpleMaterial(name, scene) {
  52022. var _this = _super.call(this, name, scene) || this;
  52023. /**
  52024. * Number of Simultaneous lights allowed on the material.
  52025. */
  52026. _this.maxSimultaneousLights = 4;
  52027. /**
  52028. * If sets to true, disables all the lights affecting the material.
  52029. */
  52030. _this.disableLighting = false;
  52031. /**
  52032. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52033. */
  52034. _this.invertNormalMapX = false;
  52035. /**
  52036. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52037. */
  52038. _this.invertNormalMapY = false;
  52039. /**
  52040. * Emissivie color used to self-illuminate the model.
  52041. */
  52042. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0, 0, 0);
  52043. /**
  52044. * Occlusion Channel Strenght.
  52045. */
  52046. _this.occlusionStrength = 1.0;
  52047. /**
  52048. * If true, the light map contains occlusion information instead of lighting info.
  52049. */
  52050. _this.useLightmapAsShadowmap = false;
  52051. _this._useAlphaFromAlbedoTexture = true;
  52052. _this._useAmbientInGrayScale = true;
  52053. return _this;
  52054. }
  52055. Object.defineProperty(PBRBaseSimpleMaterial.prototype, "doubleSided", {
  52056. /**
  52057. * Gets the current double sided mode.
  52058. */
  52059. get: function () {
  52060. return this._twoSidedLighting;
  52061. },
  52062. /**
  52063. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52064. */
  52065. set: function (value) {
  52066. if (this._twoSidedLighting === value) {
  52067. return;
  52068. }
  52069. this._twoSidedLighting = value;
  52070. this.backFaceCulling = !value;
  52071. this._markAllSubMeshesAsTexturesDirty();
  52072. },
  52073. enumerable: true,
  52074. configurable: true
  52075. });
  52076. /**
  52077. * Return the active textures of the material.
  52078. */
  52079. PBRBaseSimpleMaterial.prototype.getActiveTextures = function () {
  52080. var activeTextures = _super.prototype.getActiveTextures.call(this);
  52081. if (this.environmentTexture) {
  52082. activeTextures.push(this.environmentTexture);
  52083. }
  52084. if (this.normalTexture) {
  52085. activeTextures.push(this.normalTexture);
  52086. }
  52087. if (this.emissiveTexture) {
  52088. activeTextures.push(this.emissiveTexture);
  52089. }
  52090. if (this.occlusionTexture) {
  52091. activeTextures.push(this.occlusionTexture);
  52092. }
  52093. if (this.lightmapTexture) {
  52094. activeTextures.push(this.lightmapTexture);
  52095. }
  52096. return activeTextures;
  52097. };
  52098. PBRBaseSimpleMaterial.prototype.hasTexture = function (texture) {
  52099. if (_super.prototype.hasTexture.call(this, texture)) {
  52100. return true;
  52101. }
  52102. if (this.lightmapTexture === texture) {
  52103. return true;
  52104. }
  52105. return false;
  52106. };
  52107. PBRBaseSimpleMaterial.prototype.getClassName = function () {
  52108. return "PBRBaseSimpleMaterial";
  52109. };
  52110. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52112. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  52113. ], PBRBaseSimpleMaterial.prototype, "maxSimultaneousLights", void 0);
  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, "disableLighting", void 0);
  52118. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52119. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52120. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")
  52121. ], PBRBaseSimpleMaterial.prototype, "environmentTexture", void 0);
  52122. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52123. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52124. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52125. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapX", 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, "invertNormalMapY", void 0);
  52130. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52131. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52132. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")
  52133. ], PBRBaseSimpleMaterial.prototype, "normalTexture", void 0);
  52134. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52135. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  52136. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52137. ], PBRBaseSimpleMaterial.prototype, "emissiveColor", void 0);
  52138. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52139. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52140. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52141. ], PBRBaseSimpleMaterial.prototype, "emissiveTexture", void 0);
  52142. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52143. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52144. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")
  52145. ], PBRBaseSimpleMaterial.prototype, "occlusionStrength", void 0);
  52146. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52147. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52148. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")
  52149. ], PBRBaseSimpleMaterial.prototype, "occlusionTexture", void 0);
  52150. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52151. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52152. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")
  52153. ], PBRBaseSimpleMaterial.prototype, "alphaCutOff", void 0);
  52154. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52155. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52156. ], PBRBaseSimpleMaterial.prototype, "doubleSided", null);
  52157. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52158. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52159. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  52160. ], PBRBaseSimpleMaterial.prototype, "lightmapTexture", void 0);
  52161. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52162. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52163. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52164. ], PBRBaseSimpleMaterial.prototype, "useLightmapAsShadowmap", void 0);
  52165. return PBRBaseSimpleMaterial;
  52166. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRBaseMaterial"]));
  52167. /***/ }),
  52168. /***/ "./Materials/PBR/pbrMaterial.ts":
  52169. /*!**************************************!*\
  52170. !*** ./Materials/PBR/pbrMaterial.ts ***!
  52171. \**************************************/
  52172. /*! exports provided: PBRMaterial */
  52173. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52174. "use strict";
  52175. __webpack_require__.r(__webpack_exports__);
  52176. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return PBRMaterial; });
  52177. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52178. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  52179. /* harmony import */ var _Misc_textureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/textureTools */ "./Misc/textureTools.ts");
  52180. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  52181. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  52182. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  52183. /**
  52184. * The Physically based material of BJS.
  52185. *
  52186. * This offers the main features of a standard PBR material.
  52187. * For more information, please refer to the documentation :
  52188. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  52189. */
  52190. var PBRMaterial = /** @class */ (function (_super) {
  52191. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterial, _super);
  52192. /**
  52193. * Instantiates a new PBRMaterial instance.
  52194. *
  52195. * @param name The material name
  52196. * @param scene The scene the material will be use in.
  52197. */
  52198. function PBRMaterial(name, scene) {
  52199. var _this = _super.call(this, name, scene) || this;
  52200. /**
  52201. * Intensity of the direct lights e.g. the four lights available in your scene.
  52202. * This impacts both the direct diffuse and specular highlights.
  52203. */
  52204. _this.directIntensity = 1.0;
  52205. /**
  52206. * Intensity of the emissive part of the material.
  52207. * This helps controlling the emissive effect without modifying the emissive color.
  52208. */
  52209. _this.emissiveIntensity = 1.0;
  52210. /**
  52211. * Intensity of the environment e.g. how much the environment will light the object
  52212. * either through harmonics for rough material or through the refelction for shiny ones.
  52213. */
  52214. _this.environmentIntensity = 1.0;
  52215. /**
  52216. * This is a special control allowing the reduction of the specular highlights coming from the
  52217. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52218. */
  52219. _this.specularIntensity = 1.0;
  52220. /**
  52221. * Debug Control allowing disabling the bump map on this material.
  52222. */
  52223. _this.disableBumpMap = false;
  52224. /**
  52225. * AKA Occlusion Texture Intensity in other nomenclature.
  52226. */
  52227. _this.ambientTextureStrength = 1.0;
  52228. /**
  52229. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52230. * 1 means it completely occludes it
  52231. * 0 mean it has no impact
  52232. */
  52233. _this.ambientTextureImpactOnAnalyticalLights = PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  52234. /**
  52235. * The color of a material in ambient lighting.
  52236. */
  52237. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  52238. /**
  52239. * AKA Diffuse Color in other nomenclature.
  52240. */
  52241. _this.albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  52242. /**
  52243. * AKA Specular Color in other nomenclature.
  52244. */
  52245. _this.reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  52246. /**
  52247. * The color reflected from the material.
  52248. */
  52249. _this.reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1.0, 1.0, 1.0);
  52250. /**
  52251. * The color emitted from the material.
  52252. */
  52253. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  52254. /**
  52255. * AKA Glossiness in other nomenclature.
  52256. */
  52257. _this.microSurface = 1.0;
  52258. /**
  52259. * source material index of refraction (IOR)' / 'destination material IOR.
  52260. */
  52261. _this.indexOfRefraction = 0.66;
  52262. /**
  52263. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52264. */
  52265. _this.invertRefractionY = false;
  52266. /**
  52267. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52268. * Materials half opaque for instance using refraction could benefit from this control.
  52269. */
  52270. _this.linkRefractionWithTransparency = false;
  52271. /**
  52272. * If true, the light map contains occlusion information instead of lighting info.
  52273. */
  52274. _this.useLightmapAsShadowmap = false;
  52275. /**
  52276. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52277. */
  52278. _this.useAlphaFromAlbedoTexture = false;
  52279. /**
  52280. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52281. */
  52282. _this.forceAlphaTest = false;
  52283. /**
  52284. * Defines the alpha limits in alpha test mode.
  52285. */
  52286. _this.alphaCutOff = 0.4;
  52287. /**
  52288. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52289. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52290. */
  52291. _this.useSpecularOverAlpha = true;
  52292. /**
  52293. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52294. */
  52295. _this.useMicroSurfaceFromReflectivityMapAlpha = false;
  52296. /**
  52297. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52298. */
  52299. _this.useRoughnessFromMetallicTextureAlpha = true;
  52300. /**
  52301. * Specifies if the metallic texture contains the roughness information in its green channel.
  52302. */
  52303. _this.useRoughnessFromMetallicTextureGreen = false;
  52304. /**
  52305. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52306. */
  52307. _this.useMetallnessFromMetallicTextureBlue = false;
  52308. /**
  52309. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52310. */
  52311. _this.useAmbientOcclusionFromMetallicTextureRed = false;
  52312. /**
  52313. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52314. */
  52315. _this.useAmbientInGrayScale = false;
  52316. /**
  52317. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52318. * The material will try to infer what glossiness each pixel should be.
  52319. */
  52320. _this.useAutoMicroSurfaceFromReflectivityMap = false;
  52321. /**
  52322. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52323. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52324. */
  52325. _this.useRadianceOverAlpha = true;
  52326. /**
  52327. * Allows using an object space normal map (instead of tangent space).
  52328. */
  52329. _this.useObjectSpaceNormalMap = false;
  52330. /**
  52331. * Allows using the bump map in parallax mode.
  52332. */
  52333. _this.useParallax = false;
  52334. /**
  52335. * Allows using the bump map in parallax occlusion mode.
  52336. */
  52337. _this.useParallaxOcclusion = false;
  52338. /**
  52339. * Controls the scale bias of the parallax mode.
  52340. */
  52341. _this.parallaxScaleBias = 0.05;
  52342. /**
  52343. * If sets to true, disables all the lights affecting the material.
  52344. */
  52345. _this.disableLighting = false;
  52346. /**
  52347. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52348. */
  52349. _this.forceIrradianceInFragment = false;
  52350. /**
  52351. * Number of Simultaneous lights allowed on the material.
  52352. */
  52353. _this.maxSimultaneousLights = 4;
  52354. /**
  52355. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52356. */
  52357. _this.invertNormalMapX = false;
  52358. /**
  52359. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52360. */
  52361. _this.invertNormalMapY = false;
  52362. /**
  52363. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52364. */
  52365. _this.twoSidedLighting = false;
  52366. /**
  52367. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52368. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52369. */
  52370. _this.useAlphaFresnel = false;
  52371. /**
  52372. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52373. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52374. */
  52375. _this.useLinearAlphaFresnel = false;
  52376. /**
  52377. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52378. * And/Or occlude the blended part.
  52379. */
  52380. _this.environmentBRDFTexture = null;
  52381. /**
  52382. * Force normal to face away from face.
  52383. */
  52384. _this.forceNormalForward = false;
  52385. /**
  52386. * Enables specular anti aliasing in the PBR shader.
  52387. * It will both interacts on the Geometry for analytical and IBL lighting.
  52388. * It also prefilter the roughness map based on the bump values.
  52389. */
  52390. _this.enableSpecularAntiAliasing = false;
  52391. /**
  52392. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52393. * makes the reflect vector face the model (under horizon).
  52394. */
  52395. _this.useHorizonOcclusion = true;
  52396. /**
  52397. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52398. * too much the area relying on ambient texture to define their ambient occlusion.
  52399. */
  52400. _this.useRadianceOcclusion = true;
  52401. /**
  52402. * If set to true, no lighting calculations will be applied.
  52403. */
  52404. _this.unlit = false;
  52405. _this._environmentBRDFTexture = _Misc_textureTools__WEBPACK_IMPORTED_MODULE_2__["TextureTools"].GetEnvironmentBRDFTexture(scene);
  52406. return _this;
  52407. }
  52408. Object.defineProperty(PBRMaterial.prototype, "usePhysicalLightFalloff", {
  52409. /**
  52410. * BJS is using an harcoded light falloff based on a manually sets up range.
  52411. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52412. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52413. */
  52414. get: function () {
  52415. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  52416. },
  52417. /**
  52418. * BJS is using an harcoded light falloff based on a manually sets up range.
  52419. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52420. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52421. */
  52422. set: function (value) {
  52423. if (value !== this.usePhysicalLightFalloff) {
  52424. // Ensure the effect will be rebuilt.
  52425. this._markAllSubMeshesAsTexturesDirty();
  52426. if (value) {
  52427. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  52428. }
  52429. else {
  52430. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  52431. }
  52432. }
  52433. },
  52434. enumerable: true,
  52435. configurable: true
  52436. });
  52437. Object.defineProperty(PBRMaterial.prototype, "useGLTFLightFalloff", {
  52438. /**
  52439. * In order to support the falloff compatibility with gltf, a special mode has been added
  52440. * to reproduce the gltf light falloff.
  52441. */
  52442. get: function () {
  52443. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  52444. },
  52445. /**
  52446. * In order to support the falloff compatibility with gltf, a special mode has been added
  52447. * to reproduce the gltf light falloff.
  52448. */
  52449. set: function (value) {
  52450. if (value !== this.useGLTFLightFalloff) {
  52451. // Ensure the effect will be rebuilt.
  52452. this._markAllSubMeshesAsTexturesDirty();
  52453. if (value) {
  52454. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  52455. }
  52456. else {
  52457. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  52458. }
  52459. }
  52460. },
  52461. enumerable: true,
  52462. configurable: true
  52463. });
  52464. Object.defineProperty(PBRMaterial.prototype, "imageProcessingConfiguration", {
  52465. /**
  52466. * Gets the image processing configuration used either in this material.
  52467. */
  52468. get: function () {
  52469. return this._imageProcessingConfiguration;
  52470. },
  52471. /**
  52472. * Sets the Default image processing configuration used either in the this material.
  52473. *
  52474. * If sets to null, the scene one is in use.
  52475. */
  52476. set: function (value) {
  52477. this._attachImageProcessingConfiguration(value);
  52478. // Ensure the effect will be rebuilt.
  52479. this._markAllSubMeshesAsTexturesDirty();
  52480. },
  52481. enumerable: true,
  52482. configurable: true
  52483. });
  52484. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurvesEnabled", {
  52485. /**
  52486. * Gets wether the color curves effect is enabled.
  52487. */
  52488. get: function () {
  52489. return this.imageProcessingConfiguration.colorCurvesEnabled;
  52490. },
  52491. /**
  52492. * Sets wether the color curves effect is enabled.
  52493. */
  52494. set: function (value) {
  52495. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  52496. },
  52497. enumerable: true,
  52498. configurable: true
  52499. });
  52500. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingEnabled", {
  52501. /**
  52502. * Gets wether the color grading effect is enabled.
  52503. */
  52504. get: function () {
  52505. return this.imageProcessingConfiguration.colorGradingEnabled;
  52506. },
  52507. /**
  52508. * Gets wether the color grading effect is enabled.
  52509. */
  52510. set: function (value) {
  52511. this.imageProcessingConfiguration.colorGradingEnabled = value;
  52512. },
  52513. enumerable: true,
  52514. configurable: true
  52515. });
  52516. Object.defineProperty(PBRMaterial.prototype, "cameraToneMappingEnabled", {
  52517. /**
  52518. * Gets wether tonemapping is enabled or not.
  52519. */
  52520. get: function () {
  52521. return this._imageProcessingConfiguration.toneMappingEnabled;
  52522. },
  52523. /**
  52524. * Sets wether tonemapping is enabled or not
  52525. */
  52526. set: function (value) {
  52527. this._imageProcessingConfiguration.toneMappingEnabled = value;
  52528. },
  52529. enumerable: true,
  52530. configurable: true
  52531. });
  52532. Object.defineProperty(PBRMaterial.prototype, "cameraExposure", {
  52533. /**
  52534. * The camera exposure used on this material.
  52535. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52536. * This corresponds to a photographic exposure.
  52537. */
  52538. get: function () {
  52539. return this._imageProcessingConfiguration.exposure;
  52540. },
  52541. /**
  52542. * The camera exposure used on this material.
  52543. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52544. * This corresponds to a photographic exposure.
  52545. */
  52546. set: function (value) {
  52547. this._imageProcessingConfiguration.exposure = value;
  52548. },
  52549. enumerable: true,
  52550. configurable: true
  52551. });
  52552. Object.defineProperty(PBRMaterial.prototype, "cameraContrast", {
  52553. /**
  52554. * Gets The camera contrast used on this material.
  52555. */
  52556. get: function () {
  52557. return this._imageProcessingConfiguration.contrast;
  52558. },
  52559. /**
  52560. * Sets The camera contrast used on this material.
  52561. */
  52562. set: function (value) {
  52563. this._imageProcessingConfiguration.contrast = value;
  52564. },
  52565. enumerable: true,
  52566. configurable: true
  52567. });
  52568. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingTexture", {
  52569. /**
  52570. * Gets the Color Grading 2D Lookup Texture.
  52571. */
  52572. get: function () {
  52573. return this._imageProcessingConfiguration.colorGradingTexture;
  52574. },
  52575. /**
  52576. * Sets the Color Grading 2D Lookup Texture.
  52577. */
  52578. set: function (value) {
  52579. this._imageProcessingConfiguration.colorGradingTexture = value;
  52580. },
  52581. enumerable: true,
  52582. configurable: true
  52583. });
  52584. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurves", {
  52585. /**
  52586. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52587. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52588. * 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;
  52589. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52590. */
  52591. get: function () {
  52592. return this._imageProcessingConfiguration.colorCurves;
  52593. },
  52594. /**
  52595. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52596. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52597. * 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;
  52598. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52599. */
  52600. set: function (value) {
  52601. this._imageProcessingConfiguration.colorCurves = value;
  52602. },
  52603. enumerable: true,
  52604. configurable: true
  52605. });
  52606. /**
  52607. * Returns the name of this material class.
  52608. */
  52609. PBRMaterial.prototype.getClassName = function () {
  52610. return "PBRMaterial";
  52611. };
  52612. /**
  52613. * Returns an array of the actively used textures.
  52614. * @returns - Array of BaseTextures
  52615. */
  52616. PBRMaterial.prototype.getActiveTextures = function () {
  52617. var activeTextures = _super.prototype.getActiveTextures.call(this);
  52618. if (this._albedoTexture) {
  52619. activeTextures.push(this._albedoTexture);
  52620. }
  52621. if (this._ambientTexture) {
  52622. activeTextures.push(this._ambientTexture);
  52623. }
  52624. if (this._opacityTexture) {
  52625. activeTextures.push(this._opacityTexture);
  52626. }
  52627. if (this._reflectionTexture) {
  52628. activeTextures.push(this._reflectionTexture);
  52629. }
  52630. if (this._emissiveTexture) {
  52631. activeTextures.push(this._emissiveTexture);
  52632. }
  52633. if (this._reflectivityTexture) {
  52634. activeTextures.push(this._reflectivityTexture);
  52635. }
  52636. if (this._metallicTexture) {
  52637. activeTextures.push(this._metallicTexture);
  52638. }
  52639. if (this._microSurfaceTexture) {
  52640. activeTextures.push(this._microSurfaceTexture);
  52641. }
  52642. if (this._bumpTexture) {
  52643. activeTextures.push(this._bumpTexture);
  52644. }
  52645. if (this._lightmapTexture) {
  52646. activeTextures.push(this._lightmapTexture);
  52647. }
  52648. if (this._refractionTexture) {
  52649. activeTextures.push(this._refractionTexture);
  52650. }
  52651. return activeTextures;
  52652. };
  52653. /**
  52654. * Checks to see if a texture is used in the material.
  52655. * @param texture - Base texture to use.
  52656. * @returns - Boolean specifying if a texture is used in the material.
  52657. */
  52658. PBRMaterial.prototype.hasTexture = function (texture) {
  52659. if (_super.prototype.hasTexture.call(this, texture)) {
  52660. return true;
  52661. }
  52662. if (this._albedoTexture === texture) {
  52663. return true;
  52664. }
  52665. if (this._ambientTexture === texture) {
  52666. return true;
  52667. }
  52668. if (this._opacityTexture === texture) {
  52669. return true;
  52670. }
  52671. if (this._reflectionTexture === texture) {
  52672. return true;
  52673. }
  52674. if (this._reflectivityTexture === texture) {
  52675. return true;
  52676. }
  52677. if (this._metallicTexture === texture) {
  52678. return true;
  52679. }
  52680. if (this._microSurfaceTexture === texture) {
  52681. return true;
  52682. }
  52683. if (this._bumpTexture === texture) {
  52684. return true;
  52685. }
  52686. if (this._lightmapTexture === texture) {
  52687. return true;
  52688. }
  52689. if (this._refractionTexture === texture) {
  52690. return true;
  52691. }
  52692. return false;
  52693. };
  52694. /**
  52695. * Makes a duplicate of the current material.
  52696. * @param name - name to use for the new material.
  52697. */
  52698. PBRMaterial.prototype.clone = function (name) {
  52699. var _this = this;
  52700. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMaterial(name, _this.getScene()); }, this);
  52701. clone.id = name;
  52702. clone.name = name;
  52703. return clone;
  52704. };
  52705. /**
  52706. * Serializes this PBR Material.
  52707. * @returns - An object with the serialized material.
  52708. */
  52709. PBRMaterial.prototype.serialize = function () {
  52710. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  52711. serializationObject.customType = "BABYLON.PBRMaterial";
  52712. return serializationObject;
  52713. };
  52714. // Statics
  52715. /**
  52716. * Parses a PBR Material from a serialized object.
  52717. * @param source - Serialized object.
  52718. * @param scene - BJS scene instance.
  52719. * @param rootUrl - url for the scene object
  52720. * @returns - PBRMaterial
  52721. */
  52722. PBRMaterial.Parse = function (source, scene, rootUrl) {
  52723. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMaterial(source.name, scene); }, source, scene, rootUrl);
  52724. };
  52725. /**
  52726. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52727. */
  52728. PBRMaterial.PBRMATERIAL_OPAQUE = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_OPAQUE;
  52729. /**
  52730. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52731. */
  52732. PBRMaterial.PBRMATERIAL_ALPHATEST = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATEST;
  52733. /**
  52734. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52735. */
  52736. PBRMaterial.PBRMATERIAL_ALPHABLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHABLEND;
  52737. /**
  52738. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52739. * They are also discarded below the alpha cutoff threshold to improve performances.
  52740. */
  52741. PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATESTANDBLEND;
  52742. /**
  52743. * Defines the default value of how much AO map is occluding the analytical lights
  52744. * (point spot...).
  52745. */
  52746. PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  52747. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52748. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52749. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52750. ], PBRMaterial.prototype, "directIntensity", void 0);
  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, "emissiveIntensity", 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, "environmentIntensity", 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, "specularIntensity", 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, "disableBumpMap", void 0);
  52767. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52768. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52769. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52770. ], PBRMaterial.prototype, "albedoTexture", 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, "ambientTexture", void 0);
  52775. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52776. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52777. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52778. ], PBRMaterial.prototype, "ambientTextureStrength", 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, "ambientTextureImpactOnAnalyticalLights", void 0);
  52783. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52784. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52785. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  52786. ], PBRMaterial.prototype, "opacityTexture", 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"])("_markAllSubMeshesAsTexturesDirty")
  52790. ], PBRMaterial.prototype, "reflectionTexture", 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, "emissiveTexture", 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, "reflectivityTexture", 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, "metallicTexture", void 0);
  52803. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52804. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52805. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52806. ], PBRMaterial.prototype, "metallic", 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, "roughness", void 0);
  52811. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52812. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52813. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52814. ], PBRMaterial.prototype, "microSurfaceTexture", 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, "bumpTexture", 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", null)
  52822. ], PBRMaterial.prototype, "lightmapTexture", 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")
  52826. ], PBRMaterial.prototype, "refractionTexture", void 0);
  52827. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52828. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient"),
  52829. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52830. ], PBRMaterial.prototype, "ambientColor", void 0);
  52831. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52832. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("albedo"),
  52833. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52834. ], PBRMaterial.prototype, "albedoColor", void 0);
  52835. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52836. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflectivity"),
  52837. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52838. ], PBRMaterial.prototype, "reflectivityColor", void 0);
  52839. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52840. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflection"),
  52841. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52842. ], PBRMaterial.prototype, "reflectionColor", void 0);
  52843. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52844. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  52845. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52846. ], PBRMaterial.prototype, "emissiveColor", void 0);
  52847. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52848. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52849. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52850. ], PBRMaterial.prototype, "microSurface", 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, "indexOfRefraction", 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, "invertRefractionY", 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, "linkRefractionWithTransparency", 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, "useLightmapAsShadowmap", 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"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  52870. ], PBRMaterial.prototype, "useAlphaFromAlbedoTexture", 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, "forceAlphaTest", 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, "alphaCutOff", 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"])("_markAllSubMeshesAsTexturesDirty")
  52882. ], PBRMaterial.prototype, "useSpecularOverAlpha", 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, "useMicroSurfaceFromReflectivityMapAlpha", 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, "useRoughnessFromMetallicTextureAlpha", 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, "useRoughnessFromMetallicTextureGreen", 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, "useMetallnessFromMetallicTextureBlue", 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, "useAmbientOcclusionFromMetallicTextureRed", 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, "useAmbientInGrayScale", 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, "useAutoMicroSurfaceFromReflectivityMap", void 0);
  52911. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52912. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52913. ], PBRMaterial.prototype, "usePhysicalLightFalloff", null);
  52914. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52915. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52916. ], PBRMaterial.prototype, "useGLTFLightFalloff", null);
  52917. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52918. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52919. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52920. ], PBRMaterial.prototype, "useRadianceOverAlpha", void 0);
  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, "useObjectSpaceNormalMap", 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, "useParallax", 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, "useParallaxOcclusion", 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, "parallaxScaleBias", 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"])("_markAllSubMeshesAsLightsDirty")
  52940. ], PBRMaterial.prototype, "disableLighting", 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"])("_markAllSubMeshesAsTexturesDirty")
  52944. ], PBRMaterial.prototype, "forceIrradianceInFragment", 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"])("_markAllSubMeshesAsLightsDirty")
  52948. ], PBRMaterial.prototype, "maxSimultaneousLights", 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"])("_markAllSubMeshesAsTexturesDirty")
  52952. ], PBRMaterial.prototype, "invertNormalMapX", 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, "invertNormalMapY", 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, "twoSidedLighting", 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, "useAlphaFresnel", 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, "useLinearAlphaFresnel", void 0);
  52969. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52970. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52971. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52972. ], PBRMaterial.prototype, "environmentBRDFTexture", void 0);
  52973. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52974. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52975. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52976. ], PBRMaterial.prototype, "forceNormalForward", 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, "enableSpecularAntiAliasing", 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, "useHorizonOcclusion", 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, "useRadianceOcclusion", 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"])("_markAllSubMeshesAsMiscDirty")
  52992. ], PBRMaterial.prototype, "unlit", void 0);
  52993. return PBRMaterial;
  52994. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"]));
  52995. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PBRMaterial"] = PBRMaterial;
  52996. /***/ }),
  52997. /***/ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts":
  52998. /*!*******************************************************!*\
  52999. !*** ./Materials/PBR/pbrMetallicRoughnessMaterial.ts ***!
  53000. \*******************************************************/
  53001. /*! exports provided: PBRMetallicRoughnessMaterial */
  53002. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53003. "use strict";
  53004. __webpack_require__.r(__webpack_exports__);
  53005. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return PBRMetallicRoughnessMaterial; });
  53006. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53007. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53008. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  53009. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  53010. /**
  53011. * The PBR material of BJS following the metal roughness convention.
  53012. *
  53013. * This fits to the PBR convention in the GLTF definition:
  53014. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53015. */
  53016. var PBRMetallicRoughnessMaterial = /** @class */ (function (_super) {
  53017. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMetallicRoughnessMaterial, _super);
  53018. /**
  53019. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53020. *
  53021. * @param name The material name
  53022. * @param scene The scene the material will be use in.
  53023. */
  53024. function PBRMetallicRoughnessMaterial(name, scene) {
  53025. var _this = _super.call(this, name, scene) || this;
  53026. _this._useRoughnessFromMetallicTextureAlpha = false;
  53027. _this._useRoughnessFromMetallicTextureGreen = true;
  53028. _this._useMetallnessFromMetallicTextureBlue = true;
  53029. _this.metallic = 1.0;
  53030. _this.roughness = 1.0;
  53031. return _this;
  53032. }
  53033. /**
  53034. * Return the currrent class name of the material.
  53035. */
  53036. PBRMetallicRoughnessMaterial.prototype.getClassName = function () {
  53037. return "PBRMetallicRoughnessMaterial";
  53038. };
  53039. /**
  53040. * Return the active textures of the material.
  53041. */
  53042. PBRMetallicRoughnessMaterial.prototype.getActiveTextures = function () {
  53043. var activeTextures = _super.prototype.getActiveTextures.call(this);
  53044. if (this.baseTexture) {
  53045. activeTextures.push(this.baseTexture);
  53046. }
  53047. if (this.metallicRoughnessTexture) {
  53048. activeTextures.push(this.metallicRoughnessTexture);
  53049. }
  53050. return activeTextures;
  53051. };
  53052. /**
  53053. * Checks to see if a texture is used in the material.
  53054. * @param texture - Base texture to use.
  53055. * @returns - Boolean specifying if a texture is used in the material.
  53056. */
  53057. PBRMetallicRoughnessMaterial.prototype.hasTexture = function (texture) {
  53058. if (_super.prototype.hasTexture.call(this, texture)) {
  53059. return true;
  53060. }
  53061. if (this.baseTexture === texture) {
  53062. return true;
  53063. }
  53064. if (this.metallicRoughnessTexture === texture) {
  53065. return true;
  53066. }
  53067. return false;
  53068. };
  53069. /**
  53070. * Makes a duplicate of the current material.
  53071. * @param name - name to use for the new material.
  53072. */
  53073. PBRMetallicRoughnessMaterial.prototype.clone = function (name) {
  53074. var _this = this;
  53075. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMetallicRoughnessMaterial(name, _this.getScene()); }, this);
  53076. clone.id = name;
  53077. clone.name = name;
  53078. return clone;
  53079. };
  53080. /**
  53081. * Serialize the material to a parsable JSON object.
  53082. */
  53083. PBRMetallicRoughnessMaterial.prototype.serialize = function () {
  53084. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  53085. serializationObject.customType = "BABYLON.PBRMetallicRoughnessMaterial";
  53086. return serializationObject;
  53087. };
  53088. /**
  53089. * Parses a JSON object correponding to the serialize function.
  53090. */
  53091. PBRMetallicRoughnessMaterial.Parse = function (source, scene, rootUrl) {
  53092. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMetallicRoughnessMaterial(source.name, scene); }, source, scene, rootUrl);
  53093. };
  53094. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53095. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])(),
  53096. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  53097. ], PBRMetallicRoughnessMaterial.prototype, "baseColor", void 0);
  53098. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53099. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53100. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  53101. ], PBRMetallicRoughnessMaterial.prototype, "baseTexture", void 0);
  53102. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53103. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53104. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53105. ], PBRMetallicRoughnessMaterial.prototype, "metallic", 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, "roughness", void 0);
  53110. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53112. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_metallicTexture")
  53113. ], PBRMetallicRoughnessMaterial.prototype, "metallicRoughnessTexture", void 0);
  53114. return PBRMetallicRoughnessMaterial;
  53115. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  53116. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRMetallicRoughnessMaterial"] = PBRMetallicRoughnessMaterial;
  53117. /***/ }),
  53118. /***/ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts":
  53119. /*!********************************************************!*\
  53120. !*** ./Materials/PBR/pbrSpecularGlossinessMaterial.ts ***!
  53121. \********************************************************/
  53122. /*! exports provided: PBRSpecularGlossinessMaterial */
  53123. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53124. "use strict";
  53125. __webpack_require__.r(__webpack_exports__);
  53126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return PBRSpecularGlossinessMaterial; });
  53127. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53128. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53129. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  53130. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  53131. /**
  53132. * The PBR material of BJS following the specular glossiness convention.
  53133. *
  53134. * This fits to the PBR convention in the GLTF definition:
  53135. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53136. */
  53137. var PBRSpecularGlossinessMaterial = /** @class */ (function (_super) {
  53138. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRSpecularGlossinessMaterial, _super);
  53139. /**
  53140. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53141. *
  53142. * @param name The material name
  53143. * @param scene The scene the material will be use in.
  53144. */
  53145. function PBRSpecularGlossinessMaterial(name, scene) {
  53146. var _this = _super.call(this, name, scene) || this;
  53147. _this._useMicroSurfaceFromReflectivityMapAlpha = true;
  53148. return _this;
  53149. }
  53150. /**
  53151. * Return the currrent class name of the material.
  53152. */
  53153. PBRSpecularGlossinessMaterial.prototype.getClassName = function () {
  53154. return "PBRSpecularGlossinessMaterial";
  53155. };
  53156. /**
  53157. * Return the active textures of the material.
  53158. */
  53159. PBRSpecularGlossinessMaterial.prototype.getActiveTextures = function () {
  53160. var activeTextures = _super.prototype.getActiveTextures.call(this);
  53161. if (this.diffuseTexture) {
  53162. activeTextures.push(this.diffuseTexture);
  53163. }
  53164. if (this.specularGlossinessTexture) {
  53165. activeTextures.push(this.specularGlossinessTexture);
  53166. }
  53167. return activeTextures;
  53168. };
  53169. /**
  53170. * Checks to see if a texture is used in the material.
  53171. * @param texture - Base texture to use.
  53172. * @returns - Boolean specifying if a texture is used in the material.
  53173. */
  53174. PBRSpecularGlossinessMaterial.prototype.hasTexture = function (texture) {
  53175. if (_super.prototype.hasTexture.call(this, texture)) {
  53176. return true;
  53177. }
  53178. if (this.diffuseTexture === texture) {
  53179. return true;
  53180. }
  53181. if (this.specularGlossinessTexture === texture) {
  53182. return true;
  53183. }
  53184. return false;
  53185. };
  53186. /**
  53187. * Makes a duplicate of the current material.
  53188. * @param name - name to use for the new material.
  53189. */
  53190. PBRSpecularGlossinessMaterial.prototype.clone = function (name) {
  53191. var _this = this;
  53192. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRSpecularGlossinessMaterial(name, _this.getScene()); }, this);
  53193. clone.id = name;
  53194. clone.name = name;
  53195. return clone;
  53196. };
  53197. /**
  53198. * Serialize the material to a parsable JSON object.
  53199. */
  53200. PBRSpecularGlossinessMaterial.prototype.serialize = function () {
  53201. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  53202. serializationObject.customType = "BABYLON.PBRSpecularGlossinessMaterial";
  53203. return serializationObject;
  53204. };
  53205. /**
  53206. * Parses a JSON object correponding to the serialize function.
  53207. */
  53208. PBRSpecularGlossinessMaterial.Parse = function (source, scene, rootUrl) {
  53209. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRSpecularGlossinessMaterial(source.name, scene); }, source, scene, rootUrl);
  53210. };
  53211. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53212. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse"),
  53213. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  53214. ], PBRSpecularGlossinessMaterial.prototype, "diffuseColor", void 0);
  53215. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53216. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53217. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  53218. ], PBRSpecularGlossinessMaterial.prototype, "diffuseTexture", void 0);
  53219. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53220. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular"),
  53221. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityColor")
  53222. ], PBRSpecularGlossinessMaterial.prototype, "specularColor", void 0);
  53223. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53224. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53225. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_microSurface")
  53226. ], PBRSpecularGlossinessMaterial.prototype, "glossiness", void 0);
  53227. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53228. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53229. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityTexture")
  53230. ], PBRSpecularGlossinessMaterial.prototype, "specularGlossinessTexture", void 0);
  53231. return PBRSpecularGlossinessMaterial;
  53232. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  53233. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRSpecularGlossinessMaterial"] = PBRSpecularGlossinessMaterial;
  53234. /***/ }),
  53235. /***/ "./Materials/Textures/Loaders/ddsTextureLoader.ts":
  53236. /*!********************************************************!*\
  53237. !*** ./Materials/Textures/Loaders/ddsTextureLoader.ts ***!
  53238. \********************************************************/
  53239. /*! exports provided: _DDSTextureLoader */
  53240. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53241. "use strict";
  53242. __webpack_require__.r(__webpack_exports__);
  53243. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _DDSTextureLoader; });
  53244. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  53245. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  53246. /* harmony import */ var _Misc_dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/dds */ "./Misc/dds.ts");
  53247. /**
  53248. * Implementation of the DDS Texture Loader.
  53249. * @hidden
  53250. */
  53251. var _DDSTextureLoader = /** @class */ (function () {
  53252. function _DDSTextureLoader() {
  53253. /**
  53254. * Defines wether the loader supports cascade loading the different faces.
  53255. */
  53256. this.supportCascades = true;
  53257. }
  53258. /**
  53259. * This returns if the loader support the current file information.
  53260. * @param extension defines the file extension of the file being loaded
  53261. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53262. * @param fallback defines the fallback internal texture if any
  53263. * @param isBase64 defines whether the texture is encoded as a base64
  53264. * @param isBuffer defines whether the texture data are stored as a buffer
  53265. * @returns true if the loader can load the specified file
  53266. */
  53267. _DDSTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  53268. return extension.indexOf(".dds") === 0;
  53269. };
  53270. /**
  53271. * Transform the url before loading if required.
  53272. * @param rootUrl the url of the texture
  53273. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53274. * @returns the transformed texture
  53275. */
  53276. _DDSTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  53277. return rootUrl;
  53278. };
  53279. /**
  53280. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53281. * @param rootUrl the url of the texture
  53282. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53283. * @returns the fallback texture
  53284. */
  53285. _DDSTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  53286. return null;
  53287. };
  53288. /**
  53289. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53290. * @param data contains the texture data
  53291. * @param texture defines the BabylonJS internal texture
  53292. * @param createPolynomials will be true if polynomials have been requested
  53293. * @param onLoad defines the callback to trigger once the texture is ready
  53294. * @param onError defines the callback to trigger in case of error
  53295. */
  53296. _DDSTextureLoader.prototype.loadCubeData = function (imgs, texture, createPolynomials, onLoad, onError) {
  53297. var engine = texture.getEngine();
  53298. var info;
  53299. var loadMipmap = false;
  53300. if (Array.isArray(imgs)) {
  53301. for (var index = 0; index < imgs.length; index++) {
  53302. var data_1 = imgs[index];
  53303. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data_1);
  53304. texture.width = info.width;
  53305. texture.height = info.height;
  53306. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  53307. engine._unpackFlipY(info.isCompressed);
  53308. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data_1, info, loadMipmap, 6, -1, index);
  53309. if (!info.isFourCC && info.mipmapCount === 1) {
  53310. engine.generateMipMapsForCubemap(texture);
  53311. }
  53312. }
  53313. }
  53314. else {
  53315. var data = imgs;
  53316. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  53317. texture.width = info.width;
  53318. texture.height = info.height;
  53319. if (createPolynomials) {
  53320. info.sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]();
  53321. }
  53322. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  53323. engine._unpackFlipY(info.isCompressed);
  53324. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data, info, loadMipmap, 6);
  53325. if (!info.isFourCC && info.mipmapCount === 1) {
  53326. engine.generateMipMapsForCubemap(texture);
  53327. }
  53328. }
  53329. engine._setCubeMapTextureParams(loadMipmap);
  53330. texture.isReady = true;
  53331. if (onLoad) {
  53332. onLoad({ isDDS: true, width: texture.width, info: info, data: imgs, texture: texture });
  53333. }
  53334. };
  53335. /**
  53336. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53337. * @param data contains the texture data
  53338. * @param texture defines the BabylonJS internal texture
  53339. * @param callback defines the method to call once ready to upload
  53340. */
  53341. _DDSTextureLoader.prototype.loadData = function (data, texture, callback) {
  53342. var info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  53343. var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps && ((info.width >> (info.mipmapCount - 1)) === 1);
  53344. callback(info.width, info.height, loadMipmap, info.isFourCC, function () {
  53345. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(texture.getEngine(), texture, data, info, loadMipmap, 1);
  53346. });
  53347. };
  53348. return _DDSTextureLoader;
  53349. }());
  53350. // Register the loader.
  53351. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _DDSTextureLoader());
  53352. /***/ }),
  53353. /***/ "./Materials/Textures/Loaders/envTextureLoader.ts":
  53354. /*!********************************************************!*\
  53355. !*** ./Materials/Textures/Loaders/envTextureLoader.ts ***!
  53356. \********************************************************/
  53357. /*! exports provided: _ENVTextureLoader */
  53358. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53359. "use strict";
  53360. __webpack_require__.r(__webpack_exports__);
  53361. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _ENVTextureLoader; });
  53362. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  53363. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  53364. /**
  53365. * Implementation of the ENV Texture Loader.
  53366. * @hidden
  53367. */
  53368. var _ENVTextureLoader = /** @class */ (function () {
  53369. function _ENVTextureLoader() {
  53370. /**
  53371. * Defines wether the loader supports cascade loading the different faces.
  53372. */
  53373. this.supportCascades = false;
  53374. }
  53375. /**
  53376. * This returns if the loader support the current file information.
  53377. * @param extension defines the file extension of the file being loaded
  53378. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53379. * @param fallback defines the fallback internal texture if any
  53380. * @param isBase64 defines whether the texture is encoded as a base64
  53381. * @param isBuffer defines whether the texture data are stored as a buffer
  53382. * @returns true if the loader can load the specified file
  53383. */
  53384. _ENVTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  53385. return extension.indexOf(".env") === 0;
  53386. };
  53387. /**
  53388. * Transform the url before loading if required.
  53389. * @param rootUrl the url of the texture
  53390. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53391. * @returns the transformed texture
  53392. */
  53393. _ENVTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  53394. return rootUrl;
  53395. };
  53396. /**
  53397. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53398. * @param rootUrl the url of the texture
  53399. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53400. * @returns the fallback texture
  53401. */
  53402. _ENVTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  53403. return null;
  53404. };
  53405. /**
  53406. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53407. * @param data contains the texture data
  53408. * @param texture defines the BabylonJS internal texture
  53409. * @param createPolynomials will be true if polynomials have been requested
  53410. * @param onLoad defines the callback to trigger once the texture is ready
  53411. * @param onError defines the callback to trigger in case of error
  53412. */
  53413. _ENVTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  53414. if (Array.isArray(data)) {
  53415. return;
  53416. }
  53417. data = data;
  53418. var info = _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].GetEnvInfo(data);
  53419. if (info) {
  53420. texture.width = info.width;
  53421. texture.height = info.width;
  53422. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvSpherical(texture, info);
  53423. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvLevelsAsync(texture, data, info).then(function () {
  53424. texture.isReady = true;
  53425. if (onLoad) {
  53426. onLoad();
  53427. }
  53428. });
  53429. }
  53430. else if (onError) {
  53431. onError("Can not parse the environment file", null);
  53432. }
  53433. };
  53434. /**
  53435. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53436. * @param data contains the texture data
  53437. * @param texture defines the BabylonJS internal texture
  53438. * @param callback defines the method to call once ready to upload
  53439. */
  53440. _ENVTextureLoader.prototype.loadData = function (data, texture, callback) {
  53441. throw ".env not supported in 2d.";
  53442. };
  53443. return _ENVTextureLoader;
  53444. }());
  53445. // Register the loader.
  53446. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _ENVTextureLoader());
  53447. /***/ }),
  53448. /***/ "./Materials/Textures/Loaders/index.ts":
  53449. /*!*********************************************!*\
  53450. !*** ./Materials/Textures/Loaders/index.ts ***!
  53451. \*********************************************/
  53452. /*! exports provided: _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader */
  53453. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53454. "use strict";
  53455. __webpack_require__.r(__webpack_exports__);
  53456. /* harmony import */ var _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  53457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  53458. /* harmony import */ var _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  53459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__["_ENVTextureLoader"]; });
  53460. /* harmony import */ var _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  53461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__["_KTXTextureLoader"]; });
  53462. /* harmony import */ var _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tgaTextureLoader */ "./Materials/Textures/Loaders/tgaTextureLoader.ts");
  53463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__["_TGATextureLoader"]; });
  53464. /***/ }),
  53465. /***/ "./Materials/Textures/Loaders/ktxTextureLoader.ts":
  53466. /*!********************************************************!*\
  53467. !*** ./Materials/Textures/Loaders/ktxTextureLoader.ts ***!
  53468. \********************************************************/
  53469. /*! exports provided: _KTXTextureLoader */
  53470. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53471. "use strict";
  53472. __webpack_require__.r(__webpack_exports__);
  53473. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _KTXTextureLoader; });
  53474. /* harmony import */ var _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  53475. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  53476. /**
  53477. * Implementation of the KTX Texture Loader.
  53478. * @hidden
  53479. */
  53480. var _KTXTextureLoader = /** @class */ (function () {
  53481. function _KTXTextureLoader() {
  53482. /**
  53483. * Defines wether the loader supports cascade loading the different faces.
  53484. */
  53485. this.supportCascades = false;
  53486. }
  53487. /**
  53488. * This returns if the loader support the current file information.
  53489. * @param extension defines the file extension of the file being loaded
  53490. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53491. * @param fallback defines the fallback internal texture if any
  53492. * @param isBase64 defines whether the texture is encoded as a base64
  53493. * @param isBuffer defines whether the texture data are stored as a buffer
  53494. * @returns true if the loader can load the specified file
  53495. */
  53496. _KTXTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  53497. if (textureFormatInUse && !isBase64 && !fallback && !isBuffer) {
  53498. return true;
  53499. }
  53500. return false;
  53501. };
  53502. /**
  53503. * Transform the url before loading if required.
  53504. * @param rootUrl the url of the texture
  53505. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53506. * @returns the transformed texture
  53507. */
  53508. _KTXTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  53509. var lastDot = rootUrl.lastIndexOf('.');
  53510. if (lastDot != -1 && rootUrl.substring(lastDot + 1) == "ktx") {
  53511. // Already transformed
  53512. return rootUrl;
  53513. }
  53514. return (lastDot > -1 ? rootUrl.substring(0, lastDot) : rootUrl) + textureFormatInUse;
  53515. };
  53516. /**
  53517. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53518. * @param rootUrl the url of the texture
  53519. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53520. * @returns the fallback texture
  53521. */
  53522. _KTXTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  53523. // remove the format appended to the rootUrl in the original createCubeTexture call.
  53524. var exp = new RegExp("" + textureFormatInUse + "$");
  53525. return rootUrl.replace(exp, "");
  53526. };
  53527. /**
  53528. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53529. * @param data contains the texture data
  53530. * @param texture defines the BabylonJS internal texture
  53531. * @param createPolynomials will be true if polynomials have been requested
  53532. * @param onLoad defines the callback to trigger once the texture is ready
  53533. * @param onError defines the callback to trigger in case of error
  53534. */
  53535. _KTXTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  53536. if (Array.isArray(data)) {
  53537. return;
  53538. }
  53539. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  53540. texture._invertVScale = !texture.invertY;
  53541. var engine = texture.getEngine();
  53542. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 6);
  53543. var loadMipmap = ktx.numberOfMipmapLevels > 1 && texture.generateMipMaps;
  53544. engine._unpackFlipY(true);
  53545. ktx.uploadLevels(texture, texture.generateMipMaps);
  53546. texture.width = ktx.pixelWidth;
  53547. texture.height = ktx.pixelHeight;
  53548. engine._setCubeMapTextureParams(loadMipmap);
  53549. texture.isReady = true;
  53550. };
  53551. /**
  53552. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53553. * @param data contains the texture data
  53554. * @param texture defines the BabylonJS internal texture
  53555. * @param callback defines the method to call once ready to upload
  53556. */
  53557. _KTXTextureLoader.prototype.loadData = function (data, texture, callback) {
  53558. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  53559. texture._invertVScale = !texture.invertY;
  53560. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 1);
  53561. callback(ktx.pixelWidth, ktx.pixelHeight, false, true, function () {
  53562. ktx.uploadLevels(texture, texture.generateMipMaps);
  53563. }, ktx.isInvalid);
  53564. };
  53565. return _KTXTextureLoader;
  53566. }());
  53567. // Register the loader.
  53568. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.unshift(new _KTXTextureLoader());
  53569. /***/ }),
  53570. /***/ "./Materials/Textures/Loaders/tgaTextureLoader.ts":
  53571. /*!********************************************************!*\
  53572. !*** ./Materials/Textures/Loaders/tgaTextureLoader.ts ***!
  53573. \********************************************************/
  53574. /*! exports provided: _TGATextureLoader */
  53575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53576. "use strict";
  53577. __webpack_require__.r(__webpack_exports__);
  53578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _TGATextureLoader; });
  53579. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tga */ "./Misc/tga.ts");
  53580. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  53581. /**
  53582. * Implementation of the TGA Texture Loader.
  53583. * @hidden
  53584. */
  53585. var _TGATextureLoader = /** @class */ (function () {
  53586. function _TGATextureLoader() {
  53587. /**
  53588. * Defines wether the loader supports cascade loading the different faces.
  53589. */
  53590. this.supportCascades = false;
  53591. }
  53592. /**
  53593. * This returns if the loader support the current file information.
  53594. * @param extension defines the file extension of the file being loaded
  53595. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53596. * @param fallback defines the fallback internal texture if any
  53597. * @param isBase64 defines whether the texture is encoded as a base64
  53598. * @param isBuffer defines whether the texture data are stored as a buffer
  53599. * @returns true if the loader can load the specified file
  53600. */
  53601. _TGATextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  53602. return extension.indexOf(".tga") === 0;
  53603. };
  53604. /**
  53605. * Transform the url before loading if required.
  53606. * @param rootUrl the url of the texture
  53607. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53608. * @returns the transformed texture
  53609. */
  53610. _TGATextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  53611. return rootUrl;
  53612. };
  53613. /**
  53614. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53615. * @param rootUrl the url of the texture
  53616. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53617. * @returns the fallback texture
  53618. */
  53619. _TGATextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  53620. return null;
  53621. };
  53622. /**
  53623. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53624. * @param data contains the texture data
  53625. * @param texture defines the BabylonJS internal texture
  53626. * @param createPolynomials will be true if polynomials have been requested
  53627. * @param onLoad defines the callback to trigger once the texture is ready
  53628. * @param onError defines the callback to trigger in case of error
  53629. */
  53630. _TGATextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  53631. throw ".env not supported in Cube.";
  53632. };
  53633. /**
  53634. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53635. * @param data contains the texture data
  53636. * @param texture defines the BabylonJS internal texture
  53637. * @param callback defines the method to call once ready to upload
  53638. */
  53639. _TGATextureLoader.prototype.loadData = function (data, texture, callback) {
  53640. var uintData = new Uint8Array(data);
  53641. var header = _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].GetTGAHeader(uintData);
  53642. callback(header.width, header.height, texture.generateMipMaps, false, function () {
  53643. _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].UploadContent(texture, uintData);
  53644. });
  53645. };
  53646. return _TGATextureLoader;
  53647. }());
  53648. // Register the loader.
  53649. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _TGATextureLoader());
  53650. /***/ }),
  53651. /***/ "./Materials/Textures/Procedurals/customProceduralTexture.ts":
  53652. /*!*******************************************************************!*\
  53653. !*** ./Materials/Textures/Procedurals/customProceduralTexture.ts ***!
  53654. \*******************************************************************/
  53655. /*! exports provided: CustomProceduralTexture */
  53656. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53657. "use strict";
  53658. __webpack_require__.r(__webpack_exports__);
  53659. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return CustomProceduralTexture; });
  53660. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53661. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  53662. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  53663. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  53664. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  53665. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  53666. /**
  53667. * 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.
  53668. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53669. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53670. */
  53671. var CustomProceduralTexture = /** @class */ (function (_super) {
  53672. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomProceduralTexture, _super);
  53673. /**
  53674. * Instantiates a new Custom Procedural Texture.
  53675. * 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.
  53676. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53677. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53678. * @param name Define the name of the texture
  53679. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53680. * @param size Define the size of the texture to create
  53681. * @param scene Define the scene the texture belongs to
  53682. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53683. * @param generateMipMaps Define if the texture should creates mip maps or not
  53684. */
  53685. function CustomProceduralTexture(name, texturePath, size, scene, fallbackTexture, generateMipMaps) {
  53686. var _this = _super.call(this, name, size, null, scene, fallbackTexture, generateMipMaps) || this;
  53687. _this._animate = true;
  53688. _this._time = 0;
  53689. _this._texturePath = texturePath;
  53690. //Try to load json
  53691. _this._loadJson(texturePath);
  53692. _this.refreshRate = 1;
  53693. return _this;
  53694. }
  53695. CustomProceduralTexture.prototype._loadJson = function (jsonUrl) {
  53696. var _this = this;
  53697. var noConfigFile = function () {
  53698. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Log("No config file found in " + jsonUrl + " trying to use ShadersStore or DOM element");
  53699. try {
  53700. _this.setFragment(_this._texturePath);
  53701. }
  53702. catch (ex) {
  53703. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("No json or ShaderStore or DOM element found for CustomProceduralTexture");
  53704. }
  53705. };
  53706. var configFileUrl = jsonUrl + "/config.json";
  53707. var xhr = new XMLHttpRequest();
  53708. xhr.open("GET", configFileUrl, true);
  53709. xhr.addEventListener("load", function () {
  53710. if (xhr.status === 200 || (xhr.responseText && xhr.responseText.length > 0)) {
  53711. try {
  53712. _this._config = JSON.parse(xhr.response);
  53713. _this.updateShaderUniforms();
  53714. _this.updateTextures();
  53715. _this.setFragment(_this._texturePath + "/custom");
  53716. _this._animate = _this._config.animate;
  53717. _this.refreshRate = _this._config.refreshrate;
  53718. }
  53719. catch (ex) {
  53720. noConfigFile();
  53721. }
  53722. }
  53723. else {
  53724. noConfigFile();
  53725. }
  53726. }, false);
  53727. xhr.addEventListener("error", function () {
  53728. noConfigFile();
  53729. }, false);
  53730. try {
  53731. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].UseCustomRequestHeaders) {
  53732. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].InjectCustomRequestHeaders(xhr);
  53733. }
  53734. xhr.send();
  53735. }
  53736. catch (ex) {
  53737. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("CustomProceduralTexture: Error on XHR send request.");
  53738. }
  53739. };
  53740. /**
  53741. * Is the texture ready to be used ? (rendered at least once)
  53742. * @returns true if ready, otherwise, false.
  53743. */
  53744. CustomProceduralTexture.prototype.isReady = function () {
  53745. if (!_super.prototype.isReady.call(this)) {
  53746. return false;
  53747. }
  53748. for (var name in this._textures) {
  53749. var texture = this._textures[name];
  53750. if (!texture.isReady()) {
  53751. return false;
  53752. }
  53753. }
  53754. return true;
  53755. };
  53756. /**
  53757. * Render the texture to its associated render target.
  53758. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53759. */
  53760. CustomProceduralTexture.prototype.render = function (useCameraPostProcess) {
  53761. var scene = this.getScene();
  53762. if (this._animate && scene) {
  53763. this._time += scene.getAnimationRatio() * 0.03;
  53764. this.updateShaderUniforms();
  53765. }
  53766. _super.prototype.render.call(this, useCameraPostProcess);
  53767. };
  53768. /**
  53769. * Update the list of dependant textures samplers in the shader.
  53770. */
  53771. CustomProceduralTexture.prototype.updateTextures = function () {
  53772. for (var i = 0; i < this._config.sampler2Ds.length; i++) {
  53773. 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()));
  53774. }
  53775. };
  53776. /**
  53777. * Update the uniform values of the procedural texture in the shader.
  53778. */
  53779. CustomProceduralTexture.prototype.updateShaderUniforms = function () {
  53780. if (this._config) {
  53781. for (var j = 0; j < this._config.uniforms.length; j++) {
  53782. var uniform = this._config.uniforms[j];
  53783. switch (uniform.type) {
  53784. case "float":
  53785. this.setFloat(uniform.name, uniform.value);
  53786. break;
  53787. case "color3":
  53788. this.setColor3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](uniform.r, uniform.g, uniform.b));
  53789. break;
  53790. case "color4":
  53791. this.setColor4(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](uniform.r, uniform.g, uniform.b, uniform.a));
  53792. break;
  53793. case "vector2":
  53794. this.setVector2(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](uniform.x, uniform.y));
  53795. break;
  53796. case "vector3":
  53797. this.setVector3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](uniform.x, uniform.y, uniform.z));
  53798. break;
  53799. }
  53800. }
  53801. }
  53802. this.setFloat("time", this._time);
  53803. };
  53804. Object.defineProperty(CustomProceduralTexture.prototype, "animate", {
  53805. /**
  53806. * Define if the texture animates or not.
  53807. */
  53808. get: function () {
  53809. return this._animate;
  53810. },
  53811. set: function (value) {
  53812. this._animate = value;
  53813. },
  53814. enumerable: true,
  53815. configurable: true
  53816. });
  53817. return CustomProceduralTexture;
  53818. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_5__["ProceduralTexture"]));
  53819. /***/ }),
  53820. /***/ "./Materials/Textures/Procedurals/index.ts":
  53821. /*!*************************************************!*\
  53822. !*** ./Materials/Textures/Procedurals/index.ts ***!
  53823. \*************************************************/
  53824. /*! exports provided: ProceduralTexture, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  53825. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53826. "use strict";
  53827. __webpack_require__.r(__webpack_exports__);
  53828. /* harmony import */ var _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./customProceduralTexture */ "./Materials/Textures/Procedurals/customProceduralTexture.ts");
  53829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  53830. /* harmony import */ var _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./noiseProceduralTexture */ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts");
  53831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__["NoiseProceduralTexture"]; });
  53832. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  53833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]; });
  53834. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  53835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__["ProceduralTextureSceneComponent"]; });
  53836. /***/ }),
  53837. /***/ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts":
  53838. /*!******************************************************************!*\
  53839. !*** ./Materials/Textures/Procedurals/noiseProceduralTexture.ts ***!
  53840. \******************************************************************/
  53841. /*! exports provided: NoiseProceduralTexture */
  53842. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53843. "use strict";
  53844. __webpack_require__.r(__webpack_exports__);
  53845. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return NoiseProceduralTexture; });
  53846. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53847. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  53848. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  53849. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  53850. /* harmony import */ var _Shaders_noise_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Shaders/noise.fragment */ "./Shaders/noise.fragment.ts");
  53851. /**
  53852. * Class used to generate noise procedural textures
  53853. */
  53854. var NoiseProceduralTexture = /** @class */ (function (_super) {
  53855. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NoiseProceduralTexture, _super);
  53856. /**
  53857. * Creates a new NoiseProceduralTexture
  53858. * @param name defines the name fo the texture
  53859. * @param size defines the size of the texture (default is 256)
  53860. * @param scene defines the hosting scene
  53861. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53862. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53863. */
  53864. function NoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  53865. if (size === void 0) { size = 256; }
  53866. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene; }
  53867. var _this = _super.call(this, name, size, "noise", scene, fallbackTexture, generateMipMaps) || this;
  53868. _this._time = 0;
  53869. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53870. _this.brightness = 0.2;
  53871. /** Defines the number of octaves to process */
  53872. _this.octaves = 3;
  53873. /** Defines the level of persistence (0.8 by default) */
  53874. _this.persistence = 0.8;
  53875. /** Gets or sets animation speed factor (default is 1) */
  53876. _this.animationSpeedFactor = 1;
  53877. _this.autoClear = false;
  53878. _this._updateShaderUniforms();
  53879. return _this;
  53880. }
  53881. NoiseProceduralTexture.prototype._updateShaderUniforms = function () {
  53882. var scene = this.getScene();
  53883. if (!scene) {
  53884. return;
  53885. }
  53886. this._time += scene.getAnimationRatio() * this.animationSpeedFactor * 0.01;
  53887. this.setFloat("brightness", this.brightness);
  53888. this.setFloat("persistence", this.persistence);
  53889. this.setFloat("timeScale", this._time);
  53890. };
  53891. NoiseProceduralTexture.prototype._getDefines = function () {
  53892. return "#define OCTAVES " + (this.octaves | 0);
  53893. };
  53894. /** Generate the current state of the procedural texture */
  53895. NoiseProceduralTexture.prototype.render = function (useCameraPostProcess) {
  53896. this._updateShaderUniforms();
  53897. _super.prototype.render.call(this, useCameraPostProcess);
  53898. };
  53899. /**
  53900. * Serializes this noise procedural texture
  53901. * @returns a serialized noise procedural texture object
  53902. */
  53903. NoiseProceduralTexture.prototype.serialize = function () {
  53904. var serializationObject = {};
  53905. serializationObject.customType = "BABYLON.NoiseProceduralTexture";
  53906. serializationObject.brightness = this.brightness;
  53907. serializationObject.octaves = this.octaves;
  53908. serializationObject.persistence = this.persistence;
  53909. serializationObject.animationSpeedFactor = this.animationSpeedFactor;
  53910. serializationObject.size = this.getSize().width;
  53911. serializationObject.generateMipMaps = this._generateMipMaps;
  53912. return serializationObject;
  53913. };
  53914. /**
  53915. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53916. * @param parsedTexture defines parsed texture data
  53917. * @param scene defines the current scene
  53918. * @param rootUrl defines the root URL containing noise procedural texture information
  53919. * @returns a parsed NoiseProceduralTexture
  53920. */
  53921. NoiseProceduralTexture.Parse = function (parsedTexture, scene) {
  53922. var texture = new NoiseProceduralTexture(parsedTexture.name, parsedTexture.size, scene, undefined, parsedTexture.generateMipMaps);
  53923. texture.brightness = parsedTexture.brightness;
  53924. texture.octaves = parsedTexture.octaves;
  53925. texture.persistence = parsedTexture.persistence;
  53926. texture.animationSpeedFactor = parsedTexture.animationSpeedFactor;
  53927. return texture;
  53928. };
  53929. return NoiseProceduralTexture;
  53930. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]));
  53931. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.NoiseProceduralTexture"] = NoiseProceduralTexture;
  53932. /***/ }),
  53933. /***/ "./Materials/Textures/Procedurals/proceduralTexture.ts":
  53934. /*!*************************************************************!*\
  53935. !*** ./Materials/Textures/Procedurals/proceduralTexture.ts ***!
  53936. \*************************************************************/
  53937. /*! exports provided: ProceduralTexture */
  53938. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53939. "use strict";
  53940. __webpack_require__.r(__webpack_exports__);
  53941. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return ProceduralTexture; });
  53942. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53943. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  53944. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/observable */ "./Misc/observable.ts");
  53945. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Meshes/buffer */ "./Meshes/buffer.ts");
  53946. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  53947. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/material */ "./Materials/material.ts");
  53948. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  53949. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  53950. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  53951. /* harmony import */ var _Shaders_procedural_vertex__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Shaders/procedural.vertex */ "./Shaders/procedural.vertex.ts");
  53952. /**
  53953. * 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.
  53954. * This is the base class of any Procedural texture and contains most of the shareable code.
  53955. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  53956. */
  53957. var ProceduralTexture = /** @class */ (function (_super) {
  53958. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ProceduralTexture, _super);
  53959. /**
  53960. * Instantiates a new procedural texture.
  53961. * 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.
  53962. * This is the base class of any Procedural texture and contains most of the shareable code.
  53963. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  53964. * @param name Define the name of the texture
  53965. * @param size Define the size of the texture to create
  53966. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  53967. * @param scene Define the scene the texture belongs to
  53968. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53969. * @param generateMipMaps Define if the texture should creates mip maps or not
  53970. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  53971. */
  53972. function ProceduralTexture(name, size, fragment, scene, fallbackTexture, generateMipMaps, isCube) {
  53973. if (fallbackTexture === void 0) { fallbackTexture = null; }
  53974. if (generateMipMaps === void 0) { generateMipMaps = true; }
  53975. if (isCube === void 0) { isCube = false; }
  53976. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  53977. _this.isCube = isCube;
  53978. /**
  53979. * Define if the texture is enabled or not (disabled texture will not render)
  53980. */
  53981. _this.isEnabled = true;
  53982. /**
  53983. * Define if the texture must be cleared before rendering (default is true)
  53984. */
  53985. _this.autoClear = true;
  53986. /**
  53987. * Event raised when the texture is generated
  53988. */
  53989. _this.onGeneratedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  53990. /** @hidden */
  53991. _this._textures = {};
  53992. _this._currentRefreshId = -1;
  53993. _this._refreshRate = 1;
  53994. _this._vertexBuffers = {};
  53995. _this._uniforms = new Array();
  53996. _this._samplers = new Array();
  53997. _this._floats = {};
  53998. _this._ints = {};
  53999. _this._floatsArrays = {};
  54000. _this._colors3 = {};
  54001. _this._colors4 = {};
  54002. _this._vectors2 = {};
  54003. _this._vectors3 = {};
  54004. _this._matrices = {};
  54005. _this._fallbackTextureUsed = false;
  54006. _this._cachedDefines = "";
  54007. _this._contentUpdateId = -1;
  54008. scene = _this.getScene();
  54009. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE);
  54010. if (!component) {
  54011. component = new _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__["ProceduralTextureSceneComponent"](scene);
  54012. scene._addComponent(component);
  54013. }
  54014. scene.proceduralTextures.push(_this);
  54015. _this._engine = scene.getEngine();
  54016. _this.name = name;
  54017. _this.isRenderTarget = true;
  54018. _this._size = size;
  54019. _this._generateMipMaps = generateMipMaps;
  54020. _this.setFragment(fragment);
  54021. _this._fallbackTexture = fallbackTexture;
  54022. if (isCube) {
  54023. _this._texture = _this._engine.createRenderTargetCubeTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  54024. _this.setFloat("face", 0);
  54025. }
  54026. else {
  54027. _this._texture = _this._engine.createRenderTargetTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  54028. }
  54029. // VBO
  54030. var vertices = [];
  54031. vertices.push(1, 1);
  54032. vertices.push(-1, 1);
  54033. vertices.push(-1, -1);
  54034. vertices.push(1, -1);
  54035. _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);
  54036. _this._createIndexBuffer();
  54037. return _this;
  54038. }
  54039. /**
  54040. * The effect that is created when initializing the post process.
  54041. * @returns The created effect corrisponding the the postprocess.
  54042. */
  54043. ProceduralTexture.prototype.getEffect = function () {
  54044. return this._effect;
  54045. };
  54046. /**
  54047. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  54048. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  54049. */
  54050. ProceduralTexture.prototype.getContent = function () {
  54051. if (this._contentData && this._currentRefreshId == this._contentUpdateId) {
  54052. return this._contentData;
  54053. }
  54054. this._contentData = this.readPixels(0, 0, this._contentData);
  54055. this._contentUpdateId = this._currentRefreshId;
  54056. return this._contentData;
  54057. };
  54058. ProceduralTexture.prototype._createIndexBuffer = function () {
  54059. var engine = this._engine;
  54060. // Indices
  54061. var indices = [];
  54062. indices.push(0);
  54063. indices.push(1);
  54064. indices.push(2);
  54065. indices.push(0);
  54066. indices.push(2);
  54067. indices.push(3);
  54068. this._indexBuffer = engine.createIndexBuffer(indices);
  54069. };
  54070. /** @hidden */
  54071. ProceduralTexture.prototype._rebuild = function () {
  54072. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  54073. if (vb) {
  54074. vb._rebuild();
  54075. }
  54076. this._createIndexBuffer();
  54077. if (this.refreshRate === _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE) {
  54078. this.refreshRate = _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE;
  54079. }
  54080. };
  54081. /**
  54082. * Resets the texture in order to recreate its associated resources.
  54083. * This can be called in case of context loss
  54084. */
  54085. ProceduralTexture.prototype.reset = function () {
  54086. if (this._effect === undefined) {
  54087. return;
  54088. }
  54089. var engine = this._engine;
  54090. engine._releaseEffect(this._effect);
  54091. };
  54092. ProceduralTexture.prototype._getDefines = function () {
  54093. return "";
  54094. };
  54095. /**
  54096. * Is the texture ready to be used ? (rendered at least once)
  54097. * @returns true if ready, otherwise, false.
  54098. */
  54099. ProceduralTexture.prototype.isReady = function () {
  54100. var _this = this;
  54101. var engine = this._engine;
  54102. var shaders;
  54103. if (!this._fragment) {
  54104. return false;
  54105. }
  54106. if (this._fallbackTextureUsed) {
  54107. return true;
  54108. }
  54109. var defines = this._getDefines();
  54110. if (this._effect && defines === this._cachedDefines && this._effect.isReady()) {
  54111. return true;
  54112. }
  54113. if (this._fragment.fragmentElement !== undefined) {
  54114. shaders = { vertex: "procedural", fragmentElement: this._fragment.fragmentElement };
  54115. }
  54116. else {
  54117. shaders = { vertex: "procedural", fragment: this._fragment };
  54118. }
  54119. this._cachedDefines = defines;
  54120. this._effect = engine.createEffect(shaders, [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], this._uniforms, this._samplers, defines, undefined, undefined, function () {
  54121. _this.releaseInternalTexture();
  54122. if (_this._fallbackTexture) {
  54123. _this._texture = _this._fallbackTexture._texture;
  54124. if (_this._texture) {
  54125. _this._texture.incrementReferences();
  54126. }
  54127. }
  54128. _this._fallbackTextureUsed = true;
  54129. });
  54130. return this._effect.isReady();
  54131. };
  54132. /**
  54133. * Resets the refresh counter of the texture and start bak from scratch.
  54134. * Could be useful to regenerate the texture if it is setup to render only once.
  54135. */
  54136. ProceduralTexture.prototype.resetRefreshCounter = function () {
  54137. this._currentRefreshId = -1;
  54138. };
  54139. /**
  54140. * Set the fragment shader to use in order to render the texture.
  54141. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  54142. */
  54143. ProceduralTexture.prototype.setFragment = function (fragment) {
  54144. this._fragment = fragment;
  54145. };
  54146. Object.defineProperty(ProceduralTexture.prototype, "refreshRate", {
  54147. /**
  54148. * Define the refresh rate of the texture or the rendering frequency.
  54149. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  54150. */
  54151. get: function () {
  54152. return this._refreshRate;
  54153. },
  54154. set: function (value) {
  54155. this._refreshRate = value;
  54156. this.resetRefreshCounter();
  54157. },
  54158. enumerable: true,
  54159. configurable: true
  54160. });
  54161. /** @hidden */
  54162. ProceduralTexture.prototype._shouldRender = function () {
  54163. if (!this.isEnabled || !this.isReady() || !this._texture) {
  54164. if (this._texture) {
  54165. this._texture.isReady = false;
  54166. }
  54167. return false;
  54168. }
  54169. if (this._fallbackTextureUsed) {
  54170. return false;
  54171. }
  54172. if (this._currentRefreshId === -1) { // At least render once
  54173. this._currentRefreshId = 1;
  54174. return true;
  54175. }
  54176. if (this.refreshRate === this._currentRefreshId) {
  54177. this._currentRefreshId = 1;
  54178. return true;
  54179. }
  54180. this._currentRefreshId++;
  54181. return false;
  54182. };
  54183. /**
  54184. * Get the size the texture is rendering at.
  54185. * @returns the size (texture is always squared)
  54186. */
  54187. ProceduralTexture.prototype.getRenderSize = function () {
  54188. return this._size;
  54189. };
  54190. /**
  54191. * Resize the texture to new value.
  54192. * @param size Define the new size the texture should have
  54193. * @param generateMipMaps Define whether the new texture should create mip maps
  54194. */
  54195. ProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  54196. if (this._fallbackTextureUsed) {
  54197. return;
  54198. }
  54199. this.releaseInternalTexture();
  54200. this._texture = this._engine.createRenderTargetTexture(size, generateMipMaps);
  54201. // Update properties
  54202. this._size = size;
  54203. this._generateMipMaps = generateMipMaps;
  54204. };
  54205. ProceduralTexture.prototype._checkUniform = function (uniformName) {
  54206. if (this._uniforms.indexOf(uniformName) === -1) {
  54207. this._uniforms.push(uniformName);
  54208. }
  54209. };
  54210. /**
  54211. * Set a texture in the shader program used to render.
  54212. * @param name Define the name of the uniform samplers as defined in the shader
  54213. * @param texture Define the texture to bind to this sampler
  54214. * @return the texture itself allowing "fluent" like uniform updates
  54215. */
  54216. ProceduralTexture.prototype.setTexture = function (name, texture) {
  54217. if (this._samplers.indexOf(name) === -1) {
  54218. this._samplers.push(name);
  54219. }
  54220. this._textures[name] = texture;
  54221. return this;
  54222. };
  54223. /**
  54224. * Set a float in the shader.
  54225. * @param name Define the name of the uniform as defined in the shader
  54226. * @param value Define the value to give to the uniform
  54227. * @return the texture itself allowing "fluent" like uniform updates
  54228. */
  54229. ProceduralTexture.prototype.setFloat = function (name, value) {
  54230. this._checkUniform(name);
  54231. this._floats[name] = value;
  54232. return this;
  54233. };
  54234. /**
  54235. * Set a int in the shader.
  54236. * @param name Define the name of the uniform as defined in the shader
  54237. * @param value Define the value to give to the uniform
  54238. * @return the texture itself allowing "fluent" like uniform updates
  54239. */
  54240. ProceduralTexture.prototype.setInt = function (name, value) {
  54241. this._checkUniform(name);
  54242. this._ints[name] = value;
  54243. return this;
  54244. };
  54245. /**
  54246. * Set an array of floats in the shader.
  54247. * @param name Define the name of the uniform as defined in the shader
  54248. * @param value Define the value to give to the uniform
  54249. * @return the texture itself allowing "fluent" like uniform updates
  54250. */
  54251. ProceduralTexture.prototype.setFloats = function (name, value) {
  54252. this._checkUniform(name);
  54253. this._floatsArrays[name] = value;
  54254. return this;
  54255. };
  54256. /**
  54257. * Set a vec3 in the shader from a Color3.
  54258. * @param name Define the name of the uniform as defined in the shader
  54259. * @param value Define the value to give to the uniform
  54260. * @return the texture itself allowing "fluent" like uniform updates
  54261. */
  54262. ProceduralTexture.prototype.setColor3 = function (name, value) {
  54263. this._checkUniform(name);
  54264. this._colors3[name] = value;
  54265. return this;
  54266. };
  54267. /**
  54268. * Set a vec4 in the shader from a Color4.
  54269. * @param name Define the name of the uniform as defined in the shader
  54270. * @param value Define the value to give to the uniform
  54271. * @return the texture itself allowing "fluent" like uniform updates
  54272. */
  54273. ProceduralTexture.prototype.setColor4 = function (name, value) {
  54274. this._checkUniform(name);
  54275. this._colors4[name] = value;
  54276. return this;
  54277. };
  54278. /**
  54279. * Set a vec2 in the shader from a Vector2.
  54280. * @param name Define the name of the uniform as defined in the shader
  54281. * @param value Define the value to give to the uniform
  54282. * @return the texture itself allowing "fluent" like uniform updates
  54283. */
  54284. ProceduralTexture.prototype.setVector2 = function (name, value) {
  54285. this._checkUniform(name);
  54286. this._vectors2[name] = value;
  54287. return this;
  54288. };
  54289. /**
  54290. * Set a vec3 in the shader from a Vector3.
  54291. * @param name Define the name of the uniform as defined in the shader
  54292. * @param value Define the value to give to the uniform
  54293. * @return the texture itself allowing "fluent" like uniform updates
  54294. */
  54295. ProceduralTexture.prototype.setVector3 = function (name, value) {
  54296. this._checkUniform(name);
  54297. this._vectors3[name] = value;
  54298. return this;
  54299. };
  54300. /**
  54301. * Set a mat4 in the shader from a MAtrix.
  54302. * @param name Define the name of the uniform as defined in the shader
  54303. * @param value Define the value to give to the uniform
  54304. * @return the texture itself allowing "fluent" like uniform updates
  54305. */
  54306. ProceduralTexture.prototype.setMatrix = function (name, value) {
  54307. this._checkUniform(name);
  54308. this._matrices[name] = value;
  54309. return this;
  54310. };
  54311. /**
  54312. * Render the texture to its associated render target.
  54313. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54314. */
  54315. ProceduralTexture.prototype.render = function (useCameraPostProcess) {
  54316. var scene = this.getScene();
  54317. if (!scene) {
  54318. return;
  54319. }
  54320. var engine = this._engine;
  54321. // Render
  54322. engine.enableEffect(this._effect);
  54323. engine.setState(false);
  54324. // Texture
  54325. for (var name in this._textures) {
  54326. this._effect.setTexture(name, this._textures[name]);
  54327. }
  54328. // Float
  54329. for (name in this._ints) {
  54330. this._effect.setInt(name, this._ints[name]);
  54331. }
  54332. // Float
  54333. for (name in this._floats) {
  54334. this._effect.setFloat(name, this._floats[name]);
  54335. }
  54336. // Floats
  54337. for (name in this._floatsArrays) {
  54338. this._effect.setArray(name, this._floatsArrays[name]);
  54339. }
  54340. // Color3
  54341. for (name in this._colors3) {
  54342. this._effect.setColor3(name, this._colors3[name]);
  54343. }
  54344. // Color4
  54345. for (name in this._colors4) {
  54346. var color = this._colors4[name];
  54347. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  54348. }
  54349. // Vector2
  54350. for (name in this._vectors2) {
  54351. this._effect.setVector2(name, this._vectors2[name]);
  54352. }
  54353. // Vector3
  54354. for (name in this._vectors3) {
  54355. this._effect.setVector3(name, this._vectors3[name]);
  54356. }
  54357. // Matrix
  54358. for (name in this._matrices) {
  54359. this._effect.setMatrix(name, this._matrices[name]);
  54360. }
  54361. if (!this._texture) {
  54362. return;
  54363. }
  54364. if (this.isCube) {
  54365. for (var face = 0; face < 6; face++) {
  54366. engine.bindFramebuffer(this._texture, face, undefined, undefined, true);
  54367. // VBOs
  54368. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  54369. this._effect.setFloat("face", face);
  54370. // Clear
  54371. if (this.autoClear) {
  54372. engine.clear(scene.clearColor, true, false, false);
  54373. }
  54374. // Draw order
  54375. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  54376. // Mipmaps
  54377. if (face === 5) {
  54378. engine.generateMipMapsForCubemap(this._texture);
  54379. }
  54380. }
  54381. }
  54382. else {
  54383. engine.bindFramebuffer(this._texture, 0, undefined, undefined, true);
  54384. // VBOs
  54385. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  54386. // Clear
  54387. if (this.autoClear) {
  54388. engine.clear(scene.clearColor, true, false, false);
  54389. }
  54390. // Draw order
  54391. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  54392. }
  54393. // Unbind
  54394. engine.unBindFramebuffer(this._texture, this.isCube);
  54395. if (this.onGenerated) {
  54396. this.onGenerated();
  54397. }
  54398. this.onGeneratedObservable.notifyObservers(this);
  54399. };
  54400. /**
  54401. * Clone the texture.
  54402. * @returns the cloned texture
  54403. */
  54404. ProceduralTexture.prototype.clone = function () {
  54405. var textureSize = this.getSize();
  54406. var newTexture = new ProceduralTexture(this.name, textureSize.width, this._fragment, this.getScene(), this._fallbackTexture, this._generateMipMaps);
  54407. // Base texture
  54408. newTexture.hasAlpha = this.hasAlpha;
  54409. newTexture.level = this.level;
  54410. // RenderTarget Texture
  54411. newTexture.coordinatesMode = this.coordinatesMode;
  54412. return newTexture;
  54413. };
  54414. /**
  54415. * Dispose the texture and release its asoociated resources.
  54416. */
  54417. ProceduralTexture.prototype.dispose = function () {
  54418. var scene = this.getScene();
  54419. if (!scene) {
  54420. return;
  54421. }
  54422. var index = scene.proceduralTextures.indexOf(this);
  54423. if (index >= 0) {
  54424. scene.proceduralTextures.splice(index, 1);
  54425. }
  54426. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  54427. if (vertexBuffer) {
  54428. vertexBuffer.dispose();
  54429. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  54430. }
  54431. if (this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer)) {
  54432. this._indexBuffer = null;
  54433. }
  54434. _super.prototype.dispose.call(this);
  54435. };
  54436. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54437. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54438. ], ProceduralTexture.prototype, "isEnabled", void 0);
  54439. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54440. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54441. ], ProceduralTexture.prototype, "autoClear", void 0);
  54442. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54443. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54444. ], ProceduralTexture.prototype, "_generateMipMaps", void 0);
  54445. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54446. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54447. ], ProceduralTexture.prototype, "_size", void 0);
  54448. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54449. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54450. ], ProceduralTexture.prototype, "refreshRate", null);
  54451. return ProceduralTexture;
  54452. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"]));
  54453. /***/ }),
  54454. /***/ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts":
  54455. /*!***************************************************************************!*\
  54456. !*** ./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts ***!
  54457. \***************************************************************************/
  54458. /*! exports provided: ProceduralTextureSceneComponent */
  54459. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54460. "use strict";
  54461. __webpack_require__.r(__webpack_exports__);
  54462. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return ProceduralTextureSceneComponent; });
  54463. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  54464. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  54465. /**
  54466. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  54467. * in a given scene.
  54468. */
  54469. var ProceduralTextureSceneComponent = /** @class */ (function () {
  54470. /**
  54471. * Creates a new instance of the component for the given scene
  54472. * @param scene Defines the scene to register the component in
  54473. */
  54474. function ProceduralTextureSceneComponent(scene) {
  54475. /**
  54476. * The component name helpfull to identify the component in the list of scene components.
  54477. */
  54478. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE;
  54479. this.scene = scene;
  54480. this.scene.proceduralTextures = new Array();
  54481. scene.layers = new Array();
  54482. }
  54483. /**
  54484. * Registers the component in a given scene
  54485. */
  54486. ProceduralTextureSceneComponent.prototype.register = function () {
  54487. this.scene._beforeClearStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear);
  54488. };
  54489. /**
  54490. * Rebuilds the elements related to this component in case of
  54491. * context lost for instance.
  54492. */
  54493. ProceduralTextureSceneComponent.prototype.rebuild = function () {
  54494. // Nothing to do here.
  54495. };
  54496. /**
  54497. * Disposes the component and the associated ressources.
  54498. */
  54499. ProceduralTextureSceneComponent.prototype.dispose = function () {
  54500. // Nothing to do here.
  54501. };
  54502. ProceduralTextureSceneComponent.prototype._beforeClear = function () {
  54503. if (this.scene.proceduralTexturesEnabled) {
  54504. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  54505. for (var proceduralIndex = 0; proceduralIndex < this.scene.proceduralTextures.length; proceduralIndex++) {
  54506. var proceduralTexture = this.scene.proceduralTextures[proceduralIndex];
  54507. if (proceduralTexture._shouldRender()) {
  54508. proceduralTexture.render();
  54509. }
  54510. }
  54511. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  54512. }
  54513. };
  54514. return ProceduralTextureSceneComponent;
  54515. }());
  54516. /***/ }),
  54517. /***/ "./Materials/Textures/baseTexture.ts":
  54518. /*!*******************************************!*\
  54519. !*** ./Materials/Textures/baseTexture.ts ***!
  54520. \*******************************************/
  54521. /*! exports provided: BaseTexture */
  54522. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54523. "use strict";
  54524. __webpack_require__.r(__webpack_exports__);
  54525. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return BaseTexture; });
  54526. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54527. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  54528. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  54529. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  54530. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  54531. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  54532. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  54533. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  54534. /**
  54535. * Base class of all the textures in babylon.
  54536. * It groups all the common properties the materials, post process, lights... might need
  54537. * in order to make a correct use of the texture.
  54538. */
  54539. var BaseTexture = /** @class */ (function () {
  54540. /**
  54541. * Instantiates a new BaseTexture.
  54542. * Base class of all the textures in babylon.
  54543. * It groups all the common properties the materials, post process, lights... might need
  54544. * in order to make a correct use of the texture.
  54545. * @param scene Define the scene the texture blongs to
  54546. */
  54547. function BaseTexture(scene) {
  54548. /**
  54549. * Gets or sets an object used to store user defined information.
  54550. */
  54551. this.metadata = null;
  54552. /**
  54553. * For internal use only. Please do not use.
  54554. */
  54555. this.reservedDataStore = null;
  54556. this._hasAlpha = false;
  54557. /**
  54558. * Defines if the alpha value should be determined via the rgb values.
  54559. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  54560. */
  54561. this.getAlphaFromRGB = false;
  54562. /**
  54563. * Intensity or strength of the texture.
  54564. * It is commonly used by materials to fine tune the intensity of the texture
  54565. */
  54566. this.level = 1;
  54567. /**
  54568. * Define the UV chanel to use starting from 0 and defaulting to 0.
  54569. * This is part of the texture as textures usually maps to one uv set.
  54570. */
  54571. this.coordinatesIndex = 0;
  54572. this._coordinatesMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_EXPLICIT_MODE;
  54573. /**
  54574. * | Value | Type | Description |
  54575. * | ----- | ------------------ | ----------- |
  54576. * | 0 | CLAMP_ADDRESSMODE | |
  54577. * | 1 | WRAP_ADDRESSMODE | |
  54578. * | 2 | MIRROR_ADDRESSMODE | |
  54579. */
  54580. this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  54581. /**
  54582. * | Value | Type | Description |
  54583. * | ----- | ------------------ | ----------- |
  54584. * | 0 | CLAMP_ADDRESSMODE | |
  54585. * | 1 | WRAP_ADDRESSMODE | |
  54586. * | 2 | MIRROR_ADDRESSMODE | |
  54587. */
  54588. this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  54589. /**
  54590. * | Value | Type | Description |
  54591. * | ----- | ------------------ | ----------- |
  54592. * | 0 | CLAMP_ADDRESSMODE | |
  54593. * | 1 | WRAP_ADDRESSMODE | |
  54594. * | 2 | MIRROR_ADDRESSMODE | |
  54595. */
  54596. this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  54597. /**
  54598. * With compliant hardware and browser (supporting anisotropic filtering)
  54599. * this defines the level of anisotropic filtering in the texture.
  54600. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  54601. */
  54602. this.anisotropicFilteringLevel = BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL;
  54603. /**
  54604. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  54605. * HDR texture are usually stored in linear space.
  54606. * This only impacts the PBR and Background materials
  54607. */
  54608. this.gammaSpace = true;
  54609. /**
  54610. * Is Z inverted in the texture (useful in a cube texture).
  54611. */
  54612. this.invertZ = false;
  54613. /**
  54614. * @hidden
  54615. */
  54616. this.lodLevelInAlpha = false;
  54617. /**
  54618. * Define if the texture is a render target.
  54619. */
  54620. this.isRenderTarget = false;
  54621. /**
  54622. * Define the list of animation attached to the texture.
  54623. */
  54624. this.animations = new Array();
  54625. /**
  54626. * An event triggered when the texture is disposed.
  54627. */
  54628. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  54629. /**
  54630. * Define the current state of the loading sequence when in delayed load mode.
  54631. */
  54632. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  54633. this._cachedSize = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  54634. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  54635. if (this._scene) {
  54636. this.uniqueId = this._scene.getUniqueId();
  54637. this._scene.addTexture(this);
  54638. }
  54639. this._uid = null;
  54640. }
  54641. Object.defineProperty(BaseTexture.prototype, "hasAlpha", {
  54642. get: function () {
  54643. return this._hasAlpha;
  54644. },
  54645. /**
  54646. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  54647. */
  54648. set: function (value) {
  54649. if (this._hasAlpha === value) {
  54650. return;
  54651. }
  54652. this._hasAlpha = value;
  54653. if (this._scene) {
  54654. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag | _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_MiscDirtyFlag);
  54655. }
  54656. },
  54657. enumerable: true,
  54658. configurable: true
  54659. });
  54660. Object.defineProperty(BaseTexture.prototype, "coordinatesMode", {
  54661. get: function () {
  54662. return this._coordinatesMode;
  54663. },
  54664. /**
  54665. * How a texture is mapped.
  54666. *
  54667. * | Value | Type | Description |
  54668. * | ----- | ----------------------------------- | ----------- |
  54669. * | 0 | EXPLICIT_MODE | |
  54670. * | 1 | SPHERICAL_MODE | |
  54671. * | 2 | PLANAR_MODE | |
  54672. * | 3 | CUBIC_MODE | |
  54673. * | 4 | PROJECTION_MODE | |
  54674. * | 5 | SKYBOX_MODE | |
  54675. * | 6 | INVCUBIC_MODE | |
  54676. * | 7 | EQUIRECTANGULAR_MODE | |
  54677. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  54678. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  54679. */
  54680. set: function (value) {
  54681. if (this._coordinatesMode === value) {
  54682. return;
  54683. }
  54684. this._coordinatesMode = value;
  54685. if (this._scene) {
  54686. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  54687. }
  54688. },
  54689. enumerable: true,
  54690. configurable: true
  54691. });
  54692. Object.defineProperty(BaseTexture.prototype, "isCube", {
  54693. /**
  54694. * Define if the texture is a cube texture or if false a 2d texture.
  54695. */
  54696. get: function () {
  54697. if (!this._texture) {
  54698. return false;
  54699. }
  54700. return this._texture.isCube;
  54701. },
  54702. set: function (value) {
  54703. if (!this._texture) {
  54704. return;
  54705. }
  54706. this._texture.isCube = value;
  54707. },
  54708. enumerable: true,
  54709. configurable: true
  54710. });
  54711. Object.defineProperty(BaseTexture.prototype, "is3D", {
  54712. /**
  54713. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  54714. */
  54715. get: function () {
  54716. if (!this._texture) {
  54717. return false;
  54718. }
  54719. return this._texture.is3D;
  54720. },
  54721. set: function (value) {
  54722. if (!this._texture) {
  54723. return;
  54724. }
  54725. this._texture.is3D = value;
  54726. },
  54727. enumerable: true,
  54728. configurable: true
  54729. });
  54730. Object.defineProperty(BaseTexture.prototype, "isRGBD", {
  54731. /**
  54732. * Gets whether or not the texture contains RGBD data.
  54733. */
  54734. get: function () {
  54735. return this._texture != null && this._texture._isRGBD;
  54736. },
  54737. enumerable: true,
  54738. configurable: true
  54739. });
  54740. Object.defineProperty(BaseTexture.prototype, "noMipmap", {
  54741. /**
  54742. * Are mip maps generated for this texture or not.
  54743. */
  54744. get: function () {
  54745. return false;
  54746. },
  54747. enumerable: true,
  54748. configurable: true
  54749. });
  54750. Object.defineProperty(BaseTexture.prototype, "lodGenerationOffset", {
  54751. /**
  54752. * With prefiltered texture, defined the offset used during the prefiltering steps.
  54753. */
  54754. get: function () {
  54755. if (this._texture) {
  54756. return this._texture._lodGenerationOffset;
  54757. }
  54758. return 0.0;
  54759. },
  54760. set: function (value) {
  54761. if (this._texture) {
  54762. this._texture._lodGenerationOffset = value;
  54763. }
  54764. },
  54765. enumerable: true,
  54766. configurable: true
  54767. });
  54768. Object.defineProperty(BaseTexture.prototype, "lodGenerationScale", {
  54769. /**
  54770. * With prefiltered texture, defined the scale used during the prefiltering steps.
  54771. */
  54772. get: function () {
  54773. if (this._texture) {
  54774. return this._texture._lodGenerationScale;
  54775. }
  54776. return 0.0;
  54777. },
  54778. set: function (value) {
  54779. if (this._texture) {
  54780. this._texture._lodGenerationScale = value;
  54781. }
  54782. },
  54783. enumerable: true,
  54784. configurable: true
  54785. });
  54786. Object.defineProperty(BaseTexture.prototype, "uid", {
  54787. /**
  54788. * Define the unique id of the texture in the scene.
  54789. */
  54790. get: function () {
  54791. if (!this._uid) {
  54792. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].RandomId();
  54793. }
  54794. return this._uid;
  54795. },
  54796. enumerable: true,
  54797. configurable: true
  54798. });
  54799. /**
  54800. * Return a string representation of the texture.
  54801. * @returns the texture as a string
  54802. */
  54803. BaseTexture.prototype.toString = function () {
  54804. return this.name;
  54805. };
  54806. /**
  54807. * Get the class name of the texture.
  54808. * @returns "BaseTexture"
  54809. */
  54810. BaseTexture.prototype.getClassName = function () {
  54811. return "BaseTexture";
  54812. };
  54813. Object.defineProperty(BaseTexture.prototype, "onDispose", {
  54814. /**
  54815. * Callback triggered when the texture has been disposed.
  54816. * Kept for back compatibility, you can use the onDisposeObservable instead.
  54817. */
  54818. set: function (callback) {
  54819. if (this._onDisposeObserver) {
  54820. this.onDisposeObservable.remove(this._onDisposeObserver);
  54821. }
  54822. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  54823. },
  54824. enumerable: true,
  54825. configurable: true
  54826. });
  54827. Object.defineProperty(BaseTexture.prototype, "isBlocking", {
  54828. /**
  54829. * Define if the texture is preventinga material to render or not.
  54830. * If not and the texture is not ready, the engine will use a default black texture instead.
  54831. */
  54832. get: function () {
  54833. return true;
  54834. },
  54835. enumerable: true,
  54836. configurable: true
  54837. });
  54838. /**
  54839. * Get the scene the texture belongs to.
  54840. * @returns the scene or null if undefined
  54841. */
  54842. BaseTexture.prototype.getScene = function () {
  54843. return this._scene;
  54844. };
  54845. /**
  54846. * Get the texture transform matrix used to offset tile the texture for istance.
  54847. * @returns the transformation matrix
  54848. */
  54849. BaseTexture.prototype.getTextureMatrix = function () {
  54850. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  54851. };
  54852. /**
  54853. * Get the texture reflection matrix used to rotate/transform the reflection.
  54854. * @returns the reflection matrix
  54855. */
  54856. BaseTexture.prototype.getReflectionTextureMatrix = function () {
  54857. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  54858. };
  54859. /**
  54860. * Get the underlying lower level texture from Babylon.
  54861. * @returns the insternal texture
  54862. */
  54863. BaseTexture.prototype.getInternalTexture = function () {
  54864. return this._texture;
  54865. };
  54866. /**
  54867. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  54868. * @returns true if ready or not blocking
  54869. */
  54870. BaseTexture.prototype.isReadyOrNotBlocking = function () {
  54871. return !this.isBlocking || this.isReady();
  54872. };
  54873. /**
  54874. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  54875. * @returns true if fully ready
  54876. */
  54877. BaseTexture.prototype.isReady = function () {
  54878. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  54879. this.delayLoad();
  54880. return false;
  54881. }
  54882. if (this._texture) {
  54883. return this._texture.isReady;
  54884. }
  54885. return false;
  54886. };
  54887. /**
  54888. * Get the size of the texture.
  54889. * @returns the texture size.
  54890. */
  54891. BaseTexture.prototype.getSize = function () {
  54892. if (this._texture) {
  54893. if (this._texture.width) {
  54894. this._cachedSize.width = this._texture.width;
  54895. this._cachedSize.height = this._texture.height;
  54896. return this._cachedSize;
  54897. }
  54898. if (this._texture._size) {
  54899. this._cachedSize.width = this._texture._size;
  54900. this._cachedSize.height = this._texture._size;
  54901. return this._cachedSize;
  54902. }
  54903. }
  54904. return this._cachedSize;
  54905. };
  54906. /**
  54907. * Get the base size of the texture.
  54908. * It can be different from the size if the texture has been resized for POT for instance
  54909. * @returns the base size
  54910. */
  54911. BaseTexture.prototype.getBaseSize = function () {
  54912. if (!this.isReady() || !this._texture) {
  54913. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  54914. }
  54915. if (this._texture._size) {
  54916. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture._size, this._texture._size);
  54917. }
  54918. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture.baseWidth, this._texture.baseHeight);
  54919. };
  54920. /**
  54921. * Update the sampling mode of the texture.
  54922. * Default is Trilinear mode.
  54923. *
  54924. * | Value | Type | Description |
  54925. * | ----- | ------------------ | ----------- |
  54926. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  54927. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  54928. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  54929. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  54930. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  54931. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  54932. * | 7 | NEAREST_LINEAR | |
  54933. * | 8 | NEAREST_NEAREST | |
  54934. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  54935. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  54936. * | 11 | LINEAR_LINEAR | |
  54937. * | 12 | LINEAR_NEAREST | |
  54938. *
  54939. * > _mag_: magnification filter (close to the viewer)
  54940. * > _min_: minification filter (far from the viewer)
  54941. * > _mip_: filter used between mip map levels
  54942. *@param samplingMode Define the new sampling mode of the texture
  54943. */
  54944. BaseTexture.prototype.updateSamplingMode = function (samplingMode) {
  54945. if (!this._texture) {
  54946. return;
  54947. }
  54948. var scene = this.getScene();
  54949. if (!scene) {
  54950. return;
  54951. }
  54952. scene.getEngine().updateTextureSamplingMode(samplingMode, this._texture);
  54953. };
  54954. /**
  54955. * Scales the texture if is `canRescale()`
  54956. * @param ratio the resize factor we want to use to rescale
  54957. */
  54958. BaseTexture.prototype.scale = function (ratio) {
  54959. };
  54960. Object.defineProperty(BaseTexture.prototype, "canRescale", {
  54961. /**
  54962. * Get if the texture can rescale.
  54963. */
  54964. get: function () {
  54965. return false;
  54966. },
  54967. enumerable: true,
  54968. configurable: true
  54969. });
  54970. /** @hidden */
  54971. BaseTexture.prototype._getFromCache = function (url, noMipmap, sampling) {
  54972. if (!this._scene) {
  54973. return null;
  54974. }
  54975. var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
  54976. for (var index = 0; index < texturesCache.length; index++) {
  54977. var texturesCacheEntry = texturesCache[index];
  54978. if (texturesCacheEntry.url === url && texturesCacheEntry.generateMipMaps === !noMipmap) {
  54979. if (!sampling || sampling === texturesCacheEntry.samplingMode) {
  54980. texturesCacheEntry.incrementReferences();
  54981. return texturesCacheEntry;
  54982. }
  54983. }
  54984. }
  54985. return null;
  54986. };
  54987. /** @hidden */
  54988. BaseTexture.prototype._rebuild = function () {
  54989. };
  54990. /**
  54991. * Triggers the load sequence in delayed load mode.
  54992. */
  54993. BaseTexture.prototype.delayLoad = function () {
  54994. };
  54995. /**
  54996. * Clones the texture.
  54997. * @returns the cloned texture
  54998. */
  54999. BaseTexture.prototype.clone = function () {
  55000. return null;
  55001. };
  55002. Object.defineProperty(BaseTexture.prototype, "textureType", {
  55003. /**
  55004. * Get the texture underlying type (INT, FLOAT...)
  55005. */
  55006. get: function () {
  55007. if (!this._texture) {
  55008. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  55009. }
  55010. return (this._texture.type !== undefined) ? this._texture.type : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  55011. },
  55012. enumerable: true,
  55013. configurable: true
  55014. });
  55015. Object.defineProperty(BaseTexture.prototype, "textureFormat", {
  55016. /**
  55017. * Get the texture underlying format (RGB, RGBA...)
  55018. */
  55019. get: function () {
  55020. if (!this._texture) {
  55021. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  55022. }
  55023. return (this._texture.format !== undefined) ? this._texture.format : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  55024. },
  55025. enumerable: true,
  55026. configurable: true
  55027. });
  55028. /**
  55029. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  55030. * This will returns an RGBA array buffer containing either in values (0-255) or
  55031. * float values (0-1) depending of the underlying buffer type.
  55032. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  55033. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  55034. * @param buffer defines a user defined buffer to fill with data (can be null)
  55035. * @returns The Array buffer containing the pixels data.
  55036. */
  55037. BaseTexture.prototype.readPixels = function (faceIndex, level, buffer) {
  55038. if (faceIndex === void 0) { faceIndex = 0; }
  55039. if (level === void 0) { level = 0; }
  55040. if (buffer === void 0) { buffer = null; }
  55041. if (!this._texture) {
  55042. return null;
  55043. }
  55044. var size = this.getSize();
  55045. var width = size.width;
  55046. var height = size.height;
  55047. var scene = this.getScene();
  55048. if (!scene) {
  55049. return null;
  55050. }
  55051. var engine = scene.getEngine();
  55052. if (level != 0) {
  55053. width = width / Math.pow(2, level);
  55054. height = height / Math.pow(2, level);
  55055. width = Math.round(width);
  55056. height = Math.round(height);
  55057. }
  55058. if (this._texture.isCube) {
  55059. return engine._readTexturePixels(this._texture, width, height, faceIndex, level, buffer);
  55060. }
  55061. return engine._readTexturePixels(this._texture, width, height, -1, level, buffer);
  55062. };
  55063. /**
  55064. * Release and destroy the underlying lower level texture aka internalTexture.
  55065. */
  55066. BaseTexture.prototype.releaseInternalTexture = function () {
  55067. if (this._texture) {
  55068. this._texture.dispose();
  55069. this._texture = null;
  55070. }
  55071. };
  55072. Object.defineProperty(BaseTexture.prototype, "sphericalPolynomial", {
  55073. /**
  55074. * Get the polynomial representation of the texture data.
  55075. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  55076. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  55077. */
  55078. get: function () {
  55079. if (!this._texture || !_Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"] || !this.isReady()) {
  55080. return null;
  55081. }
  55082. if (!this._texture._sphericalPolynomial) {
  55083. this._texture._sphericalPolynomial =
  55084. _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapTextureToSphericalPolynomial(this);
  55085. }
  55086. return this._texture._sphericalPolynomial;
  55087. },
  55088. set: function (value) {
  55089. if (this._texture) {
  55090. this._texture._sphericalPolynomial = value;
  55091. }
  55092. },
  55093. enumerable: true,
  55094. configurable: true
  55095. });
  55096. Object.defineProperty(BaseTexture.prototype, "_lodTextureHigh", {
  55097. /** @hidden */
  55098. get: function () {
  55099. if (this._texture) {
  55100. return this._texture._lodTextureHigh;
  55101. }
  55102. return null;
  55103. },
  55104. enumerable: true,
  55105. configurable: true
  55106. });
  55107. Object.defineProperty(BaseTexture.prototype, "_lodTextureMid", {
  55108. /** @hidden */
  55109. get: function () {
  55110. if (this._texture) {
  55111. return this._texture._lodTextureMid;
  55112. }
  55113. return null;
  55114. },
  55115. enumerable: true,
  55116. configurable: true
  55117. });
  55118. Object.defineProperty(BaseTexture.prototype, "_lodTextureLow", {
  55119. /** @hidden */
  55120. get: function () {
  55121. if (this._texture) {
  55122. return this._texture._lodTextureLow;
  55123. }
  55124. return null;
  55125. },
  55126. enumerable: true,
  55127. configurable: true
  55128. });
  55129. /**
  55130. * Dispose the texture and release its associated resources.
  55131. */
  55132. BaseTexture.prototype.dispose = function () {
  55133. if (!this._scene) {
  55134. return;
  55135. }
  55136. // Animations
  55137. this._scene.stopAnimation(this);
  55138. // Remove from scene
  55139. this._scene._removePendingData(this);
  55140. var index = this._scene.textures.indexOf(this);
  55141. if (index >= 0) {
  55142. this._scene.textures.splice(index, 1);
  55143. }
  55144. this._scene.onTextureRemovedObservable.notifyObservers(this);
  55145. if (this._texture === undefined) {
  55146. return;
  55147. }
  55148. // Release
  55149. this.releaseInternalTexture();
  55150. // Callback
  55151. this.onDisposeObservable.notifyObservers(this);
  55152. this.onDisposeObservable.clear();
  55153. };
  55154. /**
  55155. * Serialize the texture into a JSON representation that can be parsed later on.
  55156. * @returns the JSON representation of the texture
  55157. */
  55158. BaseTexture.prototype.serialize = function () {
  55159. if (!this.name) {
  55160. return null;
  55161. }
  55162. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  55163. // Animations
  55164. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  55165. return serializationObject;
  55166. };
  55167. /**
  55168. * Helper function to be called back once a list of texture contains only ready textures.
  55169. * @param textures Define the list of textures to wait for
  55170. * @param callback Define the callback triggered once the entire list will be ready
  55171. */
  55172. BaseTexture.WhenAllReady = function (textures, callback) {
  55173. var numRemaining = textures.length;
  55174. if (numRemaining === 0) {
  55175. callback();
  55176. return;
  55177. }
  55178. var _loop_1 = function () {
  55179. texture = textures[i];
  55180. if (texture.isReady()) {
  55181. if (--numRemaining === 0) {
  55182. callback();
  55183. }
  55184. }
  55185. else {
  55186. onLoadObservable = texture.onLoadObservable;
  55187. var onLoadCallback_1 = function () {
  55188. onLoadObservable.removeCallback(onLoadCallback_1);
  55189. if (--numRemaining === 0) {
  55190. callback();
  55191. }
  55192. };
  55193. onLoadObservable.add(onLoadCallback_1);
  55194. }
  55195. };
  55196. var texture, onLoadObservable;
  55197. for (var i = 0; i < textures.length; i++) {
  55198. _loop_1();
  55199. }
  55200. };
  55201. /**
  55202. * Default anisotropic filtering level for the application.
  55203. * It is set to 4 as a good tradeoff between perf and quality.
  55204. */
  55205. BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4;
  55206. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55207. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55208. ], BaseTexture.prototype, "uniqueId", void 0);
  55209. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55210. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55211. ], BaseTexture.prototype, "name", void 0);
  55212. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55213. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55214. ], BaseTexture.prototype, "metadata", void 0);
  55215. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55216. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("hasAlpha")
  55217. ], BaseTexture.prototype, "_hasAlpha", void 0);
  55218. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55219. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55220. ], BaseTexture.prototype, "getAlphaFromRGB", void 0);
  55221. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55222. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55223. ], BaseTexture.prototype, "level", void 0);
  55224. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55225. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55226. ], BaseTexture.prototype, "coordinatesIndex", void 0);
  55227. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55228. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("coordinatesMode")
  55229. ], BaseTexture.prototype, "_coordinatesMode", void 0);
  55230. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55231. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55232. ], BaseTexture.prototype, "wrapU", void 0);
  55233. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55234. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55235. ], BaseTexture.prototype, "wrapV", void 0);
  55236. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55237. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55238. ], BaseTexture.prototype, "wrapR", void 0);
  55239. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55240. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55241. ], BaseTexture.prototype, "anisotropicFilteringLevel", void 0);
  55242. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55243. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55244. ], BaseTexture.prototype, "isCube", null);
  55245. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55246. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55247. ], BaseTexture.prototype, "is3D", null);
  55248. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55249. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55250. ], BaseTexture.prototype, "gammaSpace", void 0);
  55251. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55252. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55253. ], BaseTexture.prototype, "invertZ", void 0);
  55254. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55255. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55256. ], BaseTexture.prototype, "lodLevelInAlpha", void 0);
  55257. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55258. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55259. ], BaseTexture.prototype, "lodGenerationOffset", null);
  55260. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55261. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55262. ], BaseTexture.prototype, "lodGenerationScale", null);
  55263. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55264. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55265. ], BaseTexture.prototype, "isRenderTarget", void 0);
  55266. return BaseTexture;
  55267. }());
  55268. /***/ }),
  55269. /***/ "./Materials/Textures/colorGradingTexture.ts":
  55270. /*!***************************************************!*\
  55271. !*** ./Materials/Textures/colorGradingTexture.ts ***!
  55272. \***************************************************/
  55273. /*! exports provided: ColorGradingTexture */
  55274. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55275. "use strict";
  55276. __webpack_require__.r(__webpack_exports__);
  55277. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return ColorGradingTexture; });
  55278. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55279. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55280. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  55281. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55282. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55283. /**
  55284. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55285. * It can help converting any input color in a desired output one. This can then be used to create effects
  55286. * from sepia, black and white to sixties or futuristic rendering...
  55287. *
  55288. * The only supported format is currently 3dl.
  55289. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55290. */
  55291. var ColorGradingTexture = /** @class */ (function (_super) {
  55292. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorGradingTexture, _super);
  55293. /**
  55294. * Instantiates a ColorGradingTexture from the following parameters.
  55295. *
  55296. * @param url The location of the color gradind data (currently only supporting 3dl)
  55297. * @param scene The scene the texture will be used in
  55298. */
  55299. function ColorGradingTexture(url, scene) {
  55300. var _this = _super.call(this, scene) || this;
  55301. if (!url) {
  55302. return _this;
  55303. }
  55304. _this._engine = scene.getEngine();
  55305. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  55306. _this.name = url;
  55307. _this.url = url;
  55308. _this.hasAlpha = false;
  55309. _this.isCube = false;
  55310. _this.is3D = _this._engine.webGLVersion > 1;
  55311. _this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  55312. _this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  55313. _this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  55314. _this.anisotropicFilteringLevel = 1;
  55315. _this._texture = _this._getFromCache(url, true);
  55316. if (!_this._texture) {
  55317. if (!scene.useDelayedTextureLoading) {
  55318. _this.loadTexture();
  55319. }
  55320. else {
  55321. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED;
  55322. }
  55323. }
  55324. return _this;
  55325. }
  55326. /**
  55327. * Returns the texture matrix used in most of the material.
  55328. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55329. */
  55330. ColorGradingTexture.prototype.getTextureMatrix = function () {
  55331. return this._textureMatrix;
  55332. };
  55333. /**
  55334. * Occurs when the file being loaded is a .3dl LUT file.
  55335. */
  55336. ColorGradingTexture.prototype.load3dlTexture = function () {
  55337. var engine = this._engine;
  55338. var texture;
  55339. if (engine.webGLVersion === 1) {
  55340. 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);
  55341. }
  55342. else {
  55343. 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);
  55344. }
  55345. this._texture = texture;
  55346. var callback = function (text) {
  55347. if (typeof text !== "string") {
  55348. return;
  55349. }
  55350. var data = null;
  55351. var tempData = null;
  55352. var line;
  55353. var lines = text.split('\n');
  55354. var size = 0, pixelIndexW = 0, pixelIndexH = 0, pixelIndexSlice = 0;
  55355. var maxColor = 0;
  55356. for (var i = 0; i < lines.length; i++) {
  55357. line = lines[i];
  55358. if (!ColorGradingTexture._noneEmptyLineRegex.test(line)) {
  55359. continue;
  55360. }
  55361. if (line.indexOf('#') === 0) {
  55362. continue;
  55363. }
  55364. var words = line.split(" ");
  55365. if (size === 0) {
  55366. // Number of space + one
  55367. size = words.length;
  55368. data = new Uint8Array(size * size * size * 4); // volume texture of side size and rgb 8
  55369. tempData = new Float32Array(size * size * size * 4);
  55370. continue;
  55371. }
  55372. if (size != 0) {
  55373. var r = Math.max(parseInt(words[0]), 0);
  55374. var g = Math.max(parseInt(words[1]), 0);
  55375. var b = Math.max(parseInt(words[2]), 0);
  55376. maxColor = Math.max(r, maxColor);
  55377. maxColor = Math.max(g, maxColor);
  55378. maxColor = Math.max(b, maxColor);
  55379. var pixelStorageIndex = (pixelIndexW + pixelIndexSlice * size + pixelIndexH * size * size) * 4;
  55380. if (tempData) {
  55381. tempData[pixelStorageIndex + 0] = r;
  55382. tempData[pixelStorageIndex + 1] = g;
  55383. tempData[pixelStorageIndex + 2] = b;
  55384. }
  55385. // Keep for reference in case of back compat problems.
  55386. // pixelIndexSlice++;
  55387. // if (pixelIndexSlice % size == 0) {
  55388. // pixelIndexH++;
  55389. // pixelIndexSlice = 0;
  55390. // if (pixelIndexH % size == 0) {
  55391. // pixelIndexW++;
  55392. // pixelIndexH = 0;
  55393. // }
  55394. // }
  55395. pixelIndexH++;
  55396. if (pixelIndexH % size == 0) {
  55397. pixelIndexSlice++;
  55398. pixelIndexH = 0;
  55399. if (pixelIndexSlice % size == 0) {
  55400. pixelIndexW++;
  55401. pixelIndexSlice = 0;
  55402. }
  55403. }
  55404. }
  55405. }
  55406. if (tempData && data) {
  55407. for (var i = 0; i < tempData.length; i++) {
  55408. if (i > 0 && (i + 1) % 4 === 0) {
  55409. data[i] = 255;
  55410. }
  55411. else {
  55412. var value = tempData[i];
  55413. data[i] = (value / maxColor * 255);
  55414. }
  55415. }
  55416. }
  55417. if (texture.is3D) {
  55418. texture.updateSize(size, size, size);
  55419. engine.updateRawTexture3D(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  55420. }
  55421. else {
  55422. texture.updateSize(size * size, size);
  55423. engine.updateRawTexture(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  55424. }
  55425. };
  55426. var scene = this.getScene();
  55427. if (scene) {
  55428. scene._loadFile(this.url, callback);
  55429. }
  55430. else {
  55431. this._engine._loadFile(this.url, callback);
  55432. }
  55433. return this._texture;
  55434. };
  55435. /**
  55436. * Starts the loading process of the texture.
  55437. */
  55438. ColorGradingTexture.prototype.loadTexture = function () {
  55439. if (this.url && this.url.toLocaleLowerCase().indexOf(".3dl") == (this.url.length - 4)) {
  55440. this.load3dlTexture();
  55441. }
  55442. };
  55443. /**
  55444. * Clones the color gradind texture.
  55445. */
  55446. ColorGradingTexture.prototype.clone = function () {
  55447. var newTexture = new ColorGradingTexture(this.url, this.getScene());
  55448. // Base texture
  55449. newTexture.level = this.level;
  55450. return newTexture;
  55451. };
  55452. /**
  55453. * Called during delayed load for textures.
  55454. */
  55455. ColorGradingTexture.prototype.delayLoad = function () {
  55456. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  55457. return;
  55458. }
  55459. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_LOADED;
  55460. this._texture = this._getFromCache(this.url, true);
  55461. if (!this._texture) {
  55462. this.loadTexture();
  55463. }
  55464. };
  55465. /**
  55466. * Parses a color grading texture serialized by Babylon.
  55467. * @param parsedTexture The texture information being parsedTexture
  55468. * @param scene The scene to load the texture in
  55469. * @param rootUrl The root url of the data assets to load
  55470. * @return A color gradind texture
  55471. */
  55472. ColorGradingTexture.Parse = function (parsedTexture, scene) {
  55473. var texture = null;
  55474. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  55475. texture = new ColorGradingTexture(parsedTexture.name, scene);
  55476. texture.name = parsedTexture.name;
  55477. texture.level = parsedTexture.level;
  55478. }
  55479. return texture;
  55480. };
  55481. /**
  55482. * Serializes the LUT texture to json format.
  55483. */
  55484. ColorGradingTexture.prototype.serialize = function () {
  55485. if (!this.name) {
  55486. return null;
  55487. }
  55488. var serializationObject = {};
  55489. serializationObject.name = this.name;
  55490. serializationObject.level = this.level;
  55491. serializationObject.customType = "BABYLON.ColorGradingTexture";
  55492. return serializationObject;
  55493. };
  55494. /**
  55495. * Empty line regex stored for GC.
  55496. */
  55497. ColorGradingTexture._noneEmptyLineRegex = /\S+/;
  55498. return ColorGradingTexture;
  55499. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__["BaseTexture"]));
  55500. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.ColorGradingTexture"] = ColorGradingTexture;
  55501. /***/ }),
  55502. /***/ "./Materials/Textures/cubeTexture.ts":
  55503. /*!*******************************************!*\
  55504. !*** ./Materials/Textures/cubeTexture.ts ***!
  55505. \*******************************************/
  55506. /*! exports provided: CubeTexture */
  55507. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55508. "use strict";
  55509. __webpack_require__.r(__webpack_exports__);
  55510. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return CubeTexture; });
  55511. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55512. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  55513. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  55514. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55515. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  55516. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55517. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55518. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55519. /**
  55520. * Class for creating a cube texture
  55521. */
  55522. var CubeTexture = /** @class */ (function (_super) {
  55523. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTexture, _super);
  55524. /**
  55525. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  55526. * as prefiltered data.
  55527. * @param rootUrl defines the url of the texture or the root name of the six images
  55528. * @param scene defines the scene the texture is attached to
  55529. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  55530. * @param noMipmap defines if mipmaps should be created or not
  55531. * @param files defines the six files to load for the different faces
  55532. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  55533. * @param onError defines a callback triggered in case of error during load
  55534. * @param format defines the internal format to use for the texture once loaded
  55535. * @param prefiltered defines whether or not the texture is created from prefiltered data
  55536. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  55537. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  55538. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55539. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55540. * @return the cube texture
  55541. */
  55542. function CubeTexture(rootUrl, scene, extensions, noMipmap, files, onLoad, onError, format, prefiltered, forcedExtension, createPolynomials, lodScale, lodOffset) {
  55543. if (extensions === void 0) { extensions = null; }
  55544. if (noMipmap === void 0) { noMipmap = false; }
  55545. if (files === void 0) { files = null; }
  55546. if (onLoad === void 0) { onLoad = null; }
  55547. if (onError === void 0) { onError = null; }
  55548. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  55549. if (prefiltered === void 0) { prefiltered = false; }
  55550. if (forcedExtension === void 0) { forcedExtension = null; }
  55551. if (createPolynomials === void 0) { createPolynomials = false; }
  55552. if (lodScale === void 0) { lodScale = 0.8; }
  55553. if (lodOffset === void 0) { lodOffset = 0; }
  55554. var _this = _super.call(this, scene) || this;
  55555. /**
  55556. * Gets or sets the center of the bounding box associated with the cube texture.
  55557. * It must define where the camera used to render the texture was set
  55558. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  55559. */
  55560. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  55561. _this._rotationY = 0;
  55562. /** @hidden */
  55563. _this._prefiltered = false;
  55564. _this.name = rootUrl;
  55565. _this.url = rootUrl;
  55566. _this._noMipmap = noMipmap;
  55567. _this.hasAlpha = false;
  55568. _this._format = format;
  55569. _this.isCube = true;
  55570. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  55571. _this._createPolynomials = createPolynomials;
  55572. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CUBIC_MODE;
  55573. if (!rootUrl && !files) {
  55574. return _this;
  55575. }
  55576. var lastDot = rootUrl.lastIndexOf(".");
  55577. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  55578. var isDDS = (extension === ".dds");
  55579. var isEnv = (extension === ".env");
  55580. if (isEnv) {
  55581. _this.gammaSpace = false;
  55582. _this._prefiltered = false;
  55583. }
  55584. else {
  55585. _this._prefiltered = prefiltered;
  55586. if (prefiltered) {
  55587. _this.gammaSpace = false;
  55588. }
  55589. }
  55590. _this._texture = _this._getFromCache(rootUrl, noMipmap);
  55591. if (!files) {
  55592. if (!isEnv && !isDDS && !extensions) {
  55593. extensions = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"];
  55594. }
  55595. files = [];
  55596. if (extensions) {
  55597. for (var index = 0; index < extensions.length; index++) {
  55598. files.push(rootUrl + extensions[index]);
  55599. }
  55600. }
  55601. }
  55602. _this._files = files;
  55603. if (!_this._texture) {
  55604. if (!scene.useDelayedTextureLoading) {
  55605. if (prefiltered) {
  55606. _this._texture = scene.getEngine().createPrefilteredCubeTexture(rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, _this._createPolynomials);
  55607. }
  55608. else {
  55609. _this._texture = scene.getEngine().createCubeTexture(rootUrl, scene, files, noMipmap, onLoad, onError, _this._format, forcedExtension, false, lodScale, lodOffset);
  55610. }
  55611. }
  55612. else {
  55613. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  55614. }
  55615. }
  55616. else if (onLoad) {
  55617. if (_this._texture.isReady) {
  55618. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetImmediate(function () { return onLoad(); });
  55619. }
  55620. else {
  55621. _this._texture.onLoadedObservable.add(onLoad);
  55622. }
  55623. }
  55624. return _this;
  55625. }
  55626. Object.defineProperty(CubeTexture.prototype, "boundingBoxSize", {
  55627. /**
  55628. * Returns the bounding box size
  55629. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  55630. */
  55631. get: function () {
  55632. return this._boundingBoxSize;
  55633. },
  55634. /**
  55635. * Gets or sets the size of the bounding box associated with the cube texture
  55636. * When defined, the cubemap will switch to local mode
  55637. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55638. * @example https://www.babylonjs-playground.com/#RNASML
  55639. */
  55640. set: function (value) {
  55641. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  55642. return;
  55643. }
  55644. this._boundingBoxSize = value;
  55645. var scene = this.getScene();
  55646. if (scene) {
  55647. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  55648. }
  55649. },
  55650. enumerable: true,
  55651. configurable: true
  55652. });
  55653. Object.defineProperty(CubeTexture.prototype, "rotationY", {
  55654. /**
  55655. * Gets texture matrix rotation angle around Y axis radians.
  55656. */
  55657. get: function () {
  55658. return this._rotationY;
  55659. },
  55660. /**
  55661. * Sets texture matrix rotation angle around Y axis in radians.
  55662. */
  55663. set: function (value) {
  55664. this._rotationY = value;
  55665. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(this._rotationY));
  55666. },
  55667. enumerable: true,
  55668. configurable: true
  55669. });
  55670. Object.defineProperty(CubeTexture.prototype, "noMipmap", {
  55671. /**
  55672. * Are mip maps generated for this texture or not.
  55673. */
  55674. get: function () {
  55675. return this._noMipmap;
  55676. },
  55677. enumerable: true,
  55678. configurable: true
  55679. });
  55680. /**
  55681. * Creates a cube texture from an array of image urls
  55682. * @param files defines an array of image urls
  55683. * @param scene defines the hosting scene
  55684. * @param noMipmap specifies if mip maps are not used
  55685. * @returns a cube texture
  55686. */
  55687. CubeTexture.CreateFromImages = function (files, scene, noMipmap) {
  55688. var rootUrlKey = "";
  55689. files.forEach(function (url) { return rootUrlKey += url; });
  55690. return new CubeTexture(rootUrlKey, scene, null, noMipmap, files);
  55691. };
  55692. /**
  55693. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  55694. * @param url defines the url of the prefiltered texture
  55695. * @param scene defines the scene the texture is attached to
  55696. * @param forcedExtension defines the extension of the file if different from the url
  55697. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  55698. * @return the prefiltered texture
  55699. */
  55700. CubeTexture.CreateFromPrefilteredData = function (url, scene, forcedExtension, createPolynomials) {
  55701. if (forcedExtension === void 0) { forcedExtension = null; }
  55702. if (createPolynomials === void 0) { createPolynomials = true; }
  55703. return new CubeTexture(url, scene, null, false, null, null, null, undefined, true, forcedExtension, createPolynomials);
  55704. };
  55705. /**
  55706. * Get the current class name of the texture useful for serialization or dynamic coding.
  55707. * @returns "CubeTexture"
  55708. */
  55709. CubeTexture.prototype.getClassName = function () {
  55710. return "CubeTexture";
  55711. };
  55712. /**
  55713. * Update the url (and optional buffer) of this texture if url was null during construction.
  55714. * @param url the url of the texture
  55715. * @param forcedExtension defines the extension to use
  55716. * @param onLoad callback called when the texture is loaded (defaults to null)
  55717. */
  55718. CubeTexture.prototype.updateURL = function (url, forcedExtension, onLoad) {
  55719. if (this.url) {
  55720. this.releaseInternalTexture();
  55721. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  55722. }
  55723. this.url = url;
  55724. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  55725. this._prefiltered = false;
  55726. if (onLoad) {
  55727. this._delayedOnLoad = onLoad;
  55728. }
  55729. this.delayLoad(forcedExtension);
  55730. };
  55731. /**
  55732. * Delays loading of the cube texture
  55733. * @param forcedExtension defines the extension to use
  55734. */
  55735. CubeTexture.prototype.delayLoad = function (forcedExtension) {
  55736. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  55737. return;
  55738. }
  55739. var scene = this.getScene();
  55740. if (!scene) {
  55741. return;
  55742. }
  55743. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  55744. this._texture = this._getFromCache(this.url, this._noMipmap);
  55745. if (!this._texture) {
  55746. if (this._prefiltered) {
  55747. this._texture = scene.getEngine().createPrefilteredCubeTexture(this.url, scene, this.lodGenerationScale, this.lodGenerationOffset, this._delayedOnLoad, undefined, this._format, undefined, this._createPolynomials);
  55748. }
  55749. else {
  55750. this._texture = scene.getEngine().createCubeTexture(this.url, scene, this._files, this._noMipmap, this._delayedOnLoad, undefined, this._format, forcedExtension);
  55751. }
  55752. }
  55753. };
  55754. /**
  55755. * Returns the reflection texture matrix
  55756. * @returns the reflection texture matrix
  55757. */
  55758. CubeTexture.prototype.getReflectionTextureMatrix = function () {
  55759. return this._textureMatrix;
  55760. };
  55761. /**
  55762. * Sets the reflection texture matrix
  55763. * @param value Reflection texture matrix
  55764. */
  55765. CubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  55766. var _this = this;
  55767. if (value.updateFlag === this._textureMatrix.updateFlag) {
  55768. return;
  55769. }
  55770. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  55771. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  55772. }
  55773. this._textureMatrix = value;
  55774. };
  55775. /**
  55776. * Parses text to create a cube texture
  55777. * @param parsedTexture define the serialized text to read from
  55778. * @param scene defines the hosting scene
  55779. * @param rootUrl defines the root url of the cube texture
  55780. * @returns a cube texture
  55781. */
  55782. CubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  55783. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  55784. var prefiltered = false;
  55785. if (parsedTexture.prefiltered) {
  55786. prefiltered = parsedTexture.prefiltered;
  55787. }
  55788. return new CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions, false, null, null, null, undefined, prefiltered);
  55789. }, parsedTexture, scene);
  55790. // Local Cubemaps
  55791. if (parsedTexture.boundingBoxPosition) {
  55792. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  55793. }
  55794. if (parsedTexture.boundingBoxSize) {
  55795. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  55796. }
  55797. // Animations
  55798. if (parsedTexture.animations) {
  55799. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  55800. var parsedAnimation = parsedTexture.animations[animationIndex];
  55801. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  55802. if (internalClass) {
  55803. texture.animations.push(internalClass.Parse(parsedAnimation));
  55804. }
  55805. }
  55806. }
  55807. return texture;
  55808. };
  55809. /**
  55810. * Makes a clone, or deep copy, of the cube texture
  55811. * @returns a new cube texture
  55812. */
  55813. CubeTexture.prototype.clone = function () {
  55814. var _this = this;
  55815. var scene = this.getScene();
  55816. var uniqueId = 0;
  55817. var newCubeTexture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  55818. if (!scene) {
  55819. return _this;
  55820. }
  55821. var cubeTexture = new CubeTexture(_this.url, scene, _this._extensions, _this._noMipmap, _this._files);
  55822. uniqueId = cubeTexture.uniqueId;
  55823. return cubeTexture;
  55824. }, this);
  55825. newCubeTexture.uniqueId = uniqueId;
  55826. return newCubeTexture;
  55827. };
  55828. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55829. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("rotationY")
  55830. ], CubeTexture.prototype, "rotationY", null);
  55831. return CubeTexture;
  55832. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__["BaseTexture"]));
  55833. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"]._CubeTextureParser = CubeTexture.Parse;
  55834. /***/ }),
  55835. /***/ "./Materials/Textures/dynamicTexture.ts":
  55836. /*!**********************************************!*\
  55837. !*** ./Materials/Textures/dynamicTexture.ts ***!
  55838. \**********************************************/
  55839. /*! exports provided: DynamicTexture */
  55840. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55841. "use strict";
  55842. __webpack_require__.r(__webpack_exports__);
  55843. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return DynamicTexture; });
  55844. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55845. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  55846. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55847. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55848. /**
  55849. * A class extending Texture allowing drawing on a texture
  55850. * @see http://doc.babylonjs.com/how_to/dynamictexture
  55851. */
  55852. var DynamicTexture = /** @class */ (function (_super) {
  55853. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DynamicTexture, _super);
  55854. /**
  55855. * Creates a DynamicTexture
  55856. * @param name defines the name of the texture
  55857. * @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
  55858. * @param scene defines the scene where you want the texture
  55859. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  55860. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55861. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  55862. */
  55863. function DynamicTexture(name, options, scene, generateMipMaps, samplingMode, format) {
  55864. if (scene === void 0) { scene = null; }
  55865. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  55866. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA; }
  55867. var _this = _super.call(this, null, scene, !generateMipMaps, undefined, samplingMode, undefined, undefined, undefined, undefined, format) || this;
  55868. _this.name = name;
  55869. _this._engine = _this.getScene().getEngine();
  55870. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  55871. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  55872. _this._generateMipMaps = generateMipMaps;
  55873. if (options.getContext) {
  55874. _this._canvas = options;
  55875. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  55876. }
  55877. else {
  55878. _this._canvas = document.createElement("canvas");
  55879. if (options.width || options.width === 0) {
  55880. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  55881. }
  55882. else {
  55883. _this._texture = _this._engine.createDynamicTexture(options, options, generateMipMaps, samplingMode);
  55884. }
  55885. }
  55886. var textureSize = _this.getSize();
  55887. _this._canvas.width = textureSize.width;
  55888. _this._canvas.height = textureSize.height;
  55889. _this._context = _this._canvas.getContext("2d");
  55890. return _this;
  55891. }
  55892. /**
  55893. * Get the current class name of the texture useful for serialization or dynamic coding.
  55894. * @returns "DynamicTexture"
  55895. */
  55896. DynamicTexture.prototype.getClassName = function () {
  55897. return "DynamicTexture";
  55898. };
  55899. Object.defineProperty(DynamicTexture.prototype, "canRescale", {
  55900. /**
  55901. * Gets the current state of canRescale
  55902. */
  55903. get: function () {
  55904. return true;
  55905. },
  55906. enumerable: true,
  55907. configurable: true
  55908. });
  55909. DynamicTexture.prototype._recreate = function (textureSize) {
  55910. this._canvas.width = textureSize.width;
  55911. this._canvas.height = textureSize.height;
  55912. this.releaseInternalTexture();
  55913. this._texture = this._engine.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);
  55914. };
  55915. /**
  55916. * Scales the texture
  55917. * @param ratio the scale factor to apply to both width and height
  55918. */
  55919. DynamicTexture.prototype.scale = function (ratio) {
  55920. var textureSize = this.getSize();
  55921. textureSize.width *= ratio;
  55922. textureSize.height *= ratio;
  55923. this._recreate(textureSize);
  55924. };
  55925. /**
  55926. * Resizes the texture
  55927. * @param width the new width
  55928. * @param height the new height
  55929. */
  55930. DynamicTexture.prototype.scaleTo = function (width, height) {
  55931. var textureSize = this.getSize();
  55932. textureSize.width = width;
  55933. textureSize.height = height;
  55934. this._recreate(textureSize);
  55935. };
  55936. /**
  55937. * Gets the context of the canvas used by the texture
  55938. * @returns the canvas context of the dynamic texture
  55939. */
  55940. DynamicTexture.prototype.getContext = function () {
  55941. return this._context;
  55942. };
  55943. /**
  55944. * Clears the texture
  55945. */
  55946. DynamicTexture.prototype.clear = function () {
  55947. var size = this.getSize();
  55948. this._context.fillRect(0, 0, size.width, size.height);
  55949. };
  55950. /**
  55951. * Updates the texture
  55952. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  55953. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  55954. */
  55955. DynamicTexture.prototype.update = function (invertY, premulAlpha) {
  55956. if (premulAlpha === void 0) { premulAlpha = false; }
  55957. this._engine.updateDynamicTexture(this._texture, this._canvas, invertY === undefined ? true : invertY, premulAlpha, this._format || undefined);
  55958. };
  55959. /**
  55960. * Draws text onto the texture
  55961. * @param text defines the text to be drawn
  55962. * @param x defines the placement of the text from the left
  55963. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  55964. * @param font defines the font to be used with font-style, font-size, font-name
  55965. * @param color defines the color used for the text
  55966. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  55967. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  55968. * @param update defines whether texture is immediately update (default is true)
  55969. */
  55970. DynamicTexture.prototype.drawText = function (text, x, y, font, color, clearColor, invertY, update) {
  55971. if (update === void 0) { update = true; }
  55972. var size = this.getSize();
  55973. if (clearColor) {
  55974. this._context.fillStyle = clearColor;
  55975. this._context.fillRect(0, 0, size.width, size.height);
  55976. }
  55977. this._context.font = font;
  55978. if (x === null || x === undefined) {
  55979. var textSize = this._context.measureText(text);
  55980. x = (size.width - textSize.width) / 2;
  55981. }
  55982. if (y === null || y === undefined) {
  55983. var fontSize = parseInt((font.replace(/\D/g, '')));
  55984. y = (size.height / 2) + (fontSize / 3.65);
  55985. }
  55986. this._context.fillStyle = color;
  55987. this._context.fillText(text, x, y);
  55988. if (update) {
  55989. this.update(invertY);
  55990. }
  55991. };
  55992. /**
  55993. * Clones the texture
  55994. * @returns the clone of the texture.
  55995. */
  55996. DynamicTexture.prototype.clone = function () {
  55997. var scene = this.getScene();
  55998. if (!scene) {
  55999. return this;
  56000. }
  56001. var textureSize = this.getSize();
  56002. var newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);
  56003. // Base texture
  56004. newTexture.hasAlpha = this.hasAlpha;
  56005. newTexture.level = this.level;
  56006. // Dynamic Texture
  56007. newTexture.wrapU = this.wrapU;
  56008. newTexture.wrapV = this.wrapV;
  56009. return newTexture;
  56010. };
  56011. /**
  56012. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  56013. * @returns a serialized dynamic texture object
  56014. */
  56015. DynamicTexture.prototype.serialize = function () {
  56016. var scene = this.getScene();
  56017. if (scene && !scene.isReady()) {
  56018. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The scene must be ready before serializing the dynamic texture");
  56019. }
  56020. var serializationObject = _super.prototype.serialize.call(this);
  56021. serializationObject.base64String = this._canvas.toDataURL();
  56022. serializationObject.invertY = this._invertY;
  56023. serializationObject.samplingMode = this.samplingMode;
  56024. return serializationObject;
  56025. };
  56026. /** @hidden */
  56027. DynamicTexture.prototype._rebuild = function () {
  56028. this.update();
  56029. };
  56030. return DynamicTexture;
  56031. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]));
  56032. /***/ }),
  56033. /***/ "./Materials/Textures/hdrCubeTexture.ts":
  56034. /*!**********************************************!*\
  56035. !*** ./Materials/Textures/hdrCubeTexture.ts ***!
  56036. \**********************************************/
  56037. /*! exports provided: HDRCubeTexture */
  56038. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56039. "use strict";
  56040. __webpack_require__.r(__webpack_exports__);
  56041. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return HDRCubeTexture; });
  56042. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56043. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  56044. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  56045. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  56046. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56047. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56048. /* harmony import */ var _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/hdr */ "./Misc/HighDynamicRange/hdr.ts");
  56049. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  56050. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  56051. /**
  56052. * This represents a texture coming from an HDR input.
  56053. *
  56054. * The only supported format is currently panorama picture stored in RGBE format.
  56055. * Example of such files can be found on HDRLib: http://hdrlib.com/
  56056. */
  56057. var HDRCubeTexture = /** @class */ (function (_super) {
  56058. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTexture, _super);
  56059. /**
  56060. * Instantiates an HDRTexture from the following parameters.
  56061. *
  56062. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  56063. * @param scene The scene the texture will be used in
  56064. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56065. * @param noMipmap Forces to not generate the mipmap if true
  56066. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  56067. * @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)
  56068. * @param reserved Reserved flag for internal use.
  56069. */
  56070. function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, gammaSpace, reserved, onLoad, onError) {
  56071. if (noMipmap === void 0) { noMipmap = false; }
  56072. if (generateHarmonics === void 0) { generateHarmonics = true; }
  56073. if (gammaSpace === void 0) { gammaSpace = false; }
  56074. if (reserved === void 0) { reserved = false; }
  56075. if (onLoad === void 0) { onLoad = null; }
  56076. if (onError === void 0) { onError = null; }
  56077. var _this = _super.call(this, scene) || this;
  56078. _this._generateHarmonics = true;
  56079. _this._onLoad = null;
  56080. _this._onError = null;
  56081. /**
  56082. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  56083. */
  56084. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  56085. _this._isBlocking = true;
  56086. _this._rotationY = 0;
  56087. /**
  56088. * Gets or sets the center of the bounding box associated with the cube texture
  56089. * It must define where the camera used to render the texture was set
  56090. */
  56091. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  56092. if (!url) {
  56093. return _this;
  56094. }
  56095. _this.name = url;
  56096. _this.url = url;
  56097. _this.hasAlpha = false;
  56098. _this.isCube = true;
  56099. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  56100. _this._onLoad = onLoad;
  56101. _this._onError = onError;
  56102. _this.gammaSpace = gammaSpace;
  56103. _this._noMipmap = noMipmap;
  56104. _this._size = size;
  56105. _this._texture = _this._getFromCache(url, _this._noMipmap);
  56106. if (!_this._texture) {
  56107. if (!scene.useDelayedTextureLoading) {
  56108. _this.loadTexture();
  56109. }
  56110. else {
  56111. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  56112. }
  56113. }
  56114. return _this;
  56115. }
  56116. Object.defineProperty(HDRCubeTexture.prototype, "isBlocking", {
  56117. /**
  56118. * Gets wether or not the texture is blocking during loading.
  56119. */
  56120. get: function () {
  56121. return this._isBlocking;
  56122. },
  56123. /**
  56124. * Sets wether or not the texture is blocking during loading.
  56125. */
  56126. set: function (value) {
  56127. this._isBlocking = value;
  56128. },
  56129. enumerable: true,
  56130. configurable: true
  56131. });
  56132. Object.defineProperty(HDRCubeTexture.prototype, "rotationY", {
  56133. /**
  56134. * Gets texture matrix rotation angle around Y axis radians.
  56135. */
  56136. get: function () {
  56137. return this._rotationY;
  56138. },
  56139. /**
  56140. * Sets texture matrix rotation angle around Y axis in radians.
  56141. */
  56142. set: function (value) {
  56143. this._rotationY = value;
  56144. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationY(this._rotationY));
  56145. },
  56146. enumerable: true,
  56147. configurable: true
  56148. });
  56149. Object.defineProperty(HDRCubeTexture.prototype, "boundingBoxSize", {
  56150. get: function () {
  56151. return this._boundingBoxSize;
  56152. },
  56153. /**
  56154. * Gets or sets the size of the bounding box associated with the cube texture
  56155. * When defined, the cubemap will switch to local mode
  56156. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  56157. * @example https://www.babylonjs-playground.com/#RNASML
  56158. */
  56159. set: function (value) {
  56160. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  56161. return;
  56162. }
  56163. this._boundingBoxSize = value;
  56164. var scene = this.getScene();
  56165. if (scene) {
  56166. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag);
  56167. }
  56168. },
  56169. enumerable: true,
  56170. configurable: true
  56171. });
  56172. /**
  56173. * Get the current class name of the texture useful for serialization or dynamic coding.
  56174. * @returns "HDRCubeTexture"
  56175. */
  56176. HDRCubeTexture.prototype.getClassName = function () {
  56177. return "HDRCubeTexture";
  56178. };
  56179. /**
  56180. * Occurs when the file is raw .hdr file.
  56181. */
  56182. HDRCubeTexture.prototype.loadTexture = function () {
  56183. var _this = this;
  56184. var callback = function (buffer) {
  56185. _this.lodGenerationOffset = 0.0;
  56186. _this.lodGenerationScale = 0.8;
  56187. var scene = _this.getScene();
  56188. if (!scene) {
  56189. return null;
  56190. }
  56191. // Extract the raw linear data.
  56192. var data = _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__["HDRTools"].GetCubeMapTextureData(buffer, _this._size);
  56193. // Generate harmonics if needed.
  56194. if (_this._generateHarmonics) {
  56195. var sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial(data);
  56196. _this.sphericalPolynomial = sphericalPolynomial;
  56197. }
  56198. var results = [];
  56199. var byteArray = null;
  56200. // Push each faces.
  56201. for (var j = 0; j < 6; j++) {
  56202. // Create uintarray fallback.
  56203. if (!scene.getEngine().getCaps().textureFloat) {
  56204. // 3 channels of 1 bytes per pixel in bytes.
  56205. var byteBuffer = new ArrayBuffer(_this._size * _this._size * 3);
  56206. byteArray = new Uint8Array(byteBuffer);
  56207. }
  56208. var dataFace = (data[HDRCubeTexture._facesMapping[j]]);
  56209. // If special cases.
  56210. if (_this.gammaSpace || byteArray) {
  56211. for (var i = 0; i < _this._size * _this._size; i++) {
  56212. // Put in gamma space if requested.
  56213. if (_this.gammaSpace) {
  56214. dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  56215. dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  56216. dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  56217. }
  56218. // Convert to int texture for fallback.
  56219. if (byteArray) {
  56220. var r = Math.max(dataFace[(i * 3) + 0] * 255, 0);
  56221. var g = Math.max(dataFace[(i * 3) + 1] * 255, 0);
  56222. var b = Math.max(dataFace[(i * 3) + 2] * 255, 0);
  56223. // May use luminance instead if the result is not accurate.
  56224. var max = Math.max(Math.max(r, g), b);
  56225. if (max > 255) {
  56226. var scale = 255 / max;
  56227. r *= scale;
  56228. g *= scale;
  56229. b *= scale;
  56230. }
  56231. byteArray[(i * 3) + 0] = r;
  56232. byteArray[(i * 3) + 1] = g;
  56233. byteArray[(i * 3) + 2] = b;
  56234. }
  56235. }
  56236. }
  56237. if (byteArray) {
  56238. results.push(byteArray);
  56239. }
  56240. else {
  56241. results.push(dataFace);
  56242. }
  56243. }
  56244. return results;
  56245. };
  56246. var scene = this.getScene();
  56247. if (scene) {
  56248. 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);
  56249. }
  56250. };
  56251. HDRCubeTexture.prototype.clone = function () {
  56252. var scene = this.getScene();
  56253. if (!scene) {
  56254. return this;
  56255. }
  56256. var newTexture = new HDRCubeTexture(this.url, scene, this._size, this._noMipmap, this._generateHarmonics, this.gammaSpace);
  56257. // Base texture
  56258. newTexture.level = this.level;
  56259. newTexture.wrapU = this.wrapU;
  56260. newTexture.wrapV = this.wrapV;
  56261. newTexture.coordinatesIndex = this.coordinatesIndex;
  56262. newTexture.coordinatesMode = this.coordinatesMode;
  56263. return newTexture;
  56264. };
  56265. // Methods
  56266. HDRCubeTexture.prototype.delayLoad = function () {
  56267. if (this.delayLoadState !== _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED) {
  56268. return;
  56269. }
  56270. this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_LOADED;
  56271. this._texture = this._getFromCache(this.url, this._noMipmap);
  56272. if (!this._texture) {
  56273. this.loadTexture();
  56274. }
  56275. };
  56276. /**
  56277. * Get the texture reflection matrix used to rotate/transform the reflection.
  56278. * @returns the reflection matrix
  56279. */
  56280. HDRCubeTexture.prototype.getReflectionTextureMatrix = function () {
  56281. return this._textureMatrix;
  56282. };
  56283. /**
  56284. * Set the texture reflection matrix used to rotate/transform the reflection.
  56285. * @param value Define the reflection matrix to set
  56286. */
  56287. HDRCubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  56288. var _this = this;
  56289. this._textureMatrix = value;
  56290. if (value.updateFlag === this._textureMatrix.updateFlag) {
  56291. return;
  56292. }
  56293. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  56294. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  56295. }
  56296. };
  56297. /**
  56298. * Parses a JSON representation of an HDR Texture in order to create the texture
  56299. * @param parsedTexture Define the JSON representation
  56300. * @param scene Define the scene the texture should be created in
  56301. * @param rootUrl Define the root url in case we need to load relative dependencies
  56302. * @returns the newly created texture after parsing
  56303. */
  56304. HDRCubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  56305. var texture = null;
  56306. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  56307. texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace);
  56308. texture.name = parsedTexture.name;
  56309. texture.hasAlpha = parsedTexture.hasAlpha;
  56310. texture.level = parsedTexture.level;
  56311. texture.coordinatesMode = parsedTexture.coordinatesMode;
  56312. texture.isBlocking = parsedTexture.isBlocking;
  56313. }
  56314. if (texture) {
  56315. if (parsedTexture.boundingBoxPosition) {
  56316. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  56317. }
  56318. if (parsedTexture.boundingBoxSize) {
  56319. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  56320. }
  56321. if (parsedTexture.rotationY) {
  56322. texture.rotationY = parsedTexture.rotationY;
  56323. }
  56324. }
  56325. return texture;
  56326. };
  56327. HDRCubeTexture.prototype.serialize = function () {
  56328. if (!this.name) {
  56329. return null;
  56330. }
  56331. var serializationObject = {};
  56332. serializationObject.name = this.name;
  56333. serializationObject.hasAlpha = this.hasAlpha;
  56334. serializationObject.isCube = true;
  56335. serializationObject.level = this.level;
  56336. serializationObject.size = this._size;
  56337. serializationObject.coordinatesMode = this.coordinatesMode;
  56338. serializationObject.useInGammaSpace = this.gammaSpace;
  56339. serializationObject.generateHarmonics = this._generateHarmonics;
  56340. serializationObject.customType = "BABYLON.HDRCubeTexture";
  56341. serializationObject.noMipmap = this._noMipmap;
  56342. serializationObject.isBlocking = this._isBlocking;
  56343. serializationObject.rotationY = this._rotationY;
  56344. return serializationObject;
  56345. };
  56346. HDRCubeTexture._facesMapping = [
  56347. "right",
  56348. "left",
  56349. "up",
  56350. "down",
  56351. "front",
  56352. "back"
  56353. ];
  56354. return HDRCubeTexture;
  56355. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  56356. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.HDRCubeTexture"] = HDRCubeTexture;
  56357. /***/ }),
  56358. /***/ "./Materials/Textures/index.ts":
  56359. /*!*************************************!*\
  56360. !*** ./Materials/Textures/index.ts ***!
  56361. \*************************************/
  56362. /*! 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 */
  56363. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56364. "use strict";
  56365. __webpack_require__.r(__webpack_exports__);
  56366. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  56367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _baseTexture__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  56368. /* harmony import */ var _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorGradingTexture */ "./Materials/Textures/colorGradingTexture.ts");
  56369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__["ColorGradingTexture"]; });
  56370. /* harmony import */ var _cubeTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  56371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _cubeTexture__WEBPACK_IMPORTED_MODULE_2__["CubeTexture"]; });
  56372. /* harmony import */ var _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  56373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__["DynamicTexture"]; });
  56374. /* harmony import */ var _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  56375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_4__["HDRCubeTexture"]; });
  56376. /* harmony import */ var _internalTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./internalTexture */ "./Materials/Textures/internalTexture.ts");
  56377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _internalTexture__WEBPACK_IMPORTED_MODULE_5__["InternalTexture"]; });
  56378. /* harmony import */ var _internalTextureTracker__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  56379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _internalTextureTracker__WEBPACK_IMPORTED_MODULE_6__["DummyInternalTextureTracker"]; });
  56380. /* harmony import */ var _Loaders_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Loaders/index */ "./Materials/Textures/Loaders/index.ts");
  56381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_DDSTextureLoader"]; });
  56382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_ENVTextureLoader"]; });
  56383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_KTXTextureLoader"]; });
  56384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_TGATextureLoader"]; });
  56385. /* harmony import */ var _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  56386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__["MirrorTexture"]; });
  56387. /* harmony import */ var _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  56388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__["MultiRenderTarget"]; });
  56389. /* harmony import */ var _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Procedurals/index */ "./Materials/Textures/Procedurals/index.ts");
  56390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTexture"]; });
  56391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["CustomProceduralTexture"]; });
  56392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["NoiseProceduralTexture"]; });
  56393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTextureSceneComponent"]; });
  56394. /* harmony import */ var _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./rawCubeTexture */ "./Materials/Textures/rawCubeTexture.ts");
  56395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__["RawCubeTexture"]; });
  56396. /* harmony import */ var _rawTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./rawTexture */ "./Materials/Textures/rawTexture.ts");
  56397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _rawTexture__WEBPACK_IMPORTED_MODULE_12__["RawTexture"]; });
  56398. /* harmony import */ var _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./rawTexture3D */ "./Materials/Textures/rawTexture3D.ts");
  56399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  56400. /* harmony import */ var _refractionTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./refractionTexture */ "./Materials/Textures/refractionTexture.ts");
  56401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _refractionTexture__WEBPACK_IMPORTED_MODULE_14__["RefractionTexture"]; });
  56402. /* harmony import */ var _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__["RenderTargetTexture"]; });
  56404. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  56405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _texture__WEBPACK_IMPORTED_MODULE_16__["Texture"]; });
  56406. /* harmony import */ var _videoTexture__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./videoTexture */ "./Materials/Textures/videoTexture.ts");
  56407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _videoTexture__WEBPACK_IMPORTED_MODULE_17__["VideoTexture"]; });
  56408. /***/ }),
  56409. /***/ "./Materials/Textures/internalTexture.ts":
  56410. /*!***********************************************!*\
  56411. !*** ./Materials/Textures/internalTexture.ts ***!
  56412. \***********************************************/
  56413. /*! exports provided: InternalTexture */
  56414. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56415. "use strict";
  56416. __webpack_require__.r(__webpack_exports__);
  56417. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return InternalTexture; });
  56418. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  56419. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  56420. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56421. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  56422. /**
  56423. * Class used to store data associated with WebGL texture data for the engine
  56424. * This class should not be used directly
  56425. */
  56426. var InternalTexture = /** @class */ (function () {
  56427. /**
  56428. * Creates a new InternalTexture
  56429. * @param engine defines the engine to use
  56430. * @param dataSource defines the type of data that will be used
  56431. * @param delayAllocation if the texture allocation should be delayed (default: false)
  56432. */
  56433. function InternalTexture(engine, dataSource, delayAllocation) {
  56434. if (delayAllocation === void 0) { delayAllocation = false; }
  56435. /**
  56436. * Observable called when the texture is loaded
  56437. */
  56438. this.onLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  56439. /**
  56440. * Gets or set the previous tracker in the list
  56441. */
  56442. this.previous = null;
  56443. /**
  56444. * Gets or set the next tracker in the list
  56445. */
  56446. this.next = null;
  56447. // Private
  56448. /** @hidden */
  56449. this._invertVScale = false;
  56450. /** @hidden */
  56451. this._initialSlot = -1;
  56452. /** @hidden */
  56453. this._designatedSlot = -1;
  56454. /** @hidden */
  56455. this._dataSource = InternalTexture.DATASOURCE_UNKNOWN;
  56456. /** @hidden */
  56457. this._comparisonFunction = 0;
  56458. /** @hidden */
  56459. this._sphericalPolynomial = null;
  56460. /** @hidden */
  56461. this._lodGenerationScale = 0;
  56462. /** @hidden */
  56463. this._lodGenerationOffset = 0;
  56464. /** @hidden */
  56465. this._isRGBD = false;
  56466. /** @hidden */
  56467. this._references = 1;
  56468. this._engine = engine;
  56469. this._dataSource = dataSource;
  56470. if (!delayAllocation) {
  56471. this._webGLTexture = engine._createTexture();
  56472. }
  56473. }
  56474. /**
  56475. * Gets the Engine the texture belongs to.
  56476. * @returns The babylon engine
  56477. */
  56478. InternalTexture.prototype.getEngine = function () {
  56479. return this._engine;
  56480. };
  56481. Object.defineProperty(InternalTexture.prototype, "dataSource", {
  56482. /**
  56483. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  56484. */
  56485. get: function () {
  56486. return this._dataSource;
  56487. },
  56488. enumerable: true,
  56489. configurable: true
  56490. });
  56491. /**
  56492. * Increments the number of references (ie. the number of Texture that point to it)
  56493. */
  56494. InternalTexture.prototype.incrementReferences = function () {
  56495. this._references++;
  56496. };
  56497. /**
  56498. * Change the size of the texture (not the size of the content)
  56499. * @param width defines the new width
  56500. * @param height defines the new height
  56501. * @param depth defines the new depth (1 by default)
  56502. */
  56503. InternalTexture.prototype.updateSize = function (width, height, depth) {
  56504. if (depth === void 0) { depth = 1; }
  56505. this.width = width;
  56506. this.height = height;
  56507. this.depth = depth;
  56508. this.baseWidth = width;
  56509. this.baseHeight = height;
  56510. this.baseDepth = depth;
  56511. this._size = width * height * depth;
  56512. };
  56513. /** @hidden */
  56514. InternalTexture.prototype._rebuild = function () {
  56515. var _this = this;
  56516. var proxy;
  56517. this.isReady = false;
  56518. this._cachedCoordinatesMode = null;
  56519. this._cachedWrapU = null;
  56520. this._cachedWrapV = null;
  56521. this._cachedAnisotropicFilteringLevel = null;
  56522. switch (this._dataSource) {
  56523. case InternalTexture.DATASOURCE_TEMP:
  56524. return;
  56525. case InternalTexture.DATASOURCE_URL:
  56526. proxy = this._engine.createTexture(this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, function () {
  56527. proxy._swapAndDie(_this);
  56528. _this.isReady = true;
  56529. }, null, this._buffer, undefined, this.format);
  56530. return;
  56531. case InternalTexture.DATASOURCE_RAW:
  56532. proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  56533. proxy._swapAndDie(this);
  56534. this.isReady = true;
  56535. return;
  56536. case InternalTexture.DATASOURCE_RAW3D:
  56537. proxy = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  56538. proxy._swapAndDie(this);
  56539. this.isReady = true;
  56540. return;
  56541. case InternalTexture.DATASOURCE_DYNAMIC:
  56542. proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);
  56543. proxy._swapAndDie(this);
  56544. this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, undefined, undefined, true);
  56545. // The engine will make sure to update content so no need to flag it as isReady = true
  56546. return;
  56547. case InternalTexture.DATASOURCE_RENDERTARGET:
  56548. var options = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__["RenderTargetCreationOptions"]();
  56549. options.generateDepthBuffer = this._generateDepthBuffer;
  56550. options.generateMipMaps = this.generateMipMaps;
  56551. options.generateStencilBuffer = this._generateStencilBuffer;
  56552. options.samplingMode = this.samplingMode;
  56553. options.type = this.type;
  56554. if (this.isCube) {
  56555. proxy = this._engine.createRenderTargetCubeTexture(this.width, options);
  56556. }
  56557. else {
  56558. var size = {
  56559. width: this.width,
  56560. height: this.height
  56561. };
  56562. proxy = this._engine.createRenderTargetTexture(size, options);
  56563. }
  56564. proxy._swapAndDie(this);
  56565. this.isReady = true;
  56566. return;
  56567. case InternalTexture.DATASOURCE_DEPTHTEXTURE:
  56568. var depthTextureOptions = {
  56569. bilinearFiltering: this.samplingMode !== _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  56570. comparisonFunction: this._comparisonFunction,
  56571. generateStencil: this._generateStencilBuffer,
  56572. isCube: this.isCube
  56573. };
  56574. proxy = this._engine.createDepthStencilTexture({ width: this.width, height: this.height }, depthTextureOptions);
  56575. proxy._swapAndDie(this);
  56576. this.isReady = true;
  56577. return;
  56578. case InternalTexture.DATASOURCE_CUBE:
  56579. proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function () {
  56580. proxy._swapAndDie(_this);
  56581. _this.isReady = true;
  56582. }, null, this.format, this._extension);
  56583. return;
  56584. case InternalTexture.DATASOURCE_CUBERAW:
  56585. proxy = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  56586. proxy._swapAndDie(this);
  56587. this.isReady = true;
  56588. return;
  56589. case InternalTexture.DATASOURCE_CUBERAW_RGBD:
  56590. proxy = this._engine.createRawCubeTexture(null, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  56591. InternalTexture._UpdateRGBDAsync(proxy, this._bufferViewArrayArray, this._sphericalPolynomial, this._lodGenerationScale, this._lodGenerationOffset).then(function () {
  56592. proxy._swapAndDie(_this);
  56593. _this.isReady = true;
  56594. });
  56595. return;
  56596. case InternalTexture.DATASOURCE_CUBEPREFILTERED:
  56597. proxy = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, function (proxy) {
  56598. if (proxy) {
  56599. proxy._swapAndDie(_this);
  56600. }
  56601. _this.isReady = true;
  56602. }, null, this.format, this._extension);
  56603. proxy._sphericalPolynomial = this._sphericalPolynomial;
  56604. return;
  56605. }
  56606. };
  56607. /** @hidden */
  56608. InternalTexture.prototype._swapAndDie = function (target) {
  56609. target._webGLTexture = this._webGLTexture;
  56610. if (this._framebuffer) {
  56611. target._framebuffer = this._framebuffer;
  56612. }
  56613. if (this._depthStencilBuffer) {
  56614. target._depthStencilBuffer = this._depthStencilBuffer;
  56615. }
  56616. if (this._lodTextureHigh) {
  56617. if (target._lodTextureHigh) {
  56618. target._lodTextureHigh.dispose();
  56619. }
  56620. target._lodTextureHigh = this._lodTextureHigh;
  56621. }
  56622. if (this._lodTextureMid) {
  56623. if (target._lodTextureMid) {
  56624. target._lodTextureMid.dispose();
  56625. }
  56626. target._lodTextureMid = this._lodTextureMid;
  56627. }
  56628. if (this._lodTextureLow) {
  56629. if (target._lodTextureLow) {
  56630. target._lodTextureLow.dispose();
  56631. }
  56632. target._lodTextureLow = this._lodTextureLow;
  56633. }
  56634. var cache = this._engine.getLoadedTexturesCache();
  56635. var index = cache.indexOf(this);
  56636. if (index !== -1) {
  56637. cache.splice(index, 1);
  56638. }
  56639. };
  56640. /**
  56641. * Dispose the current allocated resources
  56642. */
  56643. InternalTexture.prototype.dispose = function () {
  56644. if (!this._webGLTexture) {
  56645. return;
  56646. }
  56647. this._references--;
  56648. if (this._references === 0) {
  56649. this._engine._releaseTexture(this);
  56650. this._webGLTexture = null;
  56651. this.previous = null;
  56652. this.next = null;
  56653. }
  56654. };
  56655. /** hidden */
  56656. InternalTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  56657. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("environmentTextureTools");
  56658. };
  56659. /**
  56660. * The source of the texture data is unknown
  56661. */
  56662. InternalTexture.DATASOURCE_UNKNOWN = 0;
  56663. /**
  56664. * Texture data comes from an URL
  56665. */
  56666. InternalTexture.DATASOURCE_URL = 1;
  56667. /**
  56668. * Texture data is only used for temporary storage
  56669. */
  56670. InternalTexture.DATASOURCE_TEMP = 2;
  56671. /**
  56672. * Texture data comes from raw data (ArrayBuffer)
  56673. */
  56674. InternalTexture.DATASOURCE_RAW = 3;
  56675. /**
  56676. * Texture content is dynamic (video or dynamic texture)
  56677. */
  56678. InternalTexture.DATASOURCE_DYNAMIC = 4;
  56679. /**
  56680. * Texture content is generated by rendering to it
  56681. */
  56682. InternalTexture.DATASOURCE_RENDERTARGET = 5;
  56683. /**
  56684. * Texture content is part of a multi render target process
  56685. */
  56686. InternalTexture.DATASOURCE_MULTIRENDERTARGET = 6;
  56687. /**
  56688. * Texture data comes from a cube data file
  56689. */
  56690. InternalTexture.DATASOURCE_CUBE = 7;
  56691. /**
  56692. * Texture data comes from a raw cube data
  56693. */
  56694. InternalTexture.DATASOURCE_CUBERAW = 8;
  56695. /**
  56696. * Texture data come from a prefiltered cube data file
  56697. */
  56698. InternalTexture.DATASOURCE_CUBEPREFILTERED = 9;
  56699. /**
  56700. * Texture content is raw 3D data
  56701. */
  56702. InternalTexture.DATASOURCE_RAW3D = 10;
  56703. /**
  56704. * Texture content is a depth texture
  56705. */
  56706. InternalTexture.DATASOURCE_DEPTHTEXTURE = 11;
  56707. /**
  56708. * Texture data comes from a raw cube data encoded with RGBD
  56709. */
  56710. InternalTexture.DATASOURCE_CUBERAW_RGBD = 12;
  56711. return InternalTexture;
  56712. }());
  56713. /***/ }),
  56714. /***/ "./Materials/Textures/internalTextureTracker.ts":
  56715. /*!******************************************************!*\
  56716. !*** ./Materials/Textures/internalTextureTracker.ts ***!
  56717. \******************************************************/
  56718. /*! exports provided: DummyInternalTextureTracker */
  56719. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56720. "use strict";
  56721. __webpack_require__.r(__webpack_exports__);
  56722. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return DummyInternalTextureTracker; });
  56723. /**
  56724. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  56725. */
  56726. var DummyInternalTextureTracker = /** @class */ (function () {
  56727. function DummyInternalTextureTracker() {
  56728. /**
  56729. * Gets or set the previous tracker in the list
  56730. */
  56731. this.previous = null;
  56732. /**
  56733. * Gets or set the next tracker in the list
  56734. */
  56735. this.next = null;
  56736. }
  56737. return DummyInternalTextureTracker;
  56738. }());
  56739. /***/ }),
  56740. /***/ "./Materials/Textures/mirrorTexture.ts":
  56741. /*!*********************************************!*\
  56742. !*** ./Materials/Textures/mirrorTexture.ts ***!
  56743. \*********************************************/
  56744. /*! exports provided: MirrorTexture */
  56745. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56746. "use strict";
  56747. __webpack_require__.r(__webpack_exports__);
  56748. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return MirrorTexture; });
  56749. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56750. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  56751. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56752. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56753. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  56754. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56755. /**
  56756. * Mirror texture can be used to simulate the view from a mirror in a scene.
  56757. * It will dynamically be rendered every frame to adapt to the camera point of view.
  56758. * You can then easily use it as a reflectionTexture on a flat surface.
  56759. * In case the surface is not a plane, please consider relying on reflection probes.
  56760. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  56761. */
  56762. var MirrorTexture = /** @class */ (function (_super) {
  56763. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MirrorTexture, _super);
  56764. /**
  56765. * Instantiates a Mirror Texture.
  56766. * Mirror texture can be used to simulate the view from a mirror in a scene.
  56767. * It will dynamically be rendered every frame to adapt to the camera point of view.
  56768. * You can then easily use it as a reflectionTexture on a flat surface.
  56769. * In case the surface is not a plane, please consider relying on reflection probes.
  56770. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  56771. * @param name
  56772. * @param size
  56773. * @param scene
  56774. * @param generateMipMaps
  56775. * @param type
  56776. * @param samplingMode
  56777. * @param generateDepthBuffer
  56778. */
  56779. function MirrorTexture(name, size, scene, generateMipMaps, type, samplingMode, generateDepthBuffer) {
  56780. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  56781. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  56782. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  56783. var _this = _super.call(this, name, size, scene, generateMipMaps, true, type, false, samplingMode, generateDepthBuffer) || this;
  56784. _this.scene = scene;
  56785. /**
  56786. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  56787. * 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.
  56788. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  56789. */
  56790. _this.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  56791. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  56792. _this._mirrorMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  56793. _this._adaptiveBlurKernel = 0;
  56794. _this._blurKernelX = 0;
  56795. _this._blurKernelY = 0;
  56796. _this._blurRatio = 1.0;
  56797. _this.ignoreCameraViewport = true;
  56798. _this._updateGammaSpace();
  56799. _this._imageProcessingConfigChangeObserver = scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  56800. _this._updateGammaSpace;
  56801. });
  56802. _this.onBeforeRenderObservable.add(function () {
  56803. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ReflectionToRef(_this.mirrorPlane, _this._mirrorMatrix);
  56804. _this._savedViewMatrix = scene.getViewMatrix();
  56805. _this._mirrorMatrix.multiplyToRef(_this._savedViewMatrix, _this._transformMatrix);
  56806. scene.setTransformMatrix(_this._transformMatrix, scene.getProjectionMatrix());
  56807. scene.clipPlane = _this.mirrorPlane;
  56808. scene.getEngine().cullBackFaces = false;
  56809. scene._mirroredCameraPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(scene.activeCamera.globalPosition, _this._mirrorMatrix);
  56810. });
  56811. _this.onAfterRenderObservable.add(function () {
  56812. scene.setTransformMatrix(_this._savedViewMatrix, scene.getProjectionMatrix());
  56813. scene.getEngine().cullBackFaces = true;
  56814. scene._mirroredCameraPosition = null;
  56815. delete scene.clipPlane;
  56816. });
  56817. return _this;
  56818. }
  56819. Object.defineProperty(MirrorTexture.prototype, "blurRatio", {
  56820. get: function () {
  56821. return this._blurRatio;
  56822. },
  56823. /**
  56824. * Define the blur ratio used to blur the reflection if needed.
  56825. */
  56826. set: function (value) {
  56827. if (this._blurRatio === value) {
  56828. return;
  56829. }
  56830. this._blurRatio = value;
  56831. this._preparePostProcesses();
  56832. },
  56833. enumerable: true,
  56834. configurable: true
  56835. });
  56836. Object.defineProperty(MirrorTexture.prototype, "adaptiveBlurKernel", {
  56837. /**
  56838. * Define the adaptive blur kernel used to blur the reflection if needed.
  56839. * This will autocompute the closest best match for the `blurKernel`
  56840. */
  56841. set: function (value) {
  56842. this._adaptiveBlurKernel = value;
  56843. this._autoComputeBlurKernel();
  56844. },
  56845. enumerable: true,
  56846. configurable: true
  56847. });
  56848. Object.defineProperty(MirrorTexture.prototype, "blurKernel", {
  56849. /**
  56850. * Define the blur kernel used to blur the reflection if needed.
  56851. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  56852. */
  56853. set: function (value) {
  56854. this.blurKernelX = value;
  56855. this.blurKernelY = value;
  56856. },
  56857. enumerable: true,
  56858. configurable: true
  56859. });
  56860. Object.defineProperty(MirrorTexture.prototype, "blurKernelX", {
  56861. get: function () {
  56862. return this._blurKernelX;
  56863. },
  56864. /**
  56865. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  56866. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  56867. */
  56868. set: function (value) {
  56869. if (this._blurKernelX === value) {
  56870. return;
  56871. }
  56872. this._blurKernelX = value;
  56873. this._preparePostProcesses();
  56874. },
  56875. enumerable: true,
  56876. configurable: true
  56877. });
  56878. Object.defineProperty(MirrorTexture.prototype, "blurKernelY", {
  56879. get: function () {
  56880. return this._blurKernelY;
  56881. },
  56882. /**
  56883. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  56884. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  56885. */
  56886. set: function (value) {
  56887. if (this._blurKernelY === value) {
  56888. return;
  56889. }
  56890. this._blurKernelY = value;
  56891. this._preparePostProcesses();
  56892. },
  56893. enumerable: true,
  56894. configurable: true
  56895. });
  56896. MirrorTexture.prototype._autoComputeBlurKernel = function () {
  56897. var engine = this.getScene().getEngine();
  56898. var dw = this.getRenderWidth() / engine.getRenderWidth();
  56899. var dh = this.getRenderHeight() / engine.getRenderHeight();
  56900. this.blurKernelX = this._adaptiveBlurKernel * dw;
  56901. this.blurKernelY = this._adaptiveBlurKernel * dh;
  56902. };
  56903. MirrorTexture.prototype._onRatioRescale = function () {
  56904. if (this._sizeRatio) {
  56905. this.resize(this._initialSizeParameter);
  56906. if (!this._adaptiveBlurKernel) {
  56907. this._preparePostProcesses();
  56908. }
  56909. }
  56910. if (this._adaptiveBlurKernel) {
  56911. this._autoComputeBlurKernel();
  56912. }
  56913. };
  56914. MirrorTexture.prototype._updateGammaSpace = function () {
  56915. this.gammaSpace = !this.scene.imageProcessingConfiguration.isEnabled || !this.scene.imageProcessingConfiguration.applyByPostProcess;
  56916. };
  56917. MirrorTexture.prototype._preparePostProcesses = function () {
  56918. this.clearPostProcesses(true);
  56919. if (this._blurKernelX && this._blurKernelY) {
  56920. var engine = this.getScene().getEngine();
  56921. var textureType = engine.getCaps().textureFloatRender ? _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT : _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_HALF_FLOAT;
  56922. 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);
  56923. this._blurX.autoClear = false;
  56924. if (this._blurRatio === 1 && this.samples < 2 && this._texture) {
  56925. this._blurX.inputTexture = this._texture;
  56926. }
  56927. else {
  56928. this._blurX.alwaysForcePOT = true;
  56929. }
  56930. 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);
  56931. this._blurY.autoClear = false;
  56932. this._blurY.alwaysForcePOT = this._blurRatio !== 1;
  56933. this.addPostProcess(this._blurX);
  56934. this.addPostProcess(this._blurY);
  56935. }
  56936. else {
  56937. if (this._blurY) {
  56938. this.removePostProcess(this._blurY);
  56939. this._blurY.dispose();
  56940. this._blurY = null;
  56941. }
  56942. if (this._blurX) {
  56943. this.removePostProcess(this._blurX);
  56944. this._blurX.dispose();
  56945. this._blurX = null;
  56946. }
  56947. }
  56948. };
  56949. /**
  56950. * Clone the mirror texture.
  56951. * @returns the cloned texture
  56952. */
  56953. MirrorTexture.prototype.clone = function () {
  56954. var scene = this.getScene();
  56955. if (!scene) {
  56956. return this;
  56957. }
  56958. var textureSize = this.getSize();
  56959. var newTexture = new MirrorTexture(this.name, textureSize.width, scene, this._renderTargetOptions.generateMipMaps, this._renderTargetOptions.type, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer);
  56960. // Base texture
  56961. newTexture.hasAlpha = this.hasAlpha;
  56962. newTexture.level = this.level;
  56963. // Mirror Texture
  56964. newTexture.mirrorPlane = this.mirrorPlane.clone();
  56965. if (this.renderList) {
  56966. newTexture.renderList = this.renderList.slice(0);
  56967. }
  56968. return newTexture;
  56969. };
  56970. /**
  56971. * Serialize the texture to a JSON representation you could use in Parse later on
  56972. * @returns the serialized JSON representation
  56973. */
  56974. MirrorTexture.prototype.serialize = function () {
  56975. if (!this.name) {
  56976. return null;
  56977. }
  56978. var serializationObject = _super.prototype.serialize.call(this);
  56979. serializationObject.mirrorPlane = this.mirrorPlane.asArray();
  56980. return serializationObject;
  56981. };
  56982. /**
  56983. * Dispose the texture and release its associated resources.
  56984. */
  56985. MirrorTexture.prototype.dispose = function () {
  56986. _super.prototype.dispose.call(this);
  56987. this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver);
  56988. };
  56989. return MirrorTexture;
  56990. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]));
  56991. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  56992. return new MirrorTexture(name, renderTargetSize, scene, generateMipMaps);
  56993. };
  56994. /***/ }),
  56995. /***/ "./Materials/Textures/multiRenderTarget.ts":
  56996. /*!*************************************************!*\
  56997. !*** ./Materials/Textures/multiRenderTarget.ts ***!
  56998. \*************************************************/
  56999. /*! exports provided: MultiRenderTarget */
  57000. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57001. "use strict";
  57002. __webpack_require__.r(__webpack_exports__);
  57003. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return MultiRenderTarget; });
  57004. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57005. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57006. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  57007. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57008. /**
  57009. * A multi render target, like a render target provides the ability to render to a texture.
  57010. * Unlike the render target, it can render to several draw buffers in one draw.
  57011. * This is specially interesting in deferred rendering or for any effects requiring more than
  57012. * just one color from a single pass.
  57013. */
  57014. var MultiRenderTarget = /** @class */ (function (_super) {
  57015. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiRenderTarget, _super);
  57016. /**
  57017. * Instantiate a new multi render target texture.
  57018. * A multi render target, like a render target provides the ability to render to a texture.
  57019. * Unlike the render target, it can render to several draw buffers in one draw.
  57020. * This is specially interesting in deferred rendering or for any effects requiring more than
  57021. * just one color from a single pass.
  57022. * @param name Define the name of the texture
  57023. * @param size Define the size of the buffers to render to
  57024. * @param count Define the number of target we are rendering into
  57025. * @param scene Define the scene the texture belongs to
  57026. * @param options Define the options used to create the multi render target
  57027. */
  57028. function MultiRenderTarget(name, size, count, scene, options) {
  57029. var _this = this;
  57030. var generateMipMaps = options && options.generateMipMaps ? options.generateMipMaps : false;
  57031. var generateDepthTexture = options && options.generateDepthTexture ? options.generateDepthTexture : false;
  57032. var doNotChangeAspectRatio = !options || options.doNotChangeAspectRatio === undefined ? true : options.doNotChangeAspectRatio;
  57033. _this = _super.call(this, name, size, scene, generateMipMaps, doNotChangeAspectRatio) || this;
  57034. _this._engine = scene.getEngine();
  57035. if (!_this.isSupported) {
  57036. _this.dispose();
  57037. return;
  57038. }
  57039. var types = [];
  57040. var samplingModes = [];
  57041. for (var i = 0; i < count; i++) {
  57042. if (options && options.types && options.types[i] !== undefined) {
  57043. types.push(options.types[i]);
  57044. }
  57045. else {
  57046. types.push(options && options.defaultType ? options.defaultType : _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  57047. }
  57048. if (options && options.samplingModes && options.samplingModes[i] !== undefined) {
  57049. samplingModes.push(options.samplingModes[i]);
  57050. }
  57051. else {
  57052. samplingModes.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE);
  57053. }
  57054. }
  57055. var generateDepthBuffer = !options || options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  57056. var generateStencilBuffer = !options || options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  57057. _this._size = size;
  57058. _this._multiRenderTargetOptions = {
  57059. samplingModes: samplingModes,
  57060. generateMipMaps: generateMipMaps,
  57061. generateDepthBuffer: generateDepthBuffer,
  57062. generateStencilBuffer: generateStencilBuffer,
  57063. generateDepthTexture: generateDepthTexture,
  57064. types: types,
  57065. textureCount: count
  57066. };
  57067. _this._createInternalTextures();
  57068. _this._createTextures();
  57069. return _this;
  57070. }
  57071. Object.defineProperty(MultiRenderTarget.prototype, "isSupported", {
  57072. /**
  57073. * Get if draw buffers are currently supported by the used hardware and browser.
  57074. */
  57075. get: function () {
  57076. return this._engine.webGLVersion > 1 || this._engine.getCaps().drawBuffersExtension;
  57077. },
  57078. enumerable: true,
  57079. configurable: true
  57080. });
  57081. Object.defineProperty(MultiRenderTarget.prototype, "textures", {
  57082. /**
  57083. * Get the list of textures generated by the multi render target.
  57084. */
  57085. get: function () {
  57086. return this._textures;
  57087. },
  57088. enumerable: true,
  57089. configurable: true
  57090. });
  57091. Object.defineProperty(MultiRenderTarget.prototype, "depthTexture", {
  57092. /**
  57093. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  57094. */
  57095. get: function () {
  57096. return this._textures[this._textures.length - 1];
  57097. },
  57098. enumerable: true,
  57099. configurable: true
  57100. });
  57101. Object.defineProperty(MultiRenderTarget.prototype, "wrapU", {
  57102. /**
  57103. * Set the wrapping mode on U of all the textures we are rendering to.
  57104. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  57105. */
  57106. set: function (wrap) {
  57107. if (this._textures) {
  57108. for (var i = 0; i < this._textures.length; i++) {
  57109. this._textures[i].wrapU = wrap;
  57110. }
  57111. }
  57112. },
  57113. enumerable: true,
  57114. configurable: true
  57115. });
  57116. Object.defineProperty(MultiRenderTarget.prototype, "wrapV", {
  57117. /**
  57118. * Set the wrapping mode on V of all the textures we are rendering to.
  57119. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  57120. */
  57121. set: function (wrap) {
  57122. if (this._textures) {
  57123. for (var i = 0; i < this._textures.length; i++) {
  57124. this._textures[i].wrapV = wrap;
  57125. }
  57126. }
  57127. },
  57128. enumerable: true,
  57129. configurable: true
  57130. });
  57131. /** @hidden */
  57132. MultiRenderTarget.prototype._rebuild = function () {
  57133. this.releaseInternalTextures();
  57134. this._createInternalTextures();
  57135. for (var i = 0; i < this._internalTextures.length; i++) {
  57136. var texture = this._textures[i];
  57137. texture._texture = this._internalTextures[i];
  57138. }
  57139. // Keeps references to frame buffer and stencil/depth buffer
  57140. this._texture = this._internalTextures[0];
  57141. };
  57142. MultiRenderTarget.prototype._createInternalTextures = function () {
  57143. this._internalTextures = this._engine.createMultipleRenderTarget(this._size, this._multiRenderTargetOptions);
  57144. };
  57145. MultiRenderTarget.prototype._createTextures = function () {
  57146. this._textures = [];
  57147. for (var i = 0; i < this._internalTextures.length; i++) {
  57148. var texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](null, this.getScene());
  57149. texture._texture = this._internalTextures[i];
  57150. this._textures.push(texture);
  57151. }
  57152. // Keeps references to frame buffer and stencil/depth buffer
  57153. this._texture = this._internalTextures[0];
  57154. };
  57155. Object.defineProperty(MultiRenderTarget.prototype, "samples", {
  57156. /**
  57157. * Define the number of samples used if MSAA is enabled.
  57158. */
  57159. get: function () {
  57160. return this._samples;
  57161. },
  57162. set: function (value) {
  57163. if (this._samples === value) {
  57164. return;
  57165. }
  57166. this._samples = this._engine.updateMultipleRenderTargetTextureSampleCount(this._internalTextures, value);
  57167. },
  57168. enumerable: true,
  57169. configurable: true
  57170. });
  57171. /**
  57172. * Resize all the textures in the multi render target.
  57173. * Be carrefull as it will recreate all the data in the new texture.
  57174. * @param size Define the new size
  57175. */
  57176. MultiRenderTarget.prototype.resize = function (size) {
  57177. this.releaseInternalTextures();
  57178. this._internalTextures = this._engine.createMultipleRenderTarget(size, this._multiRenderTargetOptions);
  57179. this._createInternalTextures();
  57180. };
  57181. MultiRenderTarget.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  57182. var _this = this;
  57183. engine.unBindMultiColorAttachmentFramebuffer(this._internalTextures, this.isCube, function () {
  57184. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  57185. });
  57186. };
  57187. /**
  57188. * Dispose the render targets and their associated resources
  57189. */
  57190. MultiRenderTarget.prototype.dispose = function () {
  57191. this.releaseInternalTextures();
  57192. _super.prototype.dispose.call(this);
  57193. };
  57194. /**
  57195. * Release all the underlying texture used as draw buffers.
  57196. */
  57197. MultiRenderTarget.prototype.releaseInternalTextures = function () {
  57198. if (!this._internalTextures) {
  57199. return;
  57200. }
  57201. for (var i = this._internalTextures.length - 1; i >= 0; i--) {
  57202. if (this._internalTextures[i] !== undefined) {
  57203. this._internalTextures[i].dispose();
  57204. this._internalTextures.splice(i, 1);
  57205. }
  57206. }
  57207. };
  57208. return MultiRenderTarget;
  57209. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  57210. /***/ }),
  57211. /***/ "./Materials/Textures/rawCubeTexture.ts":
  57212. /*!**********************************************!*\
  57213. !*** ./Materials/Textures/rawCubeTexture.ts ***!
  57214. \**********************************************/
  57215. /*! exports provided: RawCubeTexture */
  57216. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57217. "use strict";
  57218. __webpack_require__.r(__webpack_exports__);
  57219. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return RawCubeTexture; });
  57220. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57221. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  57222. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  57223. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  57224. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  57225. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57226. /**
  57227. * Raw cube texture where the raw buffers are passed in
  57228. */
  57229. var RawCubeTexture = /** @class */ (function (_super) {
  57230. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawCubeTexture, _super);
  57231. /**
  57232. * Creates a cube texture where the raw buffers are passed in.
  57233. * @param scene defines the scene the texture is attached to
  57234. * @param data defines the array of data to use to create each face
  57235. * @param size defines the size of the textures
  57236. * @param format defines the format of the data
  57237. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  57238. * @param generateMipMaps defines if the engine should generate the mip levels
  57239. * @param invertY defines if data must be stored with Y axis inverted
  57240. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  57241. * @param compression defines the compression used (null by default)
  57242. */
  57243. function RawCubeTexture(scene, data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  57244. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTUREFORMAT_RGBA; }
  57245. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57246. if (generateMipMaps === void 0) { generateMipMaps = false; }
  57247. if (invertY === void 0) { invertY = false; }
  57248. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57249. if (compression === void 0) { compression = null; }
  57250. var _this = _super.call(this, "", scene) || this;
  57251. _this._texture = scene.getEngine().createRawCubeTexture(data, size, format, type, generateMipMaps, invertY, samplingMode, compression);
  57252. return _this;
  57253. }
  57254. /**
  57255. * Updates the raw cube texture.
  57256. * @param data defines the data to store
  57257. * @param format defines the data format
  57258. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57259. * @param invertY defines if data must be stored with Y axis inverted
  57260. * @param compression defines the compression used (null by default)
  57261. * @param level defines which level of the texture to update
  57262. */
  57263. RawCubeTexture.prototype.update = function (data, format, type, invertY, compression) {
  57264. if (compression === void 0) { compression = null; }
  57265. this._texture.getEngine().updateRawCubeTexture(this._texture, data, format, type, invertY, compression);
  57266. };
  57267. /**
  57268. * Updates a raw cube texture with RGBD encoded data.
  57269. * @param data defines the array of data [mipmap][face] to use to create each face
  57270. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  57271. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57272. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57273. * @returns a promsie that resolves when the operation is complete
  57274. */
  57275. RawCubeTexture.prototype.updateRGBDAsync = function (data, sphericalPolynomial, lodScale, lodOffset) {
  57276. if (sphericalPolynomial === void 0) { sphericalPolynomial = null; }
  57277. if (lodScale === void 0) { lodScale = 0.8; }
  57278. if (lodOffset === void 0) { lodOffset = 0; }
  57279. return RawCubeTexture._UpdateRGBDAsync(this._texture, data, sphericalPolynomial, lodScale, lodOffset);
  57280. };
  57281. /**
  57282. * Clones the raw cube texture.
  57283. * @return a new cube texture
  57284. */
  57285. RawCubeTexture.prototype.clone = function () {
  57286. var _this = this;
  57287. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  57288. var scene = _this.getScene();
  57289. var internalTexture = _this._texture;
  57290. var texture = new RawCubeTexture(scene, internalTexture._bufferViewArray, internalTexture.width, internalTexture.format, internalTexture.type, internalTexture.generateMipMaps, internalTexture.invertY, internalTexture.samplingMode, internalTexture._compression);
  57291. if (internalTexture.dataSource === _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD) {
  57292. texture.updateRGBDAsync(internalTexture._bufferViewArrayArray, internalTexture._sphericalPolynomial, internalTexture._lodGenerationScale, internalTexture._lodGenerationOffset);
  57293. }
  57294. return texture;
  57295. }, this);
  57296. };
  57297. /** @hidden */
  57298. RawCubeTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  57299. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  57300. internalTexture._bufferViewArrayArray = data;
  57301. internalTexture._lodGenerationScale = lodScale;
  57302. internalTexture._lodGenerationOffset = lodOffset;
  57303. internalTexture._sphericalPolynomial = sphericalPolynomial;
  57304. return _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__["EnvironmentTextureTools"].UploadLevelsAsync(internalTexture, data).then(function () {
  57305. internalTexture.isReady = true;
  57306. });
  57307. };
  57308. return RawCubeTexture;
  57309. }(_Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__["CubeTexture"]));
  57310. /***/ }),
  57311. /***/ "./Materials/Textures/rawTexture.ts":
  57312. /*!******************************************!*\
  57313. !*** ./Materials/Textures/rawTexture.ts ***!
  57314. \******************************************/
  57315. /*! exports provided: RawTexture */
  57316. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57317. "use strict";
  57318. __webpack_require__.r(__webpack_exports__);
  57319. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return RawTexture; });
  57320. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57321. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57322. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57323. /**
  57324. * Raw texture can help creating a texture directly from an array of data.
  57325. * This can be super useful if you either get the data from an uncompressed source or
  57326. * if you wish to create your texture pixel by pixel.
  57327. */
  57328. var RawTexture = /** @class */ (function (_super) {
  57329. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture, _super);
  57330. /**
  57331. * Instantiates a new RawTexture.
  57332. * Raw texture can help creating a texture directly from an array of data.
  57333. * This can be super useful if you either get the data from an uncompressed source or
  57334. * if you wish to create your texture pixel by pixel.
  57335. * @param data define the array of data to use to create the texture
  57336. * @param width define the width of the texture
  57337. * @param height define the height of the texture
  57338. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  57339. * @param scene define the scene the texture belongs to
  57340. * @param generateMipMaps define whether mip maps should be generated or not
  57341. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57342. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57343. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  57344. */
  57345. function RawTexture(data, width, height,
  57346. /**
  57347. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  57348. */
  57349. format, scene, generateMipMaps, invertY, samplingMode, type) {
  57350. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57351. if (invertY === void 0) { invertY = false; }
  57352. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57353. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57354. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  57355. _this.format = format;
  57356. _this._engine = scene.getEngine();
  57357. _this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type);
  57358. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  57359. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  57360. return _this;
  57361. }
  57362. /**
  57363. * Updates the texture underlying data.
  57364. * @param data Define the new data of the texture
  57365. */
  57366. RawTexture.prototype.update = function (data) {
  57367. this._engine.updateRawTexture(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  57368. };
  57369. /**
  57370. * Creates a luminance texture from some data.
  57371. * @param data Define the texture data
  57372. * @param width Define the width of the texture
  57373. * @param height Define the height of the texture
  57374. * @param scene Define the scene the texture belongs to
  57375. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57376. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57377. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57378. * @returns the luminance texture
  57379. */
  57380. RawTexture.CreateLuminanceTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  57381. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57382. if (invertY === void 0) { invertY = false; }
  57383. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57384. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE, scene, generateMipMaps, invertY, samplingMode);
  57385. };
  57386. /**
  57387. * Creates a luminance alpha texture from some data.
  57388. * @param data Define the texture data
  57389. * @param width Define the width of the texture
  57390. * @param height Define the height of the texture
  57391. * @param scene Define the scene the texture belongs to
  57392. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57393. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57394. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57395. * @returns the luminance alpha texture
  57396. */
  57397. RawTexture.CreateLuminanceAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  57398. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57399. if (invertY === void 0) { invertY = false; }
  57400. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57401. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  57402. };
  57403. /**
  57404. * Creates an alpha texture from some data.
  57405. * @param data Define the texture data
  57406. * @param width Define the width of the texture
  57407. * @param height Define the height of the texture
  57408. * @param scene Define the scene the texture belongs to
  57409. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57410. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57411. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57412. * @returns the alpha texture
  57413. */
  57414. RawTexture.CreateAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  57415. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57416. if (invertY === void 0) { invertY = false; }
  57417. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57418. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  57419. };
  57420. /**
  57421. * Creates a RGB texture from some data.
  57422. * @param data Define the texture data
  57423. * @param width Define the width of the texture
  57424. * @param height Define the height of the texture
  57425. * @param scene Define the scene the texture belongs to
  57426. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57427. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57428. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57429. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  57430. * @returns the RGB alpha texture
  57431. */
  57432. RawTexture.CreateRGBTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  57433. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57434. if (invertY === void 0) { invertY = false; }
  57435. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57436. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57437. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB, scene, generateMipMaps, invertY, samplingMode, type);
  57438. };
  57439. /**
  57440. * Creates a RGBA texture from some data.
  57441. * @param data Define the texture data
  57442. * @param width Define the width of the texture
  57443. * @param height Define the height of the texture
  57444. * @param scene Define the scene the texture belongs to
  57445. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57446. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57447. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57448. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  57449. * @returns the RGBA texture
  57450. */
  57451. RawTexture.CreateRGBATexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  57452. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57453. if (invertY === void 0) { invertY = false; }
  57454. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57455. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57456. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode, type);
  57457. };
  57458. /**
  57459. * Creates a R texture from some data.
  57460. * @param data Define the texture data
  57461. * @param width Define the width of the texture
  57462. * @param height Define the height of the texture
  57463. * @param scene Define the scene the texture belongs to
  57464. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57465. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57466. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57467. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  57468. * @returns the R texture
  57469. */
  57470. RawTexture.CreateRTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  57471. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57472. if (invertY === void 0) { invertY = false; }
  57473. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  57474. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT; }
  57475. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_R, scene, generateMipMaps, invertY, samplingMode, type);
  57476. };
  57477. return RawTexture;
  57478. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  57479. /***/ }),
  57480. /***/ "./Materials/Textures/rawTexture3D.ts":
  57481. /*!********************************************!*\
  57482. !*** ./Materials/Textures/rawTexture3D.ts ***!
  57483. \********************************************/
  57484. /*! exports provided: RawTexture3D */
  57485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57486. "use strict";
  57487. __webpack_require__.r(__webpack_exports__);
  57488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return RawTexture3D; });
  57489. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57490. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57491. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57492. /**
  57493. * Class used to store 3D textures containing user data
  57494. */
  57495. var RawTexture3D = /** @class */ (function (_super) {
  57496. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture3D, _super);
  57497. /**
  57498. * Create a new RawTexture3D
  57499. * @param data defines the data of the texture
  57500. * @param width defines the width of the texture
  57501. * @param height defines the height of the texture
  57502. * @param depth defines the depth of the texture
  57503. * @param format defines the texture format to use
  57504. * @param scene defines the hosting scene
  57505. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57506. * @param invertY defines if texture must be stored with Y axis inverted
  57507. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57508. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57509. */
  57510. function RawTexture3D(data, width, height, depth,
  57511. /** Gets or sets the texture format to use */
  57512. format, scene, generateMipMaps, invertY, samplingMode, textureType) {
  57513. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57514. if (invertY === void 0) { invertY = false; }
  57515. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  57516. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57517. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  57518. _this.format = format;
  57519. _this._engine = scene.getEngine();
  57520. _this._texture = scene.getEngine().createRawTexture3D(data, width, height, depth, format, generateMipMaps, invertY, samplingMode, undefined, textureType);
  57521. _this.is3D = true;
  57522. return _this;
  57523. }
  57524. /**
  57525. * Update the texture with new data
  57526. * @param data defines the data to store in the texture
  57527. */
  57528. RawTexture3D.prototype.update = function (data) {
  57529. if (!this._texture) {
  57530. return;
  57531. }
  57532. this._engine.updateRawTexture3D(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  57533. };
  57534. return RawTexture3D;
  57535. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  57536. /***/ }),
  57537. /***/ "./Materials/Textures/refractionTexture.ts":
  57538. /*!*************************************************!*\
  57539. !*** ./Materials/Textures/refractionTexture.ts ***!
  57540. \*************************************************/
  57541. /*! exports provided: RefractionTexture */
  57542. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57543. "use strict";
  57544. __webpack_require__.r(__webpack_exports__);
  57545. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return RefractionTexture; });
  57546. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57547. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57548. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  57549. /**
  57550. * Creates a refraction texture used by refraction channel of the standard material.
  57551. * It is like a mirror but to see through a material.
  57552. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57553. */
  57554. var RefractionTexture = /** @class */ (function (_super) {
  57555. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionTexture, _super);
  57556. /**
  57557. * Creates a refraction texture used by refraction channel of the standard material.
  57558. * It is like a mirror but to see through a material.
  57559. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57560. * @param name Define the texture name
  57561. * @param size Define the size of the underlying texture
  57562. * @param scene Define the scene the refraction belongs to
  57563. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57564. */
  57565. function RefractionTexture(name, size, scene, generateMipMaps) {
  57566. var _this = _super.call(this, name, size, scene, generateMipMaps, true) || this;
  57567. /**
  57568. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57569. * 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.
  57570. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57571. */
  57572. _this.refractionPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  57573. /**
  57574. * Define how deep under the surface we should see.
  57575. */
  57576. _this.depth = 2.0;
  57577. _this.onBeforeRenderObservable.add(function () {
  57578. scene.clipPlane = _this.refractionPlane;
  57579. });
  57580. _this.onAfterRenderObservable.add(function () {
  57581. delete scene.clipPlane;
  57582. });
  57583. return _this;
  57584. }
  57585. /**
  57586. * Clone the refraction texture.
  57587. * @returns the cloned texture
  57588. */
  57589. RefractionTexture.prototype.clone = function () {
  57590. var scene = this.getScene();
  57591. if (!scene) {
  57592. return this;
  57593. }
  57594. var textureSize = this.getSize();
  57595. var newTexture = new RefractionTexture(this.name, textureSize.width, scene, this._generateMipMaps);
  57596. // Base texture
  57597. newTexture.hasAlpha = this.hasAlpha;
  57598. newTexture.level = this.level;
  57599. // Refraction Texture
  57600. newTexture.refractionPlane = this.refractionPlane.clone();
  57601. if (this.renderList) {
  57602. newTexture.renderList = this.renderList.slice(0);
  57603. }
  57604. newTexture.depth = this.depth;
  57605. return newTexture;
  57606. };
  57607. /**
  57608. * Serialize the texture to a JSON representation you could use in Parse later on
  57609. * @returns the serialized JSON representation
  57610. */
  57611. RefractionTexture.prototype.serialize = function () {
  57612. if (!this.name) {
  57613. return null;
  57614. }
  57615. var serializationObject = _super.prototype.serialize.call(this);
  57616. serializationObject.mirrorPlane = this.refractionPlane.asArray();
  57617. serializationObject.depth = this.depth;
  57618. return serializationObject;
  57619. };
  57620. return RefractionTexture;
  57621. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  57622. /***/ }),
  57623. /***/ "./Materials/Textures/renderTargetCreationOptions.ts":
  57624. /*!***********************************************************!*\
  57625. !*** ./Materials/Textures/renderTargetCreationOptions.ts ***!
  57626. \***********************************************************/
  57627. /*! exports provided: RenderTargetCreationOptions */
  57628. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57629. "use strict";
  57630. __webpack_require__.r(__webpack_exports__);
  57631. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetCreationOptions", function() { return RenderTargetCreationOptions; });
  57632. /**
  57633. * Define options used to create a render target texture
  57634. */
  57635. var RenderTargetCreationOptions = /** @class */ (function () {
  57636. function RenderTargetCreationOptions() {
  57637. }
  57638. return RenderTargetCreationOptions;
  57639. }());
  57640. /***/ }),
  57641. /***/ "./Materials/Textures/renderTargetTexture.ts":
  57642. /*!***************************************************!*\
  57643. !*** ./Materials/Textures/renderTargetTexture.ts ***!
  57644. \***************************************************/
  57645. /*! exports provided: RenderTargetTexture */
  57646. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57647. "use strict";
  57648. __webpack_require__.r(__webpack_exports__);
  57649. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return RenderTargetTexture; });
  57650. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57651. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  57652. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  57653. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57654. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57655. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  57656. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  57657. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57658. /**
  57659. * This Helps creating a texture that will be created from a camera in your scene.
  57660. * It is basically a dynamic texture that could be used to create special effects for instance.
  57661. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  57662. */
  57663. var RenderTargetTexture = /** @class */ (function (_super) {
  57664. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetTexture, _super);
  57665. /**
  57666. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  57667. * or used a shadow, depth texture...
  57668. * @param name The friendly name of the texture
  57669. * @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)
  57670. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  57671. * @param generateMipMaps True if mip maps need to be generated after render.
  57672. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  57673. * @param type The type of the buffer in the RTT (int, half float, float...)
  57674. * @param isCube True if a cube texture needs to be created
  57675. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  57676. * @param generateDepthBuffer True to generate a depth buffer
  57677. * @param generateStencilBuffer True to generate a stencil buffer
  57678. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  57679. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  57680. * @param delayAllocation if the texture allocation should be delayed (default: false)
  57681. */
  57682. function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectRatio, type, isCube, samplingMode, generateDepthBuffer, generateStencilBuffer, isMulti, format, delayAllocation) {
  57683. if (doNotChangeAspectRatio === void 0) { doNotChangeAspectRatio = true; }
  57684. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57685. if (isCube === void 0) { isCube = false; }
  57686. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  57687. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  57688. if (generateStencilBuffer === void 0) { generateStencilBuffer = false; }
  57689. if (isMulti === void 0) { isMulti = false; }
  57690. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA; }
  57691. if (delayAllocation === void 0) { delayAllocation = false; }
  57692. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  57693. _this.isCube = isCube;
  57694. /**
  57695. * Define if particles should be rendered in your texture.
  57696. */
  57697. _this.renderParticles = true;
  57698. /**
  57699. * Define if sprites should be rendered in your texture.
  57700. */
  57701. _this.renderSprites = false;
  57702. /**
  57703. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  57704. */
  57705. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].PROJECTION_MODE;
  57706. /**
  57707. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  57708. */
  57709. _this.ignoreCameraViewport = false;
  57710. /**
  57711. * An event triggered when the texture is unbind.
  57712. */
  57713. _this.onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57714. /**
  57715. * An event triggered when the texture is unbind.
  57716. */
  57717. _this.onAfterUnbindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57718. /**
  57719. * An event triggered before rendering the texture
  57720. */
  57721. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57722. /**
  57723. * An event triggered after rendering the texture
  57724. */
  57725. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57726. /**
  57727. * An event triggered after the texture clear
  57728. */
  57729. _this.onClearObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57730. _this._currentRefreshId = -1;
  57731. _this._refreshRate = 1;
  57732. _this._samples = 1;
  57733. /**
  57734. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  57735. * It must define where the camera used to render the texture is set
  57736. */
  57737. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  57738. scene = _this.getScene();
  57739. if (!scene) {
  57740. return _this;
  57741. }
  57742. _this.renderList = new Array();
  57743. _this._engine = scene.getEngine();
  57744. _this.name = name;
  57745. _this.isRenderTarget = true;
  57746. _this._initialSizeParameter = size;
  57747. _this._processSizeParameter(size);
  57748. _this._resizeObserver = _this.getScene().getEngine().onResizeObservable.add(function () {
  57749. });
  57750. _this._generateMipMaps = generateMipMaps ? true : false;
  57751. _this._doNotChangeAspectRatio = doNotChangeAspectRatio;
  57752. // Rendering groups
  57753. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__["RenderingManager"](scene);
  57754. _this._renderingManager._useSceneAutoClearSetup = true;
  57755. if (isMulti) {
  57756. return _this;
  57757. }
  57758. _this._renderTargetOptions = {
  57759. generateMipMaps: generateMipMaps,
  57760. type: type,
  57761. format: format,
  57762. samplingMode: samplingMode,
  57763. generateDepthBuffer: generateDepthBuffer,
  57764. generateStencilBuffer: generateStencilBuffer
  57765. };
  57766. if (samplingMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].NEAREST_SAMPLINGMODE) {
  57767. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  57768. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  57769. }
  57770. if (!delayAllocation) {
  57771. if (isCube) {
  57772. _this._texture = scene.getEngine().createRenderTargetCubeTexture(_this.getRenderSize(), _this._renderTargetOptions);
  57773. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].INVCUBIC_MODE;
  57774. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  57775. }
  57776. else {
  57777. _this._texture = scene.getEngine().createRenderTargetTexture(_this._size, _this._renderTargetOptions);
  57778. }
  57779. }
  57780. return _this;
  57781. }
  57782. Object.defineProperty(RenderTargetTexture.prototype, "renderList", {
  57783. /**
  57784. * Use this list to define the list of mesh you want to render.
  57785. */
  57786. get: function () {
  57787. return this._renderList;
  57788. },
  57789. set: function (value) {
  57790. this._renderList = value;
  57791. if (this._renderList) {
  57792. this._hookArray(this._renderList);
  57793. }
  57794. },
  57795. enumerable: true,
  57796. configurable: true
  57797. });
  57798. RenderTargetTexture.prototype._hookArray = function (array) {
  57799. var _this = this;
  57800. var oldPush = array.push;
  57801. array.push = function () {
  57802. var items = [];
  57803. for (var _i = 0; _i < arguments.length; _i++) {
  57804. items[_i] = arguments[_i];
  57805. }
  57806. var wasEmpty = array.length === 0;
  57807. var result = oldPush.apply(array, items);
  57808. if (wasEmpty) {
  57809. _this.getScene().meshes.forEach(function (mesh) {
  57810. mesh._markSubMeshesAsLightDirty();
  57811. });
  57812. }
  57813. return result;
  57814. };
  57815. var oldSplice = array.splice;
  57816. array.splice = function (index, deleteCount) {
  57817. var deleted = oldSplice.apply(array, [index, deleteCount]);
  57818. if (array.length === 0) {
  57819. _this.getScene().meshes.forEach(function (mesh) {
  57820. mesh._markSubMeshesAsLightDirty();
  57821. });
  57822. }
  57823. return deleted;
  57824. };
  57825. };
  57826. Object.defineProperty(RenderTargetTexture.prototype, "onAfterUnbind", {
  57827. /**
  57828. * Set a after unbind callback in the texture.
  57829. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  57830. */
  57831. set: function (callback) {
  57832. if (this._onAfterUnbindObserver) {
  57833. this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver);
  57834. }
  57835. this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(callback);
  57836. },
  57837. enumerable: true,
  57838. configurable: true
  57839. });
  57840. Object.defineProperty(RenderTargetTexture.prototype, "onBeforeRender", {
  57841. /**
  57842. * Set a before render callback in the texture.
  57843. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  57844. */
  57845. set: function (callback) {
  57846. if (this._onBeforeRenderObserver) {
  57847. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  57848. }
  57849. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  57850. },
  57851. enumerable: true,
  57852. configurable: true
  57853. });
  57854. Object.defineProperty(RenderTargetTexture.prototype, "onAfterRender", {
  57855. /**
  57856. * Set a after render callback in the texture.
  57857. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  57858. */
  57859. set: function (callback) {
  57860. if (this._onAfterRenderObserver) {
  57861. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  57862. }
  57863. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  57864. },
  57865. enumerable: true,
  57866. configurable: true
  57867. });
  57868. Object.defineProperty(RenderTargetTexture.prototype, "onClear", {
  57869. /**
  57870. * Set a clear callback in the texture.
  57871. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  57872. */
  57873. set: function (callback) {
  57874. if (this._onClearObserver) {
  57875. this.onClearObservable.remove(this._onClearObserver);
  57876. }
  57877. this._onClearObserver = this.onClearObservable.add(callback);
  57878. },
  57879. enumerable: true,
  57880. configurable: true
  57881. });
  57882. Object.defineProperty(RenderTargetTexture.prototype, "renderTargetOptions", {
  57883. /**
  57884. * Gets render target creation options that were used.
  57885. */
  57886. get: function () {
  57887. return this._renderTargetOptions;
  57888. },
  57889. enumerable: true,
  57890. configurable: true
  57891. });
  57892. RenderTargetTexture.prototype._onRatioRescale = function () {
  57893. if (this._sizeRatio) {
  57894. this.resize(this._initialSizeParameter);
  57895. }
  57896. };
  57897. Object.defineProperty(RenderTargetTexture.prototype, "boundingBoxSize", {
  57898. get: function () {
  57899. return this._boundingBoxSize;
  57900. },
  57901. /**
  57902. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  57903. * When defined, the cubemap will switch to local mode
  57904. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57905. * @example https://www.babylonjs-playground.com/#RNASML
  57906. */
  57907. set: function (value) {
  57908. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  57909. return;
  57910. }
  57911. this._boundingBoxSize = value;
  57912. var scene = this.getScene();
  57913. if (scene) {
  57914. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  57915. }
  57916. },
  57917. enumerable: true,
  57918. configurable: true
  57919. });
  57920. /**
  57921. * Creates a depth stencil texture.
  57922. * This is only available in WebGL 2 or with the depth texture extension available.
  57923. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  57924. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  57925. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  57926. */
  57927. RenderTargetTexture.prototype.createDepthStencilTexture = function (comparisonFunction, bilinearFiltering, generateStencil) {
  57928. if (comparisonFunction === void 0) { comparisonFunction = 0; }
  57929. if (bilinearFiltering === void 0) { bilinearFiltering = true; }
  57930. if (generateStencil === void 0) { generateStencil = false; }
  57931. if (!this.getScene()) {
  57932. return;
  57933. }
  57934. var engine = this.getScene().getEngine();
  57935. this.depthStencilTexture = engine.createDepthStencilTexture(this._size, {
  57936. bilinearFiltering: bilinearFiltering,
  57937. comparisonFunction: comparisonFunction,
  57938. generateStencil: generateStencil,
  57939. isCube: this.isCube
  57940. });
  57941. engine.setFrameBufferDepthStencilTexture(this);
  57942. };
  57943. RenderTargetTexture.prototype._processSizeParameter = function (size) {
  57944. if (size.ratio) {
  57945. this._sizeRatio = size.ratio;
  57946. this._size = {
  57947. width: this._bestReflectionRenderTargetDimension(this._engine.getRenderWidth(), this._sizeRatio),
  57948. height: this._bestReflectionRenderTargetDimension(this._engine.getRenderHeight(), this._sizeRatio)
  57949. };
  57950. }
  57951. else {
  57952. this._size = size;
  57953. }
  57954. };
  57955. Object.defineProperty(RenderTargetTexture.prototype, "samples", {
  57956. /**
  57957. * Define the number of samples to use in case of MSAA.
  57958. * It defaults to one meaning no MSAA has been enabled.
  57959. */
  57960. get: function () {
  57961. return this._samples;
  57962. },
  57963. set: function (value) {
  57964. if (this._samples === value) {
  57965. return;
  57966. }
  57967. var scene = this.getScene();
  57968. if (!scene) {
  57969. return;
  57970. }
  57971. this._samples = scene.getEngine().updateRenderTargetTextureSampleCount(this._texture, value);
  57972. },
  57973. enumerable: true,
  57974. configurable: true
  57975. });
  57976. /**
  57977. * Resets the refresh counter of the texture and start bak from scratch.
  57978. * Could be useful to regenerate the texture if it is setup to render only once.
  57979. */
  57980. RenderTargetTexture.prototype.resetRefreshCounter = function () {
  57981. this._currentRefreshId = -1;
  57982. };
  57983. Object.defineProperty(RenderTargetTexture.prototype, "refreshRate", {
  57984. /**
  57985. * Define the refresh rate of the texture or the rendering frequency.
  57986. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  57987. */
  57988. get: function () {
  57989. return this._refreshRate;
  57990. },
  57991. set: function (value) {
  57992. this._refreshRate = value;
  57993. this.resetRefreshCounter();
  57994. },
  57995. enumerable: true,
  57996. configurable: true
  57997. });
  57998. /**
  57999. * Adds a post process to the render target rendering passes.
  58000. * @param postProcess define the post process to add
  58001. */
  58002. RenderTargetTexture.prototype.addPostProcess = function (postProcess) {
  58003. if (!this._postProcessManager) {
  58004. var scene = this.getScene();
  58005. if (!scene) {
  58006. return;
  58007. }
  58008. this._postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__["PostProcessManager"](scene);
  58009. this._postProcesses = new Array();
  58010. }
  58011. this._postProcesses.push(postProcess);
  58012. this._postProcesses[0].autoClear = false;
  58013. };
  58014. /**
  58015. * Clear all the post processes attached to the render target
  58016. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  58017. */
  58018. RenderTargetTexture.prototype.clearPostProcesses = function (dispose) {
  58019. if (dispose === void 0) { dispose = false; }
  58020. if (!this._postProcesses) {
  58021. return;
  58022. }
  58023. if (dispose) {
  58024. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  58025. var postProcess = _a[_i];
  58026. postProcess.dispose();
  58027. }
  58028. }
  58029. this._postProcesses = [];
  58030. };
  58031. /**
  58032. * Remove one of the post process from the list of attached post processes to the texture
  58033. * @param postProcess define the post process to remove from the list
  58034. */
  58035. RenderTargetTexture.prototype.removePostProcess = function (postProcess) {
  58036. if (!this._postProcesses) {
  58037. return;
  58038. }
  58039. var index = this._postProcesses.indexOf(postProcess);
  58040. if (index === -1) {
  58041. return;
  58042. }
  58043. this._postProcesses.splice(index, 1);
  58044. if (this._postProcesses.length > 0) {
  58045. this._postProcesses[0].autoClear = false;
  58046. }
  58047. };
  58048. /** @hidden */
  58049. RenderTargetTexture.prototype._shouldRender = function () {
  58050. if (this._currentRefreshId === -1) { // At least render once
  58051. this._currentRefreshId = 1;
  58052. return true;
  58053. }
  58054. if (this.refreshRate === this._currentRefreshId) {
  58055. this._currentRefreshId = 1;
  58056. return true;
  58057. }
  58058. this._currentRefreshId++;
  58059. return false;
  58060. };
  58061. /**
  58062. * Gets the actual render size of the texture.
  58063. * @returns the width of the render size
  58064. */
  58065. RenderTargetTexture.prototype.getRenderSize = function () {
  58066. return this.getRenderWidth();
  58067. };
  58068. /**
  58069. * Gets the actual render width of the texture.
  58070. * @returns the width of the render size
  58071. */
  58072. RenderTargetTexture.prototype.getRenderWidth = function () {
  58073. if (this._size.width) {
  58074. return this._size.width;
  58075. }
  58076. return this._size;
  58077. };
  58078. /**
  58079. * Gets the actual render height of the texture.
  58080. * @returns the height of the render size
  58081. */
  58082. RenderTargetTexture.prototype.getRenderHeight = function () {
  58083. if (this._size.width) {
  58084. return this._size.height;
  58085. }
  58086. return this._size;
  58087. };
  58088. Object.defineProperty(RenderTargetTexture.prototype, "canRescale", {
  58089. /**
  58090. * Get if the texture can be rescaled or not.
  58091. */
  58092. get: function () {
  58093. return true;
  58094. },
  58095. enumerable: true,
  58096. configurable: true
  58097. });
  58098. /**
  58099. * Resize the texture using a ratio.
  58100. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  58101. */
  58102. RenderTargetTexture.prototype.scale = function (ratio) {
  58103. var newSize = this.getRenderSize() * ratio;
  58104. this.resize(newSize);
  58105. };
  58106. /**
  58107. * Get the texture reflection matrix used to rotate/transform the reflection.
  58108. * @returns the reflection matrix
  58109. */
  58110. RenderTargetTexture.prototype.getReflectionTextureMatrix = function () {
  58111. if (this.isCube) {
  58112. return this._textureMatrix;
  58113. }
  58114. return _super.prototype.getReflectionTextureMatrix.call(this);
  58115. };
  58116. /**
  58117. * Resize the texture to a new desired size.
  58118. * Be carrefull as it will recreate all the data in the new texture.
  58119. * @param size Define the new size. It can be:
  58120. * - a number for squared texture,
  58121. * - an object containing { width: number, height: number }
  58122. * - or an object containing a ratio { ratio: number }
  58123. */
  58124. RenderTargetTexture.prototype.resize = function (size) {
  58125. this.releaseInternalTexture();
  58126. var scene = this.getScene();
  58127. if (!scene) {
  58128. return;
  58129. }
  58130. this._processSizeParameter(size);
  58131. if (this.isCube) {
  58132. this._texture = scene.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions);
  58133. }
  58134. else {
  58135. this._texture = scene.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions);
  58136. }
  58137. };
  58138. /**
  58139. * Renders all the objects from the render list into the texture.
  58140. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  58141. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  58142. */
  58143. RenderTargetTexture.prototype.render = function (useCameraPostProcess, dumpForDebug) {
  58144. if (useCameraPostProcess === void 0) { useCameraPostProcess = false; }
  58145. if (dumpForDebug === void 0) { dumpForDebug = false; }
  58146. var scene = this.getScene();
  58147. if (!scene) {
  58148. return;
  58149. }
  58150. var engine = scene.getEngine();
  58151. if (this.useCameraPostProcesses !== undefined) {
  58152. useCameraPostProcess = this.useCameraPostProcesses;
  58153. }
  58154. if (this._waitingRenderList) {
  58155. this.renderList = [];
  58156. for (var index = 0; index < this._waitingRenderList.length; index++) {
  58157. var id = this._waitingRenderList[index];
  58158. var mesh_1 = scene.getMeshByID(id);
  58159. if (mesh_1) {
  58160. this.renderList.push(mesh_1);
  58161. }
  58162. }
  58163. delete this._waitingRenderList;
  58164. }
  58165. // Is predicate defined?
  58166. if (this.renderListPredicate) {
  58167. if (this.renderList) {
  58168. this.renderList.length = 0; // Clear previous renderList
  58169. }
  58170. else {
  58171. this.renderList = [];
  58172. }
  58173. var scene = this.getScene();
  58174. if (!scene) {
  58175. return;
  58176. }
  58177. var sceneMeshes = scene.meshes;
  58178. for (var index = 0; index < sceneMeshes.length; index++) {
  58179. var mesh = sceneMeshes[index];
  58180. if (this.renderListPredicate(mesh)) {
  58181. this.renderList.push(mesh);
  58182. }
  58183. }
  58184. }
  58185. this.onBeforeBindObservable.notifyObservers(this);
  58186. // Set custom projection.
  58187. // Needs to be before binding to prevent changing the aspect ratio.
  58188. var camera;
  58189. if (this.activeCamera) {
  58190. camera = this.activeCamera;
  58191. engine.setViewport(this.activeCamera.viewport, this.getRenderWidth(), this.getRenderHeight());
  58192. if (this.activeCamera !== scene.activeCamera) {
  58193. scene.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(true));
  58194. }
  58195. }
  58196. else {
  58197. camera = scene.activeCamera;
  58198. if (camera) {
  58199. engine.setViewport(camera.viewport, this.getRenderWidth(), this.getRenderHeight());
  58200. }
  58201. }
  58202. // Prepare renderingManager
  58203. this._renderingManager.reset();
  58204. var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
  58205. var currentRenderListLength = this.renderList ? this.renderList.length : scene.getActiveMeshes().length;
  58206. var sceneRenderId = scene.getRenderId();
  58207. for (var meshIndex = 0; meshIndex < currentRenderListLength; meshIndex++) {
  58208. var mesh = currentRenderList[meshIndex];
  58209. if (mesh) {
  58210. if (!mesh.isReady(this.refreshRate === 0)) {
  58211. this.resetRefreshCounter();
  58212. continue;
  58213. }
  58214. mesh._preActivateForIntermediateRendering(sceneRenderId);
  58215. var isMasked = void 0;
  58216. if (!this.renderList && camera) {
  58217. isMasked = ((mesh.layerMask & camera.layerMask) === 0);
  58218. }
  58219. else {
  58220. isMasked = false;
  58221. }
  58222. if (mesh.isEnabled() && mesh.isVisible && mesh.subMeshes && !isMasked) {
  58223. mesh._activate(sceneRenderId);
  58224. for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  58225. var subMesh = mesh.subMeshes[subIndex];
  58226. scene._activeIndices.addCount(subMesh.indexCount, false);
  58227. this._renderingManager.dispatch(subMesh, mesh);
  58228. }
  58229. }
  58230. }
  58231. }
  58232. for (var particleIndex = 0; particleIndex < scene.particleSystems.length; particleIndex++) {
  58233. var particleSystem = scene.particleSystems[particleIndex];
  58234. var emitter = particleSystem.emitter;
  58235. if (!particleSystem.isStarted() || !emitter || !emitter.position || !emitter.isEnabled()) {
  58236. continue;
  58237. }
  58238. if (currentRenderList.indexOf(emitter) >= 0) {
  58239. this._renderingManager.dispatchParticles(particleSystem);
  58240. }
  58241. }
  58242. if (this.isCube) {
  58243. for (var face = 0; face < 6; face++) {
  58244. this.renderToTarget(face, currentRenderList, useCameraPostProcess, dumpForDebug);
  58245. scene.incrementRenderId();
  58246. scene.resetCachedMaterial();
  58247. }
  58248. }
  58249. else {
  58250. this.renderToTarget(0, currentRenderList, useCameraPostProcess, dumpForDebug);
  58251. }
  58252. this.onAfterUnbindObservable.notifyObservers(this);
  58253. if (scene.activeCamera) {
  58254. if (this.activeCamera && this.activeCamera !== scene.activeCamera) {
  58255. scene.setTransformMatrix(scene.activeCamera.getViewMatrix(), scene.activeCamera.getProjectionMatrix(true));
  58256. }
  58257. engine.setViewport(scene.activeCamera.viewport);
  58258. }
  58259. scene.resetCachedMaterial();
  58260. };
  58261. RenderTargetTexture.prototype._bestReflectionRenderTargetDimension = function (renderDimension, scale) {
  58262. var minimum = 128;
  58263. var x = renderDimension * scale;
  58264. var curved = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].NearestPOT(x + (minimum * minimum / (minimum + x)));
  58265. // Ensure we don't exceed the render dimension (while staying POT)
  58266. return Math.min(_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].FloorPOT(renderDimension), curved);
  58267. };
  58268. RenderTargetTexture.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  58269. var _this = this;
  58270. if (!this._texture) {
  58271. return;
  58272. }
  58273. engine.unBindFramebuffer(this._texture, this.isCube, function () {
  58274. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  58275. });
  58276. };
  58277. RenderTargetTexture.prototype.renderToTarget = function (faceIndex, currentRenderList, useCameraPostProcess, dumpForDebug) {
  58278. var scene = this.getScene();
  58279. if (!scene) {
  58280. return;
  58281. }
  58282. var engine = scene.getEngine();
  58283. if (!this._texture) {
  58284. return;
  58285. }
  58286. // Bind
  58287. if (this._postProcessManager) {
  58288. this._postProcessManager._prepareFrame(this._texture, this._postProcesses);
  58289. }
  58290. else if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
  58291. if (this._texture) {
  58292. engine.bindFramebuffer(this._texture, this.isCube ? faceIndex : undefined, undefined, undefined, this.ignoreCameraViewport, this.depthStencilTexture ? this.depthStencilTexture : undefined);
  58293. }
  58294. }
  58295. this.onBeforeRenderObservable.notifyObservers(faceIndex);
  58296. // Clear
  58297. if (this.onClearObservable.hasObservers()) {
  58298. this.onClearObservable.notifyObservers(engine);
  58299. }
  58300. else {
  58301. engine.clear(this.clearColor || scene.clearColor, true, true, true);
  58302. }
  58303. if (!this._doNotChangeAspectRatio) {
  58304. scene.updateTransformMatrix(true);
  58305. }
  58306. // Before Camera Draw
  58307. for (var _i = 0, _a = scene._beforeRenderTargetDrawStage; _i < _a.length; _i++) {
  58308. var step = _a[_i];
  58309. step.action(this);
  58310. }
  58311. // Render
  58312. this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
  58313. // After Camera Draw
  58314. for (var _b = 0, _c = scene._afterRenderTargetDrawStage; _b < _c.length; _b++) {
  58315. var step = _c[_b];
  58316. step.action(this);
  58317. }
  58318. if (this._postProcessManager) {
  58319. this._postProcessManager._finalizeFrame(false, this._texture, faceIndex, this._postProcesses, this.ignoreCameraViewport);
  58320. }
  58321. else if (useCameraPostProcess) {
  58322. scene.postProcessManager._finalizeFrame(false, this._texture, faceIndex);
  58323. }
  58324. if (!this._doNotChangeAspectRatio) {
  58325. scene.updateTransformMatrix(true);
  58326. }
  58327. // Dump ?
  58328. if (dumpForDebug) {
  58329. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), engine);
  58330. }
  58331. // Unbind
  58332. if (!this.isCube || faceIndex === 5) {
  58333. if (this.isCube) {
  58334. if (faceIndex === 5) {
  58335. engine.generateMipMapsForCubemap(this._texture);
  58336. }
  58337. }
  58338. this.unbindFrameBuffer(engine, faceIndex);
  58339. }
  58340. else {
  58341. this.onAfterRenderObservable.notifyObservers(faceIndex);
  58342. }
  58343. };
  58344. /**
  58345. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  58346. * This allowed control for front to back rendering or reversly depending of the special needs.
  58347. *
  58348. * @param renderingGroupId The rendering group id corresponding to its index
  58349. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  58350. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  58351. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  58352. */
  58353. RenderTargetTexture.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  58354. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  58355. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  58356. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  58357. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  58358. };
  58359. /**
  58360. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  58361. *
  58362. * @param renderingGroupId The rendering group id corresponding to its index
  58363. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58364. */
  58365. RenderTargetTexture.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  58366. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  58367. this._renderingManager._useSceneAutoClearSetup = false;
  58368. };
  58369. /**
  58370. * Clones the texture.
  58371. * @returns the cloned texture
  58372. */
  58373. RenderTargetTexture.prototype.clone = function () {
  58374. var textureSize = this.getSize();
  58375. 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);
  58376. // Base texture
  58377. newTexture.hasAlpha = this.hasAlpha;
  58378. newTexture.level = this.level;
  58379. // RenderTarget Texture
  58380. newTexture.coordinatesMode = this.coordinatesMode;
  58381. if (this.renderList) {
  58382. newTexture.renderList = this.renderList.slice(0);
  58383. }
  58384. return newTexture;
  58385. };
  58386. /**
  58387. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  58388. * @returns The JSON representation of the texture
  58389. */
  58390. RenderTargetTexture.prototype.serialize = function () {
  58391. if (!this.name) {
  58392. return null;
  58393. }
  58394. var serializationObject = _super.prototype.serialize.call(this);
  58395. serializationObject.renderTargetSize = this.getRenderSize();
  58396. serializationObject.renderList = [];
  58397. if (this.renderList) {
  58398. for (var index = 0; index < this.renderList.length; index++) {
  58399. serializationObject.renderList.push(this.renderList[index].id);
  58400. }
  58401. }
  58402. return serializationObject;
  58403. };
  58404. /**
  58405. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  58406. */
  58407. RenderTargetTexture.prototype.disposeFramebufferObjects = function () {
  58408. var objBuffer = this.getInternalTexture();
  58409. var scene = this.getScene();
  58410. if (objBuffer && scene) {
  58411. scene.getEngine()._releaseFramebufferObjects(objBuffer);
  58412. }
  58413. };
  58414. /**
  58415. * Dispose the texture and release its associated resources.
  58416. */
  58417. RenderTargetTexture.prototype.dispose = function () {
  58418. if (this._postProcessManager) {
  58419. this._postProcessManager.dispose();
  58420. this._postProcessManager = null;
  58421. }
  58422. this.clearPostProcesses(true);
  58423. if (this._resizeObserver) {
  58424. this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver);
  58425. this._resizeObserver = null;
  58426. }
  58427. this.renderList = null;
  58428. // Remove from custom render targets
  58429. var scene = this.getScene();
  58430. if (!scene) {
  58431. return;
  58432. }
  58433. var index = scene.customRenderTargets.indexOf(this);
  58434. if (index >= 0) {
  58435. scene.customRenderTargets.splice(index, 1);
  58436. }
  58437. for (var _i = 0, _a = scene.cameras; _i < _a.length; _i++) {
  58438. var camera = _a[_i];
  58439. index = camera.customRenderTargets.indexOf(this);
  58440. if (index >= 0) {
  58441. camera.customRenderTargets.splice(index, 1);
  58442. }
  58443. }
  58444. _super.prototype.dispose.call(this);
  58445. };
  58446. /** @hidden */
  58447. RenderTargetTexture.prototype._rebuild = function () {
  58448. if (this.refreshRate === RenderTargetTexture.REFRESHRATE_RENDER_ONCE) {
  58449. this.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;
  58450. }
  58451. if (this._postProcessManager) {
  58452. this._postProcessManager._rebuild();
  58453. }
  58454. };
  58455. /**
  58456. * Clear the info related to rendering groups preventing retention point in material dispose.
  58457. */
  58458. RenderTargetTexture.prototype.freeRenderingGroups = function () {
  58459. if (this._renderingManager) {
  58460. this._renderingManager.freeRenderingGroups();
  58461. }
  58462. };
  58463. /**
  58464. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  58465. */
  58466. RenderTargetTexture.REFRESHRATE_RENDER_ONCE = 0;
  58467. /**
  58468. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  58469. */
  58470. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME = 1;
  58471. /**
  58472. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  58473. * the central point of your effect and can save a lot of performances.
  58474. */
  58475. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2;
  58476. return RenderTargetTexture;
  58477. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  58478. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  58479. return new RenderTargetTexture(name, renderTargetSize, scene, generateMipMaps);
  58480. };
  58481. /***/ }),
  58482. /***/ "./Materials/Textures/texture.ts":
  58483. /*!***************************************!*\
  58484. !*** ./Materials/Textures/texture.ts ***!
  58485. \***************************************/
  58486. /*! exports provided: Texture */
  58487. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58488. "use strict";
  58489. __webpack_require__.r(__webpack_exports__);
  58490. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return Texture; });
  58491. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58492. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  58493. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  58494. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  58495. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  58496. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  58497. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58498. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  58499. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  58500. /**
  58501. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  58502. * @see http://doc.babylonjs.com/babylon101/materials#texture
  58503. */
  58504. var Texture = /** @class */ (function (_super) {
  58505. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Texture, _super);
  58506. /**
  58507. * Instantiates a new texture.
  58508. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  58509. * @see http://doc.babylonjs.com/babylon101/materials#texture
  58510. * @param url define the url of the picture to load as a texture
  58511. * @param scene define the scene the texture will belong to
  58512. * @param noMipmap define if the texture will require mip maps or not
  58513. * @param invertY define if the texture needs to be inverted on the y axis during loading
  58514. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  58515. * @param onLoad define a callback triggered when the texture has been loaded
  58516. * @param onError define a callback triggered when an error occurred during the loading session
  58517. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  58518. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  58519. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  58520. */
  58521. function Texture(url, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format) {
  58522. if (noMipmap === void 0) { noMipmap = false; }
  58523. if (invertY === void 0) { invertY = true; }
  58524. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  58525. if (onLoad === void 0) { onLoad = null; }
  58526. if (onError === void 0) { onError = null; }
  58527. if (buffer === void 0) { buffer = null; }
  58528. if (deleteBuffer === void 0) { deleteBuffer = false; }
  58529. var _this = _super.call(this, scene) || this;
  58530. /**
  58531. * Define an offset on the texture to offset the u coordinates of the UVs
  58532. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  58533. */
  58534. _this.uOffset = 0;
  58535. /**
  58536. * Define an offset on the texture to offset the v coordinates of the UVs
  58537. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  58538. */
  58539. _this.vOffset = 0;
  58540. /**
  58541. * Define an offset on the texture to scale the u coordinates of the UVs
  58542. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  58543. */
  58544. _this.uScale = 1.0;
  58545. /**
  58546. * Define an offset on the texture to scale the v coordinates of the UVs
  58547. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  58548. */
  58549. _this.vScale = 1.0;
  58550. /**
  58551. * Define an offset on the texture to rotate around the u coordinates of the UVs
  58552. * @see http://doc.babylonjs.com/how_to/more_materials
  58553. */
  58554. _this.uAng = 0;
  58555. /**
  58556. * Define an offset on the texture to rotate around the v coordinates of the UVs
  58557. * @see http://doc.babylonjs.com/how_to/more_materials
  58558. */
  58559. _this.vAng = 0;
  58560. /**
  58561. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  58562. * @see http://doc.babylonjs.com/how_to/more_materials
  58563. */
  58564. _this.wAng = 0;
  58565. /**
  58566. * Defines the center of rotation (U)
  58567. */
  58568. _this.uRotationCenter = 0.5;
  58569. /**
  58570. * Defines the center of rotation (V)
  58571. */
  58572. _this.vRotationCenter = 0.5;
  58573. /**
  58574. * Defines the center of rotation (W)
  58575. */
  58576. _this.wRotationCenter = 0.5;
  58577. /** @hidden */
  58578. _this._initialSamplingMode = Texture.BILINEAR_SAMPLINGMODE;
  58579. /**
  58580. * Observable triggered once the texture has been loaded.
  58581. */
  58582. _this.onLoadObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  58583. _this._isBlocking = true;
  58584. _this.name = url || "";
  58585. _this.url = url;
  58586. _this._noMipmap = noMipmap;
  58587. _this._invertY = invertY;
  58588. _this._initialSamplingMode = samplingMode;
  58589. _this._buffer = buffer;
  58590. _this._deleteBuffer = deleteBuffer;
  58591. if (format) {
  58592. _this._format = format;
  58593. }
  58594. scene = _this.getScene();
  58595. if (!scene) {
  58596. return _this;
  58597. }
  58598. scene.getEngine().onBeforeTextureInitObservable.notifyObservers(_this);
  58599. var load = function () {
  58600. if (_this._texture && _this._texture._invertVScale) {
  58601. _this.vScale = -1;
  58602. }
  58603. if (_this.onLoadObservable.hasObservers()) {
  58604. _this.onLoadObservable.notifyObservers(_this);
  58605. }
  58606. if (onLoad) {
  58607. onLoad();
  58608. }
  58609. if (!_this.isBlocking && scene) {
  58610. scene.resetCachedMaterial();
  58611. }
  58612. };
  58613. if (!_this.url) {
  58614. _this._delayedOnLoad = load;
  58615. _this._delayedOnError = onError;
  58616. return _this;
  58617. }
  58618. _this._texture = _this._getFromCache(_this.url, noMipmap, samplingMode);
  58619. if (!_this._texture) {
  58620. if (!scene.useDelayedTextureLoading) {
  58621. _this._texture = scene.getEngine().createTexture(_this.url, noMipmap, invertY, scene, samplingMode, load, onError, _this._buffer, undefined, _this._format);
  58622. if (deleteBuffer) {
  58623. delete _this._buffer;
  58624. }
  58625. }
  58626. else {
  58627. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  58628. _this._delayedOnLoad = load;
  58629. _this._delayedOnError = onError;
  58630. }
  58631. }
  58632. else {
  58633. if (_this._texture.isReady) {
  58634. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(function () { return load(); });
  58635. }
  58636. else {
  58637. _this._texture.onLoadedObservable.add(load);
  58638. }
  58639. }
  58640. return _this;
  58641. }
  58642. Object.defineProperty(Texture.prototype, "noMipmap", {
  58643. /**
  58644. * Are mip maps generated for this texture or not.
  58645. */
  58646. get: function () {
  58647. return this._noMipmap;
  58648. },
  58649. enumerable: true,
  58650. configurable: true
  58651. });
  58652. Object.defineProperty(Texture.prototype, "isBlocking", {
  58653. get: function () {
  58654. return this._isBlocking;
  58655. },
  58656. /**
  58657. * Is the texture preventing material to render while loading.
  58658. * If false, a default texture will be used instead of the loading one during the preparation step.
  58659. */
  58660. set: function (value) {
  58661. this._isBlocking = value;
  58662. },
  58663. enumerable: true,
  58664. configurable: true
  58665. });
  58666. Object.defineProperty(Texture.prototype, "samplingMode", {
  58667. /**
  58668. * Get the current sampling mode associated with the texture.
  58669. */
  58670. get: function () {
  58671. if (!this._texture) {
  58672. return this._initialSamplingMode;
  58673. }
  58674. return this._texture.samplingMode;
  58675. },
  58676. enumerable: true,
  58677. configurable: true
  58678. });
  58679. Object.defineProperty(Texture.prototype, "invertY", {
  58680. /**
  58681. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  58682. */
  58683. get: function () {
  58684. return this._invertY;
  58685. },
  58686. enumerable: true,
  58687. configurable: true
  58688. });
  58689. /**
  58690. * Update the url (and optional buffer) of this texture if url was null during construction.
  58691. * @param url the url of the texture
  58692. * @param buffer the buffer of the texture (defaults to null)
  58693. * @param onLoad callback called when the texture is loaded (defaults to null)
  58694. */
  58695. Texture.prototype.updateURL = function (url, buffer, onLoad) {
  58696. if (buffer === void 0) { buffer = null; }
  58697. if (this.url) {
  58698. this.releaseInternalTexture();
  58699. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  58700. }
  58701. this.url = url;
  58702. this._buffer = buffer;
  58703. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  58704. if (onLoad) {
  58705. this._delayedOnLoad = onLoad;
  58706. }
  58707. this.delayLoad();
  58708. };
  58709. /**
  58710. * Finish the loading sequence of a texture flagged as delayed load.
  58711. * @hidden
  58712. */
  58713. Texture.prototype.delayLoad = function () {
  58714. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  58715. return;
  58716. }
  58717. var scene = this.getScene();
  58718. if (!scene) {
  58719. return;
  58720. }
  58721. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  58722. this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode);
  58723. if (!this._texture) {
  58724. this._texture = scene.getEngine().createTexture(this.url, this._noMipmap, this._invertY, scene, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format);
  58725. if (this._deleteBuffer) {
  58726. delete this._buffer;
  58727. }
  58728. }
  58729. else {
  58730. if (this._delayedOnLoad) {
  58731. if (this._texture.isReady) {
  58732. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(this._delayedOnLoad);
  58733. }
  58734. else {
  58735. this._texture.onLoadedObservable.add(this._delayedOnLoad);
  58736. }
  58737. }
  58738. }
  58739. this._delayedOnLoad = null;
  58740. this._delayedOnError = null;
  58741. };
  58742. Texture.prototype._prepareRowForTextureGeneration = function (x, y, z, t) {
  58743. x *= this.uScale;
  58744. y *= this.vScale;
  58745. x -= this.uRotationCenter * this.uScale;
  58746. y -= this.vRotationCenter * this.vScale;
  58747. z -= this.wRotationCenter;
  58748. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, this._rowGenerationMatrix, t);
  58749. t.x += this.uRotationCenter * this.uScale + this.uOffset;
  58750. t.y += this.vRotationCenter * this.vScale + this.vOffset;
  58751. t.z += this.wRotationCenter;
  58752. };
  58753. /**
  58754. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  58755. * @returns the transform matrix of the texture.
  58756. */
  58757. Texture.prototype.getTextureMatrix = function () {
  58758. var _this = this;
  58759. if (this.uOffset === this._cachedUOffset &&
  58760. this.vOffset === this._cachedVOffset &&
  58761. this.uScale === this._cachedUScale &&
  58762. this.vScale === this._cachedVScale &&
  58763. this.uAng === this._cachedUAng &&
  58764. this.vAng === this._cachedVAng &&
  58765. this.wAng === this._cachedWAng) {
  58766. return this._cachedTextureMatrix;
  58767. }
  58768. this._cachedUOffset = this.uOffset;
  58769. this._cachedVOffset = this.vOffset;
  58770. this._cachedUScale = this.uScale;
  58771. this._cachedVScale = this.vScale;
  58772. this._cachedUAng = this.uAng;
  58773. this._cachedVAng = this.vAng;
  58774. this._cachedWAng = this.wAng;
  58775. if (!this._cachedTextureMatrix) {
  58776. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  58777. this._rowGenerationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  58778. this._t0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  58779. this._t1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  58780. this._t2 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  58781. }
  58782. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix);
  58783. this._prepareRowForTextureGeneration(0, 0, 0, this._t0);
  58784. this._prepareRowForTextureGeneration(1.0, 0, 0, this._t1);
  58785. this._prepareRowForTextureGeneration(0, 1.0, 0, this._t2);
  58786. this._t1.subtractInPlace(this._t0);
  58787. this._t2.subtractInPlace(this._t0);
  58788. _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);
  58789. var scene = this.getScene();
  58790. if (!scene) {
  58791. return this._cachedTextureMatrix;
  58792. }
  58793. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  58794. return mat.hasTexture(_this);
  58795. });
  58796. return this._cachedTextureMatrix;
  58797. };
  58798. /**
  58799. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  58800. * @returns The reflection texture transform
  58801. */
  58802. Texture.prototype.getReflectionTextureMatrix = function () {
  58803. var _this = this;
  58804. var scene = this.getScene();
  58805. if (!scene) {
  58806. return this._cachedTextureMatrix;
  58807. }
  58808. if (this.uOffset === this._cachedUOffset &&
  58809. this.vOffset === this._cachedVOffset &&
  58810. this.uScale === this._cachedUScale &&
  58811. this.vScale === this._cachedVScale &&
  58812. this.coordinatesMode === this._cachedCoordinatesMode) {
  58813. if (this.coordinatesMode === Texture.PROJECTION_MODE) {
  58814. if (this._cachedProjectionMatrixId === scene.getProjectionMatrix().updateFlag) {
  58815. return this._cachedTextureMatrix;
  58816. }
  58817. }
  58818. else {
  58819. return this._cachedTextureMatrix;
  58820. }
  58821. }
  58822. if (!this._cachedTextureMatrix) {
  58823. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  58824. }
  58825. if (!this._projectionModeMatrix) {
  58826. this._projectionModeMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  58827. }
  58828. this._cachedUOffset = this.uOffset;
  58829. this._cachedVOffset = this.vOffset;
  58830. this._cachedUScale = this.uScale;
  58831. this._cachedVScale = this.vScale;
  58832. this._cachedCoordinatesMode = this.coordinatesMode;
  58833. switch (this.coordinatesMode) {
  58834. case Texture.PLANAR_MODE:
  58835. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  58836. this._cachedTextureMatrix[0] = this.uScale;
  58837. this._cachedTextureMatrix[5] = this.vScale;
  58838. this._cachedTextureMatrix[12] = this.uOffset;
  58839. this._cachedTextureMatrix[13] = this.vOffset;
  58840. break;
  58841. case Texture.PROJECTION_MODE:
  58842. _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);
  58843. var projectionMatrix = scene.getProjectionMatrix();
  58844. this._cachedProjectionMatrixId = projectionMatrix.updateFlag;
  58845. projectionMatrix.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
  58846. break;
  58847. default:
  58848. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  58849. break;
  58850. }
  58851. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  58852. return (mat.getActiveTextures().indexOf(_this) !== -1);
  58853. });
  58854. return this._cachedTextureMatrix;
  58855. };
  58856. /**
  58857. * Clones the texture.
  58858. * @returns the cloned texture
  58859. */
  58860. Texture.prototype.clone = function () {
  58861. var _this = this;
  58862. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  58863. return new Texture(_this._texture ? _this._texture.url : null, _this.getScene(), _this._noMipmap, _this._invertY, _this.samplingMode);
  58864. }, this);
  58865. };
  58866. /**
  58867. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  58868. * @returns The JSON representation of the texture
  58869. */
  58870. Texture.prototype.serialize = function () {
  58871. var serializationObject = _super.prototype.serialize.call(this);
  58872. if (typeof this._buffer === "string" && this._buffer.substr(0, 5) === "data:") {
  58873. serializationObject.base64String = this._buffer;
  58874. serializationObject.name = serializationObject.name.replace("data:", "");
  58875. }
  58876. serializationObject.invertY = this._invertY;
  58877. serializationObject.samplingMode = this.samplingMode;
  58878. return serializationObject;
  58879. };
  58880. /**
  58881. * Get the current class name of the texture useful for serialization or dynamic coding.
  58882. * @returns "Texture"
  58883. */
  58884. Texture.prototype.getClassName = function () {
  58885. return "Texture";
  58886. };
  58887. /**
  58888. * Dispose the texture and release its associated resources.
  58889. */
  58890. Texture.prototype.dispose = function () {
  58891. _super.prototype.dispose.call(this);
  58892. this.onLoadObservable.clear();
  58893. this._delayedOnLoad = null;
  58894. this._delayedOnError = null;
  58895. };
  58896. /**
  58897. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  58898. * @param parsedTexture Define the JSON representation of the texture
  58899. * @param scene Define the scene the parsed texture should be instantiated in
  58900. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58901. * @returns The parsed texture if successful
  58902. */
  58903. Texture.Parse = function (parsedTexture, scene, rootUrl) {
  58904. if (parsedTexture.customType) {
  58905. var customTexture = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Instantiate(parsedTexture.customType);
  58906. // Update Sampling Mode
  58907. var parsedCustomTexture = customTexture.Parse(parsedTexture, scene, rootUrl);
  58908. if (parsedTexture.samplingMode && parsedCustomTexture.updateSamplingMode && parsedCustomTexture._samplingMode) {
  58909. if (parsedCustomTexture._samplingMode !== parsedTexture.samplingMode) {
  58910. parsedCustomTexture.updateSamplingMode(parsedTexture.samplingMode);
  58911. }
  58912. }
  58913. return parsedCustomTexture;
  58914. }
  58915. if (parsedTexture.isCube && !parsedTexture.isRenderTarget) {
  58916. return Texture._CubeTextureParser(parsedTexture, scene, rootUrl);
  58917. }
  58918. if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
  58919. return null;
  58920. }
  58921. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  58922. var generateMipMaps = true;
  58923. if (parsedTexture.noMipmap) {
  58924. generateMipMaps = false;
  58925. }
  58926. if (parsedTexture.mirrorPlane) {
  58927. var mirrorTexture = Texture._CreateMirror(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  58928. mirrorTexture._waitingRenderList = parsedTexture.renderList;
  58929. mirrorTexture.mirrorPlane = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"].FromArray(parsedTexture.mirrorPlane);
  58930. return mirrorTexture;
  58931. }
  58932. else if (parsedTexture.isRenderTarget) {
  58933. var renderTargetTexture = null;
  58934. if (parsedTexture.isCube) {
  58935. // Search for an existing reflection probe (which contains a cube render target texture)
  58936. if (scene.reflectionProbes) {
  58937. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  58938. var probe = scene.reflectionProbes[index];
  58939. if (probe.name === parsedTexture.name) {
  58940. return probe.cubeTexture;
  58941. }
  58942. }
  58943. }
  58944. }
  58945. else {
  58946. renderTargetTexture = Texture._CreateRenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  58947. renderTargetTexture._waitingRenderList = parsedTexture.renderList;
  58948. }
  58949. return renderTargetTexture;
  58950. }
  58951. else {
  58952. var texture;
  58953. if (parsedTexture.base64String) {
  58954. texture = Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene, !generateMipMaps);
  58955. }
  58956. else {
  58957. var url = rootUrl + parsedTexture.name;
  58958. if (Texture.UseSerializedUrlIfAny && parsedTexture.url) {
  58959. url = parsedTexture.url;
  58960. }
  58961. texture = new Texture(url, scene, !generateMipMaps, parsedTexture.invertY);
  58962. }
  58963. return texture;
  58964. }
  58965. }, parsedTexture, scene);
  58966. // Update Sampling Mode
  58967. if (parsedTexture.samplingMode) {
  58968. var sampling = parsedTexture.samplingMode;
  58969. if (texture && texture.samplingMode !== sampling) {
  58970. texture.updateSamplingMode(sampling);
  58971. }
  58972. }
  58973. // Animations
  58974. if (texture && parsedTexture.animations) {
  58975. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  58976. var parsedAnimation = parsedTexture.animations[animationIndex];
  58977. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  58978. if (internalClass) {
  58979. texture.animations.push(internalClass.Parse(parsedAnimation));
  58980. }
  58981. }
  58982. }
  58983. return texture;
  58984. };
  58985. /**
  58986. * Creates a texture from its base 64 representation.
  58987. * @param data Define the base64 payload without the data: prefix
  58988. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  58989. * @param scene Define the scene the texture should belong to
  58990. * @param noMipmap Forces the texture to not create mip map information if true
  58991. * @param invertY define if the texture needs to be inverted on the y axis during loading
  58992. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  58993. * @param onLoad define a callback triggered when the texture has been loaded
  58994. * @param onError define a callback triggered when an error occurred during the loading session
  58995. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  58996. * @returns the created texture
  58997. */
  58998. Texture.CreateFromBase64String = function (data, name, scene, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  58999. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  59000. if (onLoad === void 0) { onLoad = null; }
  59001. if (onError === void 0) { onError = null; }
  59002. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  59003. return new Texture("data:" + name, scene, noMipmap, invertY, samplingMode, onLoad, onError, data, false, format);
  59004. };
  59005. /**
  59006. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  59007. * @param data Define the base64 payload without the data: prefix
  59008. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  59009. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  59010. * @param scene Define the scene the texture should belong to
  59011. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  59012. * @param noMipmap Forces the texture to not create mip map information if true
  59013. * @param invertY define if the texture needs to be inverted on the y axis during loading
  59014. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  59015. * @param onLoad define a callback triggered when the texture has been loaded
  59016. * @param onError define a callback triggered when an error occurred during the loading session
  59017. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  59018. * @returns the created texture
  59019. */
  59020. Texture.LoadFromDataString = function (name, buffer, scene, deleteBuffer, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  59021. if (deleteBuffer === void 0) { deleteBuffer = false; }
  59022. if (noMipmap === void 0) { noMipmap = false; }
  59023. if (invertY === void 0) { invertY = true; }
  59024. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  59025. if (onLoad === void 0) { onLoad = null; }
  59026. if (onError === void 0) { onError = null; }
  59027. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  59028. if (name.substr(0, 5) !== "data:") {
  59029. name = "data:" + name;
  59030. }
  59031. return new Texture(name, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format);
  59032. };
  59033. /** @hidden */
  59034. Texture._CubeTextureParser = function (jsonTexture, scene, rootUrl) {
  59035. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("CubeTexture");
  59036. };
  59037. /** @hidden */
  59038. Texture._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  59039. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("MirrorTexture");
  59040. };
  59041. /** @hidden */
  59042. Texture._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  59043. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("RenderTargetTexture");
  59044. };
  59045. /** nearest is mag = nearest and min = nearest and mip = linear */
  59046. Texture.NEAREST_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  59047. /** nearest is mag = nearest and min = nearest and mip = linear */
  59048. 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
  59049. /** Bilinear is mag = linear and min = linear and mip = nearest */
  59050. Texture.BILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  59051. /** Bilinear is mag = linear and min = linear and mip = nearest */
  59052. 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
  59053. /** Trilinear is mag = linear and min = linear and mip = linear */
  59054. Texture.TRILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  59055. /** Trilinear is mag = linear and min = linear and mip = linear */
  59056. 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
  59057. /** mag = nearest and min = nearest and mip = nearest */
  59058. Texture.NEAREST_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  59059. /** mag = nearest and min = linear and mip = nearest */
  59060. Texture.NEAREST_LINEAR_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  59061. /** mag = nearest and min = linear and mip = linear */
  59062. Texture.NEAREST_LINEAR_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  59063. /** mag = nearest and min = linear and mip = none */
  59064. Texture.NEAREST_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR;
  59065. /** mag = nearest and min = nearest and mip = none */
  59066. Texture.NEAREST_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST;
  59067. /** mag = linear and min = nearest and mip = nearest */
  59068. Texture.LINEAR_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  59069. /** mag = linear and min = nearest and mip = linear */
  59070. Texture.LINEAR_NEAREST_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  59071. /** mag = linear and min = linear and mip = none */
  59072. Texture.LINEAR_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR;
  59073. /** mag = linear and min = nearest and mip = none */
  59074. Texture.LINEAR_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST;
  59075. /** Explicit coordinates mode */
  59076. Texture.EXPLICIT_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EXPLICIT_MODE;
  59077. /** Spherical coordinates mode */
  59078. Texture.SPHERICAL_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SPHERICAL_MODE;
  59079. /** Planar coordinates mode */
  59080. Texture.PLANAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PLANAR_MODE;
  59081. /** Cubic coordinates mode */
  59082. Texture.CUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CUBIC_MODE;
  59083. /** Projection coordinates mode */
  59084. Texture.PROJECTION_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PROJECTION_MODE;
  59085. /** Inverse Cubic coordinates mode */
  59086. Texture.SKYBOX_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SKYBOX_MODE;
  59087. /** Inverse Cubic coordinates mode */
  59088. Texture.INVCUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_INVCUBIC_MODE;
  59089. /** Equirectangular coordinates mode */
  59090. Texture.EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  59091. /** Equirectangular Fixed coordinates mode */
  59092. Texture.FIXED_EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  59093. /** Equirectangular Fixed Mirrored coordinates mode */
  59094. Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  59095. /** Texture is not repeating outside of 0..1 UVs */
  59096. Texture.CLAMP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  59097. /** Texture is repeating outside of 0..1 UVs */
  59098. Texture.WRAP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  59099. /** Texture is repeating and mirrored */
  59100. Texture.MIRROR_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  59101. /**
  59102. * 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
  59103. */
  59104. Texture.UseSerializedUrlIfAny = false;
  59105. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59106. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59107. ], Texture.prototype, "url", void 0);
  59108. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59109. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59110. ], Texture.prototype, "uOffset", void 0);
  59111. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59112. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59113. ], Texture.prototype, "vOffset", void 0);
  59114. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59115. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59116. ], Texture.prototype, "uScale", void 0);
  59117. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59118. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59119. ], Texture.prototype, "vScale", void 0);
  59120. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59121. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59122. ], Texture.prototype, "uAng", void 0);
  59123. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59124. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59125. ], Texture.prototype, "vAng", void 0);
  59126. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59127. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59128. ], Texture.prototype, "wAng", void 0);
  59129. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59130. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59131. ], Texture.prototype, "uRotationCenter", void 0);
  59132. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59133. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59134. ], Texture.prototype, "vRotationCenter", void 0);
  59135. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59136. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59137. ], Texture.prototype, "wRotationCenter", void 0);
  59138. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59139. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59140. ], Texture.prototype, "isBlocking", null);
  59141. return Texture;
  59142. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]));
  59143. // References the dependencies.
  59144. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._TextureParser = Texture.Parse;
  59145. /***/ }),
  59146. /***/ "./Materials/Textures/videoTexture.ts":
  59147. /*!********************************************!*\
  59148. !*** ./Materials/Textures/videoTexture.ts ***!
  59149. \********************************************/
  59150. /*! exports provided: VideoTexture */
  59151. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59152. "use strict";
  59153. __webpack_require__.r(__webpack_exports__);
  59154. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return VideoTexture; });
  59155. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59156. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  59157. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  59158. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  59159. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  59160. /**
  59161. * If you want to display a video in your scene, this is the special texture for that.
  59162. * This special texture works similar to other textures, with the exception of a few parameters.
  59163. * @see https://doc.babylonjs.com/how_to/video_texture
  59164. */
  59165. var VideoTexture = /** @class */ (function (_super) {
  59166. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoTexture, _super);
  59167. /**
  59168. * Creates a video texture.
  59169. * If you want to display a video in your scene, this is the special texture for that.
  59170. * This special texture works similar to other textures, with the exception of a few parameters.
  59171. * @see https://doc.babylonjs.com/how_to/video_texture
  59172. * @param name optional name, will detect from video source, if not defined
  59173. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  59174. * @param scene is obviously the current scene.
  59175. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  59176. * @param invertY is false by default but can be used to invert video on Y axis
  59177. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  59178. * @param settings allows finer control over video usage
  59179. */
  59180. function VideoTexture(name, src, scene, generateMipMaps, invertY, samplingMode, settings) {
  59181. if (generateMipMaps === void 0) { generateMipMaps = false; }
  59182. if (invertY === void 0) { invertY = false; }
  59183. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  59184. if (settings === void 0) { settings = {
  59185. autoPlay: true,
  59186. loop: true,
  59187. autoUpdateTexture: true,
  59188. }; }
  59189. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  59190. _this._onUserActionRequestedObservable = null;
  59191. _this._stillImageCaptured = false;
  59192. _this._displayingPosterTexture = false;
  59193. _this._createInternalTexture = function () {
  59194. if (_this._texture != null) {
  59195. if (_this._displayingPosterTexture) {
  59196. _this._texture.dispose();
  59197. _this._displayingPosterTexture = false;
  59198. }
  59199. else {
  59200. return;
  59201. }
  59202. }
  59203. if (!_this._engine.needPOTTextures ||
  59204. (_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoWidth) && _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoHeight))) {
  59205. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  59206. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  59207. }
  59208. else {
  59209. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  59210. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  59211. _this._generateMipMaps = false;
  59212. }
  59213. _this._texture = _this._engine.createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, _this._generateMipMaps, _this.samplingMode);
  59214. if (!_this.video.autoplay && !_this._settings.poster) {
  59215. var oldHandler_1 = _this.video.onplaying;
  59216. var error_1 = false;
  59217. _this.video.onplaying = function () {
  59218. _this.video.onplaying = oldHandler_1;
  59219. _this._texture.isReady = true;
  59220. _this._updateInternalTexture();
  59221. if (!error_1) {
  59222. _this.video.pause();
  59223. }
  59224. if (_this.onLoadObservable.hasObservers()) {
  59225. _this.onLoadObservable.notifyObservers(_this);
  59226. }
  59227. };
  59228. var playing = _this.video.play();
  59229. if (playing) {
  59230. playing.then(function () {
  59231. // Everything is good.
  59232. })
  59233. .catch(function () {
  59234. error_1 = true;
  59235. // On Chrome for instance, new policies might prevent playing without user interaction.
  59236. if (_this._onUserActionRequestedObservable && _this._onUserActionRequestedObservable.hasObservers()) {
  59237. _this._onUserActionRequestedObservable.notifyObservers(_this);
  59238. }
  59239. });
  59240. }
  59241. else {
  59242. _this.video.onplaying = oldHandler_1;
  59243. _this._texture.isReady = true;
  59244. _this._updateInternalTexture();
  59245. if (_this.onLoadObservable.hasObservers()) {
  59246. _this.onLoadObservable.notifyObservers(_this);
  59247. }
  59248. }
  59249. }
  59250. else {
  59251. _this._texture.isReady = true;
  59252. _this._updateInternalTexture();
  59253. if (_this.onLoadObservable.hasObservers()) {
  59254. _this.onLoadObservable.notifyObservers(_this);
  59255. }
  59256. }
  59257. };
  59258. _this.reset = function () {
  59259. if (_this._texture == null) {
  59260. return;
  59261. }
  59262. if (!_this._displayingPosterTexture) {
  59263. _this._texture.dispose();
  59264. _this._texture = null;
  59265. }
  59266. };
  59267. _this._updateInternalTexture = function () {
  59268. if (_this._texture == null || !_this._texture.isReady) {
  59269. return;
  59270. }
  59271. if (_this.video.readyState < _this.video.HAVE_CURRENT_DATA) {
  59272. return;
  59273. }
  59274. if (_this._displayingPosterTexture) {
  59275. return;
  59276. }
  59277. _this._engine.updateVideoTexture(_this._texture, _this.video, _this._invertY);
  59278. };
  59279. _this._engine = _this.getScene().getEngine();
  59280. _this._generateMipMaps = generateMipMaps;
  59281. _this._initialSamplingMode = samplingMode;
  59282. _this.autoUpdateTexture = settings.autoUpdateTexture;
  59283. _this.name = name || _this._getName(src);
  59284. _this.video = _this._getVideo(src);
  59285. _this._settings = settings;
  59286. if (settings.poster) {
  59287. _this.video.poster = settings.poster;
  59288. }
  59289. if (settings.autoPlay !== undefined) {
  59290. _this.video.autoplay = settings.autoPlay;
  59291. }
  59292. if (settings.loop !== undefined) {
  59293. _this.video.loop = settings.loop;
  59294. }
  59295. _this.video.setAttribute("playsinline", "");
  59296. _this.video.addEventListener("paused", _this._updateInternalTexture);
  59297. _this.video.addEventListener("seeked", _this._updateInternalTexture);
  59298. _this.video.addEventListener("emptied", _this.reset);
  59299. _this._createInternalTextureOnEvent = (settings.poster && !settings.autoPlay) ? "play" : "canplay";
  59300. _this.video.addEventListener(_this._createInternalTextureOnEvent, _this._createInternalTexture);
  59301. var videoHasEnoughData = (_this.video.readyState >= _this.video.HAVE_CURRENT_DATA);
  59302. if (settings.poster &&
  59303. (!settings.autoPlay || !videoHasEnoughData)) {
  59304. _this._texture = _this._engine.createTexture(settings.poster, false, true, scene);
  59305. _this._displayingPosterTexture = true;
  59306. }
  59307. else if (videoHasEnoughData) {
  59308. _this._createInternalTexture();
  59309. }
  59310. return _this;
  59311. }
  59312. Object.defineProperty(VideoTexture.prototype, "onUserActionRequestedObservable", {
  59313. /**
  59314. * Event triggerd when a dom action is required by the user to play the video.
  59315. * This happens due to recent changes in browser policies preventing video to auto start.
  59316. */
  59317. get: function () {
  59318. if (!this._onUserActionRequestedObservable) {
  59319. this._onUserActionRequestedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  59320. }
  59321. return this._onUserActionRequestedObservable;
  59322. },
  59323. enumerable: true,
  59324. configurable: true
  59325. });
  59326. VideoTexture.prototype._getName = function (src) {
  59327. if (src instanceof HTMLVideoElement) {
  59328. return src.currentSrc;
  59329. }
  59330. if (typeof src === "object") {
  59331. return src.toString();
  59332. }
  59333. return src;
  59334. };
  59335. VideoTexture.prototype._getVideo = function (src) {
  59336. if (src instanceof HTMLVideoElement) {
  59337. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src.currentSrc, src);
  59338. return src;
  59339. }
  59340. var video = document.createElement("video");
  59341. if (typeof src === "string") {
  59342. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src, video);
  59343. video.src = src;
  59344. }
  59345. else {
  59346. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src[0], video);
  59347. src.forEach(function (url) {
  59348. var source = document.createElement("source");
  59349. source.src = url;
  59350. video.appendChild(source);
  59351. });
  59352. }
  59353. return video;
  59354. };
  59355. /**
  59356. * @hidden Internal method to initiate `update`.
  59357. */
  59358. VideoTexture.prototype._rebuild = function () {
  59359. this.update();
  59360. };
  59361. /**
  59362. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  59363. */
  59364. VideoTexture.prototype.update = function () {
  59365. if (!this.autoUpdateTexture) {
  59366. // Expecting user to call `updateTexture` manually
  59367. return;
  59368. }
  59369. this.updateTexture(true);
  59370. };
  59371. /**
  59372. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  59373. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  59374. */
  59375. VideoTexture.prototype.updateTexture = function (isVisible) {
  59376. if (!isVisible) {
  59377. return;
  59378. }
  59379. if (this.video.paused && this._stillImageCaptured) {
  59380. return;
  59381. }
  59382. this._stillImageCaptured = true;
  59383. this._updateInternalTexture();
  59384. };
  59385. /**
  59386. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  59387. * @param url New url.
  59388. */
  59389. VideoTexture.prototype.updateURL = function (url) {
  59390. this.video.src = url;
  59391. };
  59392. /**
  59393. * Dispose the texture and release its associated resources.
  59394. */
  59395. VideoTexture.prototype.dispose = function () {
  59396. _super.prototype.dispose.call(this);
  59397. if (this._onUserActionRequestedObservable) {
  59398. this._onUserActionRequestedObservable.clear();
  59399. this._onUserActionRequestedObservable = null;
  59400. }
  59401. this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture);
  59402. this.video.removeEventListener("paused", this._updateInternalTexture);
  59403. this.video.removeEventListener("seeked", this._updateInternalTexture);
  59404. this.video.removeEventListener("emptied", this.reset);
  59405. this.video.pause();
  59406. };
  59407. /**
  59408. * Creates a video texture straight from your WebCam video feed.
  59409. * @param scene Define the scene the texture should be created in
  59410. * @param onReady Define a callback to triggered once the texture will be ready
  59411. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  59412. */
  59413. VideoTexture.CreateFromWebCam = function (scene, onReady, constraints) {
  59414. var video = document.createElement("video");
  59415. video.setAttribute('autoplay', '');
  59416. video.setAttribute('muted', '');
  59417. video.setAttribute('playsinline', '');
  59418. var constraintsDeviceId;
  59419. if (constraints && constraints.deviceId) {
  59420. constraintsDeviceId = {
  59421. exact: constraints.deviceId,
  59422. };
  59423. }
  59424. window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
  59425. if (navigator.mediaDevices) {
  59426. navigator.mediaDevices.getUserMedia({ video: constraints })
  59427. .then(function (stream) {
  59428. if (video.mozSrcObject !== undefined) {
  59429. // hack for Firefox < 19
  59430. video.mozSrcObject = stream;
  59431. }
  59432. else {
  59433. video.srcObject = stream;
  59434. }
  59435. var onPlaying = function () {
  59436. if (onReady) {
  59437. onReady(new VideoTexture("video", video, scene, true, true));
  59438. }
  59439. video.removeEventListener("playing", onPlaying);
  59440. };
  59441. video.addEventListener("playing", onPlaying);
  59442. video.play();
  59443. })
  59444. .catch(function (err) {
  59445. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(err.name);
  59446. });
  59447. }
  59448. else {
  59449. navigator.getUserMedia =
  59450. navigator.getUserMedia ||
  59451. navigator.webkitGetUserMedia ||
  59452. navigator.mozGetUserMedia ||
  59453. navigator.msGetUserMedia;
  59454. if (navigator.getUserMedia) {
  59455. navigator.getUserMedia({
  59456. video: {
  59457. deviceId: constraintsDeviceId,
  59458. width: {
  59459. min: (constraints && constraints.minWidth) || 256,
  59460. max: (constraints && constraints.maxWidth) || 640,
  59461. },
  59462. height: {
  59463. min: (constraints && constraints.minHeight) || 256,
  59464. max: (constraints && constraints.maxHeight) || 480,
  59465. },
  59466. },
  59467. }, function (stream) {
  59468. if (video.mozSrcObject !== undefined) {
  59469. // hack for Firefox < 19
  59470. video.mozSrcObject = stream;
  59471. }
  59472. else {
  59473. video.src = (window.URL && window.URL.createObjectURL(stream)) || stream;
  59474. }
  59475. video.play();
  59476. if (onReady) {
  59477. onReady(new VideoTexture("video", video, scene, true, true));
  59478. }
  59479. }, function (e) {
  59480. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(e.name);
  59481. });
  59482. }
  59483. }
  59484. };
  59485. return VideoTexture;
  59486. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  59487. /***/ }),
  59488. /***/ "./Materials/colorCurves.ts":
  59489. /*!**********************************!*\
  59490. !*** ./Materials/colorCurves.ts ***!
  59491. \**********************************/
  59492. /*! exports provided: ColorCurves */
  59493. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59494. "use strict";
  59495. __webpack_require__.r(__webpack_exports__);
  59496. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return ColorCurves; });
  59497. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59498. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  59499. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  59500. /**
  59501. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59502. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59503. * 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;
  59504. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59505. */
  59506. var ColorCurves = /** @class */ (function () {
  59507. function ColorCurves() {
  59508. this._dirty = true;
  59509. this._tempColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59510. this._globalCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59511. this._highlightsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59512. this._midtonesCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59513. this._shadowsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59514. this._positiveCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59515. this._negativeCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59516. this._globalHue = 30;
  59517. this._globalDensity = 0;
  59518. this._globalSaturation = 0;
  59519. this._globalExposure = 0;
  59520. this._highlightsHue = 30;
  59521. this._highlightsDensity = 0;
  59522. this._highlightsSaturation = 0;
  59523. this._highlightsExposure = 0;
  59524. this._midtonesHue = 30;
  59525. this._midtonesDensity = 0;
  59526. this._midtonesSaturation = 0;
  59527. this._midtonesExposure = 0;
  59528. this._shadowsHue = 30;
  59529. this._shadowsDensity = 0;
  59530. this._shadowsSaturation = 0;
  59531. this._shadowsExposure = 0;
  59532. }
  59533. Object.defineProperty(ColorCurves.prototype, "globalHue", {
  59534. /**
  59535. * Gets the global Hue value.
  59536. * 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).
  59537. */
  59538. get: function () {
  59539. return this._globalHue;
  59540. },
  59541. /**
  59542. * Sets the global Hue value.
  59543. * 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).
  59544. */
  59545. set: function (value) {
  59546. this._globalHue = value;
  59547. this._dirty = true;
  59548. },
  59549. enumerable: true,
  59550. configurable: true
  59551. });
  59552. Object.defineProperty(ColorCurves.prototype, "globalDensity", {
  59553. /**
  59554. * Gets the global Density value.
  59555. * 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.
  59556. * Values less than zero provide a filter of opposite hue.
  59557. */
  59558. get: function () {
  59559. return this._globalDensity;
  59560. },
  59561. /**
  59562. * Sets the global Density value.
  59563. * 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.
  59564. * Values less than zero provide a filter of opposite hue.
  59565. */
  59566. set: function (value) {
  59567. this._globalDensity = value;
  59568. this._dirty = true;
  59569. },
  59570. enumerable: true,
  59571. configurable: true
  59572. });
  59573. Object.defineProperty(ColorCurves.prototype, "globalSaturation", {
  59574. /**
  59575. * Gets the global Saturation value.
  59576. * 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.
  59577. */
  59578. get: function () {
  59579. return this._globalSaturation;
  59580. },
  59581. /**
  59582. * Sets the global Saturation value.
  59583. * 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.
  59584. */
  59585. set: function (value) {
  59586. this._globalSaturation = value;
  59587. this._dirty = true;
  59588. },
  59589. enumerable: true,
  59590. configurable: true
  59591. });
  59592. Object.defineProperty(ColorCurves.prototype, "globalExposure", {
  59593. /**
  59594. * Gets the global Exposure value.
  59595. * 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.
  59596. */
  59597. get: function () {
  59598. return this._globalExposure;
  59599. },
  59600. /**
  59601. * Sets the global Exposure value.
  59602. * 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.
  59603. */
  59604. set: function (value) {
  59605. this._globalExposure = value;
  59606. this._dirty = true;
  59607. },
  59608. enumerable: true,
  59609. configurable: true
  59610. });
  59611. Object.defineProperty(ColorCurves.prototype, "highlightsHue", {
  59612. /**
  59613. * Gets the highlights Hue value.
  59614. * 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).
  59615. */
  59616. get: function () {
  59617. return this._highlightsHue;
  59618. },
  59619. /**
  59620. * Sets the highlights Hue value.
  59621. * 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).
  59622. */
  59623. set: function (value) {
  59624. this._highlightsHue = value;
  59625. this._dirty = true;
  59626. },
  59627. enumerable: true,
  59628. configurable: true
  59629. });
  59630. Object.defineProperty(ColorCurves.prototype, "highlightsDensity", {
  59631. /**
  59632. * Gets the highlights Density value.
  59633. * 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.
  59634. * Values less than zero provide a filter of opposite hue.
  59635. */
  59636. get: function () {
  59637. return this._highlightsDensity;
  59638. },
  59639. /**
  59640. * Sets the highlights Density value.
  59641. * 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.
  59642. * Values less than zero provide a filter of opposite hue.
  59643. */
  59644. set: function (value) {
  59645. this._highlightsDensity = value;
  59646. this._dirty = true;
  59647. },
  59648. enumerable: true,
  59649. configurable: true
  59650. });
  59651. Object.defineProperty(ColorCurves.prototype, "highlightsSaturation", {
  59652. /**
  59653. * Gets the highlights Saturation value.
  59654. * 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.
  59655. */
  59656. get: function () {
  59657. return this._highlightsSaturation;
  59658. },
  59659. /**
  59660. * Sets the highlights Saturation value.
  59661. * 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.
  59662. */
  59663. set: function (value) {
  59664. this._highlightsSaturation = value;
  59665. this._dirty = true;
  59666. },
  59667. enumerable: true,
  59668. configurable: true
  59669. });
  59670. Object.defineProperty(ColorCurves.prototype, "highlightsExposure", {
  59671. /**
  59672. * Gets the highlights Exposure value.
  59673. * 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.
  59674. */
  59675. get: function () {
  59676. return this._highlightsExposure;
  59677. },
  59678. /**
  59679. * Sets the highlights Exposure value.
  59680. * 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.
  59681. */
  59682. set: function (value) {
  59683. this._highlightsExposure = value;
  59684. this._dirty = true;
  59685. },
  59686. enumerable: true,
  59687. configurable: true
  59688. });
  59689. Object.defineProperty(ColorCurves.prototype, "midtonesHue", {
  59690. /**
  59691. * Gets the midtones Hue value.
  59692. * 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).
  59693. */
  59694. get: function () {
  59695. return this._midtonesHue;
  59696. },
  59697. /**
  59698. * Sets the midtones Hue value.
  59699. * 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).
  59700. */
  59701. set: function (value) {
  59702. this._midtonesHue = value;
  59703. this._dirty = true;
  59704. },
  59705. enumerable: true,
  59706. configurable: true
  59707. });
  59708. Object.defineProperty(ColorCurves.prototype, "midtonesDensity", {
  59709. /**
  59710. * Gets the midtones Density value.
  59711. * 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.
  59712. * Values less than zero provide a filter of opposite hue.
  59713. */
  59714. get: function () {
  59715. return this._midtonesDensity;
  59716. },
  59717. /**
  59718. * Sets the midtones Density value.
  59719. * 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.
  59720. * Values less than zero provide a filter of opposite hue.
  59721. */
  59722. set: function (value) {
  59723. this._midtonesDensity = value;
  59724. this._dirty = true;
  59725. },
  59726. enumerable: true,
  59727. configurable: true
  59728. });
  59729. Object.defineProperty(ColorCurves.prototype, "midtonesSaturation", {
  59730. /**
  59731. * Gets the midtones Saturation value.
  59732. * 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.
  59733. */
  59734. get: function () {
  59735. return this._midtonesSaturation;
  59736. },
  59737. /**
  59738. * Sets the midtones Saturation value.
  59739. * 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.
  59740. */
  59741. set: function (value) {
  59742. this._midtonesSaturation = value;
  59743. this._dirty = true;
  59744. },
  59745. enumerable: true,
  59746. configurable: true
  59747. });
  59748. Object.defineProperty(ColorCurves.prototype, "midtonesExposure", {
  59749. /**
  59750. * Gets the midtones Exposure value.
  59751. * 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.
  59752. */
  59753. get: function () {
  59754. return this._midtonesExposure;
  59755. },
  59756. /**
  59757. * Sets the midtones Exposure value.
  59758. * 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.
  59759. */
  59760. set: function (value) {
  59761. this._midtonesExposure = value;
  59762. this._dirty = true;
  59763. },
  59764. enumerable: true,
  59765. configurable: true
  59766. });
  59767. Object.defineProperty(ColorCurves.prototype, "shadowsHue", {
  59768. /**
  59769. * Gets the shadows Hue value.
  59770. * 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).
  59771. */
  59772. get: function () {
  59773. return this._shadowsHue;
  59774. },
  59775. /**
  59776. * Sets the shadows Hue value.
  59777. * 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).
  59778. */
  59779. set: function (value) {
  59780. this._shadowsHue = value;
  59781. this._dirty = true;
  59782. },
  59783. enumerable: true,
  59784. configurable: true
  59785. });
  59786. Object.defineProperty(ColorCurves.prototype, "shadowsDensity", {
  59787. /**
  59788. * Gets the shadows Density value.
  59789. * 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.
  59790. * Values less than zero provide a filter of opposite hue.
  59791. */
  59792. get: function () {
  59793. return this._shadowsDensity;
  59794. },
  59795. /**
  59796. * Sets the shadows Density value.
  59797. * 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.
  59798. * Values less than zero provide a filter of opposite hue.
  59799. */
  59800. set: function (value) {
  59801. this._shadowsDensity = value;
  59802. this._dirty = true;
  59803. },
  59804. enumerable: true,
  59805. configurable: true
  59806. });
  59807. Object.defineProperty(ColorCurves.prototype, "shadowsSaturation", {
  59808. /**
  59809. * Gets the shadows Saturation value.
  59810. * 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.
  59811. */
  59812. get: function () {
  59813. return this._shadowsSaturation;
  59814. },
  59815. /**
  59816. * Sets the shadows Saturation value.
  59817. * 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.
  59818. */
  59819. set: function (value) {
  59820. this._shadowsSaturation = value;
  59821. this._dirty = true;
  59822. },
  59823. enumerable: true,
  59824. configurable: true
  59825. });
  59826. Object.defineProperty(ColorCurves.prototype, "shadowsExposure", {
  59827. /**
  59828. * Gets the shadows Exposure value.
  59829. * 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.
  59830. */
  59831. get: function () {
  59832. return this._shadowsExposure;
  59833. },
  59834. /**
  59835. * Sets the shadows Exposure value.
  59836. * 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.
  59837. */
  59838. set: function (value) {
  59839. this._shadowsExposure = value;
  59840. this._dirty = true;
  59841. },
  59842. enumerable: true,
  59843. configurable: true
  59844. });
  59845. /**
  59846. * Returns the class name
  59847. * @returns The class name
  59848. */
  59849. ColorCurves.prototype.getClassName = function () {
  59850. return "ColorCurves";
  59851. };
  59852. /**
  59853. * Binds the color curves to the shader.
  59854. * @param colorCurves The color curve to bind
  59855. * @param effect The effect to bind to
  59856. * @param positiveUniform The positive uniform shader parameter
  59857. * @param neutralUniform The neutral uniform shader parameter
  59858. * @param negativeUniform The negative uniform shader parameter
  59859. */
  59860. ColorCurves.Bind = function (colorCurves, effect, positiveUniform, neutralUniform, negativeUniform) {
  59861. if (positiveUniform === void 0) { positiveUniform = "vCameraColorCurvePositive"; }
  59862. if (neutralUniform === void 0) { neutralUniform = "vCameraColorCurveNeutral"; }
  59863. if (negativeUniform === void 0) { negativeUniform = "vCameraColorCurveNegative"; }
  59864. if (colorCurves._dirty) {
  59865. colorCurves._dirty = false;
  59866. // Fill in global info.
  59867. colorCurves.getColorGradingDataToRef(colorCurves._globalHue, colorCurves._globalDensity, colorCurves._globalSaturation, colorCurves._globalExposure, colorCurves._globalCurve);
  59868. // Compute highlights info.
  59869. colorCurves.getColorGradingDataToRef(colorCurves._highlightsHue, colorCurves._highlightsDensity, colorCurves._highlightsSaturation, colorCurves._highlightsExposure, colorCurves._tempColor);
  59870. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._highlightsCurve);
  59871. // Compute midtones info.
  59872. colorCurves.getColorGradingDataToRef(colorCurves._midtonesHue, colorCurves._midtonesDensity, colorCurves._midtonesSaturation, colorCurves._midtonesExposure, colorCurves._tempColor);
  59873. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._midtonesCurve);
  59874. // Compute shadows info.
  59875. colorCurves.getColorGradingDataToRef(colorCurves._shadowsHue, colorCurves._shadowsDensity, colorCurves._shadowsSaturation, colorCurves._shadowsExposure, colorCurves._tempColor);
  59876. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._shadowsCurve);
  59877. // Compute deltas (neutral is midtones).
  59878. colorCurves._highlightsCurve.subtractToRef(colorCurves._midtonesCurve, colorCurves._positiveCurve);
  59879. colorCurves._midtonesCurve.subtractToRef(colorCurves._shadowsCurve, colorCurves._negativeCurve);
  59880. }
  59881. if (effect) {
  59882. effect.setFloat4(positiveUniform, colorCurves._positiveCurve.r, colorCurves._positiveCurve.g, colorCurves._positiveCurve.b, colorCurves._positiveCurve.a);
  59883. effect.setFloat4(neutralUniform, colorCurves._midtonesCurve.r, colorCurves._midtonesCurve.g, colorCurves._midtonesCurve.b, colorCurves._midtonesCurve.a);
  59884. effect.setFloat4(negativeUniform, colorCurves._negativeCurve.r, colorCurves._negativeCurve.g, colorCurves._negativeCurve.b, colorCurves._negativeCurve.a);
  59885. }
  59886. };
  59887. /**
  59888. * Prepare the list of uniforms associated with the ColorCurves effects.
  59889. * @param uniformsList The list of uniforms used in the effect
  59890. */
  59891. ColorCurves.PrepareUniforms = function (uniformsList) {
  59892. uniformsList.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative");
  59893. };
  59894. /**
  59895. * Returns color grading data based on a hue, density, saturation and exposure value.
  59896. * @param filterHue The hue of the color filter.
  59897. * @param filterDensity The density of the color filter.
  59898. * @param saturation The saturation.
  59899. * @param exposure The exposure.
  59900. * @param result The result data container.
  59901. */
  59902. ColorCurves.prototype.getColorGradingDataToRef = function (hue, density, saturation, exposure, result) {
  59903. if (hue == null) {
  59904. return;
  59905. }
  59906. hue = ColorCurves.clamp(hue, 0, 360);
  59907. density = ColorCurves.clamp(density, -100, 100);
  59908. saturation = ColorCurves.clamp(saturation, -100, 100);
  59909. exposure = ColorCurves.clamp(exposure, -100, 100);
  59910. // Remap the slider/config filter density with non-linear mapping and also scale by half
  59911. // so that the maximum filter density is only 50% control. This provides fine control
  59912. // for small values and reasonable range.
  59913. density = ColorCurves.applyColorGradingSliderNonlinear(density);
  59914. density *= 0.5;
  59915. exposure = ColorCurves.applyColorGradingSliderNonlinear(exposure);
  59916. if (density < 0) {
  59917. density *= -1;
  59918. hue = (hue + 180) % 360;
  59919. }
  59920. ColorCurves.fromHSBToRef(hue, density, 50 + 0.25 * exposure, result);
  59921. result.scaleToRef(2, result);
  59922. result.a = 1 + 0.01 * saturation;
  59923. };
  59924. /**
  59925. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  59926. * @param value The input slider value in range [-100,100].
  59927. * @returns Adjusted value.
  59928. */
  59929. ColorCurves.applyColorGradingSliderNonlinear = function (value) {
  59930. value /= 100;
  59931. var x = Math.abs(value);
  59932. x = Math.pow(x, 2);
  59933. if (value < 0) {
  59934. x *= -1;
  59935. }
  59936. x *= 100;
  59937. return x;
  59938. };
  59939. /**
  59940. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  59941. * @param hue The hue (H) input.
  59942. * @param saturation The saturation (S) input.
  59943. * @param brightness The brightness (B) input.
  59944. * @result An RGBA color represented as Vector4.
  59945. */
  59946. ColorCurves.fromHSBToRef = function (hue, saturation, brightness, result) {
  59947. var h = ColorCurves.clamp(hue, 0, 360);
  59948. var s = ColorCurves.clamp(saturation / 100, 0, 1);
  59949. var v = ColorCurves.clamp(brightness / 100, 0, 1);
  59950. if (s === 0) {
  59951. result.r = v;
  59952. result.g = v;
  59953. result.b = v;
  59954. }
  59955. else {
  59956. // sector 0 to 5
  59957. h /= 60;
  59958. var i = Math.floor(h);
  59959. // fractional part of h
  59960. var f = h - i;
  59961. var p = v * (1 - s);
  59962. var q = v * (1 - s * f);
  59963. var t = v * (1 - s * (1 - f));
  59964. switch (i) {
  59965. case 0:
  59966. result.r = v;
  59967. result.g = t;
  59968. result.b = p;
  59969. break;
  59970. case 1:
  59971. result.r = q;
  59972. result.g = v;
  59973. result.b = p;
  59974. break;
  59975. case 2:
  59976. result.r = p;
  59977. result.g = v;
  59978. result.b = t;
  59979. break;
  59980. case 3:
  59981. result.r = p;
  59982. result.g = q;
  59983. result.b = v;
  59984. break;
  59985. case 4:
  59986. result.r = t;
  59987. result.g = p;
  59988. result.b = v;
  59989. break;
  59990. default: // case 5:
  59991. result.r = v;
  59992. result.g = p;
  59993. result.b = q;
  59994. break;
  59995. }
  59996. }
  59997. result.a = 1;
  59998. };
  59999. /**
  60000. * Returns a value clamped between min and max
  60001. * @param value The value to clamp
  60002. * @param min The minimum of value
  60003. * @param max The maximum of value
  60004. * @returns The clamped value.
  60005. */
  60006. ColorCurves.clamp = function (value, min, max) {
  60007. return Math.min(Math.max(value, min), max);
  60008. };
  60009. /**
  60010. * Clones the current color curve instance.
  60011. * @return The cloned curves
  60012. */
  60013. ColorCurves.prototype.clone = function () {
  60014. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ColorCurves(); }, this);
  60015. };
  60016. /**
  60017. * Serializes the current color curve instance to a json representation.
  60018. * @return a JSON representation
  60019. */
  60020. ColorCurves.prototype.serialize = function () {
  60021. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  60022. };
  60023. /**
  60024. * Parses the color curve from a json representation.
  60025. * @param source the JSON source to parse
  60026. * @return The parsed curves
  60027. */
  60028. ColorCurves.Parse = function (source) {
  60029. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ColorCurves(); }, source, null, null);
  60030. };
  60031. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60032. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60033. ], ColorCurves.prototype, "_globalHue", void 0);
  60034. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60035. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60036. ], ColorCurves.prototype, "_globalDensity", void 0);
  60037. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60038. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60039. ], ColorCurves.prototype, "_globalSaturation", void 0);
  60040. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60041. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60042. ], ColorCurves.prototype, "_globalExposure", void 0);
  60043. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60044. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60045. ], ColorCurves.prototype, "_highlightsHue", void 0);
  60046. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60047. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60048. ], ColorCurves.prototype, "_highlightsDensity", void 0);
  60049. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60050. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60051. ], ColorCurves.prototype, "_highlightsSaturation", void 0);
  60052. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60053. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60054. ], ColorCurves.prototype, "_highlightsExposure", void 0);
  60055. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60056. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60057. ], ColorCurves.prototype, "_midtonesHue", void 0);
  60058. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60059. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60060. ], ColorCurves.prototype, "_midtonesDensity", void 0);
  60061. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60062. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60063. ], ColorCurves.prototype, "_midtonesSaturation", void 0);
  60064. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60065. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60066. ], ColorCurves.prototype, "_midtonesExposure", void 0);
  60067. return ColorCurves;
  60068. }());
  60069. // References the dependencies.
  60070. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ColorCurvesParser = ColorCurves.Parse;
  60071. /***/ }),
  60072. /***/ "./Materials/effect.ts":
  60073. /*!*****************************!*\
  60074. !*** ./Materials/effect.ts ***!
  60075. \*****************************/
  60076. /*! exports provided: EffectFallbacks, EffectCreationOptions, Effect */
  60077. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60078. "use strict";
  60079. __webpack_require__.r(__webpack_exports__);
  60080. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return EffectFallbacks; });
  60081. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return EffectCreationOptions; });
  60082. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return Effect; });
  60083. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  60084. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  60085. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  60086. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  60087. /**
  60088. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  60089. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  60090. */
  60091. var EffectFallbacks = /** @class */ (function () {
  60092. function EffectFallbacks() {
  60093. this._defines = {};
  60094. this._currentRank = 32;
  60095. this._maxRank = -1;
  60096. }
  60097. /**
  60098. * Removes the fallback from the bound mesh.
  60099. */
  60100. EffectFallbacks.prototype.unBindMesh = function () {
  60101. this._mesh = null;
  60102. };
  60103. /**
  60104. * Adds a fallback on the specified property.
  60105. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  60106. * @param define The name of the define in the shader
  60107. */
  60108. EffectFallbacks.prototype.addFallback = function (rank, define) {
  60109. if (!this._defines[rank]) {
  60110. if (rank < this._currentRank) {
  60111. this._currentRank = rank;
  60112. }
  60113. if (rank > this._maxRank) {
  60114. this._maxRank = rank;
  60115. }
  60116. this._defines[rank] = new Array();
  60117. }
  60118. this._defines[rank].push(define);
  60119. };
  60120. /**
  60121. * Sets the mesh to use CPU skinning when needing to fallback.
  60122. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  60123. * @param mesh The mesh to use the fallbacks.
  60124. */
  60125. EffectFallbacks.prototype.addCPUSkinningFallback = function (rank, mesh) {
  60126. this._mesh = mesh;
  60127. if (rank < this._currentRank) {
  60128. this._currentRank = rank;
  60129. }
  60130. if (rank > this._maxRank) {
  60131. this._maxRank = rank;
  60132. }
  60133. };
  60134. Object.defineProperty(EffectFallbacks.prototype, "isMoreFallbacks", {
  60135. /**
  60136. * Checks to see if more fallbacks are still availible.
  60137. */
  60138. get: function () {
  60139. return this._currentRank <= this._maxRank;
  60140. },
  60141. enumerable: true,
  60142. configurable: true
  60143. });
  60144. /**
  60145. * Removes the defines that shoould be removed when falling back.
  60146. * @param currentDefines defines the current define statements for the shader.
  60147. * @param effect defines the current effect we try to compile
  60148. * @returns The resulting defines with defines of the current rank removed.
  60149. */
  60150. EffectFallbacks.prototype.reduce = function (currentDefines, effect) {
  60151. // First we try to switch to CPU skinning
  60152. if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0 && this._mesh.material) {
  60153. this._mesh.computeBonesUsingShaders = false;
  60154. currentDefines = currentDefines.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0");
  60155. effect._bonesComputationForcedToCPU = true;
  60156. var scene = this._mesh.getScene();
  60157. for (var index = 0; index < scene.meshes.length; index++) {
  60158. var otherMesh = scene.meshes[index];
  60159. if (!otherMesh.material) {
  60160. continue;
  60161. }
  60162. if (!otherMesh.computeBonesUsingShaders || otherMesh.numBoneInfluencers === 0) {
  60163. continue;
  60164. }
  60165. if (otherMesh.material.getEffect() === effect) {
  60166. otherMesh.computeBonesUsingShaders = false;
  60167. }
  60168. else if (otherMesh.subMeshes) {
  60169. for (var _i = 0, _a = otherMesh.subMeshes; _i < _a.length; _i++) {
  60170. var subMesh = _a[_i];
  60171. var subMeshEffect = subMesh.effect;
  60172. if (subMeshEffect === effect) {
  60173. otherMesh.computeBonesUsingShaders = false;
  60174. break;
  60175. }
  60176. }
  60177. }
  60178. }
  60179. }
  60180. else {
  60181. var currentFallbacks = this._defines[this._currentRank];
  60182. if (currentFallbacks) {
  60183. for (var index = 0; index < currentFallbacks.length; index++) {
  60184. currentDefines = currentDefines.replace("#define " + currentFallbacks[index], "");
  60185. }
  60186. }
  60187. this._currentRank++;
  60188. }
  60189. return currentDefines;
  60190. };
  60191. return EffectFallbacks;
  60192. }());
  60193. /**
  60194. * Options to be used when creating an effect.
  60195. */
  60196. var EffectCreationOptions = /** @class */ (function () {
  60197. function EffectCreationOptions() {
  60198. }
  60199. return EffectCreationOptions;
  60200. }());
  60201. /**
  60202. * Effect containing vertex and fragment shader that can be executed on an object.
  60203. */
  60204. var Effect = /** @class */ (function () {
  60205. /**
  60206. * Instantiates an effect.
  60207. * An effect can be used to create/manage/execute vertex and fragment shaders.
  60208. * @param baseName Name of the effect.
  60209. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  60210. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  60211. * @param samplers List of sampler variables that will be passed to the shader.
  60212. * @param engine Engine to be used to render the effect
  60213. * @param defines Define statements to be added to the shader.
  60214. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  60215. * @param onCompiled Callback that will be called when the shader is compiled.
  60216. * @param onError Callback that will be called if an error occurs during shader compilation.
  60217. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  60218. */
  60219. function Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, engine, defines, fallbacks, onCompiled, onError, indexParameters) {
  60220. if (samplers === void 0) { samplers = null; }
  60221. if (defines === void 0) { defines = null; }
  60222. if (fallbacks === void 0) { fallbacks = null; }
  60223. if (onCompiled === void 0) { onCompiled = null; }
  60224. if (onError === void 0) { onError = null; }
  60225. var _this = this;
  60226. /**
  60227. * Unique ID of the effect.
  60228. */
  60229. this.uniqueId = 0;
  60230. /**
  60231. * Observable that will be called when the shader is compiled.
  60232. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  60233. */
  60234. this.onCompileObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  60235. /**
  60236. * Observable that will be called if an error occurs during shader compilation.
  60237. */
  60238. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  60239. /** @hidden */
  60240. this._bonesComputationForcedToCPU = false;
  60241. this._uniformBuffersNames = {};
  60242. this._isReady = false;
  60243. this._compilationError = "";
  60244. this.name = baseName;
  60245. if (attributesNamesOrOptions.attributes) {
  60246. var options = attributesNamesOrOptions;
  60247. this._engine = uniformsNamesOrEngine;
  60248. this._attributesNames = options.attributes;
  60249. this._uniformsNames = options.uniformsNames.concat(options.samplers);
  60250. this._samplers = options.samplers.slice();
  60251. this.defines = options.defines;
  60252. this.onError = options.onError;
  60253. this.onCompiled = options.onCompiled;
  60254. this._fallbacks = options.fallbacks;
  60255. this._indexParameters = options.indexParameters;
  60256. this._transformFeedbackVaryings = options.transformFeedbackVaryings;
  60257. if (options.uniformBuffersNames) {
  60258. for (var i = 0; i < options.uniformBuffersNames.length; i++) {
  60259. this._uniformBuffersNames[options.uniformBuffersNames[i]] = i;
  60260. }
  60261. }
  60262. }
  60263. else {
  60264. this._engine = engine;
  60265. this.defines = defines;
  60266. this._uniformsNames = uniformsNamesOrEngine.concat(samplers);
  60267. this._samplers = samplers ? samplers.slice() : [];
  60268. this._attributesNames = attributesNamesOrOptions;
  60269. this.onError = onError;
  60270. this.onCompiled = onCompiled;
  60271. this._indexParameters = indexParameters;
  60272. this._fallbacks = fallbacks;
  60273. }
  60274. this.uniqueId = Effect._uniqueIdSeed++;
  60275. var vertexSource;
  60276. var fragmentSource;
  60277. if (baseName.vertexElement) {
  60278. vertexSource = document.getElementById(baseName.vertexElement);
  60279. if (!vertexSource) {
  60280. vertexSource = baseName.vertexElement;
  60281. }
  60282. }
  60283. else {
  60284. vertexSource = baseName.vertex || baseName;
  60285. }
  60286. if (baseName.fragmentElement) {
  60287. fragmentSource = document.getElementById(baseName.fragmentElement);
  60288. if (!fragmentSource) {
  60289. fragmentSource = baseName.fragmentElement;
  60290. }
  60291. }
  60292. else {
  60293. fragmentSource = baseName.fragment || baseName;
  60294. }
  60295. this._loadVertexShader(vertexSource, function (vertexCode) {
  60296. _this._processIncludes(vertexCode, function (vertexCodeWithIncludes) {
  60297. _this._processShaderConversion(vertexCodeWithIncludes, false, function (migratedVertexCode) {
  60298. _this._loadFragmentShader(fragmentSource, function (fragmentCode) {
  60299. _this._processIncludes(fragmentCode, function (fragmentCodeWithIncludes) {
  60300. _this._processShaderConversion(fragmentCodeWithIncludes, true, function (migratedFragmentCode) {
  60301. if (baseName) {
  60302. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  60303. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  60304. _this._vertexSourceCode = "#define SHADER_NAME vertex:" + vertex + "\n" + migratedVertexCode;
  60305. _this._fragmentSourceCode = "#define SHADER_NAME fragment:" + fragment + "\n" + migratedFragmentCode;
  60306. }
  60307. else {
  60308. _this._vertexSourceCode = migratedVertexCode;
  60309. _this._fragmentSourceCode = migratedFragmentCode;
  60310. }
  60311. _this._prepareEffect();
  60312. });
  60313. });
  60314. });
  60315. });
  60316. });
  60317. });
  60318. }
  60319. Object.defineProperty(Effect.prototype, "onBindObservable", {
  60320. /**
  60321. * Observable that will be called when effect is bound.
  60322. */
  60323. get: function () {
  60324. if (!this._onBindObservable) {
  60325. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  60326. }
  60327. return this._onBindObservable;
  60328. },
  60329. enumerable: true,
  60330. configurable: true
  60331. });
  60332. Object.defineProperty(Effect.prototype, "key", {
  60333. /**
  60334. * Unique key for this effect
  60335. */
  60336. get: function () {
  60337. return this._key;
  60338. },
  60339. enumerable: true,
  60340. configurable: true
  60341. });
  60342. /**
  60343. * If the effect has been compiled and prepared.
  60344. * @returns if the effect is compiled and prepared.
  60345. */
  60346. Effect.prototype.isReady = function () {
  60347. if (!this._isReady && this._program && this._program.isParallelCompiled) {
  60348. return this._engine._isProgramCompiled(this._program);
  60349. }
  60350. return this._isReady;
  60351. };
  60352. /**
  60353. * The engine the effect was initialized with.
  60354. * @returns the engine.
  60355. */
  60356. Effect.prototype.getEngine = function () {
  60357. return this._engine;
  60358. };
  60359. /**
  60360. * The compiled webGL program for the effect
  60361. * @returns the webGL program.
  60362. */
  60363. Effect.prototype.getProgram = function () {
  60364. return this._program;
  60365. };
  60366. /**
  60367. * The set of names of attribute variables for the shader.
  60368. * @returns An array of attribute names.
  60369. */
  60370. Effect.prototype.getAttributesNames = function () {
  60371. return this._attributesNames;
  60372. };
  60373. /**
  60374. * Returns the attribute at the given index.
  60375. * @param index The index of the attribute.
  60376. * @returns The location of the attribute.
  60377. */
  60378. Effect.prototype.getAttributeLocation = function (index) {
  60379. return this._attributes[index];
  60380. };
  60381. /**
  60382. * Returns the attribute based on the name of the variable.
  60383. * @param name of the attribute to look up.
  60384. * @returns the attribute location.
  60385. */
  60386. Effect.prototype.getAttributeLocationByName = function (name) {
  60387. var index = this._attributesNames.indexOf(name);
  60388. return this._attributes[index];
  60389. };
  60390. /**
  60391. * The number of attributes.
  60392. * @returns the numnber of attributes.
  60393. */
  60394. Effect.prototype.getAttributesCount = function () {
  60395. return this._attributes.length;
  60396. };
  60397. /**
  60398. * Gets the index of a uniform variable.
  60399. * @param uniformName of the uniform to look up.
  60400. * @returns the index.
  60401. */
  60402. Effect.prototype.getUniformIndex = function (uniformName) {
  60403. return this._uniformsNames.indexOf(uniformName);
  60404. };
  60405. /**
  60406. * Returns the attribute based on the name of the variable.
  60407. * @param uniformName of the uniform to look up.
  60408. * @returns the location of the uniform.
  60409. */
  60410. Effect.prototype.getUniform = function (uniformName) {
  60411. return this._uniforms[this._uniformsNames.indexOf(uniformName)];
  60412. };
  60413. /**
  60414. * Returns an array of sampler variable names
  60415. * @returns The array of sampler variable neames.
  60416. */
  60417. Effect.prototype.getSamplers = function () {
  60418. return this._samplers;
  60419. };
  60420. /**
  60421. * The error from the last compilation.
  60422. * @returns the error string.
  60423. */
  60424. Effect.prototype.getCompilationError = function () {
  60425. return this._compilationError;
  60426. };
  60427. /**
  60428. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  60429. * @param func The callback to be used.
  60430. */
  60431. Effect.prototype.executeWhenCompiled = function (func) {
  60432. var _this = this;
  60433. if (this.isReady()) {
  60434. func(this);
  60435. return;
  60436. }
  60437. this.onCompileObservable.add(function (effect) {
  60438. func(effect);
  60439. });
  60440. if (!this._program || this._program.isParallelCompiled) {
  60441. setTimeout(function () {
  60442. _this._checkIsReady();
  60443. }, 16);
  60444. }
  60445. };
  60446. Effect.prototype._checkIsReady = function () {
  60447. var _this = this;
  60448. if (this.isReady()) {
  60449. return;
  60450. }
  60451. setTimeout(function () {
  60452. _this._checkIsReady();
  60453. }, 16);
  60454. };
  60455. /** @hidden */
  60456. Effect.prototype._loadVertexShader = function (vertex, callback) {
  60457. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  60458. // DOM element ?
  60459. if (vertex instanceof HTMLElement) {
  60460. var vertexCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(vertex);
  60461. callback(vertexCode);
  60462. return;
  60463. }
  60464. }
  60465. // Base64 encoded ?
  60466. if (vertex.substr(0, 7) === "base64:") {
  60467. var vertexBinary = window.atob(vertex.substr(7));
  60468. callback(vertexBinary);
  60469. return;
  60470. }
  60471. // Is in local store ?
  60472. if (Effect.ShadersStore[vertex + "VertexShader"]) {
  60473. callback(Effect.ShadersStore[vertex + "VertexShader"]);
  60474. return;
  60475. }
  60476. var vertexShaderUrl;
  60477. if (vertex[0] === "." || vertex[0] === "/" || vertex.indexOf("http") > -1) {
  60478. vertexShaderUrl = vertex;
  60479. }
  60480. else {
  60481. vertexShaderUrl = Effect.ShadersRepository + vertex;
  60482. }
  60483. // Vertex shader
  60484. this._engine._loadFile(vertexShaderUrl + ".vertex.fx", callback);
  60485. };
  60486. /** @hidden */
  60487. Effect.prototype._loadFragmentShader = function (fragment, callback) {
  60488. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  60489. // DOM element ?
  60490. if (fragment instanceof HTMLElement) {
  60491. var fragmentCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(fragment);
  60492. callback(fragmentCode);
  60493. return;
  60494. }
  60495. }
  60496. // Base64 encoded ?
  60497. if (fragment.substr(0, 7) === "base64:") {
  60498. var fragmentBinary = window.atob(fragment.substr(7));
  60499. callback(fragmentBinary);
  60500. return;
  60501. }
  60502. // Is in local store ?
  60503. if (Effect.ShadersStore[fragment + "PixelShader"]) {
  60504. callback(Effect.ShadersStore[fragment + "PixelShader"]);
  60505. return;
  60506. }
  60507. if (Effect.ShadersStore[fragment + "FragmentShader"]) {
  60508. callback(Effect.ShadersStore[fragment + "FragmentShader"]);
  60509. return;
  60510. }
  60511. var fragmentShaderUrl;
  60512. if (fragment[0] === "." || fragment[0] === "/" || fragment.indexOf("http") > -1) {
  60513. fragmentShaderUrl = fragment;
  60514. }
  60515. else {
  60516. fragmentShaderUrl = Effect.ShadersRepository + fragment;
  60517. }
  60518. // Fragment shader
  60519. this._engine._loadFile(fragmentShaderUrl + ".fragment.fx", callback);
  60520. };
  60521. /** @hidden */
  60522. Effect.prototype._dumpShadersSource = function (vertexCode, fragmentCode, defines) {
  60523. // Rebuild shaders source code
  60524. var shaderVersion = (this._engine.webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  60525. var prefix = shaderVersion + (defines ? defines + "\n" : "");
  60526. vertexCode = prefix + vertexCode;
  60527. fragmentCode = prefix + fragmentCode;
  60528. // Number lines of shaders source code
  60529. var i = 2;
  60530. var regex = /\n/gm;
  60531. var formattedVertexCode = "\n1\t" + vertexCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  60532. i = 2;
  60533. var formattedFragmentCode = "\n1\t" + fragmentCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  60534. // Dump shaders name and formatted source code
  60535. if (this.name.vertexElement) {
  60536. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertexElement + formattedVertexCode);
  60537. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragmentElement + formattedFragmentCode);
  60538. }
  60539. else if (this.name.vertex) {
  60540. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertex + formattedVertexCode);
  60541. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragment + formattedFragmentCode);
  60542. }
  60543. else {
  60544. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name + formattedVertexCode);
  60545. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name + formattedFragmentCode);
  60546. }
  60547. };
  60548. Effect.prototype._processShaderConversion = function (sourceCode, isFragment, callback) {
  60549. var preparedSourceCode = this._processPrecision(sourceCode);
  60550. if (this._engine.webGLVersion == 1) {
  60551. callback(preparedSourceCode);
  60552. return;
  60553. }
  60554. // Already converted
  60555. if (preparedSourceCode.indexOf("#version 3") !== -1) {
  60556. callback(preparedSourceCode.replace("#version 300 es", ""));
  60557. return;
  60558. }
  60559. var hasDrawBuffersExtension = preparedSourceCode.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;
  60560. // Remove extensions
  60561. // #extension GL_OES_standard_derivatives : enable
  60562. // #extension GL_EXT_shader_texture_lod : enable
  60563. // #extension GL_EXT_frag_depth : enable
  60564. // #extension GL_EXT_draw_buffers : require
  60565. var regex = /#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;
  60566. var result = preparedSourceCode.replace(regex, "");
  60567. // Migrate to GLSL v300
  60568. result = result.replace(/varying(?![\n\r])\s/g, isFragment ? "in " : "out ");
  60569. result = result.replace(/attribute[ \t]/g, "in ");
  60570. result = result.replace(/[ \t]attribute/g, " in");
  60571. result = result.replace(/texture2D\s*\(/g, "texture(");
  60572. if (isFragment) {
  60573. result = result.replace(/texture2DLodEXT\s*\(/g, "textureLod(");
  60574. result = result.replace(/textureCubeLodEXT\s*\(/g, "textureLod(");
  60575. result = result.replace(/textureCube\s*\(/g, "texture(");
  60576. result = result.replace(/gl_FragDepthEXT/g, "gl_FragDepth");
  60577. result = result.replace(/gl_FragColor/g, "glFragColor");
  60578. result = result.replace(/gl_FragData/g, "glFragData");
  60579. result = result.replace(/void\s+?main\s*\(/g, (hasDrawBuffersExtension ? "" : "out vec4 glFragColor;\n") + "void main(");
  60580. }
  60581. callback(result);
  60582. };
  60583. Effect.prototype._processIncludes = function (sourceCode, callback) {
  60584. var _this = this;
  60585. var regex = /#include<(.+)>(\((.*)\))*(\[(.*)\])*/g;
  60586. var match = regex.exec(sourceCode);
  60587. var returnValue = new String(sourceCode);
  60588. while (match != null) {
  60589. var includeFile = match[1];
  60590. // Uniform declaration
  60591. if (includeFile.indexOf("__decl__") !== -1) {
  60592. includeFile = includeFile.replace(/__decl__/, "");
  60593. if (this._engine.supportsUniformBuffers) {
  60594. includeFile = includeFile.replace(/Vertex/, "Ubo");
  60595. includeFile = includeFile.replace(/Fragment/, "Ubo");
  60596. }
  60597. includeFile = includeFile + "Declaration";
  60598. }
  60599. if (Effect.IncludesShadersStore[includeFile]) {
  60600. // Substitution
  60601. var includeContent = Effect.IncludesShadersStore[includeFile];
  60602. if (match[2]) {
  60603. var splits = match[3].split(",");
  60604. for (var index = 0; index < splits.length; index += 2) {
  60605. var source = new RegExp(splits[index], "g");
  60606. var dest = splits[index + 1];
  60607. includeContent = includeContent.replace(source, dest);
  60608. }
  60609. }
  60610. if (match[4]) {
  60611. var indexString = match[5];
  60612. if (indexString.indexOf("..") !== -1) {
  60613. var indexSplits = indexString.split("..");
  60614. var minIndex = parseInt(indexSplits[0]);
  60615. var maxIndex = parseInt(indexSplits[1]);
  60616. var sourceIncludeContent = includeContent.slice(0);
  60617. includeContent = "";
  60618. if (isNaN(maxIndex)) {
  60619. maxIndex = this._indexParameters[indexSplits[1]];
  60620. }
  60621. for (var i = minIndex; i < maxIndex; i++) {
  60622. if (!this._engine.supportsUniformBuffers) {
  60623. // Ubo replacement
  60624. sourceIncludeContent = sourceIncludeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  60625. return p1 + "{X}";
  60626. });
  60627. }
  60628. includeContent += sourceIncludeContent.replace(/\{X\}/g, i.toString()) + "\n";
  60629. }
  60630. }
  60631. else {
  60632. if (!this._engine.supportsUniformBuffers) {
  60633. // Ubo replacement
  60634. includeContent = includeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  60635. return p1 + "{X}";
  60636. });
  60637. }
  60638. includeContent = includeContent.replace(/\{X\}/g, indexString);
  60639. }
  60640. }
  60641. // Replace
  60642. returnValue = returnValue.replace(match[0], includeContent);
  60643. }
  60644. else {
  60645. var includeShaderUrl = Effect.ShadersRepository + "ShadersInclude/" + includeFile + ".fx";
  60646. this._engine._loadFile(includeShaderUrl, function (fileContent) {
  60647. Effect.IncludesShadersStore[includeFile] = fileContent;
  60648. _this._processIncludes(returnValue, callback);
  60649. });
  60650. return;
  60651. }
  60652. match = regex.exec(sourceCode);
  60653. }
  60654. callback(returnValue);
  60655. };
  60656. Effect.prototype._processPrecision = function (source) {
  60657. if (source.indexOf("precision highp float") === -1) {
  60658. if (!this._engine.getCaps().highPrecisionShaderSupported) {
  60659. source = "precision mediump float;\n" + source;
  60660. }
  60661. else {
  60662. source = "precision highp float;\n" + source;
  60663. }
  60664. }
  60665. else {
  60666. if (!this._engine.getCaps().highPrecisionShaderSupported) { // Moving highp to mediump
  60667. source = source.replace("precision highp float", "precision mediump float");
  60668. }
  60669. }
  60670. return source;
  60671. };
  60672. /**
  60673. * Recompiles the webGL program
  60674. * @param vertexSourceCode The source code for the vertex shader.
  60675. * @param fragmentSourceCode The source code for the fragment shader.
  60676. * @param onCompiled Callback called when completed.
  60677. * @param onError Callback called on error.
  60678. * @hidden
  60679. */
  60680. Effect.prototype._rebuildProgram = function (vertexSourceCode, fragmentSourceCode, onCompiled, onError) {
  60681. var _this = this;
  60682. this._isReady = false;
  60683. this._vertexSourceCodeOverride = vertexSourceCode;
  60684. this._fragmentSourceCodeOverride = fragmentSourceCode;
  60685. this.onError = function (effect, error) {
  60686. if (onError) {
  60687. onError(error);
  60688. }
  60689. };
  60690. this.onCompiled = function () {
  60691. var scenes = _this.getEngine().scenes;
  60692. for (var i = 0; i < scenes.length; i++) {
  60693. scenes[i].markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  60694. }
  60695. if (onCompiled) {
  60696. onCompiled(_this._program);
  60697. }
  60698. };
  60699. this._fallbacks = null;
  60700. this._prepareEffect();
  60701. };
  60702. /**
  60703. * Gets the uniform locations of the the specified variable names
  60704. * @param names THe names of the variables to lookup.
  60705. * @returns Array of locations in the same order as variable names.
  60706. */
  60707. Effect.prototype.getSpecificUniformLocations = function (names) {
  60708. var engine = this._engine;
  60709. return engine.getUniforms(this._program, names);
  60710. };
  60711. /**
  60712. * Prepares the effect
  60713. * @hidden
  60714. */
  60715. Effect.prototype._prepareEffect = function () {
  60716. var _this = this;
  60717. var attributesNames = this._attributesNames;
  60718. var defines = this.defines;
  60719. var fallbacks = this._fallbacks;
  60720. this._valueCache = {};
  60721. var previousProgram = this._program;
  60722. try {
  60723. var engine_1 = this._engine;
  60724. if (this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride) {
  60725. this._program = engine_1.createRawShaderProgram(this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, undefined, this._transformFeedbackVaryings);
  60726. }
  60727. else {
  60728. this._program = engine_1.createShaderProgram(this._vertexSourceCode, this._fragmentSourceCode, defines, undefined, this._transformFeedbackVaryings);
  60729. }
  60730. this._program.__SPECTOR_rebuildProgram = this._rebuildProgram.bind(this);
  60731. engine_1._executeWhenProgramIsCompiled(this._program, function () {
  60732. if (engine_1.supportsUniformBuffers) {
  60733. for (var name in _this._uniformBuffersNames) {
  60734. _this.bindUniformBlock(name, _this._uniformBuffersNames[name]);
  60735. }
  60736. }
  60737. _this._uniforms = engine_1.getUniforms(_this._program, _this._uniformsNames);
  60738. _this._attributes = engine_1.getAttributes(_this._program, attributesNames);
  60739. var index;
  60740. for (index = 0; index < _this._samplers.length; index++) {
  60741. var sampler = _this.getUniform(_this._samplers[index]);
  60742. if (sampler == null) {
  60743. _this._samplers.splice(index, 1);
  60744. index--;
  60745. }
  60746. }
  60747. engine_1.bindSamplers(_this);
  60748. _this._compilationError = "";
  60749. _this._isReady = true;
  60750. if (_this.onCompiled) {
  60751. _this.onCompiled(_this);
  60752. }
  60753. _this.onCompileObservable.notifyObservers(_this);
  60754. _this.onCompileObservable.clear();
  60755. // Unbind mesh reference in fallbacks
  60756. if (_this._fallbacks) {
  60757. _this._fallbacks.unBindMesh();
  60758. }
  60759. if (previousProgram) {
  60760. _this.getEngine()._deleteProgram(previousProgram);
  60761. }
  60762. });
  60763. if (this._program.isParallelCompiled) {
  60764. this._checkIsReady();
  60765. }
  60766. }
  60767. catch (e) {
  60768. this._compilationError = e.message;
  60769. // Let's go through fallbacks then
  60770. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Unable to compile effect:");
  60771. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Uniforms: " + this._uniformsNames.map(function (uniform) {
  60772. return " " + uniform;
  60773. }));
  60774. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Attributes: " + attributesNames.map(function (attribute) {
  60775. return " " + attribute;
  60776. }));
  60777. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Error: " + this._compilationError);
  60778. if (previousProgram) {
  60779. this._program = previousProgram;
  60780. this._isReady = true;
  60781. if (this.onError) {
  60782. this.onError(this, this._compilationError);
  60783. }
  60784. this.onErrorObservable.notifyObservers(this);
  60785. }
  60786. if (fallbacks && fallbacks.isMoreFallbacks) {
  60787. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Trying next fallback.");
  60788. this.defines = fallbacks.reduce(this.defines, this);
  60789. this._prepareEffect();
  60790. }
  60791. else { // Sorry we did everything we can
  60792. if (this.onError) {
  60793. this.onError(this, this._compilationError);
  60794. }
  60795. this.onErrorObservable.notifyObservers(this);
  60796. this.onErrorObservable.clear();
  60797. // Unbind mesh reference in fallbacks
  60798. if (this._fallbacks) {
  60799. this._fallbacks.unBindMesh();
  60800. }
  60801. }
  60802. }
  60803. };
  60804. Object.defineProperty(Effect.prototype, "isSupported", {
  60805. /**
  60806. * Checks if the effect is supported. (Must be called after compilation)
  60807. */
  60808. get: function () {
  60809. return this._compilationError === "";
  60810. },
  60811. enumerable: true,
  60812. configurable: true
  60813. });
  60814. /**
  60815. * Binds a texture to the engine to be used as output of the shader.
  60816. * @param channel Name of the output variable.
  60817. * @param texture Texture to bind.
  60818. * @hidden
  60819. */
  60820. Effect.prototype._bindTexture = function (channel, texture) {
  60821. this._engine._bindTexture(this._samplers.indexOf(channel), texture);
  60822. };
  60823. /**
  60824. * Sets a texture on the engine to be used in the shader.
  60825. * @param channel Name of the sampler variable.
  60826. * @param texture Texture to set.
  60827. */
  60828. Effect.prototype.setTexture = function (channel, texture) {
  60829. this._engine.setTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  60830. };
  60831. /**
  60832. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  60833. * @param channel Name of the sampler variable.
  60834. * @param texture Texture to set.
  60835. */
  60836. Effect.prototype.setDepthStencilTexture = function (channel, texture) {
  60837. this._engine.setDepthStencilTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  60838. };
  60839. /**
  60840. * Sets an array of textures on the engine to be used in the shader.
  60841. * @param channel Name of the variable.
  60842. * @param textures Textures to set.
  60843. */
  60844. Effect.prototype.setTextureArray = function (channel, textures) {
  60845. if (this._samplers.indexOf(channel + "Ex") === -1) {
  60846. var initialPos = this._samplers.indexOf(channel);
  60847. for (var index = 1; index < textures.length; index++) {
  60848. this._samplers.splice(initialPos + index, 0, channel + "Ex");
  60849. }
  60850. }
  60851. this._engine.setTextureArray(this._samplers.indexOf(channel), this.getUniform(channel), textures);
  60852. };
  60853. /**
  60854. * 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)
  60855. * @param channel Name of the sampler variable.
  60856. * @param postProcess Post process to get the input texture from.
  60857. */
  60858. Effect.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  60859. this._engine.setTextureFromPostProcess(this._samplers.indexOf(channel), postProcess);
  60860. };
  60861. /**
  60862. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  60863. * 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)
  60864. * @param channel Name of the sampler variable.
  60865. * @param postProcess Post process to get the output texture from.
  60866. */
  60867. Effect.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  60868. this._engine.setTextureFromPostProcessOutput(this._samplers.indexOf(channel), postProcess);
  60869. };
  60870. /** @hidden */
  60871. Effect.prototype._cacheMatrix = function (uniformName, matrix) {
  60872. var cache = this._valueCache[uniformName];
  60873. var flag = matrix.updateFlag;
  60874. if (cache !== undefined && cache === flag) {
  60875. return false;
  60876. }
  60877. this._valueCache[uniformName] = flag;
  60878. return true;
  60879. };
  60880. /** @hidden */
  60881. Effect.prototype._cacheFloat2 = function (uniformName, x, y) {
  60882. var cache = this._valueCache[uniformName];
  60883. if (!cache) {
  60884. cache = [x, y];
  60885. this._valueCache[uniformName] = cache;
  60886. return true;
  60887. }
  60888. var changed = false;
  60889. if (cache[0] !== x) {
  60890. cache[0] = x;
  60891. changed = true;
  60892. }
  60893. if (cache[1] !== y) {
  60894. cache[1] = y;
  60895. changed = true;
  60896. }
  60897. return changed;
  60898. };
  60899. /** @hidden */
  60900. Effect.prototype._cacheFloat3 = function (uniformName, x, y, z) {
  60901. var cache = this._valueCache[uniformName];
  60902. if (!cache) {
  60903. cache = [x, y, z];
  60904. this._valueCache[uniformName] = cache;
  60905. return true;
  60906. }
  60907. var changed = false;
  60908. if (cache[0] !== x) {
  60909. cache[0] = x;
  60910. changed = true;
  60911. }
  60912. if (cache[1] !== y) {
  60913. cache[1] = y;
  60914. changed = true;
  60915. }
  60916. if (cache[2] !== z) {
  60917. cache[2] = z;
  60918. changed = true;
  60919. }
  60920. return changed;
  60921. };
  60922. /** @hidden */
  60923. Effect.prototype._cacheFloat4 = function (uniformName, x, y, z, w) {
  60924. var cache = this._valueCache[uniformName];
  60925. if (!cache) {
  60926. cache = [x, y, z, w];
  60927. this._valueCache[uniformName] = cache;
  60928. return true;
  60929. }
  60930. var changed = false;
  60931. if (cache[0] !== x) {
  60932. cache[0] = x;
  60933. changed = true;
  60934. }
  60935. if (cache[1] !== y) {
  60936. cache[1] = y;
  60937. changed = true;
  60938. }
  60939. if (cache[2] !== z) {
  60940. cache[2] = z;
  60941. changed = true;
  60942. }
  60943. if (cache[3] !== w) {
  60944. cache[3] = w;
  60945. changed = true;
  60946. }
  60947. return changed;
  60948. };
  60949. /**
  60950. * Binds a buffer to a uniform.
  60951. * @param buffer Buffer to bind.
  60952. * @param name Name of the uniform variable to bind to.
  60953. */
  60954. Effect.prototype.bindUniformBuffer = function (buffer, name) {
  60955. var bufferName = this._uniformBuffersNames[name];
  60956. if (bufferName === undefined || Effect._baseCache[bufferName] === buffer) {
  60957. return;
  60958. }
  60959. Effect._baseCache[bufferName] = buffer;
  60960. this._engine.bindUniformBufferBase(buffer, bufferName);
  60961. };
  60962. /**
  60963. * Binds block to a uniform.
  60964. * @param blockName Name of the block to bind.
  60965. * @param index Index to bind.
  60966. */
  60967. Effect.prototype.bindUniformBlock = function (blockName, index) {
  60968. this._engine.bindUniformBlock(this._program, blockName, index);
  60969. };
  60970. /**
  60971. * Sets an interger value on a uniform variable.
  60972. * @param uniformName Name of the variable.
  60973. * @param value Value to be set.
  60974. * @returns this effect.
  60975. */
  60976. Effect.prototype.setInt = function (uniformName, value) {
  60977. var cache = this._valueCache[uniformName];
  60978. if (cache !== undefined && cache === value) {
  60979. return this;
  60980. }
  60981. this._valueCache[uniformName] = value;
  60982. this._engine.setInt(this.getUniform(uniformName), value);
  60983. return this;
  60984. };
  60985. /**
  60986. * Sets an int array on a uniform variable.
  60987. * @param uniformName Name of the variable.
  60988. * @param array array to be set.
  60989. * @returns this effect.
  60990. */
  60991. Effect.prototype.setIntArray = function (uniformName, array) {
  60992. this._valueCache[uniformName] = null;
  60993. this._engine.setIntArray(this.getUniform(uniformName), array);
  60994. return this;
  60995. };
  60996. /**
  60997. * 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)
  60998. * @param uniformName Name of the variable.
  60999. * @param array array to be set.
  61000. * @returns this effect.
  61001. */
  61002. Effect.prototype.setIntArray2 = function (uniformName, array) {
  61003. this._valueCache[uniformName] = null;
  61004. this._engine.setIntArray2(this.getUniform(uniformName), array);
  61005. return this;
  61006. };
  61007. /**
  61008. * 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)
  61009. * @param uniformName Name of the variable.
  61010. * @param array array to be set.
  61011. * @returns this effect.
  61012. */
  61013. Effect.prototype.setIntArray3 = function (uniformName, array) {
  61014. this._valueCache[uniformName] = null;
  61015. this._engine.setIntArray3(this.getUniform(uniformName), array);
  61016. return this;
  61017. };
  61018. /**
  61019. * 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)
  61020. * @param uniformName Name of the variable.
  61021. * @param array array to be set.
  61022. * @returns this effect.
  61023. */
  61024. Effect.prototype.setIntArray4 = function (uniformName, array) {
  61025. this._valueCache[uniformName] = null;
  61026. this._engine.setIntArray4(this.getUniform(uniformName), array);
  61027. return this;
  61028. };
  61029. /**
  61030. * Sets an float array on a uniform variable.
  61031. * @param uniformName Name of the variable.
  61032. * @param array array to be set.
  61033. * @returns this effect.
  61034. */
  61035. Effect.prototype.setFloatArray = function (uniformName, array) {
  61036. this._valueCache[uniformName] = null;
  61037. this._engine.setFloatArray(this.getUniform(uniformName), array);
  61038. return this;
  61039. };
  61040. /**
  61041. * 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)
  61042. * @param uniformName Name of the variable.
  61043. * @param array array to be set.
  61044. * @returns this effect.
  61045. */
  61046. Effect.prototype.setFloatArray2 = function (uniformName, array) {
  61047. this._valueCache[uniformName] = null;
  61048. this._engine.setFloatArray2(this.getUniform(uniformName), array);
  61049. return this;
  61050. };
  61051. /**
  61052. * 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)
  61053. * @param uniformName Name of the variable.
  61054. * @param array array to be set.
  61055. * @returns this effect.
  61056. */
  61057. Effect.prototype.setFloatArray3 = function (uniformName, array) {
  61058. this._valueCache[uniformName] = null;
  61059. this._engine.setFloatArray3(this.getUniform(uniformName), array);
  61060. return this;
  61061. };
  61062. /**
  61063. * 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)
  61064. * @param uniformName Name of the variable.
  61065. * @param array array to be set.
  61066. * @returns this effect.
  61067. */
  61068. Effect.prototype.setFloatArray4 = function (uniformName, array) {
  61069. this._valueCache[uniformName] = null;
  61070. this._engine.setFloatArray4(this.getUniform(uniformName), array);
  61071. return this;
  61072. };
  61073. /**
  61074. * Sets an array on a uniform variable.
  61075. * @param uniformName Name of the variable.
  61076. * @param array array to be set.
  61077. * @returns this effect.
  61078. */
  61079. Effect.prototype.setArray = function (uniformName, array) {
  61080. this._valueCache[uniformName] = null;
  61081. this._engine.setArray(this.getUniform(uniformName), array);
  61082. return this;
  61083. };
  61084. /**
  61085. * 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)
  61086. * @param uniformName Name of the variable.
  61087. * @param array array to be set.
  61088. * @returns this effect.
  61089. */
  61090. Effect.prototype.setArray2 = function (uniformName, array) {
  61091. this._valueCache[uniformName] = null;
  61092. this._engine.setArray2(this.getUniform(uniformName), array);
  61093. return this;
  61094. };
  61095. /**
  61096. * 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)
  61097. * @param uniformName Name of the variable.
  61098. * @param array array to be set.
  61099. * @returns this effect.
  61100. */
  61101. Effect.prototype.setArray3 = function (uniformName, array) {
  61102. this._valueCache[uniformName] = null;
  61103. this._engine.setArray3(this.getUniform(uniformName), array);
  61104. return this;
  61105. };
  61106. /**
  61107. * 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)
  61108. * @param uniformName Name of the variable.
  61109. * @param array array to be set.
  61110. * @returns this effect.
  61111. */
  61112. Effect.prototype.setArray4 = function (uniformName, array) {
  61113. this._valueCache[uniformName] = null;
  61114. this._engine.setArray4(this.getUniform(uniformName), array);
  61115. return this;
  61116. };
  61117. /**
  61118. * Sets matrices on a uniform variable.
  61119. * @param uniformName Name of the variable.
  61120. * @param matrices matrices to be set.
  61121. * @returns this effect.
  61122. */
  61123. Effect.prototype.setMatrices = function (uniformName, matrices) {
  61124. if (!matrices) {
  61125. return this;
  61126. }
  61127. this._valueCache[uniformName] = null;
  61128. this._engine.setMatrices(this.getUniform(uniformName), matrices);
  61129. return this;
  61130. };
  61131. /**
  61132. * Sets matrix on a uniform variable.
  61133. * @param uniformName Name of the variable.
  61134. * @param matrix matrix to be set.
  61135. * @returns this effect.
  61136. */
  61137. Effect.prototype.setMatrix = function (uniformName, matrix) {
  61138. if (this._cacheMatrix(uniformName, matrix)) {
  61139. this._engine.setMatrix(this.getUniform(uniformName), matrix);
  61140. }
  61141. return this;
  61142. };
  61143. /**
  61144. * 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)
  61145. * @param uniformName Name of the variable.
  61146. * @param matrix matrix to be set.
  61147. * @returns this effect.
  61148. */
  61149. Effect.prototype.setMatrix3x3 = function (uniformName, matrix) {
  61150. this._valueCache[uniformName] = null;
  61151. this._engine.setMatrix3x3(this.getUniform(uniformName), matrix);
  61152. return this;
  61153. };
  61154. /**
  61155. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  61156. * @param uniformName Name of the variable.
  61157. * @param matrix matrix to be set.
  61158. * @returns this effect.
  61159. */
  61160. Effect.prototype.setMatrix2x2 = function (uniformName, matrix) {
  61161. this._valueCache[uniformName] = null;
  61162. this._engine.setMatrix2x2(this.getUniform(uniformName), matrix);
  61163. return this;
  61164. };
  61165. /**
  61166. * Sets a float on a uniform variable.
  61167. * @param uniformName Name of the variable.
  61168. * @param value value to be set.
  61169. * @returns this effect.
  61170. */
  61171. Effect.prototype.setFloat = function (uniformName, value) {
  61172. var cache = this._valueCache[uniformName];
  61173. if (cache !== undefined && cache === value) {
  61174. return this;
  61175. }
  61176. this._valueCache[uniformName] = value;
  61177. this._engine.setFloat(this.getUniform(uniformName), value);
  61178. return this;
  61179. };
  61180. /**
  61181. * Sets a boolean on a uniform variable.
  61182. * @param uniformName Name of the variable.
  61183. * @param bool value to be set.
  61184. * @returns this effect.
  61185. */
  61186. Effect.prototype.setBool = function (uniformName, bool) {
  61187. var cache = this._valueCache[uniformName];
  61188. if (cache !== undefined && cache === bool) {
  61189. return this;
  61190. }
  61191. this._valueCache[uniformName] = bool;
  61192. this._engine.setBool(this.getUniform(uniformName), bool ? 1 : 0);
  61193. return this;
  61194. };
  61195. /**
  61196. * Sets a Vector2 on a uniform variable.
  61197. * @param uniformName Name of the variable.
  61198. * @param vector2 vector2 to be set.
  61199. * @returns this effect.
  61200. */
  61201. Effect.prototype.setVector2 = function (uniformName, vector2) {
  61202. if (this._cacheFloat2(uniformName, vector2.x, vector2.y)) {
  61203. this._engine.setFloat2(this.getUniform(uniformName), vector2.x, vector2.y);
  61204. }
  61205. return this;
  61206. };
  61207. /**
  61208. * Sets a float2 on a uniform variable.
  61209. * @param uniformName Name of the variable.
  61210. * @param x First float in float2.
  61211. * @param y Second float in float2.
  61212. * @returns this effect.
  61213. */
  61214. Effect.prototype.setFloat2 = function (uniformName, x, y) {
  61215. if (this._cacheFloat2(uniformName, x, y)) {
  61216. this._engine.setFloat2(this.getUniform(uniformName), x, y);
  61217. }
  61218. return this;
  61219. };
  61220. /**
  61221. * Sets a Vector3 on a uniform variable.
  61222. * @param uniformName Name of the variable.
  61223. * @param vector3 Value to be set.
  61224. * @returns this effect.
  61225. */
  61226. Effect.prototype.setVector3 = function (uniformName, vector3) {
  61227. if (this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z)) {
  61228. this._engine.setFloat3(this.getUniform(uniformName), vector3.x, vector3.y, vector3.z);
  61229. }
  61230. return this;
  61231. };
  61232. /**
  61233. * Sets a float3 on a uniform variable.
  61234. * @param uniformName Name of the variable.
  61235. * @param x First float in float3.
  61236. * @param y Second float in float3.
  61237. * @param z Third float in float3.
  61238. * @returns this effect.
  61239. */
  61240. Effect.prototype.setFloat3 = function (uniformName, x, y, z) {
  61241. if (this._cacheFloat3(uniformName, x, y, z)) {
  61242. this._engine.setFloat3(this.getUniform(uniformName), x, y, z);
  61243. }
  61244. return this;
  61245. };
  61246. /**
  61247. * Sets a Vector4 on a uniform variable.
  61248. * @param uniformName Name of the variable.
  61249. * @param vector4 Value to be set.
  61250. * @returns this effect.
  61251. */
  61252. Effect.prototype.setVector4 = function (uniformName, vector4) {
  61253. if (this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w)) {
  61254. this._engine.setFloat4(this.getUniform(uniformName), vector4.x, vector4.y, vector4.z, vector4.w);
  61255. }
  61256. return this;
  61257. };
  61258. /**
  61259. * Sets a float4 on a uniform variable.
  61260. * @param uniformName Name of the variable.
  61261. * @param x First float in float4.
  61262. * @param y Second float in float4.
  61263. * @param z Third float in float4.
  61264. * @param w Fourth float in float4.
  61265. * @returns this effect.
  61266. */
  61267. Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {
  61268. if (this._cacheFloat4(uniformName, x, y, z, w)) {
  61269. this._engine.setFloat4(this.getUniform(uniformName), x, y, z, w);
  61270. }
  61271. return this;
  61272. };
  61273. /**
  61274. * Sets a Color3 on a uniform variable.
  61275. * @param uniformName Name of the variable.
  61276. * @param color3 Value to be set.
  61277. * @returns this effect.
  61278. */
  61279. Effect.prototype.setColor3 = function (uniformName, color3) {
  61280. if (this._cacheFloat3(uniformName, color3.r, color3.g, color3.b)) {
  61281. this._engine.setColor3(this.getUniform(uniformName), color3);
  61282. }
  61283. return this;
  61284. };
  61285. /**
  61286. * Sets a Color4 on a uniform variable.
  61287. * @param uniformName Name of the variable.
  61288. * @param color3 Value to be set.
  61289. * @param alpha Alpha value to be set.
  61290. * @returns this effect.
  61291. */
  61292. Effect.prototype.setColor4 = function (uniformName, color3, alpha) {
  61293. if (this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha)) {
  61294. this._engine.setColor4(this.getUniform(uniformName), color3, alpha);
  61295. }
  61296. return this;
  61297. };
  61298. /**
  61299. * Sets a Color4 on a uniform variable
  61300. * @param uniformName defines the name of the variable
  61301. * @param color4 defines the value to be set
  61302. * @returns this effect.
  61303. */
  61304. Effect.prototype.setDirectColor4 = function (uniformName, color4) {
  61305. if (this._cacheFloat4(uniformName, color4.r, color4.g, color4.b, color4.a)) {
  61306. this._engine.setDirectColor4(this.getUniform(uniformName), color4);
  61307. }
  61308. return this;
  61309. };
  61310. /**
  61311. * This function will add a new shader to the shader store
  61312. * @param name the name of the shader
  61313. * @param pixelShader optional pixel shader content
  61314. * @param vertexShader optional vertex shader content
  61315. */
  61316. Effect.RegisterShader = function (name, pixelShader, vertexShader) {
  61317. if (pixelShader) {
  61318. Effect.ShadersStore[name + "PixelShader"] = pixelShader;
  61319. }
  61320. if (vertexShader) {
  61321. Effect.ShadersStore[name + "VertexShader"] = vertexShader;
  61322. }
  61323. };
  61324. /**
  61325. * Resets the cache of effects.
  61326. */
  61327. Effect.ResetCache = function () {
  61328. Effect._baseCache = {};
  61329. };
  61330. /**
  61331. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  61332. */
  61333. Effect.ShadersRepository = "src/Shaders/";
  61334. Effect._uniqueIdSeed = 0;
  61335. Effect._baseCache = {};
  61336. /**
  61337. * Store of each shader (The can be looked up using effect.key)
  61338. */
  61339. Effect.ShadersStore = {};
  61340. /**
  61341. * Store of each included file for a shader (The can be looked up using effect.key)
  61342. */
  61343. Effect.IncludesShadersStore = {};
  61344. return Effect;
  61345. }());
  61346. /***/ }),
  61347. /***/ "./Materials/fresnelParameters.ts":
  61348. /*!****************************************!*\
  61349. !*** ./Materials/fresnelParameters.ts ***!
  61350. \****************************************/
  61351. /*! exports provided: FresnelParameters */
  61352. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61353. "use strict";
  61354. __webpack_require__.r(__webpack_exports__);
  61355. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return FresnelParameters; });
  61356. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  61357. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  61358. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  61359. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  61360. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  61361. /**
  61362. * This represents all the required information to add a fresnel effect on a material:
  61363. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  61364. */
  61365. var FresnelParameters = /** @class */ (function () {
  61366. function FresnelParameters() {
  61367. this._isEnabled = true;
  61368. /**
  61369. * Define the color used on edges (grazing angle)
  61370. */
  61371. this.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].White();
  61372. /**
  61373. * Define the color used on center
  61374. */
  61375. this.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  61376. /**
  61377. * Define bias applied to computed fresnel term
  61378. */
  61379. this.bias = 0;
  61380. /**
  61381. * Defined the power exponent applied to fresnel term
  61382. */
  61383. this.power = 1;
  61384. }
  61385. Object.defineProperty(FresnelParameters.prototype, "isEnabled", {
  61386. /**
  61387. * Define if the fresnel effect is enable or not.
  61388. */
  61389. get: function () {
  61390. return this._isEnabled;
  61391. },
  61392. set: function (value) {
  61393. if (this._isEnabled === value) {
  61394. return;
  61395. }
  61396. this._isEnabled = value;
  61397. _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);
  61398. },
  61399. enumerable: true,
  61400. configurable: true
  61401. });
  61402. /**
  61403. * Clones the current fresnel and its valuues
  61404. * @returns a clone fresnel configuration
  61405. */
  61406. FresnelParameters.prototype.clone = function () {
  61407. var newFresnelParameters = new FresnelParameters();
  61408. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newFresnelParameters);
  61409. return newFresnelParameters;
  61410. };
  61411. /**
  61412. * Serializes the current fresnel parameters to a JSON representation.
  61413. * @return the JSON serialization
  61414. */
  61415. FresnelParameters.prototype.serialize = function () {
  61416. var serializationObject = {};
  61417. serializationObject.isEnabled = this.isEnabled;
  61418. serializationObject.leftColor = this.leftColor.asArray();
  61419. serializationObject.rightColor = this.rightColor.asArray();
  61420. serializationObject.bias = this.bias;
  61421. serializationObject.power = this.power;
  61422. return serializationObject;
  61423. };
  61424. /**
  61425. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  61426. * @param parsedFresnelParameters Define the JSON representation
  61427. * @returns the parsed parameters
  61428. */
  61429. FresnelParameters.Parse = function (parsedFresnelParameters) {
  61430. var fresnelParameters = new FresnelParameters();
  61431. fresnelParameters.isEnabled = parsedFresnelParameters.isEnabled;
  61432. fresnelParameters.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.leftColor);
  61433. fresnelParameters.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.rightColor);
  61434. fresnelParameters.bias = parsedFresnelParameters.bias;
  61435. fresnelParameters.power = parsedFresnelParameters.power || 1.0;
  61436. return fresnelParameters;
  61437. };
  61438. return FresnelParameters;
  61439. }());
  61440. // References the dependencies.
  61441. _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]._FresnelParametersParser = FresnelParameters.Parse;
  61442. /***/ }),
  61443. /***/ "./Materials/imageProcessingConfiguration.ts":
  61444. /*!***************************************************!*\
  61445. !*** ./Materials/imageProcessingConfiguration.ts ***!
  61446. \***************************************************/
  61447. /*! exports provided: ImageProcessingConfigurationDefines, ImageProcessingConfiguration */
  61448. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61449. "use strict";
  61450. __webpack_require__.r(__webpack_exports__);
  61451. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return ImageProcessingConfigurationDefines; });
  61452. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return ImageProcessingConfiguration; });
  61453. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  61454. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  61455. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  61456. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  61457. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  61458. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  61459. /* harmony import */ var _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/colorCurves */ "./Materials/colorCurves.ts");
  61460. /**
  61461. * @hidden
  61462. */
  61463. var ImageProcessingConfigurationDefines = /** @class */ (function (_super) {
  61464. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingConfigurationDefines, _super);
  61465. function ImageProcessingConfigurationDefines() {
  61466. var _this = _super.call(this) || this;
  61467. _this.IMAGEPROCESSING = false;
  61468. _this.VIGNETTE = false;
  61469. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  61470. _this.VIGNETTEBLENDMODEOPAQUE = false;
  61471. _this.TONEMAPPING = false;
  61472. _this.TONEMAPPING_ACES = false;
  61473. _this.CONTRAST = false;
  61474. _this.COLORCURVES = false;
  61475. _this.COLORGRADING = false;
  61476. _this.COLORGRADING3D = false;
  61477. _this.SAMPLER3DGREENDEPTH = false;
  61478. _this.SAMPLER3DBGRMAP = false;
  61479. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  61480. _this.EXPOSURE = false;
  61481. _this.rebuild();
  61482. return _this;
  61483. }
  61484. return ImageProcessingConfigurationDefines;
  61485. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__["MaterialDefines"]));
  61486. /**
  61487. * This groups together the common properties used for image processing either in direct forward pass
  61488. * or through post processing effect depending on the use of the image processing pipeline in your scene
  61489. * or not.
  61490. */
  61491. var ImageProcessingConfiguration = /** @class */ (function () {
  61492. function ImageProcessingConfiguration() {
  61493. /**
  61494. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  61495. */
  61496. this.colorCurves = new _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"]();
  61497. this._colorCurvesEnabled = false;
  61498. this._colorGradingEnabled = false;
  61499. this._colorGradingWithGreenDepth = true;
  61500. this._colorGradingBGR = true;
  61501. /** @hidden */
  61502. this._exposure = 1.0;
  61503. this._toneMappingEnabled = false;
  61504. this._toneMappingType = ImageProcessingConfiguration.TONEMAPPING_STANDARD;
  61505. this._contrast = 1.0;
  61506. /**
  61507. * Vignette stretch size.
  61508. */
  61509. this.vignetteStretch = 0;
  61510. /**
  61511. * Vignette centre X Offset.
  61512. */
  61513. this.vignetteCentreX = 0;
  61514. /**
  61515. * Vignette centre Y Offset.
  61516. */
  61517. this.vignetteCentreY = 0;
  61518. /**
  61519. * Vignette weight or intensity of the vignette effect.
  61520. */
  61521. this.vignetteWeight = 1.5;
  61522. /**
  61523. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  61524. * if vignetteEnabled is set to true.
  61525. */
  61526. this.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  61527. /**
  61528. * Camera field of view used by the Vignette effect.
  61529. */
  61530. this.vignetteCameraFov = 0.5;
  61531. this._vignetteBlendMode = ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;
  61532. this._vignetteEnabled = false;
  61533. this._applyByPostProcess = false;
  61534. this._isEnabled = true;
  61535. /**
  61536. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  61537. */
  61538. this.onUpdateParameters = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  61539. }
  61540. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorCurvesEnabled", {
  61541. /**
  61542. * Gets wether the color curves effect is enabled.
  61543. */
  61544. get: function () {
  61545. return this._colorCurvesEnabled;
  61546. },
  61547. /**
  61548. * Sets wether the color curves effect is enabled.
  61549. */
  61550. set: function (value) {
  61551. if (this._colorCurvesEnabled === value) {
  61552. return;
  61553. }
  61554. this._colorCurvesEnabled = value;
  61555. this._updateParameters();
  61556. },
  61557. enumerable: true,
  61558. configurable: true
  61559. });
  61560. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingTexture", {
  61561. /**
  61562. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  61563. */
  61564. get: function () {
  61565. return this._colorGradingTexture;
  61566. },
  61567. /**
  61568. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  61569. */
  61570. set: function (value) {
  61571. if (this._colorGradingTexture === value) {
  61572. return;
  61573. }
  61574. this._colorGradingTexture = value;
  61575. this._updateParameters();
  61576. },
  61577. enumerable: true,
  61578. configurable: true
  61579. });
  61580. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingEnabled", {
  61581. /**
  61582. * Gets wether the color grading effect is enabled.
  61583. */
  61584. get: function () {
  61585. return this._colorGradingEnabled;
  61586. },
  61587. /**
  61588. * Sets wether the color grading effect is enabled.
  61589. */
  61590. set: function (value) {
  61591. if (this._colorGradingEnabled === value) {
  61592. return;
  61593. }
  61594. this._colorGradingEnabled = value;
  61595. this._updateParameters();
  61596. },
  61597. enumerable: true,
  61598. configurable: true
  61599. });
  61600. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingWithGreenDepth", {
  61601. /**
  61602. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  61603. */
  61604. get: function () {
  61605. return this._colorGradingWithGreenDepth;
  61606. },
  61607. /**
  61608. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  61609. */
  61610. set: function (value) {
  61611. if (this._colorGradingWithGreenDepth === value) {
  61612. return;
  61613. }
  61614. this._colorGradingWithGreenDepth = value;
  61615. this._updateParameters();
  61616. },
  61617. enumerable: true,
  61618. configurable: true
  61619. });
  61620. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingBGR", {
  61621. /**
  61622. * Gets wether the color grading texture contains BGR values.
  61623. */
  61624. get: function () {
  61625. return this._colorGradingBGR;
  61626. },
  61627. /**
  61628. * Sets wether the color grading texture contains BGR values.
  61629. */
  61630. set: function (value) {
  61631. if (this._colorGradingBGR === value) {
  61632. return;
  61633. }
  61634. this._colorGradingBGR = value;
  61635. this._updateParameters();
  61636. },
  61637. enumerable: true,
  61638. configurable: true
  61639. });
  61640. Object.defineProperty(ImageProcessingConfiguration.prototype, "exposure", {
  61641. /**
  61642. * Gets the Exposure used in the effect.
  61643. */
  61644. get: function () {
  61645. return this._exposure;
  61646. },
  61647. /**
  61648. * Sets the Exposure used in the effect.
  61649. */
  61650. set: function (value) {
  61651. if (this._exposure === value) {
  61652. return;
  61653. }
  61654. this._exposure = value;
  61655. this._updateParameters();
  61656. },
  61657. enumerable: true,
  61658. configurable: true
  61659. });
  61660. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingEnabled", {
  61661. /**
  61662. * Gets wether the tone mapping effect is enabled.
  61663. */
  61664. get: function () {
  61665. return this._toneMappingEnabled;
  61666. },
  61667. /**
  61668. * Sets wether the tone mapping effect is enabled.
  61669. */
  61670. set: function (value) {
  61671. if (this._toneMappingEnabled === value) {
  61672. return;
  61673. }
  61674. this._toneMappingEnabled = value;
  61675. this._updateParameters();
  61676. },
  61677. enumerable: true,
  61678. configurable: true
  61679. });
  61680. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingType", {
  61681. /**
  61682. * Gets the type of tone mapping effect.
  61683. */
  61684. get: function () {
  61685. return this._toneMappingType;
  61686. },
  61687. /**
  61688. * Sets the type of tone mapping effect used in BabylonJS.
  61689. */
  61690. set: function (value) {
  61691. if (this._toneMappingType === value) {
  61692. return;
  61693. }
  61694. this._toneMappingType = value;
  61695. this._updateParameters();
  61696. },
  61697. enumerable: true,
  61698. configurable: true
  61699. });
  61700. Object.defineProperty(ImageProcessingConfiguration.prototype, "contrast", {
  61701. /**
  61702. * Gets the contrast used in the effect.
  61703. */
  61704. get: function () {
  61705. return this._contrast;
  61706. },
  61707. /**
  61708. * Sets the contrast used in the effect.
  61709. */
  61710. set: function (value) {
  61711. if (this._contrast === value) {
  61712. return;
  61713. }
  61714. this._contrast = value;
  61715. this._updateParameters();
  61716. },
  61717. enumerable: true,
  61718. configurable: true
  61719. });
  61720. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteBlendMode", {
  61721. /**
  61722. * Gets the vignette blend mode allowing different kind of effect.
  61723. */
  61724. get: function () {
  61725. return this._vignetteBlendMode;
  61726. },
  61727. /**
  61728. * Sets the vignette blend mode allowing different kind of effect.
  61729. */
  61730. set: function (value) {
  61731. if (this._vignetteBlendMode === value) {
  61732. return;
  61733. }
  61734. this._vignetteBlendMode = value;
  61735. this._updateParameters();
  61736. },
  61737. enumerable: true,
  61738. configurable: true
  61739. });
  61740. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteEnabled", {
  61741. /**
  61742. * Gets wether the vignette effect is enabled.
  61743. */
  61744. get: function () {
  61745. return this._vignetteEnabled;
  61746. },
  61747. /**
  61748. * Sets wether the vignette effect is enabled.
  61749. */
  61750. set: function (value) {
  61751. if (this._vignetteEnabled === value) {
  61752. return;
  61753. }
  61754. this._vignetteEnabled = value;
  61755. this._updateParameters();
  61756. },
  61757. enumerable: true,
  61758. configurable: true
  61759. });
  61760. Object.defineProperty(ImageProcessingConfiguration.prototype, "applyByPostProcess", {
  61761. /**
  61762. * Gets wether the image processing is applied through a post process or not.
  61763. */
  61764. get: function () {
  61765. return this._applyByPostProcess;
  61766. },
  61767. /**
  61768. * Sets wether the image processing is applied through a post process or not.
  61769. */
  61770. set: function (value) {
  61771. if (this._applyByPostProcess === value) {
  61772. return;
  61773. }
  61774. this._applyByPostProcess = value;
  61775. this._updateParameters();
  61776. },
  61777. enumerable: true,
  61778. configurable: true
  61779. });
  61780. Object.defineProperty(ImageProcessingConfiguration.prototype, "isEnabled", {
  61781. /**
  61782. * Gets wether the image processing is enabled or not.
  61783. */
  61784. get: function () {
  61785. return this._isEnabled;
  61786. },
  61787. /**
  61788. * Sets wether the image processing is enabled or not.
  61789. */
  61790. set: function (value) {
  61791. if (this._isEnabled === value) {
  61792. return;
  61793. }
  61794. this._isEnabled = value;
  61795. this._updateParameters();
  61796. },
  61797. enumerable: true,
  61798. configurable: true
  61799. });
  61800. /**
  61801. * Method called each time the image processing information changes requires to recompile the effect.
  61802. */
  61803. ImageProcessingConfiguration.prototype._updateParameters = function () {
  61804. this.onUpdateParameters.notifyObservers(this);
  61805. };
  61806. /**
  61807. * Gets the current class name.
  61808. * @return "ImageProcessingConfiguration"
  61809. */
  61810. ImageProcessingConfiguration.prototype.getClassName = function () {
  61811. return "ImageProcessingConfiguration";
  61812. };
  61813. /**
  61814. * Prepare the list of uniforms associated with the Image Processing effects.
  61815. * @param uniforms The list of uniforms used in the effect
  61816. * @param defines the list of defines currently in use
  61817. */
  61818. ImageProcessingConfiguration.PrepareUniforms = function (uniforms, defines) {
  61819. if (defines.EXPOSURE) {
  61820. uniforms.push("exposureLinear");
  61821. }
  61822. if (defines.CONTRAST) {
  61823. uniforms.push("contrast");
  61824. }
  61825. if (defines.COLORGRADING) {
  61826. uniforms.push("colorTransformSettings");
  61827. }
  61828. if (defines.VIGNETTE) {
  61829. uniforms.push("vInverseScreenSize");
  61830. uniforms.push("vignetteSettings1");
  61831. uniforms.push("vignetteSettings2");
  61832. }
  61833. if (defines.COLORCURVES) {
  61834. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].PrepareUniforms(uniforms);
  61835. }
  61836. };
  61837. /**
  61838. * Prepare the list of samplers associated with the Image Processing effects.
  61839. * @param samplersList The list of uniforms used in the effect
  61840. * @param defines the list of defines currently in use
  61841. */
  61842. ImageProcessingConfiguration.PrepareSamplers = function (samplersList, defines) {
  61843. if (defines.COLORGRADING) {
  61844. samplersList.push("txColorTransform");
  61845. }
  61846. };
  61847. /**
  61848. * Prepare the list of defines associated to the shader.
  61849. * @param defines the list of defines to complete
  61850. * @param forPostProcess Define if we are currently in post process mode or not
  61851. */
  61852. ImageProcessingConfiguration.prototype.prepareDefines = function (defines, forPostProcess) {
  61853. if (forPostProcess === void 0) { forPostProcess = false; }
  61854. if (forPostProcess !== this.applyByPostProcess || !this._isEnabled) {
  61855. defines.VIGNETTE = false;
  61856. defines.TONEMAPPING = false;
  61857. defines.TONEMAPPING_ACES = false;
  61858. defines.CONTRAST = false;
  61859. defines.EXPOSURE = false;
  61860. defines.COLORCURVES = false;
  61861. defines.COLORGRADING = false;
  61862. defines.COLORGRADING3D = false;
  61863. defines.IMAGEPROCESSING = false;
  61864. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled;
  61865. return;
  61866. }
  61867. defines.VIGNETTE = this.vignetteEnabled;
  61868. defines.VIGNETTEBLENDMODEMULTIPLY = (this.vignetteBlendMode === ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY);
  61869. defines.VIGNETTEBLENDMODEOPAQUE = !defines.VIGNETTEBLENDMODEMULTIPLY;
  61870. defines.TONEMAPPING = this.toneMappingEnabled;
  61871. switch (this._toneMappingType) {
  61872. case ImageProcessingConfiguration.TONEMAPPING_ACES:
  61873. defines.TONEMAPPING_ACES = true;
  61874. break;
  61875. default:
  61876. defines.TONEMAPPING_ACES = false;
  61877. break;
  61878. }
  61879. defines.CONTRAST = (this.contrast !== 1.0);
  61880. defines.EXPOSURE = (this.exposure !== 1.0);
  61881. defines.COLORCURVES = (this.colorCurvesEnabled && !!this.colorCurves);
  61882. defines.COLORGRADING = (this.colorGradingEnabled && !!this.colorGradingTexture);
  61883. if (defines.COLORGRADING) {
  61884. defines.COLORGRADING3D = this.colorGradingTexture.is3D;
  61885. }
  61886. else {
  61887. defines.COLORGRADING3D = false;
  61888. }
  61889. defines.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth;
  61890. defines.SAMPLER3DBGRMAP = this.colorGradingBGR;
  61891. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess;
  61892. defines.IMAGEPROCESSING = defines.VIGNETTE || defines.TONEMAPPING || defines.CONTRAST || defines.EXPOSURE || defines.COLORCURVES || defines.COLORGRADING;
  61893. };
  61894. /**
  61895. * Returns true if all the image processing information are ready.
  61896. * @returns True if ready, otherwise, false
  61897. */
  61898. ImageProcessingConfiguration.prototype.isReady = function () {
  61899. // Color Grading texure can not be none blocking.
  61900. return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady();
  61901. };
  61902. /**
  61903. * Binds the image processing to the shader.
  61904. * @param effect The effect to bind to
  61905. * @param aspectRatio Define the current aspect ratio of the effect
  61906. */
  61907. ImageProcessingConfiguration.prototype.bind = function (effect, aspectRatio) {
  61908. if (aspectRatio === void 0) { aspectRatio = 1; }
  61909. // Color Curves
  61910. if (this._colorCurvesEnabled && this.colorCurves) {
  61911. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].Bind(this.colorCurves, effect);
  61912. }
  61913. // Vignette
  61914. if (this._vignetteEnabled) {
  61915. var inverseWidth = 1 / effect.getEngine().getRenderWidth();
  61916. var inverseHeight = 1 / effect.getEngine().getRenderHeight();
  61917. effect.setFloat2("vInverseScreenSize", inverseWidth, inverseHeight);
  61918. var vignetteScaleY = Math.tan(this.vignetteCameraFov * 0.5);
  61919. var vignetteScaleX = vignetteScaleY * aspectRatio;
  61920. var vignetteScaleGeometricMean = Math.sqrt(vignetteScaleX * vignetteScaleY);
  61921. vignetteScaleX = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleX, vignetteScaleGeometricMean, this.vignetteStretch);
  61922. vignetteScaleY = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleY, vignetteScaleGeometricMean, this.vignetteStretch);
  61923. effect.setFloat4("vignetteSettings1", vignetteScaleX, vignetteScaleY, -vignetteScaleX * this.vignetteCentreX, -vignetteScaleY * this.vignetteCentreY);
  61924. var vignettePower = -2.0 * this.vignetteWeight;
  61925. effect.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, vignettePower);
  61926. }
  61927. // Exposure
  61928. effect.setFloat("exposureLinear", this.exposure);
  61929. // Contrast
  61930. effect.setFloat("contrast", this.contrast);
  61931. // Color transform settings
  61932. if (this.colorGradingTexture) {
  61933. effect.setTexture("txColorTransform", this.colorGradingTexture);
  61934. var textureSize = this.colorGradingTexture.getSize().height;
  61935. effect.setFloat4("colorTransformSettings", (textureSize - 1) / textureSize, // textureScale
  61936. 0.5 / textureSize, // textureOffset
  61937. textureSize, // textureSize
  61938. this.colorGradingTexture.level // weight
  61939. );
  61940. }
  61941. };
  61942. /**
  61943. * Clones the current image processing instance.
  61944. * @return The cloned image processing
  61945. */
  61946. ImageProcessingConfiguration.prototype.clone = function () {
  61947. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ImageProcessingConfiguration(); }, this);
  61948. };
  61949. /**
  61950. * Serializes the current image processing instance to a json representation.
  61951. * @return a JSON representation
  61952. */
  61953. ImageProcessingConfiguration.prototype.serialize = function () {
  61954. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  61955. };
  61956. /**
  61957. * Parses the image processing from a json representation.
  61958. * @param source the JSON source to parse
  61959. * @return The parsed image processing
  61960. */
  61961. ImageProcessingConfiguration.Parse = function (source) {
  61962. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ImageProcessingConfiguration(); }, source, null, null);
  61963. };
  61964. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_MULTIPLY", {
  61965. /**
  61966. * Used to apply the vignette as a mix with the pixel color.
  61967. */
  61968. get: function () {
  61969. return this._VIGNETTEMODE_MULTIPLY;
  61970. },
  61971. enumerable: true,
  61972. configurable: true
  61973. });
  61974. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_OPAQUE", {
  61975. /**
  61976. * Used to apply the vignette as a replacement of the pixel color.
  61977. */
  61978. get: function () {
  61979. return this._VIGNETTEMODE_OPAQUE;
  61980. },
  61981. enumerable: true,
  61982. configurable: true
  61983. });
  61984. /**
  61985. * Default tone mapping applied in BabylonJS.
  61986. */
  61987. ImageProcessingConfiguration.TONEMAPPING_STANDARD = 0;
  61988. /**
  61989. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  61990. * to other engines rendering to increase portability.
  61991. */
  61992. ImageProcessingConfiguration.TONEMAPPING_ACES = 1;
  61993. // Static constants associated to the image processing.
  61994. ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY = 0;
  61995. ImageProcessingConfiguration._VIGNETTEMODE_OPAQUE = 1;
  61996. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61997. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColorCurves"])()
  61998. ], ImageProcessingConfiguration.prototype, "colorCurves", void 0);
  61999. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62000. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62001. ], ImageProcessingConfiguration.prototype, "_colorCurvesEnabled", void 0);
  62002. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62003. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("colorGradingTexture")
  62004. ], ImageProcessingConfiguration.prototype, "_colorGradingTexture", void 0);
  62005. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62006. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62007. ], ImageProcessingConfiguration.prototype, "_colorGradingEnabled", void 0);
  62008. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62009. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62010. ], ImageProcessingConfiguration.prototype, "_colorGradingWithGreenDepth", void 0);
  62011. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62012. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62013. ], ImageProcessingConfiguration.prototype, "_colorGradingBGR", void 0);
  62014. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62015. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62016. ], ImageProcessingConfiguration.prototype, "_exposure", void 0);
  62017. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62018. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62019. ], ImageProcessingConfiguration.prototype, "_toneMappingEnabled", void 0);
  62020. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62021. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62022. ], ImageProcessingConfiguration.prototype, "_toneMappingType", void 0);
  62023. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62024. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62025. ], ImageProcessingConfiguration.prototype, "_contrast", void 0);
  62026. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62027. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62028. ], ImageProcessingConfiguration.prototype, "vignetteStretch", void 0);
  62029. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62030. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62031. ], ImageProcessingConfiguration.prototype, "vignetteCentreX", void 0);
  62032. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62033. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62034. ], ImageProcessingConfiguration.prototype, "vignetteCentreY", void 0);
  62035. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62036. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62037. ], ImageProcessingConfiguration.prototype, "vignetteWeight", void 0);
  62038. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62039. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  62040. ], ImageProcessingConfiguration.prototype, "vignetteColor", void 0);
  62041. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62042. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62043. ], ImageProcessingConfiguration.prototype, "vignetteCameraFov", void 0);
  62044. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62045. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62046. ], ImageProcessingConfiguration.prototype, "_vignetteBlendMode", void 0);
  62047. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62048. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62049. ], ImageProcessingConfiguration.prototype, "_vignetteEnabled", void 0);
  62050. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62051. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62052. ], ImageProcessingConfiguration.prototype, "_applyByPostProcess", void 0);
  62053. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62054. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62055. ], ImageProcessingConfiguration.prototype, "_isEnabled", void 0);
  62056. return ImageProcessingConfiguration;
  62057. }());
  62058. // References the dependencies.
  62059. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ImageProcessingConfigurationParser = ImageProcessingConfiguration.Parse;
  62060. /***/ }),
  62061. /***/ "./Materials/index.ts":
  62062. /*!****************************!*\
  62063. !*** ./Materials/index.ts ***!
  62064. \****************************/
  62065. /*! 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 */
  62066. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62067. "use strict";
  62068. __webpack_require__.r(__webpack_exports__);
  62069. /* harmony import */ var _Background_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Background/index */ "./Materials/Background/index.ts");
  62070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Background_index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  62071. /* harmony import */ var _colorCurves__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorCurves */ "./Materials/colorCurves.ts");
  62072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _colorCurves__WEBPACK_IMPORTED_MODULE_1__["ColorCurves"]; });
  62073. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  62074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectFallbacks"]; });
  62075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectCreationOptions"]; });
  62076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["Effect"]; });
  62077. /* harmony import */ var _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fresnelParameters */ "./Materials/fresnelParameters.ts");
  62078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__["FresnelParameters"]; });
  62079. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  62080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfigurationDefines"]; });
  62081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfiguration"]; });
  62082. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  62083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _material__WEBPACK_IMPORTED_MODULE_5__["Material"]; });
  62084. /* harmony import */ var _materialDefines__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./materialDefines */ "./Materials/materialDefines.ts");
  62085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _materialDefines__WEBPACK_IMPORTED_MODULE_6__["MaterialDefines"]; });
  62086. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  62087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"]; });
  62088. /* harmony import */ var _multiMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./multiMaterial */ "./Materials/multiMaterial.ts");
  62089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _multiMaterial__WEBPACK_IMPORTED_MODULE_8__["MultiMaterial"]; });
  62090. /* harmony import */ var _PBR_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./PBR/index */ "./Materials/PBR/index.ts");
  62091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseMaterial"]; });
  62092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseSimpleMaterial"]; });
  62093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMaterial"]; });
  62094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMetallicRoughnessMaterial"]; });
  62095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRSpecularGlossinessMaterial"]; });
  62096. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  62097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _pushMaterial__WEBPACK_IMPORTED_MODULE_10__["PushMaterial"]; });
  62098. /* harmony import */ var _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./shaderMaterial */ "./Materials/shaderMaterial.ts");
  62099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__["ShaderMaterial"]; });
  62100. /* harmony import */ var _standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./standardMaterial */ "./Materials/standardMaterial.ts");
  62101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterialDefines"]; });
  62102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]; });
  62103. /* harmony import */ var _Textures_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Textures/index */ "./Materials/Textures/index.ts");
  62104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["BaseTexture"]; });
  62105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CubeTexture"]; });
  62106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["HDRCubeTexture"]; });
  62107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["InternalTexture"]; });
  62108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DummyInternalTextureTracker"]; });
  62109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MirrorTexture"]; });
  62110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MultiRenderTarget"]; });
  62111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RenderTargetTexture"]; });
  62112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["Texture"]; });
  62113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ColorGradingTexture"]; });
  62114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DynamicTexture"]; });
  62115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTexture"]; });
  62116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawCubeTexture"]; });
  62117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture"]; });
  62118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  62119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RefractionTexture"]; });
  62120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["VideoTexture"]; });
  62121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_DDSTextureLoader"]; });
  62122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_ENVTextureLoader"]; });
  62123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_KTXTextureLoader"]; });
  62124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_TGATextureLoader"]; });
  62125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CustomProceduralTexture"]; });
  62126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["NoiseProceduralTexture"]; });
  62127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTextureSceneComponent"]; });
  62128. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  62129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__["UniformBuffer"]; });
  62130. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  62131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _materialFlags__WEBPACK_IMPORTED_MODULE_15__["MaterialFlags"]; });
  62132. /***/ }),
  62133. /***/ "./Materials/material.ts":
  62134. /*!*******************************!*\
  62135. !*** ./Materials/material.ts ***!
  62136. \*******************************/
  62137. /*! exports provided: Material */
  62138. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62139. "use strict";
  62140. __webpack_require__.r(__webpack_exports__);
  62141. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return Material; });
  62142. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  62143. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  62144. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  62145. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  62146. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  62147. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  62148. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  62149. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  62150. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  62151. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  62152. /**
  62153. * Base class for the main features of a material in Babylon.js
  62154. */
  62155. var Material = /** @class */ (function () {
  62156. /**
  62157. * Creates a material instance
  62158. * @param name defines the name of the material
  62159. * @param scene defines the scene to reference
  62160. * @param doNotAdd specifies if the material should be added to the scene
  62161. */
  62162. function Material(name, scene, doNotAdd) {
  62163. /**
  62164. * Gets or sets user defined metadata
  62165. */
  62166. this.metadata = null;
  62167. /**
  62168. * For internal use only. Please do not use.
  62169. */
  62170. this.reservedDataStore = null;
  62171. /**
  62172. * Specifies if the ready state should be checked on each call
  62173. */
  62174. this.checkReadyOnEveryCall = false;
  62175. /**
  62176. * Specifies if the ready state should be checked once
  62177. */
  62178. this.checkReadyOnlyOnce = false;
  62179. /**
  62180. * The state of the material
  62181. */
  62182. this.state = "";
  62183. /**
  62184. * The alpha value of the material
  62185. */
  62186. this._alpha = 1.0;
  62187. /**
  62188. * Specifies if back face culling is enabled
  62189. */
  62190. this._backFaceCulling = true;
  62191. /**
  62192. * Specifies if the material should be serialized
  62193. */
  62194. this.doNotSerialize = false;
  62195. /**
  62196. * @hidden
  62197. */
  62198. this._storeEffectOnSubMeshes = false;
  62199. /**
  62200. * An event triggered when the material is disposed
  62201. */
  62202. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  62203. /**
  62204. * Stores the value of the alpha mode
  62205. */
  62206. this._alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  62207. /**
  62208. * Stores the state of the need depth pre-pass value
  62209. */
  62210. this._needDepthPrePass = false;
  62211. /**
  62212. * Specifies if depth writing should be disabled
  62213. */
  62214. this.disableDepthWrite = false;
  62215. /**
  62216. * Specifies if depth writing should be forced
  62217. */
  62218. this.forceDepthWrite = false;
  62219. /**
  62220. * Specifies if there should be a separate pass for culling
  62221. */
  62222. this.separateCullingPass = false;
  62223. /**
  62224. * Stores the state specifing if fog should be enabled
  62225. */
  62226. this._fogEnabled = true;
  62227. /**
  62228. * Stores the size of points
  62229. */
  62230. this.pointSize = 1.0;
  62231. /**
  62232. * Stores the z offset value
  62233. */
  62234. this.zOffset = 0;
  62235. /**
  62236. * @hidden
  62237. * Specifies if the material was previously ready
  62238. */
  62239. this._wasPreviouslyReady = false;
  62240. /**
  62241. * Stores the fill mode state
  62242. */
  62243. this._fillMode = Material.TriangleFillMode;
  62244. /** @hidden */
  62245. this._indexInSceneMaterialArray = -1;
  62246. this.name = name;
  62247. this.id = name || _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RandomId();
  62248. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  62249. this.uniqueId = this._scene.getUniqueId();
  62250. if (this._scene.useRightHandedSystem) {
  62251. this.sideOrientation = Material.ClockWiseSideOrientation;
  62252. }
  62253. else {
  62254. this.sideOrientation = Material.CounterClockWiseSideOrientation;
  62255. }
  62256. this._uniformBuffer = new _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__["UniformBuffer"](this._scene.getEngine());
  62257. this._useUBO = this.getScene().getEngine().supportsUniformBuffers;
  62258. if (!doNotAdd) {
  62259. this._scene.addMaterial(this);
  62260. }
  62261. if (this._scene.useMaterialMeshMap) {
  62262. this.meshMap = {};
  62263. }
  62264. }
  62265. Object.defineProperty(Material.prototype, "alpha", {
  62266. /**
  62267. * Gets the alpha value of the material
  62268. */
  62269. get: function () {
  62270. return this._alpha;
  62271. },
  62272. /**
  62273. * Sets the alpha value of the material
  62274. */
  62275. set: function (value) {
  62276. if (this._alpha === value) {
  62277. return;
  62278. }
  62279. this._alpha = value;
  62280. this.markAsDirty(Material.MiscDirtyFlag);
  62281. },
  62282. enumerable: true,
  62283. configurable: true
  62284. });
  62285. Object.defineProperty(Material.prototype, "backFaceCulling", {
  62286. /**
  62287. * Gets the back-face culling state
  62288. */
  62289. get: function () {
  62290. return this._backFaceCulling;
  62291. },
  62292. /**
  62293. * Sets the back-face culling state
  62294. */
  62295. set: function (value) {
  62296. if (this._backFaceCulling === value) {
  62297. return;
  62298. }
  62299. this._backFaceCulling = value;
  62300. this.markAsDirty(Material.TextureDirtyFlag);
  62301. },
  62302. enumerable: true,
  62303. configurable: true
  62304. });
  62305. Object.defineProperty(Material.prototype, "hasRenderTargetTextures", {
  62306. /**
  62307. * Gets a boolean indicating that current material needs to register RTT
  62308. */
  62309. get: function () {
  62310. return false;
  62311. },
  62312. enumerable: true,
  62313. configurable: true
  62314. });
  62315. Object.defineProperty(Material.prototype, "onDispose", {
  62316. /**
  62317. * Called during a dispose event
  62318. */
  62319. set: function (callback) {
  62320. if (this._onDisposeObserver) {
  62321. this.onDisposeObservable.remove(this._onDisposeObserver);
  62322. }
  62323. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  62324. },
  62325. enumerable: true,
  62326. configurable: true
  62327. });
  62328. Object.defineProperty(Material.prototype, "onBindObservable", {
  62329. /**
  62330. * An event triggered when the material is bound
  62331. */
  62332. get: function () {
  62333. if (!this._onBindObservable) {
  62334. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  62335. }
  62336. return this._onBindObservable;
  62337. },
  62338. enumerable: true,
  62339. configurable: true
  62340. });
  62341. Object.defineProperty(Material.prototype, "onBind", {
  62342. /**
  62343. * Called during a bind event
  62344. */
  62345. set: function (callback) {
  62346. if (this._onBindObserver) {
  62347. this.onBindObservable.remove(this._onBindObserver);
  62348. }
  62349. this._onBindObserver = this.onBindObservable.add(callback);
  62350. },
  62351. enumerable: true,
  62352. configurable: true
  62353. });
  62354. Object.defineProperty(Material.prototype, "onUnBindObservable", {
  62355. /**
  62356. * An event triggered when the material is unbound
  62357. */
  62358. get: function () {
  62359. if (!this._onUnBindObservable) {
  62360. this._onUnBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  62361. }
  62362. return this._onUnBindObservable;
  62363. },
  62364. enumerable: true,
  62365. configurable: true
  62366. });
  62367. Object.defineProperty(Material.prototype, "alphaMode", {
  62368. /**
  62369. * Gets the value of the alpha mode
  62370. */
  62371. get: function () {
  62372. return this._alphaMode;
  62373. },
  62374. /**
  62375. * Sets the value of the alpha mode.
  62376. *
  62377. * | Value | Type | Description |
  62378. * | --- | --- | --- |
  62379. * | 0 | ALPHA_DISABLE | |
  62380. * | 1 | ALPHA_ADD | |
  62381. * | 2 | ALPHA_COMBINE | |
  62382. * | 3 | ALPHA_SUBTRACT | |
  62383. * | 4 | ALPHA_MULTIPLY | |
  62384. * | 5 | ALPHA_MAXIMIZED | |
  62385. * | 6 | ALPHA_ONEONE | |
  62386. * | 7 | ALPHA_PREMULTIPLIED | |
  62387. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  62388. * | 9 | ALPHA_INTERPOLATE | |
  62389. * | 10 | ALPHA_SCREENMODE | |
  62390. *
  62391. */
  62392. set: function (value) {
  62393. if (this._alphaMode === value) {
  62394. return;
  62395. }
  62396. this._alphaMode = value;
  62397. this.markAsDirty(Material.TextureDirtyFlag);
  62398. },
  62399. enumerable: true,
  62400. configurable: true
  62401. });
  62402. Object.defineProperty(Material.prototype, "needDepthPrePass", {
  62403. /**
  62404. * Gets the depth pre-pass value
  62405. */
  62406. get: function () {
  62407. return this._needDepthPrePass;
  62408. },
  62409. /**
  62410. * Sets the need depth pre-pass value
  62411. */
  62412. set: function (value) {
  62413. if (this._needDepthPrePass === value) {
  62414. return;
  62415. }
  62416. this._needDepthPrePass = value;
  62417. if (this._needDepthPrePass) {
  62418. this.checkReadyOnEveryCall = true;
  62419. }
  62420. },
  62421. enumerable: true,
  62422. configurable: true
  62423. });
  62424. Object.defineProperty(Material.prototype, "fogEnabled", {
  62425. /**
  62426. * Gets the value of the fog enabled state
  62427. */
  62428. get: function () {
  62429. return this._fogEnabled;
  62430. },
  62431. /**
  62432. * Sets the state for enabling fog
  62433. */
  62434. set: function (value) {
  62435. if (this._fogEnabled === value) {
  62436. return;
  62437. }
  62438. this._fogEnabled = value;
  62439. this.markAsDirty(Material.MiscDirtyFlag);
  62440. },
  62441. enumerable: true,
  62442. configurable: true
  62443. });
  62444. Object.defineProperty(Material.prototype, "wireframe", {
  62445. /**
  62446. * Gets a value specifying if wireframe mode is enabled
  62447. */
  62448. get: function () {
  62449. switch (this._fillMode) {
  62450. case Material.WireFrameFillMode:
  62451. case Material.LineListDrawMode:
  62452. case Material.LineLoopDrawMode:
  62453. case Material.LineStripDrawMode:
  62454. return true;
  62455. }
  62456. return this._scene.forceWireframe;
  62457. },
  62458. /**
  62459. * Sets the state of wireframe mode
  62460. */
  62461. set: function (value) {
  62462. this.fillMode = (value ? Material.WireFrameFillMode : Material.TriangleFillMode);
  62463. },
  62464. enumerable: true,
  62465. configurable: true
  62466. });
  62467. Object.defineProperty(Material.prototype, "pointsCloud", {
  62468. /**
  62469. * Gets the value specifying if point clouds are enabled
  62470. */
  62471. get: function () {
  62472. switch (this._fillMode) {
  62473. case Material.PointFillMode:
  62474. case Material.PointListDrawMode:
  62475. return true;
  62476. }
  62477. return this._scene.forcePointsCloud;
  62478. },
  62479. /**
  62480. * Sets the state of point cloud mode
  62481. */
  62482. set: function (value) {
  62483. this.fillMode = (value ? Material.PointFillMode : Material.TriangleFillMode);
  62484. },
  62485. enumerable: true,
  62486. configurable: true
  62487. });
  62488. Object.defineProperty(Material.prototype, "fillMode", {
  62489. /**
  62490. * Gets the material fill mode
  62491. */
  62492. get: function () {
  62493. return this._fillMode;
  62494. },
  62495. /**
  62496. * Sets the material fill mode
  62497. */
  62498. set: function (value) {
  62499. if (this._fillMode === value) {
  62500. return;
  62501. }
  62502. this._fillMode = value;
  62503. this.markAsDirty(Material.MiscDirtyFlag);
  62504. },
  62505. enumerable: true,
  62506. configurable: true
  62507. });
  62508. /**
  62509. * Returns a string representation of the current material
  62510. * @param fullDetails defines a boolean indicating which levels of logging is desired
  62511. * @returns a string with material information
  62512. */
  62513. Material.prototype.toString = function (fullDetails) {
  62514. var ret = "Name: " + this.name;
  62515. if (fullDetails) {
  62516. }
  62517. return ret;
  62518. };
  62519. /**
  62520. * Gets the class name of the material
  62521. * @returns a string with the class name of the material
  62522. */
  62523. Material.prototype.getClassName = function () {
  62524. return "Material";
  62525. };
  62526. Object.defineProperty(Material.prototype, "isFrozen", {
  62527. /**
  62528. * Specifies if updates for the material been locked
  62529. */
  62530. get: function () {
  62531. return this.checkReadyOnlyOnce;
  62532. },
  62533. enumerable: true,
  62534. configurable: true
  62535. });
  62536. /**
  62537. * Locks updates for the material
  62538. */
  62539. Material.prototype.freeze = function () {
  62540. this.checkReadyOnlyOnce = true;
  62541. };
  62542. /**
  62543. * Unlocks updates for the material
  62544. */
  62545. Material.prototype.unfreeze = function () {
  62546. this.checkReadyOnlyOnce = false;
  62547. };
  62548. /**
  62549. * Specifies if the material is ready to be used
  62550. * @param mesh defines the mesh to check
  62551. * @param useInstances specifies if instances should be used
  62552. * @returns a boolean indicating if the material is ready to be used
  62553. */
  62554. Material.prototype.isReady = function (mesh, useInstances) {
  62555. return true;
  62556. };
  62557. /**
  62558. * Specifies that the submesh is ready to be used
  62559. * @param mesh defines the mesh to check
  62560. * @param subMesh defines which submesh to check
  62561. * @param useInstances specifies that instances should be used
  62562. * @returns a boolean indicating that the submesh is ready or not
  62563. */
  62564. Material.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  62565. return false;
  62566. };
  62567. /**
  62568. * Returns the material effect
  62569. * @returns the effect associated with the material
  62570. */
  62571. Material.prototype.getEffect = function () {
  62572. return this._effect;
  62573. };
  62574. /**
  62575. * Returns the current scene
  62576. * @returns a Scene
  62577. */
  62578. Material.prototype.getScene = function () {
  62579. return this._scene;
  62580. };
  62581. /**
  62582. * Specifies if the material will require alpha blending
  62583. * @returns a boolean specifying if alpha blending is needed
  62584. */
  62585. Material.prototype.needAlphaBlending = function () {
  62586. return (this.alpha < 1.0);
  62587. };
  62588. /**
  62589. * Specifies if the mesh will require alpha blending
  62590. * @param mesh defines the mesh to check
  62591. * @returns a boolean specifying if alpha blending is needed for the mesh
  62592. */
  62593. Material.prototype.needAlphaBlendingForMesh = function (mesh) {
  62594. return this.needAlphaBlending() || (mesh.visibility < 1.0) || mesh.hasVertexAlpha;
  62595. };
  62596. /**
  62597. * Specifies if this material should be rendered in alpha test mode
  62598. * @returns a boolean specifying if an alpha test is needed.
  62599. */
  62600. Material.prototype.needAlphaTesting = function () {
  62601. return false;
  62602. };
  62603. /**
  62604. * Gets the texture used for the alpha test
  62605. * @returns the texture to use for alpha testing
  62606. */
  62607. Material.prototype.getAlphaTestTexture = function () {
  62608. return null;
  62609. };
  62610. /**
  62611. * Marks the material to indicate that it needs to be re-calculated
  62612. */
  62613. Material.prototype.markDirty = function () {
  62614. this._wasPreviouslyReady = false;
  62615. };
  62616. /** @hidden */
  62617. Material.prototype._preBind = function (effect, overrideOrientation) {
  62618. if (overrideOrientation === void 0) { overrideOrientation = null; }
  62619. var engine = this._scene.getEngine();
  62620. var orientation = (overrideOrientation == null) ? this.sideOrientation : overrideOrientation;
  62621. var reverse = orientation === Material.ClockWiseSideOrientation;
  62622. engine.enableEffect(effect ? effect : this._effect);
  62623. engine.setState(this.backFaceCulling, this.zOffset, false, reverse);
  62624. return reverse;
  62625. };
  62626. /**
  62627. * Binds the material to the mesh
  62628. * @param world defines the world transformation matrix
  62629. * @param mesh defines the mesh to bind the material to
  62630. */
  62631. Material.prototype.bind = function (world, mesh) {
  62632. };
  62633. /**
  62634. * Binds the submesh to the material
  62635. * @param world defines the world transformation matrix
  62636. * @param mesh defines the mesh containing the submesh
  62637. * @param subMesh defines the submesh to bind the material to
  62638. */
  62639. Material.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  62640. };
  62641. /**
  62642. * Binds the world matrix to the material
  62643. * @param world defines the world transformation matrix
  62644. */
  62645. Material.prototype.bindOnlyWorldMatrix = function (world) {
  62646. };
  62647. /**
  62648. * Binds the scene's uniform buffer to the effect.
  62649. * @param effect defines the effect to bind to the scene uniform buffer
  62650. * @param sceneUbo defines the uniform buffer storing scene data
  62651. */
  62652. Material.prototype.bindSceneUniformBuffer = function (effect, sceneUbo) {
  62653. sceneUbo.bindToEffect(effect, "Scene");
  62654. };
  62655. /**
  62656. * Binds the view matrix to the effect
  62657. * @param effect defines the effect to bind the view matrix to
  62658. */
  62659. Material.prototype.bindView = function (effect) {
  62660. if (!this._useUBO) {
  62661. effect.setMatrix("view", this.getScene().getViewMatrix());
  62662. }
  62663. else {
  62664. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  62665. }
  62666. };
  62667. /**
  62668. * Binds the view projection matrix to the effect
  62669. * @param effect defines the effect to bind the view projection matrix to
  62670. */
  62671. Material.prototype.bindViewProjection = function (effect) {
  62672. if (!this._useUBO) {
  62673. effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  62674. }
  62675. else {
  62676. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  62677. }
  62678. };
  62679. /**
  62680. * Specifies if material alpha testing should be turned on for the mesh
  62681. * @param mesh defines the mesh to check
  62682. */
  62683. Material.prototype._shouldTurnAlphaTestOn = function (mesh) {
  62684. return (!this.needAlphaBlendingForMesh(mesh) && this.needAlphaTesting());
  62685. };
  62686. /**
  62687. * Processes to execute after binding the material to a mesh
  62688. * @param mesh defines the rendered mesh
  62689. */
  62690. Material.prototype._afterBind = function (mesh) {
  62691. this._scene._cachedMaterial = this;
  62692. if (mesh) {
  62693. this._scene._cachedVisibility = mesh.visibility;
  62694. }
  62695. else {
  62696. this._scene._cachedVisibility = 1;
  62697. }
  62698. if (this._onBindObservable && mesh) {
  62699. this._onBindObservable.notifyObservers(mesh);
  62700. }
  62701. if (this.disableDepthWrite) {
  62702. var engine = this._scene.getEngine();
  62703. this._cachedDepthWriteState = engine.getDepthWrite();
  62704. engine.setDepthWrite(false);
  62705. }
  62706. };
  62707. /**
  62708. * Unbinds the material from the mesh
  62709. */
  62710. Material.prototype.unbind = function () {
  62711. if (this._onUnBindObservable) {
  62712. this._onUnBindObservable.notifyObservers(this);
  62713. }
  62714. if (this.disableDepthWrite) {
  62715. var engine = this._scene.getEngine();
  62716. engine.setDepthWrite(this._cachedDepthWriteState);
  62717. }
  62718. };
  62719. /**
  62720. * Gets the active textures from the material
  62721. * @returns an array of textures
  62722. */
  62723. Material.prototype.getActiveTextures = function () {
  62724. return [];
  62725. };
  62726. /**
  62727. * Specifies if the material uses a texture
  62728. * @param texture defines the texture to check against the material
  62729. * @returns a boolean specifying if the material uses the texture
  62730. */
  62731. Material.prototype.hasTexture = function (texture) {
  62732. return false;
  62733. };
  62734. /**
  62735. * Makes a duplicate of the material, and gives it a new name
  62736. * @param name defines the new name for the duplicated material
  62737. * @returns the cloned material
  62738. */
  62739. Material.prototype.clone = function (name) {
  62740. return null;
  62741. };
  62742. /**
  62743. * Gets the meshes bound to the material
  62744. * @returns an array of meshes bound to the material
  62745. */
  62746. Material.prototype.getBindedMeshes = function () {
  62747. var _this = this;
  62748. if (this.meshMap) {
  62749. var result = new Array();
  62750. for (var meshId in this.meshMap) {
  62751. var mesh = this.meshMap[meshId];
  62752. if (mesh) {
  62753. result.push(mesh);
  62754. }
  62755. }
  62756. return result;
  62757. }
  62758. else {
  62759. var meshes = this._scene.meshes;
  62760. return meshes.filter(function (mesh) { return mesh.material === _this; });
  62761. }
  62762. };
  62763. /**
  62764. * Force shader compilation
  62765. * @param mesh defines the mesh associated with this material
  62766. * @param onCompiled defines a function to execute once the material is compiled
  62767. * @param options defines the options to configure the compilation
  62768. */
  62769. Material.prototype.forceCompilation = function (mesh, onCompiled, options) {
  62770. var _this = this;
  62771. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  62772. var subMesh = new _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__["BaseSubMesh"]();
  62773. var scene = this.getScene();
  62774. var checkReady = function () {
  62775. if (!_this._scene || !_this._scene.getEngine()) {
  62776. return;
  62777. }
  62778. if (subMesh._materialDefines) {
  62779. subMesh._materialDefines._renderId = -1;
  62780. }
  62781. var clipPlaneState = scene.clipPlane;
  62782. if (localOptions.clipPlane) {
  62783. scene.clipPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"](0, 0, 0, 1);
  62784. }
  62785. if (_this._storeEffectOnSubMeshes) {
  62786. if (_this.isReadyForSubMesh(mesh, subMesh)) {
  62787. if (onCompiled) {
  62788. onCompiled(_this);
  62789. }
  62790. }
  62791. else {
  62792. setTimeout(checkReady, 16);
  62793. }
  62794. }
  62795. else {
  62796. if (_this.isReady()) {
  62797. if (onCompiled) {
  62798. onCompiled(_this);
  62799. }
  62800. }
  62801. else {
  62802. setTimeout(checkReady, 16);
  62803. }
  62804. }
  62805. if (localOptions.clipPlane) {
  62806. scene.clipPlane = clipPlaneState;
  62807. }
  62808. };
  62809. checkReady();
  62810. };
  62811. /**
  62812. * Force shader compilation
  62813. * @param mesh defines the mesh that will use this material
  62814. * @param options defines additional options for compiling the shaders
  62815. * @returns a promise that resolves when the compilation completes
  62816. */
  62817. Material.prototype.forceCompilationAsync = function (mesh, options) {
  62818. var _this = this;
  62819. return new Promise(function (resolve) {
  62820. _this.forceCompilation(mesh, function () {
  62821. resolve();
  62822. }, options);
  62823. });
  62824. };
  62825. /**
  62826. * Marks a define in the material to indicate that it needs to be re-computed
  62827. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  62828. */
  62829. Material.prototype.markAsDirty = function (flag) {
  62830. if (this.getScene().blockMaterialDirtyMechanism) {
  62831. return;
  62832. }
  62833. Material._DirtyCallbackArray.length = 0;
  62834. if (flag & Material.TextureDirtyFlag) {
  62835. Material._DirtyCallbackArray.push(Material._TextureDirtyCallBack);
  62836. }
  62837. if (flag & Material.LightDirtyFlag) {
  62838. Material._DirtyCallbackArray.push(Material._LightsDirtyCallBack);
  62839. }
  62840. if (flag & Material.FresnelDirtyFlag) {
  62841. Material._DirtyCallbackArray.push(Material._FresnelDirtyCallBack);
  62842. }
  62843. if (flag & Material.AttributesDirtyFlag) {
  62844. Material._DirtyCallbackArray.push(Material._AttributeDirtyCallBack);
  62845. }
  62846. if (flag & Material.MiscDirtyFlag) {
  62847. Material._DirtyCallbackArray.push(Material._MiscDirtyCallBack);
  62848. }
  62849. if (Material._DirtyCallbackArray.length) {
  62850. this._markAllSubMeshesAsDirty(Material._RunDirtyCallBacks);
  62851. }
  62852. this.getScene().resetCachedMaterial();
  62853. };
  62854. /**
  62855. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  62856. * @param func defines a function which checks material defines against the submeshes
  62857. */
  62858. Material.prototype._markAllSubMeshesAsDirty = function (func) {
  62859. if (this.getScene().blockMaterialDirtyMechanism) {
  62860. return;
  62861. }
  62862. var meshes = this.getScene().meshes;
  62863. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  62864. var mesh = meshes_1[_i];
  62865. if (!mesh.subMeshes) {
  62866. continue;
  62867. }
  62868. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  62869. var subMesh = _b[_a];
  62870. if (subMesh.getMaterial() !== this) {
  62871. continue;
  62872. }
  62873. if (!subMesh._materialDefines) {
  62874. continue;
  62875. }
  62876. func(subMesh._materialDefines);
  62877. }
  62878. }
  62879. };
  62880. /**
  62881. * Indicates that image processing needs to be re-calculated for all submeshes
  62882. */
  62883. Material.prototype._markAllSubMeshesAsImageProcessingDirty = function () {
  62884. this._markAllSubMeshesAsDirty(Material._ImageProcessingDirtyCallBack);
  62885. };
  62886. /**
  62887. * Indicates that textures need to be re-calculated for all submeshes
  62888. */
  62889. Material.prototype._markAllSubMeshesAsTexturesDirty = function () {
  62890. this._markAllSubMeshesAsDirty(Material._TextureDirtyCallBack);
  62891. };
  62892. /**
  62893. * Indicates that fresnel needs to be re-calculated for all submeshes
  62894. */
  62895. Material.prototype._markAllSubMeshesAsFresnelDirty = function () {
  62896. this._markAllSubMeshesAsDirty(Material._FresnelDirtyCallBack);
  62897. };
  62898. /**
  62899. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  62900. */
  62901. Material.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function () {
  62902. this._markAllSubMeshesAsDirty(Material._FresnelAndMiscDirtyCallBack);
  62903. };
  62904. /**
  62905. * Indicates that lights need to be re-calculated for all submeshes
  62906. */
  62907. Material.prototype._markAllSubMeshesAsLightsDirty = function () {
  62908. this._markAllSubMeshesAsDirty(Material._LightsDirtyCallBack);
  62909. };
  62910. /**
  62911. * Indicates that attributes need to be re-calculated for all submeshes
  62912. */
  62913. Material.prototype._markAllSubMeshesAsAttributesDirty = function () {
  62914. this._markAllSubMeshesAsDirty(Material._AttributeDirtyCallBack);
  62915. };
  62916. /**
  62917. * Indicates that misc needs to be re-calculated for all submeshes
  62918. */
  62919. Material.prototype._markAllSubMeshesAsMiscDirty = function () {
  62920. this._markAllSubMeshesAsDirty(Material._MiscDirtyCallBack);
  62921. };
  62922. /**
  62923. * Indicates that textures and misc need to be re-calculated for all submeshes
  62924. */
  62925. Material.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function () {
  62926. this._markAllSubMeshesAsDirty(Material._TextureAndMiscDirtyCallBack);
  62927. };
  62928. /**
  62929. * Disposes the material
  62930. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  62931. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  62932. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  62933. */
  62934. Material.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  62935. var scene = this.getScene();
  62936. // Animations
  62937. scene.stopAnimation(this);
  62938. scene.freeProcessedMaterials();
  62939. // Remove from scene
  62940. scene.removeMaterial(this);
  62941. if (notBoundToMesh !== true) {
  62942. // Remove from meshes
  62943. if (this.meshMap) {
  62944. for (var meshId in this.meshMap) {
  62945. var mesh = this.meshMap[meshId];
  62946. if (mesh) {
  62947. mesh.material = null; // will set the entry in the map to undefined
  62948. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  62949. }
  62950. }
  62951. }
  62952. else {
  62953. var meshes = scene.meshes;
  62954. for (var _i = 0, meshes_2 = meshes; _i < meshes_2.length; _i++) {
  62955. var mesh = meshes_2[_i];
  62956. if (mesh.material === this) {
  62957. mesh.material = null;
  62958. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  62959. }
  62960. }
  62961. }
  62962. }
  62963. this._uniformBuffer.dispose();
  62964. // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
  62965. if (forceDisposeEffect && this._effect) {
  62966. if (!this._storeEffectOnSubMeshes) {
  62967. scene.getEngine()._releaseEffect(this._effect);
  62968. }
  62969. this._effect = null;
  62970. }
  62971. // Callback
  62972. this.onDisposeObservable.notifyObservers(this);
  62973. this.onDisposeObservable.clear();
  62974. if (this._onBindObservable) {
  62975. this._onBindObservable.clear();
  62976. }
  62977. if (this._onUnBindObservable) {
  62978. this._onUnBindObservable.clear();
  62979. }
  62980. };
  62981. /** @hidden */
  62982. Material.prototype.releaseVertexArrayObject = function (mesh, forceDisposeEffect) {
  62983. if (mesh.geometry) {
  62984. var geometry = (mesh.geometry);
  62985. var scene = this.getScene();
  62986. if (this._storeEffectOnSubMeshes) {
  62987. for (var _i = 0, _a = mesh.subMeshes; _i < _a.length; _i++) {
  62988. var subMesh = _a[_i];
  62989. geometry._releaseVertexArrayObject(subMesh._materialEffect);
  62990. if (forceDisposeEffect && subMesh._materialEffect) {
  62991. scene.getEngine()._releaseEffect(subMesh._materialEffect);
  62992. }
  62993. }
  62994. }
  62995. else {
  62996. geometry._releaseVertexArrayObject(this._effect);
  62997. }
  62998. }
  62999. };
  63000. /**
  63001. * Serializes this material
  63002. * @returns the serialized material object
  63003. */
  63004. Material.prototype.serialize = function () {
  63005. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  63006. };
  63007. /**
  63008. * Creates a material from parsed material data
  63009. * @param parsedMaterial defines parsed material data
  63010. * @param scene defines the hosting scene
  63011. * @param rootUrl defines the root URL to use to load textures
  63012. * @returns a new material
  63013. */
  63014. Material.Parse = function (parsedMaterial, scene, rootUrl) {
  63015. if (!parsedMaterial.customType) {
  63016. parsedMaterial.customType = "BABYLON.StandardMaterial";
  63017. }
  63018. else if (parsedMaterial.customType === "BABYLON.PBRMaterial" && parsedMaterial.overloadedAlbedo) {
  63019. parsedMaterial.customType = "BABYLON.LegacyPBRMaterial";
  63020. if (!BABYLON.LegacyPBRMaterial) {
  63021. _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.");
  63022. return;
  63023. }
  63024. }
  63025. var materialType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedMaterial.customType);
  63026. return materialType.Parse(parsedMaterial, scene, rootUrl);
  63027. };
  63028. /**
  63029. * Returns the triangle fill mode
  63030. */
  63031. Material.TriangleFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFillMode;
  63032. /**
  63033. * Returns the wireframe mode
  63034. */
  63035. Material.WireFrameFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_WireFrameFillMode;
  63036. /**
  63037. * Returns the point fill mode
  63038. */
  63039. Material.PointFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointFillMode;
  63040. /**
  63041. * Returns the point list draw mode
  63042. */
  63043. Material.PointListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointListDrawMode;
  63044. /**
  63045. * Returns the line list draw mode
  63046. */
  63047. Material.LineListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineListDrawMode;
  63048. /**
  63049. * Returns the line loop draw mode
  63050. */
  63051. Material.LineLoopDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineLoopDrawMode;
  63052. /**
  63053. * Returns the line strip draw mode
  63054. */
  63055. Material.LineStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineStripDrawMode;
  63056. /**
  63057. * Returns the triangle strip draw mode
  63058. */
  63059. Material.TriangleStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleStripDrawMode;
  63060. /**
  63061. * Returns the triangle fan draw mode
  63062. */
  63063. Material.TriangleFanDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFanDrawMode;
  63064. /**
  63065. * Stores the clock-wise side orientation
  63066. */
  63067. Material.ClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_ClockWiseSideOrientation;
  63068. /**
  63069. * Stores the counter clock-wise side orientation
  63070. */
  63071. Material.CounterClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_CounterClockWiseSideOrientation;
  63072. /**
  63073. * The dirty texture flag value
  63074. */
  63075. Material.TextureDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TextureDirtyFlag;
  63076. /**
  63077. * The dirty light flag value
  63078. */
  63079. Material.LightDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LightDirtyFlag;
  63080. /**
  63081. * The dirty fresnel flag value
  63082. */
  63083. Material.FresnelDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_FresnelDirtyFlag;
  63084. /**
  63085. * The dirty attribute flag value
  63086. */
  63087. Material.AttributesDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AttributesDirtyFlag;
  63088. /**
  63089. * The dirty misc flag value
  63090. */
  63091. Material.MiscDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_MiscDirtyFlag;
  63092. /**
  63093. * The all dirty flag value
  63094. */
  63095. Material.AllDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AllDirtyFlag;
  63096. Material._ImageProcessingDirtyCallBack = function (defines) { return defines.markAsImageProcessingDirty(); };
  63097. Material._TextureDirtyCallBack = function (defines) { return defines.markAsTexturesDirty(); };
  63098. Material._FresnelDirtyCallBack = function (defines) { return defines.markAsFresnelDirty(); };
  63099. Material._MiscDirtyCallBack = function (defines) { return defines.markAsMiscDirty(); };
  63100. Material._LightsDirtyCallBack = function (defines) { return defines.markAsLightDirty(); };
  63101. Material._AttributeDirtyCallBack = function (defines) { return defines.markAsAttributesDirty(); };
  63102. Material._FresnelAndMiscDirtyCallBack = function (defines) {
  63103. Material._FresnelDirtyCallBack(defines);
  63104. Material._MiscDirtyCallBack(defines);
  63105. };
  63106. Material._TextureAndMiscDirtyCallBack = function (defines) {
  63107. Material._TextureDirtyCallBack(defines);
  63108. Material._MiscDirtyCallBack(defines);
  63109. };
  63110. Material._DirtyCallbackArray = [];
  63111. Material._RunDirtyCallBacks = function (defines) {
  63112. for (var _i = 0, _a = Material._DirtyCallbackArray; _i < _a.length; _i++) {
  63113. var cb = _a[_i];
  63114. cb(defines);
  63115. }
  63116. };
  63117. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63118. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63119. ], Material.prototype, "id", void 0);
  63120. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63121. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63122. ], Material.prototype, "uniqueId", void 0);
  63123. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63124. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63125. ], Material.prototype, "name", void 0);
  63126. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63127. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63128. ], Material.prototype, "checkReadyOnEveryCall", void 0);
  63129. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63130. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63131. ], Material.prototype, "checkReadyOnlyOnce", void 0);
  63132. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63133. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63134. ], Material.prototype, "state", void 0);
  63135. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63136. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alpha")
  63137. ], Material.prototype, "_alpha", void 0);
  63138. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63139. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("backFaceCulling")
  63140. ], Material.prototype, "_backFaceCulling", void 0);
  63141. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63142. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63143. ], Material.prototype, "sideOrientation", void 0);
  63144. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63145. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alphaMode")
  63146. ], Material.prototype, "_alphaMode", void 0);
  63147. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63148. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63149. ], Material.prototype, "_needDepthPrePass", void 0);
  63150. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63151. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63152. ], Material.prototype, "disableDepthWrite", void 0);
  63153. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63154. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63155. ], Material.prototype, "forceDepthWrite", void 0);
  63156. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63157. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63158. ], Material.prototype, "separateCullingPass", void 0);
  63159. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63160. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("fogEnabled")
  63161. ], Material.prototype, "_fogEnabled", void 0);
  63162. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63163. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63164. ], Material.prototype, "pointSize", void 0);
  63165. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63166. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63167. ], Material.prototype, "zOffset", void 0);
  63168. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63169. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63170. ], Material.prototype, "wireframe", null);
  63171. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63172. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63173. ], Material.prototype, "pointsCloud", null);
  63174. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63175. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63176. ], Material.prototype, "fillMode", null);
  63177. return Material;
  63178. }());
  63179. /***/ }),
  63180. /***/ "./Materials/materialDefines.ts":
  63181. /*!**************************************!*\
  63182. !*** ./Materials/materialDefines.ts ***!
  63183. \**************************************/
  63184. /*! exports provided: MaterialDefines */
  63185. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63186. "use strict";
  63187. __webpack_require__.r(__webpack_exports__);
  63188. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return MaterialDefines; });
  63189. /**
  63190. * Manages the defines for the Material
  63191. */
  63192. var MaterialDefines = /** @class */ (function () {
  63193. function MaterialDefines() {
  63194. this._isDirty = true;
  63195. /** @hidden */
  63196. this._areLightsDirty = true;
  63197. /** @hidden */
  63198. this._areAttributesDirty = true;
  63199. /** @hidden */
  63200. this._areTexturesDirty = true;
  63201. /** @hidden */
  63202. this._areFresnelDirty = true;
  63203. /** @hidden */
  63204. this._areMiscDirty = true;
  63205. /** @hidden */
  63206. this._areImageProcessingDirty = true;
  63207. /** @hidden */
  63208. this._normals = false;
  63209. /** @hidden */
  63210. this._uvs = false;
  63211. /** @hidden */
  63212. this._needNormals = false;
  63213. /** @hidden */
  63214. this._needUVs = false;
  63215. }
  63216. Object.defineProperty(MaterialDefines.prototype, "isDirty", {
  63217. /**
  63218. * Specifies if the material needs to be re-calculated
  63219. */
  63220. get: function () {
  63221. return this._isDirty;
  63222. },
  63223. enumerable: true,
  63224. configurable: true
  63225. });
  63226. /**
  63227. * Marks the material to indicate that it has been re-calculated
  63228. */
  63229. MaterialDefines.prototype.markAsProcessed = function () {
  63230. this._isDirty = false;
  63231. this._areAttributesDirty = false;
  63232. this._areTexturesDirty = false;
  63233. this._areFresnelDirty = false;
  63234. this._areLightsDirty = false;
  63235. this._areMiscDirty = false;
  63236. this._areImageProcessingDirty = false;
  63237. };
  63238. /**
  63239. * Marks the material to indicate that it needs to be re-calculated
  63240. */
  63241. MaterialDefines.prototype.markAsUnprocessed = function () {
  63242. this._isDirty = true;
  63243. };
  63244. /**
  63245. * Marks the material to indicate all of its defines need to be re-calculated
  63246. */
  63247. MaterialDefines.prototype.markAllAsDirty = function () {
  63248. this._areTexturesDirty = true;
  63249. this._areAttributesDirty = true;
  63250. this._areLightsDirty = true;
  63251. this._areFresnelDirty = true;
  63252. this._areMiscDirty = true;
  63253. this._areImageProcessingDirty = true;
  63254. this._isDirty = true;
  63255. };
  63256. /**
  63257. * Marks the material to indicate that image processing needs to be re-calculated
  63258. */
  63259. MaterialDefines.prototype.markAsImageProcessingDirty = function () {
  63260. this._areImageProcessingDirty = true;
  63261. this._isDirty = true;
  63262. };
  63263. /**
  63264. * Marks the material to indicate the lights need to be re-calculated
  63265. */
  63266. MaterialDefines.prototype.markAsLightDirty = function () {
  63267. this._areLightsDirty = true;
  63268. this._isDirty = true;
  63269. };
  63270. /**
  63271. * Marks the attribute state as changed
  63272. */
  63273. MaterialDefines.prototype.markAsAttributesDirty = function () {
  63274. this._areAttributesDirty = true;
  63275. this._isDirty = true;
  63276. };
  63277. /**
  63278. * Marks the texture state as changed
  63279. */
  63280. MaterialDefines.prototype.markAsTexturesDirty = function () {
  63281. this._areTexturesDirty = true;
  63282. this._isDirty = true;
  63283. };
  63284. /**
  63285. * Marks the fresnel state as changed
  63286. */
  63287. MaterialDefines.prototype.markAsFresnelDirty = function () {
  63288. this._areFresnelDirty = true;
  63289. this._isDirty = true;
  63290. };
  63291. /**
  63292. * Marks the misc state as changed
  63293. */
  63294. MaterialDefines.prototype.markAsMiscDirty = function () {
  63295. this._areMiscDirty = true;
  63296. this._isDirty = true;
  63297. };
  63298. /**
  63299. * Rebuilds the material defines
  63300. */
  63301. MaterialDefines.prototype.rebuild = function () {
  63302. if (this._keys) {
  63303. delete this._keys;
  63304. }
  63305. this._keys = [];
  63306. for (var _i = 0, _a = Object.keys(this); _i < _a.length; _i++) {
  63307. var key = _a[_i];
  63308. if (key[0] === "_") {
  63309. continue;
  63310. }
  63311. this._keys.push(key);
  63312. }
  63313. };
  63314. /**
  63315. * Specifies if two material defines are equal
  63316. * @param other - A material define instance to compare to
  63317. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  63318. */
  63319. MaterialDefines.prototype.isEqual = function (other) {
  63320. if (this._keys.length !== other._keys.length) {
  63321. return false;
  63322. }
  63323. for (var index = 0; index < this._keys.length; index++) {
  63324. var prop = this._keys[index];
  63325. if (this[prop] !== other[prop]) {
  63326. return false;
  63327. }
  63328. }
  63329. return true;
  63330. };
  63331. /**
  63332. * Clones this instance's defines to another instance
  63333. * @param other - material defines to clone values to
  63334. */
  63335. MaterialDefines.prototype.cloneTo = function (other) {
  63336. if (this._keys.length !== other._keys.length) {
  63337. other._keys = this._keys.slice(0);
  63338. }
  63339. for (var index = 0; index < this._keys.length; index++) {
  63340. var prop = this._keys[index];
  63341. other[prop] = this[prop];
  63342. }
  63343. };
  63344. /**
  63345. * Resets the material define values
  63346. */
  63347. MaterialDefines.prototype.reset = function () {
  63348. for (var index = 0; index < this._keys.length; index++) {
  63349. var prop = this._keys[index];
  63350. var type = typeof this[prop];
  63351. switch (type) {
  63352. case "number":
  63353. this[prop] = 0;
  63354. break;
  63355. case "string":
  63356. this[prop] = "";
  63357. break;
  63358. default:
  63359. this[prop] = false;
  63360. break;
  63361. }
  63362. }
  63363. };
  63364. /**
  63365. * Converts the material define values to a string
  63366. * @returns - String of material define information
  63367. */
  63368. MaterialDefines.prototype.toString = function () {
  63369. var result = "";
  63370. for (var index = 0; index < this._keys.length; index++) {
  63371. var prop = this._keys[index];
  63372. var value = this[prop];
  63373. var type = typeof value;
  63374. switch (type) {
  63375. case "number":
  63376. case "string":
  63377. result += "#define " + prop + " " + value + "\n";
  63378. break;
  63379. default:
  63380. if (value) {
  63381. result += "#define " + prop + "\n";
  63382. }
  63383. break;
  63384. }
  63385. }
  63386. return result;
  63387. };
  63388. return MaterialDefines;
  63389. }());
  63390. /***/ }),
  63391. /***/ "./Materials/materialFlags.ts":
  63392. /*!************************************!*\
  63393. !*** ./Materials/materialFlags.ts ***!
  63394. \************************************/
  63395. /*! exports provided: MaterialFlags */
  63396. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63397. "use strict";
  63398. __webpack_require__.r(__webpack_exports__);
  63399. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return MaterialFlags; });
  63400. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  63401. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  63402. /**
  63403. * This groups all the flags used to control the materials channel.
  63404. */
  63405. var MaterialFlags = /** @class */ (function () {
  63406. function MaterialFlags() {
  63407. }
  63408. Object.defineProperty(MaterialFlags, "DiffuseTextureEnabled", {
  63409. /**
  63410. * Are diffuse textures enabled in the application.
  63411. */
  63412. get: function () {
  63413. return this._DiffuseTextureEnabled;
  63414. },
  63415. set: function (value) {
  63416. if (this._DiffuseTextureEnabled === value) {
  63417. return;
  63418. }
  63419. this._DiffuseTextureEnabled = value;
  63420. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63421. },
  63422. enumerable: true,
  63423. configurable: true
  63424. });
  63425. Object.defineProperty(MaterialFlags, "AmbientTextureEnabled", {
  63426. /**
  63427. * Are ambient textures enabled in the application.
  63428. */
  63429. get: function () {
  63430. return this._AmbientTextureEnabled;
  63431. },
  63432. set: function (value) {
  63433. if (this._AmbientTextureEnabled === value) {
  63434. return;
  63435. }
  63436. this._AmbientTextureEnabled = value;
  63437. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63438. },
  63439. enumerable: true,
  63440. configurable: true
  63441. });
  63442. Object.defineProperty(MaterialFlags, "OpacityTextureEnabled", {
  63443. /**
  63444. * Are opacity textures enabled in the application.
  63445. */
  63446. get: function () {
  63447. return this._OpacityTextureEnabled;
  63448. },
  63449. set: function (value) {
  63450. if (this._OpacityTextureEnabled === value) {
  63451. return;
  63452. }
  63453. this._OpacityTextureEnabled = value;
  63454. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63455. },
  63456. enumerable: true,
  63457. configurable: true
  63458. });
  63459. Object.defineProperty(MaterialFlags, "ReflectionTextureEnabled", {
  63460. /**
  63461. * Are reflection textures enabled in the application.
  63462. */
  63463. get: function () {
  63464. return this._ReflectionTextureEnabled;
  63465. },
  63466. set: function (value) {
  63467. if (this._ReflectionTextureEnabled === value) {
  63468. return;
  63469. }
  63470. this._ReflectionTextureEnabled = value;
  63471. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63472. },
  63473. enumerable: true,
  63474. configurable: true
  63475. });
  63476. Object.defineProperty(MaterialFlags, "EmissiveTextureEnabled", {
  63477. /**
  63478. * Are emissive textures enabled in the application.
  63479. */
  63480. get: function () {
  63481. return this._EmissiveTextureEnabled;
  63482. },
  63483. set: function (value) {
  63484. if (this._EmissiveTextureEnabled === value) {
  63485. return;
  63486. }
  63487. this._EmissiveTextureEnabled = value;
  63488. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63489. },
  63490. enumerable: true,
  63491. configurable: true
  63492. });
  63493. Object.defineProperty(MaterialFlags, "SpecularTextureEnabled", {
  63494. /**
  63495. * Are specular textures enabled in the application.
  63496. */
  63497. get: function () {
  63498. return this._SpecularTextureEnabled;
  63499. },
  63500. set: function (value) {
  63501. if (this._SpecularTextureEnabled === value) {
  63502. return;
  63503. }
  63504. this._SpecularTextureEnabled = value;
  63505. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63506. },
  63507. enumerable: true,
  63508. configurable: true
  63509. });
  63510. Object.defineProperty(MaterialFlags, "BumpTextureEnabled", {
  63511. /**
  63512. * Are bump textures enabled in the application.
  63513. */
  63514. get: function () {
  63515. return this._BumpTextureEnabled;
  63516. },
  63517. set: function (value) {
  63518. if (this._BumpTextureEnabled === value) {
  63519. return;
  63520. }
  63521. this._BumpTextureEnabled = value;
  63522. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63523. },
  63524. enumerable: true,
  63525. configurable: true
  63526. });
  63527. Object.defineProperty(MaterialFlags, "LightmapTextureEnabled", {
  63528. /**
  63529. * Are lightmap textures enabled in the application.
  63530. */
  63531. get: function () {
  63532. return this._LightmapTextureEnabled;
  63533. },
  63534. set: function (value) {
  63535. if (this._LightmapTextureEnabled === value) {
  63536. return;
  63537. }
  63538. this._LightmapTextureEnabled = value;
  63539. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63540. },
  63541. enumerable: true,
  63542. configurable: true
  63543. });
  63544. Object.defineProperty(MaterialFlags, "RefractionTextureEnabled", {
  63545. /**
  63546. * Are refraction textures enabled in the application.
  63547. */
  63548. get: function () {
  63549. return this._RefractionTextureEnabled;
  63550. },
  63551. set: function (value) {
  63552. if (this._RefractionTextureEnabled === value) {
  63553. return;
  63554. }
  63555. this._RefractionTextureEnabled = value;
  63556. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63557. },
  63558. enumerable: true,
  63559. configurable: true
  63560. });
  63561. Object.defineProperty(MaterialFlags, "ColorGradingTextureEnabled", {
  63562. /**
  63563. * Are color grading textures enabled in the application.
  63564. */
  63565. get: function () {
  63566. return this._ColorGradingTextureEnabled;
  63567. },
  63568. set: function (value) {
  63569. if (this._ColorGradingTextureEnabled === value) {
  63570. return;
  63571. }
  63572. this._ColorGradingTextureEnabled = value;
  63573. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63574. },
  63575. enumerable: true,
  63576. configurable: true
  63577. });
  63578. Object.defineProperty(MaterialFlags, "FresnelEnabled", {
  63579. /**
  63580. * Are fresnels enabled in the application.
  63581. */
  63582. get: function () {
  63583. return this._FresnelEnabled;
  63584. },
  63585. set: function (value) {
  63586. if (this._FresnelEnabled === value) {
  63587. return;
  63588. }
  63589. this._FresnelEnabled = value;
  63590. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_FresnelDirtyFlag);
  63591. },
  63592. enumerable: true,
  63593. configurable: true
  63594. });
  63595. // Flags used to enable or disable a type of texture for all Standard Materials
  63596. MaterialFlags._DiffuseTextureEnabled = true;
  63597. MaterialFlags._AmbientTextureEnabled = true;
  63598. MaterialFlags._OpacityTextureEnabled = true;
  63599. MaterialFlags._ReflectionTextureEnabled = true;
  63600. MaterialFlags._EmissiveTextureEnabled = true;
  63601. MaterialFlags._SpecularTextureEnabled = true;
  63602. MaterialFlags._BumpTextureEnabled = true;
  63603. MaterialFlags._LightmapTextureEnabled = true;
  63604. MaterialFlags._RefractionTextureEnabled = true;
  63605. MaterialFlags._ColorGradingTextureEnabled = true;
  63606. MaterialFlags._FresnelEnabled = true;
  63607. return MaterialFlags;
  63608. }());
  63609. /***/ }),
  63610. /***/ "./Materials/materialHelper.ts":
  63611. /*!*************************************!*\
  63612. !*** ./Materials/materialHelper.ts ***!
  63613. \*************************************/
  63614. /*! exports provided: MaterialHelper */
  63615. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63616. "use strict";
  63617. __webpack_require__.r(__webpack_exports__);
  63618. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return MaterialHelper; });
  63619. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  63620. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  63621. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  63622. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  63623. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  63624. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Lights/light */ "./Lights/light.ts");
  63625. /**
  63626. * "Static Class" containing the most commonly used helper while dealing with material for
  63627. * rendering purpose.
  63628. *
  63629. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  63630. *
  63631. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  63632. */
  63633. var MaterialHelper = /** @class */ (function () {
  63634. function MaterialHelper() {
  63635. }
  63636. /**
  63637. * Bind the current view position to an effect.
  63638. * @param effect The effect to be bound
  63639. * @param scene The scene the eyes position is used from
  63640. */
  63641. MaterialHelper.BindEyePosition = function (effect, scene) {
  63642. if (scene._forcedViewPosition) {
  63643. effect.setVector3("vEyePosition", scene._forcedViewPosition);
  63644. return;
  63645. }
  63646. effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  63647. };
  63648. /**
  63649. * Helps preparing the defines values about the UVs in used in the effect.
  63650. * UVs are shared as much as we can accross channels in the shaders.
  63651. * @param texture The texture we are preparing the UVs for
  63652. * @param defines The defines to update
  63653. * @param key The channel key "diffuse", "specular"... used in the shader
  63654. */
  63655. MaterialHelper.PrepareDefinesForMergedUV = function (texture, defines, key) {
  63656. defines._needUVs = true;
  63657. defines[key] = true;
  63658. if (texture.getTextureMatrix().isIdentityAs3x2()) {
  63659. defines[key + "DIRECTUV"] = texture.coordinatesIndex + 1;
  63660. if (texture.coordinatesIndex === 0) {
  63661. defines["MAINUV1"] = true;
  63662. }
  63663. else {
  63664. defines["MAINUV2"] = true;
  63665. }
  63666. }
  63667. else {
  63668. defines[key + "DIRECTUV"] = 0;
  63669. }
  63670. };
  63671. /**
  63672. * Binds a texture matrix value to its corrsponding uniform
  63673. * @param texture The texture to bind the matrix for
  63674. * @param uniformBuffer The uniform buffer receivin the data
  63675. * @param key The channel key "diffuse", "specular"... used in the shader
  63676. */
  63677. MaterialHelper.BindTextureMatrix = function (texture, uniformBuffer, key) {
  63678. var matrix = texture.getTextureMatrix();
  63679. if (!matrix.isIdentityAs3x2()) {
  63680. uniformBuffer.updateMatrix(key + "Matrix", matrix);
  63681. }
  63682. };
  63683. /**
  63684. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  63685. * @param mesh defines the current mesh
  63686. * @param scene defines the current scene
  63687. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  63688. * @param pointsCloud defines if point cloud rendering has to be turned on
  63689. * @param fogEnabled defines if fog has to be turned on
  63690. * @param alphaTest defines if alpha testing has to be turned on
  63691. * @param defines defines the current list of defines
  63692. */
  63693. MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, alphaTest, defines) {
  63694. if (defines._areMiscDirty) {
  63695. defines["LOGARITHMICDEPTH"] = useLogarithmicDepth;
  63696. defines["POINTSIZE"] = pointsCloud;
  63697. defines["FOG"] = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE && fogEnabled);
  63698. defines["NONUNIFORMSCALING"] = mesh.nonUniformScaling;
  63699. defines["ALPHATEST"] = alphaTest;
  63700. }
  63701. };
  63702. /**
  63703. * Helper used to prepare the list of defines associated with frame values for shader compilation
  63704. * @param scene defines the current scene
  63705. * @param engine defines the current engine
  63706. * @param defines specifies the list of active defines
  63707. * @param useInstances defines if instances have to be turned on
  63708. * @param useClipPlane defines if clip plane have to be turned on
  63709. */
  63710. MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances, useClipPlane) {
  63711. if (useClipPlane === void 0) { useClipPlane = null; }
  63712. var changed = false;
  63713. var useClipPlane1 = false;
  63714. var useClipPlane2 = false;
  63715. var useClipPlane3 = false;
  63716. var useClipPlane4 = false;
  63717. useClipPlane1 = useClipPlane == null ? (scene.clipPlane !== undefined && scene.clipPlane !== null) : useClipPlane;
  63718. useClipPlane2 = useClipPlane == null ? (scene.clipPlane2 !== undefined && scene.clipPlane2 !== null) : useClipPlane;
  63719. useClipPlane3 = useClipPlane == null ? (scene.clipPlane3 !== undefined && scene.clipPlane3 !== null) : useClipPlane;
  63720. useClipPlane4 = useClipPlane == null ? (scene.clipPlane4 !== undefined && scene.clipPlane4 !== null) : useClipPlane;
  63721. if (defines["CLIPPLANE"] !== useClipPlane1) {
  63722. defines["CLIPPLANE"] = useClipPlane1;
  63723. changed = true;
  63724. }
  63725. if (defines["CLIPPLANE2"] !== useClipPlane2) {
  63726. defines["CLIPPLANE2"] = useClipPlane2;
  63727. changed = true;
  63728. }
  63729. if (defines["CLIPPLANE3"] !== useClipPlane3) {
  63730. defines["CLIPPLANE3"] = useClipPlane3;
  63731. changed = true;
  63732. }
  63733. if (defines["CLIPPLANE4"] !== useClipPlane4) {
  63734. defines["CLIPPLANE4"] = useClipPlane4;
  63735. changed = true;
  63736. }
  63737. if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
  63738. defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
  63739. changed = true;
  63740. }
  63741. if (defines["INSTANCES"] !== useInstances) {
  63742. defines["INSTANCES"] = useInstances;
  63743. changed = true;
  63744. }
  63745. if (changed) {
  63746. defines.markAsUnprocessed();
  63747. }
  63748. };
  63749. /**
  63750. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  63751. * @param mesh The mesh containing the geometry data we will draw
  63752. * @param defines The defines to update
  63753. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  63754. * @param useBones Precise whether bones should be used or not (override mesh info)
  63755. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  63756. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  63757. * @returns false if defines are considered not dirty and have not been checked
  63758. */
  63759. MaterialHelper.PrepareDefinesForAttributes = function (mesh, defines, useVertexColor, useBones, useMorphTargets, useVertexAlpha) {
  63760. if (useMorphTargets === void 0) { useMorphTargets = false; }
  63761. if (useVertexAlpha === void 0) { useVertexAlpha = true; }
  63762. if (!defines._areAttributesDirty && defines._needNormals === defines._normals && defines._needUVs === defines._uvs) {
  63763. return false;
  63764. }
  63765. defines._normals = defines._needNormals;
  63766. defines._uvs = defines._needUVs;
  63767. defines["NORMAL"] = (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind));
  63768. if (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind)) {
  63769. defines["TANGENT"] = true;
  63770. }
  63771. if (defines._needUVs) {
  63772. defines["UV1"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  63773. defines["UV2"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  63774. }
  63775. else {
  63776. defines["UV1"] = false;
  63777. defines["UV2"] = false;
  63778. }
  63779. if (useVertexColor) {
  63780. var hasVertexColors = mesh.useVertexColors && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  63781. defines["VERTEXCOLOR"] = hasVertexColors;
  63782. defines["VERTEXALPHA"] = mesh.hasVertexAlpha && hasVertexColors && useVertexAlpha;
  63783. }
  63784. if (useBones) {
  63785. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  63786. defines["NUM_BONE_INFLUENCERS"] = mesh.numBoneInfluencers;
  63787. var materialSupportsBoneTexture = defines["BONETEXTURE"] !== undefined;
  63788. if (mesh.skeleton.isUsingTextureForMatrices && materialSupportsBoneTexture) {
  63789. defines["BONETEXTURE"] = true;
  63790. }
  63791. else {
  63792. defines["BonesPerMesh"] = (mesh.skeleton.bones.length + 1);
  63793. defines["BONETEXTURE"] = materialSupportsBoneTexture ? false : undefined;
  63794. }
  63795. }
  63796. else {
  63797. defines["NUM_BONE_INFLUENCERS"] = 0;
  63798. defines["BonesPerMesh"] = 0;
  63799. }
  63800. }
  63801. if (useMorphTargets) {
  63802. var manager = mesh.morphTargetManager;
  63803. if (manager) {
  63804. defines["MORPHTARGETS_TANGENT"] = manager.supportsTangents && defines["TANGENT"];
  63805. defines["MORPHTARGETS_NORMAL"] = manager.supportsNormals && defines["NORMAL"];
  63806. defines["MORPHTARGETS"] = (manager.numInfluencers > 0);
  63807. defines["NUM_MORPH_INFLUENCERS"] = manager.numInfluencers;
  63808. }
  63809. else {
  63810. defines["MORPHTARGETS_TANGENT"] = false;
  63811. defines["MORPHTARGETS_NORMAL"] = false;
  63812. defines["MORPHTARGETS"] = false;
  63813. defines["NUM_MORPH_INFLUENCERS"] = 0;
  63814. }
  63815. }
  63816. return true;
  63817. };
  63818. /**
  63819. * Prepares the defines related to the light information passed in parameter
  63820. * @param scene The scene we are intending to draw
  63821. * @param mesh The mesh the effect is compiling for
  63822. * @param defines The defines to update
  63823. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  63824. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  63825. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  63826. * @returns true if normals will be required for the rest of the effect
  63827. */
  63828. MaterialHelper.PrepareDefinesForLights = function (scene, mesh, defines, specularSupported, maxSimultaneousLights, disableLighting) {
  63829. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  63830. if (disableLighting === void 0) { disableLighting = false; }
  63831. if (!defines._areLightsDirty) {
  63832. return defines._needNormals;
  63833. }
  63834. var lightIndex = 0;
  63835. var needNormals = false;
  63836. var needRebuild = false;
  63837. var lightmapMode = false;
  63838. var shadowEnabled = false;
  63839. var specularEnabled = false;
  63840. if (scene.lightsEnabled && !disableLighting) {
  63841. for (var _i = 0, _a = mesh._lightSources; _i < _a.length; _i++) {
  63842. var light = _a[_i];
  63843. needNormals = true;
  63844. if (defines["LIGHT" + lightIndex] === undefined) {
  63845. needRebuild = true;
  63846. }
  63847. defines["LIGHT" + lightIndex] = true;
  63848. defines["SPOTLIGHT" + lightIndex] = false;
  63849. defines["HEMILIGHT" + lightIndex] = false;
  63850. defines["POINTLIGHT" + lightIndex] = false;
  63851. defines["DIRLIGHT" + lightIndex] = false;
  63852. light.prepareLightSpecificDefines(defines, lightIndex);
  63853. // FallOff.
  63854. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = false;
  63855. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = false;
  63856. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = false;
  63857. switch (light.falloffType) {
  63858. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_GLTF:
  63859. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = true;
  63860. break;
  63861. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_PHYSICAL:
  63862. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = true;
  63863. break;
  63864. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_STANDARD:
  63865. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = true;
  63866. break;
  63867. }
  63868. // Specular
  63869. if (specularSupported && !light.specular.equalsFloats(0, 0, 0)) {
  63870. specularEnabled = true;
  63871. }
  63872. // Shadows
  63873. defines["SHADOW" + lightIndex] = false;
  63874. defines["SHADOWPCF" + lightIndex] = false;
  63875. defines["SHADOWPCSS" + lightIndex] = false;
  63876. defines["SHADOWPOISSON" + lightIndex] = false;
  63877. defines["SHADOWESM" + lightIndex] = false;
  63878. defines["SHADOWCUBE" + lightIndex] = false;
  63879. defines["SHADOWLOWQUALITY" + lightIndex] = false;
  63880. defines["SHADOWMEDIUMQUALITY" + lightIndex] = false;
  63881. if (mesh && mesh.receiveShadows && scene.shadowsEnabled && light.shadowEnabled) {
  63882. var shadowGenerator = light.getShadowGenerator();
  63883. if (shadowGenerator) {
  63884. var shadowMap = shadowGenerator.getShadowMap();
  63885. if (shadowMap) {
  63886. if (shadowMap.renderList && shadowMap.renderList.length > 0) {
  63887. shadowEnabled = true;
  63888. shadowGenerator.prepareDefines(defines, lightIndex);
  63889. }
  63890. }
  63891. }
  63892. }
  63893. if (light.lightmapMode != _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_DEFAULT) {
  63894. lightmapMode = true;
  63895. defines["LIGHTMAPEXCLUDED" + lightIndex] = true;
  63896. defines["LIGHTMAPNOSPECULAR" + lightIndex] = (light.lightmapMode == _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_SHADOWSONLY);
  63897. }
  63898. else {
  63899. defines["LIGHTMAPEXCLUDED" + lightIndex] = false;
  63900. defines["LIGHTMAPNOSPECULAR" + lightIndex] = false;
  63901. }
  63902. lightIndex++;
  63903. if (lightIndex === maxSimultaneousLights) {
  63904. break;
  63905. }
  63906. }
  63907. }
  63908. defines["SPECULARTERM"] = specularEnabled;
  63909. defines["SHADOWS"] = shadowEnabled;
  63910. // Resetting all other lights if any
  63911. for (var index = lightIndex; index < maxSimultaneousLights; index++) {
  63912. if (defines["LIGHT" + index] !== undefined) {
  63913. defines["LIGHT" + index] = false;
  63914. defines["HEMILIGHT" + index] = false;
  63915. defines["POINTLIGHT" + index] = false;
  63916. defines["DIRLIGHT" + index] = false;
  63917. defines["SPOTLIGHT" + index] = false;
  63918. defines["SHADOW" + index] = false;
  63919. defines["SHADOWPCF" + index] = false;
  63920. defines["SHADOWPCSS" + index] = false;
  63921. defines["SHADOWPOISSON" + index] = false;
  63922. defines["SHADOWESM" + index] = false;
  63923. defines["SHADOWCUBE" + index] = false;
  63924. defines["SHADOWLOWQUALITY" + index] = false;
  63925. defines["SHADOWMEDIUMQUALITY" + index] = false;
  63926. }
  63927. }
  63928. var caps = scene.getEngine().getCaps();
  63929. if (defines["SHADOWFLOAT"] === undefined) {
  63930. needRebuild = true;
  63931. }
  63932. defines["SHADOWFLOAT"] = shadowEnabled &&
  63933. ((caps.textureFloatRender && caps.textureFloatLinearFiltering) ||
  63934. (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering));
  63935. defines["LIGHTMAPEXCLUDED"] = lightmapMode;
  63936. if (needRebuild) {
  63937. defines.rebuild();
  63938. }
  63939. return needNormals;
  63940. };
  63941. /**
  63942. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  63943. * that won t be acctive due to defines being turned off.
  63944. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  63945. * @param samplersList The samplers list
  63946. * @param defines The defines helping in the list generation
  63947. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  63948. */
  63949. MaterialHelper.PrepareUniformsAndSamplersList = function (uniformsListOrOptions, samplersList, defines, maxSimultaneousLights) {
  63950. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  63951. var uniformsList;
  63952. var uniformBuffersList = null;
  63953. if (uniformsListOrOptions.uniformsNames) {
  63954. var options = uniformsListOrOptions;
  63955. uniformsList = options.uniformsNames;
  63956. uniformBuffersList = options.uniformBuffersNames;
  63957. samplersList = options.samplers;
  63958. defines = options.defines;
  63959. maxSimultaneousLights = options.maxSimultaneousLights;
  63960. }
  63961. else {
  63962. uniformsList = uniformsListOrOptions;
  63963. if (!samplersList) {
  63964. samplersList = [];
  63965. }
  63966. }
  63967. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  63968. if (!defines["LIGHT" + lightIndex]) {
  63969. break;
  63970. }
  63971. uniformsList.push("vLightData" + lightIndex, "vLightDiffuse" + lightIndex, "vLightSpecular" + lightIndex, "vLightDirection" + lightIndex, "vLightFalloff" + lightIndex, "vLightGround" + lightIndex, "lightMatrix" + lightIndex, "shadowsInfo" + lightIndex, "depthValues" + lightIndex);
  63972. if (uniformBuffersList) {
  63973. uniformBuffersList.push("Light" + lightIndex);
  63974. }
  63975. samplersList.push("shadowSampler" + lightIndex);
  63976. samplersList.push("depthSampler" + lightIndex);
  63977. if (defines["PROJECTEDLIGHTTEXTURE" + lightIndex]) {
  63978. samplersList.push("projectionLightSampler" + lightIndex);
  63979. uniformsList.push("textureProjectionMatrix" + lightIndex);
  63980. }
  63981. }
  63982. if (defines["NUM_MORPH_INFLUENCERS"]) {
  63983. uniformsList.push("morphTargetInfluences");
  63984. }
  63985. };
  63986. /**
  63987. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  63988. * @param defines The defines to update while falling back
  63989. * @param fallbacks The authorized effect fallbacks
  63990. * @param maxSimultaneousLights The maximum number of lights allowed
  63991. * @param rank the current rank of the Effect
  63992. * @returns The newly affected rank
  63993. */
  63994. MaterialHelper.HandleFallbacksForShadows = function (defines, fallbacks, maxSimultaneousLights, rank) {
  63995. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  63996. if (rank === void 0) { rank = 0; }
  63997. var lightFallbackRank = 0;
  63998. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  63999. if (!defines["LIGHT" + lightIndex]) {
  64000. break;
  64001. }
  64002. if (lightIndex > 0) {
  64003. lightFallbackRank = rank + lightIndex;
  64004. fallbacks.addFallback(lightFallbackRank, "LIGHT" + lightIndex);
  64005. }
  64006. if (!defines["SHADOWS"]) {
  64007. if (defines["SHADOW" + lightIndex]) {
  64008. fallbacks.addFallback(rank, "SHADOW" + lightIndex);
  64009. }
  64010. if (defines["SHADOWPCF" + lightIndex]) {
  64011. fallbacks.addFallback(rank, "SHADOWPCF" + lightIndex);
  64012. }
  64013. if (defines["SHADOWPCSS" + lightIndex]) {
  64014. fallbacks.addFallback(rank, "SHADOWPCSS" + lightIndex);
  64015. }
  64016. if (defines["SHADOWPOISSON" + lightIndex]) {
  64017. fallbacks.addFallback(rank, "SHADOWPOISSON" + lightIndex);
  64018. }
  64019. if (defines["SHADOWESM" + lightIndex]) {
  64020. fallbacks.addFallback(rank, "SHADOWESM" + lightIndex);
  64021. }
  64022. }
  64023. }
  64024. return lightFallbackRank++;
  64025. };
  64026. /**
  64027. * Prepares the list of attributes required for morph targets according to the effect defines.
  64028. * @param attribs The current list of supported attribs
  64029. * @param mesh The mesh to prepare the morph targets attributes for
  64030. * @param defines The current Defines of the effect
  64031. */
  64032. MaterialHelper.PrepareAttributesForMorphTargets = function (attribs, mesh, defines) {
  64033. var influencers = defines["NUM_MORPH_INFLUENCERS"];
  64034. if (influencers > 0 && _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine) {
  64035. var maxAttributesCount = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine.getCaps().maxVertexAttribs;
  64036. var manager = mesh.morphTargetManager;
  64037. var normal = manager && manager.supportsNormals && defines["NORMAL"];
  64038. var tangent = manager && manager.supportsTangents && defines["TANGENT"];
  64039. for (var index = 0; index < influencers; index++) {
  64040. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind + index);
  64041. if (normal) {
  64042. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind + index);
  64043. }
  64044. if (tangent) {
  64045. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind + index);
  64046. }
  64047. if (attribs.length > maxAttributesCount) {
  64048. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add more vertex attributes for mesh " + mesh.name);
  64049. }
  64050. }
  64051. }
  64052. };
  64053. /**
  64054. * Prepares the list of attributes required for bones according to the effect defines.
  64055. * @param attribs The current list of supported attribs
  64056. * @param mesh The mesh to prepare the bones attributes for
  64057. * @param defines The current Defines of the effect
  64058. * @param fallbacks The current efffect fallback strategy
  64059. */
  64060. MaterialHelper.PrepareAttributesForBones = function (attribs, mesh, defines, fallbacks) {
  64061. if (defines["NUM_BONE_INFLUENCERS"] > 0) {
  64062. fallbacks.addCPUSkinningFallback(0, mesh);
  64063. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  64064. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  64065. if (defines["NUM_BONE_INFLUENCERS"] > 4) {
  64066. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesExtraKind);
  64067. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsExtraKind);
  64068. }
  64069. }
  64070. };
  64071. /**
  64072. * Prepares the list of attributes required for instances according to the effect defines.
  64073. * @param attribs The current list of supported attribs
  64074. * @param defines The current Defines of the effect
  64075. */
  64076. MaterialHelper.PrepareAttributesForInstances = function (attribs, defines) {
  64077. if (defines["INSTANCES"]) {
  64078. attribs.push("world0");
  64079. attribs.push("world1");
  64080. attribs.push("world2");
  64081. attribs.push("world3");
  64082. }
  64083. };
  64084. /**
  64085. * Binds the light shadow information to the effect for the given mesh.
  64086. * @param light The light containing the generator
  64087. * @param scene The scene the lights belongs to
  64088. * @param mesh The mesh we are binding the information to render
  64089. * @param lightIndex The light index in the effect used to render the mesh
  64090. * @param effect The effect we are binding the data to
  64091. */
  64092. MaterialHelper.BindLightShadow = function (light, mesh, lightIndex, effect) {
  64093. if (light.shadowEnabled && mesh.receiveShadows) {
  64094. var shadowGenerator = light.getShadowGenerator();
  64095. if (shadowGenerator) {
  64096. shadowGenerator.bindShadowLight(lightIndex, effect);
  64097. }
  64098. }
  64099. };
  64100. /**
  64101. * Binds the light information to the effect.
  64102. * @param light The light containing the generator
  64103. * @param effect The effect we are binding the data to
  64104. * @param lightIndex The light index in the effect used to render
  64105. */
  64106. MaterialHelper.BindLightProperties = function (light, effect, lightIndex) {
  64107. light.transferToEffect(effect, lightIndex + "");
  64108. };
  64109. /**
  64110. * Binds the lights information from the scene to the effect for the given mesh.
  64111. * @param scene The scene the lights belongs to
  64112. * @param mesh The mesh we are binding the information to render
  64113. * @param effect The effect we are binding the data to
  64114. * @param defines The generated defines for the effect
  64115. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  64116. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  64117. */
  64118. MaterialHelper.BindLights = function (scene, mesh, effect, defines, maxSimultaneousLights, usePhysicalLightFalloff) {
  64119. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  64120. if (usePhysicalLightFalloff === void 0) { usePhysicalLightFalloff = false; }
  64121. var len = Math.min(mesh._lightSources.length, maxSimultaneousLights);
  64122. for (var i = 0; i < len; i++) {
  64123. var light = mesh._lightSources[i];
  64124. var iAsString = i.toString();
  64125. var scaledIntensity = light.getScaledIntensity();
  64126. light._uniformBuffer.bindToEffect(effect, "Light" + i);
  64127. MaterialHelper.BindLightProperties(light, effect, i);
  64128. light.diffuse.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0]);
  64129. light._uniformBuffer.updateColor4("vLightDiffuse", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0], usePhysicalLightFalloff ? light.radius : light.range, iAsString);
  64130. if (defines["SPECULARTERM"]) {
  64131. light.specular.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1]);
  64132. light._uniformBuffer.updateColor3("vLightSpecular", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1], iAsString);
  64133. }
  64134. // Shadows
  64135. if (scene.shadowsEnabled) {
  64136. this.BindLightShadow(light, mesh, iAsString, effect);
  64137. }
  64138. light._uniformBuffer.update();
  64139. }
  64140. };
  64141. /**
  64142. * Binds the fog information from the scene to the effect for the given mesh.
  64143. * @param scene The scene the lights belongs to
  64144. * @param mesh The mesh we are binding the information to render
  64145. * @param effect The effect we are binding the data to
  64146. * @param linearSpace Defines if the fog effect is applied in linear space
  64147. */
  64148. MaterialHelper.BindFogParameters = function (scene, mesh, effect, linearSpace) {
  64149. if (linearSpace === void 0) { linearSpace = false; }
  64150. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
  64151. effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
  64152. // Convert fog color to linear space if used in a linear space computed shader.
  64153. if (linearSpace) {
  64154. scene.fogColor.toLinearSpaceToRef(this._tempFogColor);
  64155. effect.setColor3("vFogColor", this._tempFogColor);
  64156. }
  64157. else {
  64158. effect.setColor3("vFogColor", scene.fogColor);
  64159. }
  64160. }
  64161. };
  64162. /**
  64163. * Binds the bones information from the mesh to the effect.
  64164. * @param mesh The mesh we are binding the information to render
  64165. * @param effect The effect we are binding the data to
  64166. */
  64167. MaterialHelper.BindBonesParameters = function (mesh, effect) {
  64168. if (!effect || !mesh) {
  64169. return;
  64170. }
  64171. if (mesh.computeBonesUsingShaders && effect._bonesComputationForcedToCPU) {
  64172. mesh.computeBonesUsingShaders = false;
  64173. }
  64174. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  64175. var skeleton = mesh.skeleton;
  64176. if (skeleton.isUsingTextureForMatrices && effect.getUniformIndex("boneTextureWidth") > -1) {
  64177. var boneTexture = skeleton.getTransformMatrixTexture();
  64178. effect.setTexture("boneSampler", boneTexture);
  64179. effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  64180. }
  64181. else {
  64182. var matrices = skeleton.getTransformMatrices(mesh);
  64183. if (matrices) {
  64184. effect.setMatrices("mBones", matrices);
  64185. }
  64186. }
  64187. }
  64188. };
  64189. /**
  64190. * Binds the morph targets information from the mesh to the effect.
  64191. * @param abstractMesh The mesh we are binding the information to render
  64192. * @param effect The effect we are binding the data to
  64193. */
  64194. MaterialHelper.BindMorphTargetParameters = function (abstractMesh, effect) {
  64195. var manager = abstractMesh.morphTargetManager;
  64196. if (!abstractMesh || !manager) {
  64197. return;
  64198. }
  64199. effect.setFloatArray("morphTargetInfluences", manager.influences);
  64200. };
  64201. /**
  64202. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  64203. * @param defines The generated defines used in the effect
  64204. * @param effect The effect we are binding the data to
  64205. * @param scene The scene we are willing to render with logarithmic scale for
  64206. */
  64207. MaterialHelper.BindLogDepth = function (defines, effect, scene) {
  64208. if (defines["LOGARITHMICDEPTH"]) {
  64209. effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  64210. }
  64211. };
  64212. /**
  64213. * Binds the clip plane information from the scene to the effect.
  64214. * @param scene The scene the clip plane information are extracted from
  64215. * @param effect The effect we are binding the data to
  64216. */
  64217. MaterialHelper.BindClipPlane = function (effect, scene) {
  64218. if (scene.clipPlane) {
  64219. var clipPlane = scene.clipPlane;
  64220. effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  64221. }
  64222. if (scene.clipPlane2) {
  64223. var clipPlane = scene.clipPlane2;
  64224. effect.setFloat4("vClipPlane2", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  64225. }
  64226. if (scene.clipPlane3) {
  64227. var clipPlane = scene.clipPlane3;
  64228. effect.setFloat4("vClipPlane3", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  64229. }
  64230. if (scene.clipPlane4) {
  64231. var clipPlane = scene.clipPlane4;
  64232. effect.setFloat4("vClipPlane4", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  64233. }
  64234. };
  64235. MaterialHelper._tempFogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  64236. return MaterialHelper;
  64237. }());
  64238. /***/ }),
  64239. /***/ "./Materials/multiMaterial.ts":
  64240. /*!************************************!*\
  64241. !*** ./Materials/multiMaterial.ts ***!
  64242. \************************************/
  64243. /*! exports provided: MultiMaterial */
  64244. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64245. "use strict";
  64246. __webpack_require__.r(__webpack_exports__);
  64247. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return MultiMaterial; });
  64248. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64249. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  64250. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  64251. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  64252. /**
  64253. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64254. * separate meshes. This can be use to improve performances.
  64255. * @see http://doc.babylonjs.com/how_to/multi_materials
  64256. */
  64257. var MultiMaterial = /** @class */ (function (_super) {
  64258. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiMaterial, _super);
  64259. /**
  64260. * Instantiates a new Multi Material
  64261. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64262. * separate meshes. This can be use to improve performances.
  64263. * @see http://doc.babylonjs.com/how_to/multi_materials
  64264. * @param name Define the name in the scene
  64265. * @param scene Define the scene the material belongs to
  64266. */
  64267. function MultiMaterial(name, scene) {
  64268. var _this = _super.call(this, name, scene, true) || this;
  64269. scene.multiMaterials.push(_this);
  64270. _this.subMaterials = new Array();
  64271. _this._storeEffectOnSubMeshes = true; // multimaterial is considered like a push material
  64272. return _this;
  64273. }
  64274. Object.defineProperty(MultiMaterial.prototype, "subMaterials", {
  64275. /**
  64276. * Gets or Sets the list of Materials used within the multi material.
  64277. * They need to be ordered according to the submeshes order in the associated mesh
  64278. */
  64279. get: function () {
  64280. return this._subMaterials;
  64281. },
  64282. set: function (value) {
  64283. this._subMaterials = value;
  64284. this._hookArray(value);
  64285. },
  64286. enumerable: true,
  64287. configurable: true
  64288. });
  64289. /**
  64290. * Function used to align with Node.getChildren()
  64291. * @returns the list of Materials used within the multi material
  64292. */
  64293. MultiMaterial.prototype.getChildren = function () {
  64294. return this.subMaterials;
  64295. };
  64296. MultiMaterial.prototype._hookArray = function (array) {
  64297. var _this = this;
  64298. var oldPush = array.push;
  64299. array.push = function () {
  64300. var items = [];
  64301. for (var _i = 0; _i < arguments.length; _i++) {
  64302. items[_i] = arguments[_i];
  64303. }
  64304. var result = oldPush.apply(array, items);
  64305. _this._markAllSubMeshesAsTexturesDirty();
  64306. return result;
  64307. };
  64308. var oldSplice = array.splice;
  64309. array.splice = function (index, deleteCount) {
  64310. var deleted = oldSplice.apply(array, [index, deleteCount]);
  64311. _this._markAllSubMeshesAsTexturesDirty();
  64312. return deleted;
  64313. };
  64314. };
  64315. /**
  64316. * Get one of the submaterial by its index in the submaterials array
  64317. * @param index The index to look the sub material at
  64318. * @returns The Material if the index has been defined
  64319. */
  64320. MultiMaterial.prototype.getSubMaterial = function (index) {
  64321. if (index < 0 || index >= this.subMaterials.length) {
  64322. return this.getScene().defaultMaterial;
  64323. }
  64324. return this.subMaterials[index];
  64325. };
  64326. /**
  64327. * Get the list of active textures for the whole sub materials list.
  64328. * @returns All the textures that will be used during the rendering
  64329. */
  64330. MultiMaterial.prototype.getActiveTextures = function () {
  64331. var _a;
  64332. return (_a = _super.prototype.getActiveTextures.call(this)).concat.apply(_a, this.subMaterials.map(function (subMaterial) {
  64333. if (subMaterial) {
  64334. return subMaterial.getActiveTextures();
  64335. }
  64336. else {
  64337. return [];
  64338. }
  64339. }));
  64340. };
  64341. /**
  64342. * Gets the current class name of the material e.g. "MultiMaterial"
  64343. * Mainly use in serialization.
  64344. * @returns the class name
  64345. */
  64346. MultiMaterial.prototype.getClassName = function () {
  64347. return "MultiMaterial";
  64348. };
  64349. /**
  64350. * Checks if the material is ready to render the requested sub mesh
  64351. * @param mesh Define the mesh the submesh belongs to
  64352. * @param subMesh Define the sub mesh to look readyness for
  64353. * @param useInstances Define whether or not the material is used with instances
  64354. * @returns true if ready, otherwise false
  64355. */
  64356. MultiMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  64357. for (var index = 0; index < this.subMaterials.length; index++) {
  64358. var subMaterial = this.subMaterials[index];
  64359. if (subMaterial) {
  64360. if (subMaterial._storeEffectOnSubMeshes) {
  64361. if (!subMaterial.isReadyForSubMesh(mesh, subMesh, useInstances)) {
  64362. return false;
  64363. }
  64364. continue;
  64365. }
  64366. if (!subMaterial.isReady(mesh)) {
  64367. return false;
  64368. }
  64369. }
  64370. }
  64371. return true;
  64372. };
  64373. /**
  64374. * Clones the current material and its related sub materials
  64375. * @param name Define the name of the newly cloned material
  64376. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  64377. * @returns the cloned material
  64378. */
  64379. MultiMaterial.prototype.clone = function (name, cloneChildren) {
  64380. var newMultiMaterial = new MultiMaterial(name, this.getScene());
  64381. for (var index = 0; index < this.subMaterials.length; index++) {
  64382. var subMaterial = null;
  64383. var current = this.subMaterials[index];
  64384. if (cloneChildren && current) {
  64385. subMaterial = current.clone(name + "-" + current.name);
  64386. }
  64387. else {
  64388. subMaterial = this.subMaterials[index];
  64389. }
  64390. newMultiMaterial.subMaterials.push(subMaterial);
  64391. }
  64392. return newMultiMaterial;
  64393. };
  64394. /**
  64395. * Serializes the materials into a JSON representation.
  64396. * @returns the JSON representation
  64397. */
  64398. MultiMaterial.prototype.serialize = function () {
  64399. var serializationObject = {};
  64400. serializationObject.name = this.name;
  64401. serializationObject.id = this.id;
  64402. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  64403. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].GetTags(this);
  64404. }
  64405. serializationObject.materials = [];
  64406. for (var matIndex = 0; matIndex < this.subMaterials.length; matIndex++) {
  64407. var subMat = this.subMaterials[matIndex];
  64408. if (subMat) {
  64409. serializationObject.materials.push(subMat.id);
  64410. }
  64411. else {
  64412. serializationObject.materials.push(null);
  64413. }
  64414. }
  64415. return serializationObject;
  64416. };
  64417. /**
  64418. * Dispose the material and release its associated resources
  64419. * @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)
  64420. * @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)
  64421. * @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)
  64422. */
  64423. MultiMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, forceDisposeChildren) {
  64424. var scene = this.getScene();
  64425. if (!scene) {
  64426. return;
  64427. }
  64428. if (forceDisposeChildren) {
  64429. for (var index = 0; index < this.subMaterials.length; index++) {
  64430. var subMaterial = this.subMaterials[index];
  64431. if (subMaterial) {
  64432. subMaterial.dispose(forceDisposeEffect, forceDisposeTextures);
  64433. }
  64434. }
  64435. }
  64436. var index = scene.multiMaterials.indexOf(this);
  64437. if (index >= 0) {
  64438. scene.multiMaterials.splice(index, 1);
  64439. }
  64440. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  64441. };
  64442. /**
  64443. * Creates a MultiMaterial from parsed MultiMaterial data.
  64444. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  64445. * @param scene defines the hosting scene
  64446. * @returns a new MultiMaterial
  64447. */
  64448. MultiMaterial.ParseMultiMaterial = function (parsedMultiMaterial, scene) {
  64449. var multiMaterial = new MultiMaterial(parsedMultiMaterial.name, scene);
  64450. multiMaterial.id = parsedMultiMaterial.id;
  64451. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  64452. _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].AddTagsTo(multiMaterial, parsedMultiMaterial.tags);
  64453. }
  64454. for (var matIndex = 0; matIndex < parsedMultiMaterial.materials.length; matIndex++) {
  64455. var subMatId = parsedMultiMaterial.materials[matIndex];
  64456. if (subMatId) {
  64457. multiMaterial.subMaterials.push(scene.getMaterialByID(subMatId));
  64458. }
  64459. else {
  64460. multiMaterial.subMaterials.push(null);
  64461. }
  64462. }
  64463. return multiMaterial;
  64464. };
  64465. return MultiMaterial;
  64466. }(_Materials_material__WEBPACK_IMPORTED_MODULE_1__["Material"]));
  64467. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.MultiMaterial"] = MultiMaterial;
  64468. /***/ }),
  64469. /***/ "./Materials/pushMaterial.ts":
  64470. /*!***********************************!*\
  64471. !*** ./Materials/pushMaterial.ts ***!
  64472. \***********************************/
  64473. /*! exports provided: PushMaterial */
  64474. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64475. "use strict";
  64476. __webpack_require__.r(__webpack_exports__);
  64477. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return PushMaterial; });
  64478. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64479. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64480. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  64481. /**
  64482. * Base class of materials working in push mode in babylon JS
  64483. * @hidden
  64484. */
  64485. var PushMaterial = /** @class */ (function (_super) {
  64486. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PushMaterial, _super);
  64487. function PushMaterial(name, scene) {
  64488. var _this = _super.call(this, name, scene) || this;
  64489. _this._normalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  64490. /**
  64491. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  64492. * This means that the material can keep using a previous shader while a new one is being compiled.
  64493. * This is mostly used when shader parallel compilation is supported (true by default)
  64494. */
  64495. _this.allowShaderHotSwapping = true;
  64496. _this._storeEffectOnSubMeshes = true;
  64497. return _this;
  64498. }
  64499. PushMaterial.prototype.getEffect = function () {
  64500. return this._activeEffect;
  64501. };
  64502. PushMaterial.prototype.isReady = function (mesh, useInstances) {
  64503. if (!mesh) {
  64504. return false;
  64505. }
  64506. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  64507. return true;
  64508. }
  64509. return this.isReadyForSubMesh(mesh, mesh.subMeshes[0], useInstances);
  64510. };
  64511. /**
  64512. * Binds the given world matrix to the active effect
  64513. *
  64514. * @param world the matrix to bind
  64515. */
  64516. PushMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  64517. this._activeEffect.setMatrix("world", world);
  64518. };
  64519. /**
  64520. * Binds the given normal matrix to the active effect
  64521. *
  64522. * @param normalMatrix the matrix to bind
  64523. */
  64524. PushMaterial.prototype.bindOnlyNormalMatrix = function (normalMatrix) {
  64525. this._activeEffect.setMatrix("normalMatrix", normalMatrix);
  64526. };
  64527. PushMaterial.prototype.bind = function (world, mesh) {
  64528. if (!mesh) {
  64529. return;
  64530. }
  64531. this.bindForSubMesh(world, mesh, mesh.subMeshes[0]);
  64532. };
  64533. PushMaterial.prototype._afterBind = function (mesh, effect) {
  64534. if (effect === void 0) { effect = null; }
  64535. _super.prototype._afterBind.call(this, mesh);
  64536. this.getScene()._cachedEffect = effect;
  64537. };
  64538. PushMaterial.prototype._mustRebind = function (scene, effect, visibility) {
  64539. if (visibility === void 0) { visibility = 1; }
  64540. return scene.isCachedMaterialInvalid(this, effect, visibility);
  64541. };
  64542. return PushMaterial;
  64543. }(_Materials_material__WEBPACK_IMPORTED_MODULE_2__["Material"]));
  64544. /***/ }),
  64545. /***/ "./Materials/shaderMaterial.ts":
  64546. /*!*************************************!*\
  64547. !*** ./Materials/shaderMaterial.ts ***!
  64548. \*************************************/
  64549. /*! exports provided: ShaderMaterial */
  64550. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64551. "use strict";
  64552. __webpack_require__.r(__webpack_exports__);
  64553. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return ShaderMaterial; });
  64554. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64555. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  64556. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64557. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  64558. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  64559. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  64560. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  64561. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  64562. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  64563. /**
  64564. * 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.
  64565. *
  64566. * This returned material effects how the mesh will look based on the code in the shaders.
  64567. *
  64568. * @see http://doc.babylonjs.com/how_to/shader_material
  64569. */
  64570. var ShaderMaterial = /** @class */ (function (_super) {
  64571. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShaderMaterial, _super);
  64572. /**
  64573. * Instantiate a new shader material.
  64574. * 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.
  64575. * This returned material effects how the mesh will look based on the code in the shaders.
  64576. * @see http://doc.babylonjs.com/how_to/shader_material
  64577. * @param name Define the name of the material in the scene
  64578. * @param scene Define the scene the material belongs to
  64579. * @param shaderPath Defines the route to the shader code in one of three ways:
  64580. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  64581. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  64582. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  64583. * @param options Define the options used to create the shader
  64584. */
  64585. function ShaderMaterial(name, scene, shaderPath, options) {
  64586. if (options === void 0) { options = {}; }
  64587. var _this = _super.call(this, name, scene) || this;
  64588. _this._textures = {};
  64589. _this._textureArrays = {};
  64590. _this._floats = {};
  64591. _this._ints = {};
  64592. _this._floatsArrays = {};
  64593. _this._colors3 = {};
  64594. _this._colors3Arrays = {};
  64595. _this._colors4 = {};
  64596. _this._vectors2 = {};
  64597. _this._vectors3 = {};
  64598. _this._vectors4 = {};
  64599. _this._matrices = {};
  64600. _this._matrices3x3 = {};
  64601. _this._matrices2x2 = {};
  64602. _this._vectors2Arrays = {};
  64603. _this._vectors3Arrays = {};
  64604. _this._cachedWorldViewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  64605. _this._shaderPath = shaderPath;
  64606. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ needAlphaBlending: false, needAlphaTesting: false, attributes: ["position", "normal", "uv"], uniforms: ["worldViewProjection"], uniformBuffers: [], samplers: [], defines: [] }, options);
  64607. return _this;
  64608. }
  64609. /**
  64610. * Gets the current class name of the material e.g. "ShaderMaterial"
  64611. * Mainly use in serialization.
  64612. * @returns the class name
  64613. */
  64614. ShaderMaterial.prototype.getClassName = function () {
  64615. return "ShaderMaterial";
  64616. };
  64617. /**
  64618. * Specifies if the material will require alpha blending
  64619. * @returns a boolean specifying if alpha blending is needed
  64620. */
  64621. ShaderMaterial.prototype.needAlphaBlending = function () {
  64622. return (this.alpha < 1.0) || this._options.needAlphaBlending;
  64623. };
  64624. /**
  64625. * Specifies if this material should be rendered in alpha test mode
  64626. * @returns a boolean specifying if an alpha test is needed.
  64627. */
  64628. ShaderMaterial.prototype.needAlphaTesting = function () {
  64629. return this._options.needAlphaTesting;
  64630. };
  64631. ShaderMaterial.prototype._checkUniform = function (uniformName) {
  64632. if (this._options.uniforms.indexOf(uniformName) === -1) {
  64633. this._options.uniforms.push(uniformName);
  64634. }
  64635. };
  64636. /**
  64637. * Set a texture in the shader.
  64638. * @param name Define the name of the uniform samplers as defined in the shader
  64639. * @param texture Define the texture to bind to this sampler
  64640. * @return the material itself allowing "fluent" like uniform updates
  64641. */
  64642. ShaderMaterial.prototype.setTexture = function (name, texture) {
  64643. if (this._options.samplers.indexOf(name) === -1) {
  64644. this._options.samplers.push(name);
  64645. }
  64646. this._textures[name] = texture;
  64647. return this;
  64648. };
  64649. /**
  64650. * Set a texture array in the shader.
  64651. * @param name Define the name of the uniform sampler array as defined in the shader
  64652. * @param textures Define the list of textures to bind to this sampler
  64653. * @return the material itself allowing "fluent" like uniform updates
  64654. */
  64655. ShaderMaterial.prototype.setTextureArray = function (name, textures) {
  64656. if (this._options.samplers.indexOf(name) === -1) {
  64657. this._options.samplers.push(name);
  64658. }
  64659. this._checkUniform(name);
  64660. this._textureArrays[name] = textures;
  64661. return this;
  64662. };
  64663. /**
  64664. * Set a float in the shader.
  64665. * @param name Define the name of the uniform as defined in the shader
  64666. * @param value Define the value to give to the uniform
  64667. * @return the material itself allowing "fluent" like uniform updates
  64668. */
  64669. ShaderMaterial.prototype.setFloat = function (name, value) {
  64670. this._checkUniform(name);
  64671. this._floats[name] = value;
  64672. return this;
  64673. };
  64674. /**
  64675. * Set a int in the shader.
  64676. * @param name Define the name of the uniform as defined in the shader
  64677. * @param value Define the value to give to the uniform
  64678. * @return the material itself allowing "fluent" like uniform updates
  64679. */
  64680. ShaderMaterial.prototype.setInt = function (name, value) {
  64681. this._checkUniform(name);
  64682. this._ints[name] = value;
  64683. return this;
  64684. };
  64685. /**
  64686. * Set an array of floats in the shader.
  64687. * @param name Define the name of the uniform as defined in the shader
  64688. * @param value Define the value to give to the uniform
  64689. * @return the material itself allowing "fluent" like uniform updates
  64690. */
  64691. ShaderMaterial.prototype.setFloats = function (name, value) {
  64692. this._checkUniform(name);
  64693. this._floatsArrays[name] = value;
  64694. return this;
  64695. };
  64696. /**
  64697. * Set a vec3 in the shader from a Color3.
  64698. * @param name Define the name of the uniform as defined in the shader
  64699. * @param value Define the value to give to the uniform
  64700. * @return the material itself allowing "fluent" like uniform updates
  64701. */
  64702. ShaderMaterial.prototype.setColor3 = function (name, value) {
  64703. this._checkUniform(name);
  64704. this._colors3[name] = value;
  64705. return this;
  64706. };
  64707. /**
  64708. * Set a vec3 array in the shader from a Color3 array.
  64709. * @param name Define the name of the uniform as defined in the shader
  64710. * @param value Define the value to give to the uniform
  64711. * @return the material itself allowing "fluent" like uniform updates
  64712. */
  64713. ShaderMaterial.prototype.setColor3Array = function (name, value) {
  64714. this._checkUniform(name);
  64715. this._colors3Arrays[name] = value.reduce(function (arr, color) {
  64716. color.toArray(arr, arr.length);
  64717. return arr;
  64718. }, []);
  64719. return this;
  64720. };
  64721. /**
  64722. * Set a vec4 in the shader from a Color4.
  64723. * @param name Define the name of the uniform as defined in the shader
  64724. * @param value Define the value to give to the uniform
  64725. * @return the material itself allowing "fluent" like uniform updates
  64726. */
  64727. ShaderMaterial.prototype.setColor4 = function (name, value) {
  64728. this._checkUniform(name);
  64729. this._colors4[name] = value;
  64730. return this;
  64731. };
  64732. /**
  64733. * Set a vec2 in the shader from a Vector2.
  64734. * @param name Define the name of the uniform as defined in the shader
  64735. * @param value Define the value to give to the uniform
  64736. * @return the material itself allowing "fluent" like uniform updates
  64737. */
  64738. ShaderMaterial.prototype.setVector2 = function (name, value) {
  64739. this._checkUniform(name);
  64740. this._vectors2[name] = value;
  64741. return this;
  64742. };
  64743. /**
  64744. * Set a vec3 in the shader from a Vector3.
  64745. * @param name Define the name of the uniform as defined in the shader
  64746. * @param value Define the value to give to the uniform
  64747. * @return the material itself allowing "fluent" like uniform updates
  64748. */
  64749. ShaderMaterial.prototype.setVector3 = function (name, value) {
  64750. this._checkUniform(name);
  64751. this._vectors3[name] = value;
  64752. return this;
  64753. };
  64754. /**
  64755. * Set a vec4 in the shader from a Vector4.
  64756. * @param name Define the name of the uniform as defined in the shader
  64757. * @param value Define the value to give to the uniform
  64758. * @return the material itself allowing "fluent" like uniform updates
  64759. */
  64760. ShaderMaterial.prototype.setVector4 = function (name, value) {
  64761. this._checkUniform(name);
  64762. this._vectors4[name] = value;
  64763. return this;
  64764. };
  64765. /**
  64766. * Set a mat4 in the shader from a Matrix.
  64767. * @param name Define the name of the uniform as defined in the shader
  64768. * @param value Define the value to give to the uniform
  64769. * @return the material itself allowing "fluent" like uniform updates
  64770. */
  64771. ShaderMaterial.prototype.setMatrix = function (name, value) {
  64772. this._checkUniform(name);
  64773. this._matrices[name] = value;
  64774. return this;
  64775. };
  64776. /**
  64777. * Set a mat3 in the shader from a Float32Array.
  64778. * @param name Define the name of the uniform as defined in the shader
  64779. * @param value Define the value to give to the uniform
  64780. * @return the material itself allowing "fluent" like uniform updates
  64781. */
  64782. ShaderMaterial.prototype.setMatrix3x3 = function (name, value) {
  64783. this._checkUniform(name);
  64784. this._matrices3x3[name] = value;
  64785. return this;
  64786. };
  64787. /**
  64788. * Set a mat2 in the shader from a Float32Array.
  64789. * @param name Define the name of the uniform as defined in the shader
  64790. * @param value Define the value to give to the uniform
  64791. * @return the material itself allowing "fluent" like uniform updates
  64792. */
  64793. ShaderMaterial.prototype.setMatrix2x2 = function (name, value) {
  64794. this._checkUniform(name);
  64795. this._matrices2x2[name] = value;
  64796. return this;
  64797. };
  64798. /**
  64799. * Set a vec2 array in the shader from a number array.
  64800. * @param name Define the name of the uniform as defined in the shader
  64801. * @param value Define the value to give to the uniform
  64802. * @return the material itself allowing "fluent" like uniform updates
  64803. */
  64804. ShaderMaterial.prototype.setArray2 = function (name, value) {
  64805. this._checkUniform(name);
  64806. this._vectors2Arrays[name] = value;
  64807. return this;
  64808. };
  64809. /**
  64810. * Set a vec3 array in the shader from a number array.
  64811. * @param name Define the name of the uniform as defined in the shader
  64812. * @param value Define the value to give to the uniform
  64813. * @return the material itself allowing "fluent" like uniform updates
  64814. */
  64815. ShaderMaterial.prototype.setArray3 = function (name, value) {
  64816. this._checkUniform(name);
  64817. this._vectors3Arrays[name] = value;
  64818. return this;
  64819. };
  64820. ShaderMaterial.prototype._checkCache = function (mesh, useInstances) {
  64821. if (!mesh) {
  64822. return true;
  64823. }
  64824. if (this._effect && (this._effect.defines.indexOf("#define INSTANCES") !== -1) !== useInstances) {
  64825. return false;
  64826. }
  64827. return false;
  64828. };
  64829. /**
  64830. * Checks if the material is ready to render the requested mesh
  64831. * @param mesh Define the mesh to render
  64832. * @param useInstances Define whether or not the material is used with instances
  64833. * @returns true if ready, otherwise false
  64834. */
  64835. ShaderMaterial.prototype.isReady = function (mesh, useInstances) {
  64836. var scene = this.getScene();
  64837. var engine = scene.getEngine();
  64838. if (!this.checkReadyOnEveryCall) {
  64839. if (this._renderId === scene.getRenderId()) {
  64840. if (this._checkCache(mesh, useInstances)) {
  64841. return true;
  64842. }
  64843. }
  64844. }
  64845. // Instances
  64846. var defines = [];
  64847. var attribs = [];
  64848. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  64849. for (var index = 0; index < this._options.defines.length; index++) {
  64850. defines.push(this._options.defines[index]);
  64851. }
  64852. for (var index = 0; index < this._options.attributes.length; index++) {
  64853. attribs.push(this._options.attributes[index]);
  64854. }
  64855. if (mesh && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  64856. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind);
  64857. defines.push("#define VERTEXCOLOR");
  64858. }
  64859. if (useInstances) {
  64860. defines.push("#define INSTANCES");
  64861. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  64862. }
  64863. // Bones
  64864. if (mesh && mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  64865. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  64866. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind);
  64867. if (mesh.numBoneInfluencers > 4) {
  64868. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind);
  64869. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsExtraKind);
  64870. }
  64871. var skeleton = mesh.skeleton;
  64872. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  64873. fallbacks.addCPUSkinningFallback(0, mesh);
  64874. if (skeleton.isUsingTextureForMatrices) {
  64875. defines.push("#define BONETEXTURE");
  64876. if (this._options.uniforms.indexOf("boneTextureWidth") === -1) {
  64877. this._options.uniforms.push("boneTextureWidth");
  64878. }
  64879. if (this._options.samplers.indexOf("boneSampler") === -1) {
  64880. this._options.samplers.push("boneSampler");
  64881. }
  64882. }
  64883. else {
  64884. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  64885. if (this._options.uniforms.indexOf("mBones") === -1) {
  64886. this._options.uniforms.push("mBones");
  64887. }
  64888. }
  64889. }
  64890. else {
  64891. defines.push("#define NUM_BONE_INFLUENCERS 0");
  64892. }
  64893. // Textures
  64894. for (var name in this._textures) {
  64895. if (!this._textures[name].isReady()) {
  64896. return false;
  64897. }
  64898. }
  64899. // Alpha test
  64900. if (mesh && this._shouldTurnAlphaTestOn(mesh)) {
  64901. defines.push("#define ALPHATEST");
  64902. }
  64903. var previousEffect = this._effect;
  64904. var join = defines.join("\n");
  64905. this._effect = engine.createEffect(this._shaderPath, {
  64906. attributes: attribs,
  64907. uniformsNames: this._options.uniforms,
  64908. uniformBuffersNames: this._options.uniformBuffers,
  64909. samplers: this._options.samplers,
  64910. defines: join,
  64911. fallbacks: fallbacks,
  64912. onCompiled: this.onCompiled,
  64913. onError: this.onError
  64914. }, engine);
  64915. if (!this._effect.isReady()) {
  64916. return false;
  64917. }
  64918. if (previousEffect !== this._effect) {
  64919. scene.resetCachedMaterial();
  64920. }
  64921. this._renderId = scene.getRenderId();
  64922. return true;
  64923. };
  64924. /**
  64925. * Binds the world matrix to the material
  64926. * @param world defines the world transformation matrix
  64927. */
  64928. ShaderMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  64929. var scene = this.getScene();
  64930. if (!this._effect) {
  64931. return;
  64932. }
  64933. if (this._options.uniforms.indexOf("world") !== -1) {
  64934. this._effect.setMatrix("world", world);
  64935. }
  64936. if (this._options.uniforms.indexOf("worldView") !== -1) {
  64937. world.multiplyToRef(scene.getViewMatrix(), this._cachedWorldViewMatrix);
  64938. this._effect.setMatrix("worldView", this._cachedWorldViewMatrix);
  64939. }
  64940. if (this._options.uniforms.indexOf("worldViewProjection") !== -1) {
  64941. this._effect.setMatrix("worldViewProjection", world.multiply(scene.getTransformMatrix()));
  64942. }
  64943. };
  64944. /**
  64945. * Binds the material to the mesh
  64946. * @param world defines the world transformation matrix
  64947. * @param mesh defines the mesh to bind the material to
  64948. */
  64949. ShaderMaterial.prototype.bind = function (world, mesh) {
  64950. // Std values
  64951. this.bindOnlyWorldMatrix(world);
  64952. if (this._effect && this.getScene().getCachedMaterial() !== this) {
  64953. if (this._options.uniforms.indexOf("view") !== -1) {
  64954. this._effect.setMatrix("view", this.getScene().getViewMatrix());
  64955. }
  64956. if (this._options.uniforms.indexOf("projection") !== -1) {
  64957. this._effect.setMatrix("projection", this.getScene().getProjectionMatrix());
  64958. }
  64959. if (this._options.uniforms.indexOf("viewProjection") !== -1) {
  64960. this._effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  64961. }
  64962. // Bones
  64963. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindBonesParameters(mesh, this._effect);
  64964. var name;
  64965. // Texture
  64966. for (name in this._textures) {
  64967. this._effect.setTexture(name, this._textures[name]);
  64968. }
  64969. // Texture arrays
  64970. for (name in this._textureArrays) {
  64971. this._effect.setTextureArray(name, this._textureArrays[name]);
  64972. }
  64973. // Int
  64974. for (name in this._ints) {
  64975. this._effect.setInt(name, this._ints[name]);
  64976. }
  64977. // Float
  64978. for (name in this._floats) {
  64979. this._effect.setFloat(name, this._floats[name]);
  64980. }
  64981. // Floats
  64982. for (name in this._floatsArrays) {
  64983. this._effect.setArray(name, this._floatsArrays[name]);
  64984. }
  64985. // Color3
  64986. for (name in this._colors3) {
  64987. this._effect.setColor3(name, this._colors3[name]);
  64988. }
  64989. for (name in this._colors3Arrays) {
  64990. this._effect.setArray3(name, this._colors3Arrays[name]);
  64991. }
  64992. // Color4
  64993. for (name in this._colors4) {
  64994. var color = this._colors4[name];
  64995. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  64996. }
  64997. // Vector2
  64998. for (name in this._vectors2) {
  64999. this._effect.setVector2(name, this._vectors2[name]);
  65000. }
  65001. // Vector3
  65002. for (name in this._vectors3) {
  65003. this._effect.setVector3(name, this._vectors3[name]);
  65004. }
  65005. // Vector4
  65006. for (name in this._vectors4) {
  65007. this._effect.setVector4(name, this._vectors4[name]);
  65008. }
  65009. // Matrix
  65010. for (name in this._matrices) {
  65011. this._effect.setMatrix(name, this._matrices[name]);
  65012. }
  65013. // Matrix 3x3
  65014. for (name in this._matrices3x3) {
  65015. this._effect.setMatrix3x3(name, this._matrices3x3[name]);
  65016. }
  65017. // Matrix 2x2
  65018. for (name in this._matrices2x2) {
  65019. this._effect.setMatrix2x2(name, this._matrices2x2[name]);
  65020. }
  65021. // Vector2Array
  65022. for (name in this._vectors2Arrays) {
  65023. this._effect.setArray2(name, this._vectors2Arrays[name]);
  65024. }
  65025. // Vector3Array
  65026. for (name in this._vectors3Arrays) {
  65027. this._effect.setArray3(name, this._vectors3Arrays[name]);
  65028. }
  65029. }
  65030. this._afterBind(mesh);
  65031. };
  65032. /**
  65033. * Gets the active textures from the material
  65034. * @returns an array of textures
  65035. */
  65036. ShaderMaterial.prototype.getActiveTextures = function () {
  65037. var activeTextures = _super.prototype.getActiveTextures.call(this);
  65038. for (var name in this._textures) {
  65039. activeTextures.push(this._textures[name]);
  65040. }
  65041. for (var name in this._textureArrays) {
  65042. var array = this._textureArrays[name];
  65043. for (var index = 0; index < array.length; index++) {
  65044. activeTextures.push(array[index]);
  65045. }
  65046. }
  65047. return activeTextures;
  65048. };
  65049. /**
  65050. * Specifies if the material uses a texture
  65051. * @param texture defines the texture to check against the material
  65052. * @returns a boolean specifying if the material uses the texture
  65053. */
  65054. ShaderMaterial.prototype.hasTexture = function (texture) {
  65055. if (_super.prototype.hasTexture.call(this, texture)) {
  65056. return true;
  65057. }
  65058. for (var name in this._textures) {
  65059. if (this._textures[name] === texture) {
  65060. return true;
  65061. }
  65062. }
  65063. for (var name in this._textureArrays) {
  65064. var array = this._textureArrays[name];
  65065. for (var index = 0; index < array.length; index++) {
  65066. if (array[index] === texture) {
  65067. return true;
  65068. }
  65069. }
  65070. }
  65071. return false;
  65072. };
  65073. /**
  65074. * Makes a duplicate of the material, and gives it a new name
  65075. * @param name defines the new name for the duplicated material
  65076. * @returns the cloned material
  65077. */
  65078. ShaderMaterial.prototype.clone = function (name) {
  65079. var newShaderMaterial = new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options);
  65080. return newShaderMaterial;
  65081. };
  65082. /**
  65083. * Disposes the material
  65084. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  65085. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  65086. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  65087. */
  65088. ShaderMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  65089. if (forceDisposeTextures) {
  65090. var name;
  65091. for (name in this._textures) {
  65092. this._textures[name].dispose();
  65093. }
  65094. for (name in this._textureArrays) {
  65095. var array = this._textureArrays[name];
  65096. for (var index = 0; index < array.length; index++) {
  65097. array[index].dispose();
  65098. }
  65099. }
  65100. }
  65101. this._textures = {};
  65102. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures, notBoundToMesh);
  65103. };
  65104. /**
  65105. * Serializes this material in a JSON representation
  65106. * @returns the serialized material object
  65107. */
  65108. ShaderMaterial.prototype.serialize = function () {
  65109. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  65110. serializationObject.customType = "ShaderMaterial";
  65111. serializationObject.options = this._options;
  65112. serializationObject.shaderPath = this._shaderPath;
  65113. var name;
  65114. // Texture
  65115. serializationObject.textures = {};
  65116. for (name in this._textures) {
  65117. serializationObject.textures[name] = this._textures[name].serialize();
  65118. }
  65119. // Texture arrays
  65120. serializationObject.textureArrays = {};
  65121. for (name in this._textureArrays) {
  65122. serializationObject.textureArrays[name] = [];
  65123. var array = this._textureArrays[name];
  65124. for (var index = 0; index < array.length; index++) {
  65125. serializationObject.textureArrays[name].push(array[index].serialize());
  65126. }
  65127. }
  65128. // Float
  65129. serializationObject.floats = {};
  65130. for (name in this._floats) {
  65131. serializationObject.floats[name] = this._floats[name];
  65132. }
  65133. // Float s
  65134. serializationObject.FloatArrays = {};
  65135. for (name in this._floatsArrays) {
  65136. serializationObject.FloatArrays[name] = this._floatsArrays[name];
  65137. }
  65138. // Color3
  65139. serializationObject.colors3 = {};
  65140. for (name in this._colors3) {
  65141. serializationObject.colors3[name] = this._colors3[name].asArray();
  65142. }
  65143. // Color3 array
  65144. serializationObject.colors3Arrays = {};
  65145. for (name in this._colors3Arrays) {
  65146. serializationObject.colors3Arrays[name] = this._colors3Arrays[name];
  65147. }
  65148. // Color4
  65149. serializationObject.colors4 = {};
  65150. for (name in this._colors4) {
  65151. serializationObject.colors4[name] = this._colors4[name].asArray();
  65152. }
  65153. // Vector2
  65154. serializationObject.vectors2 = {};
  65155. for (name in this._vectors2) {
  65156. serializationObject.vectors2[name] = this._vectors2[name].asArray();
  65157. }
  65158. // Vector3
  65159. serializationObject.vectors3 = {};
  65160. for (name in this._vectors3) {
  65161. serializationObject.vectors3[name] = this._vectors3[name].asArray();
  65162. }
  65163. // Vector4
  65164. serializationObject.vectors4 = {};
  65165. for (name in this._vectors4) {
  65166. serializationObject.vectors4[name] = this._vectors4[name].asArray();
  65167. }
  65168. // Matrix
  65169. serializationObject.matrices = {};
  65170. for (name in this._matrices) {
  65171. serializationObject.matrices[name] = this._matrices[name].asArray();
  65172. }
  65173. // Matrix 3x3
  65174. serializationObject.matrices3x3 = {};
  65175. for (name in this._matrices3x3) {
  65176. serializationObject.matrices3x3[name] = this._matrices3x3[name];
  65177. }
  65178. // Matrix 2x2
  65179. serializationObject.matrices2x2 = {};
  65180. for (name in this._matrices2x2) {
  65181. serializationObject.matrices2x2[name] = this._matrices2x2[name];
  65182. }
  65183. // Vector2Array
  65184. serializationObject.vectors2Arrays = {};
  65185. for (name in this._vectors2Arrays) {
  65186. serializationObject.vectors2Arrays[name] = this._vectors2Arrays[name];
  65187. }
  65188. // Vector3Array
  65189. serializationObject.vectors3Arrays = {};
  65190. for (name in this._vectors3Arrays) {
  65191. serializationObject.vectors3Arrays[name] = this._vectors3Arrays[name];
  65192. }
  65193. return serializationObject;
  65194. };
  65195. /**
  65196. * Creates a shader material from parsed shader material data
  65197. * @param source defines the JSON represnetation of the material
  65198. * @param scene defines the hosting scene
  65199. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  65200. * @returns a new material
  65201. */
  65202. ShaderMaterial.Parse = function (source, scene, rootUrl) {
  65203. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ShaderMaterial(source.name, scene, source.shaderPath, source.options); }, source, scene, rootUrl);
  65204. var name;
  65205. // Texture
  65206. for (name in source.textures) {
  65207. material.setTexture(name, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(source.textures[name], scene, rootUrl));
  65208. }
  65209. // Texture arrays
  65210. for (name in source.textureArrays) {
  65211. var array = source.textureArrays[name];
  65212. var textureArray = new Array();
  65213. for (var index = 0; index < array.length; index++) {
  65214. textureArray.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(array[index], scene, rootUrl));
  65215. }
  65216. material.setTextureArray(name, textureArray);
  65217. }
  65218. // Float
  65219. for (name in source.floats) {
  65220. material.setFloat(name, source.floats[name]);
  65221. }
  65222. // Float s
  65223. for (name in source.floatsArrays) {
  65224. material.setFloats(name, source.floatsArrays[name]);
  65225. }
  65226. // Color3
  65227. for (name in source.colors3) {
  65228. material.setColor3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(source.colors3[name]));
  65229. }
  65230. // Color3 arrays
  65231. for (name in source.colors3Arrays) {
  65232. var colors = source.colors3Arrays[name].reduce(function (arr, num, i) {
  65233. if (i % 3 === 0) {
  65234. arr.push([num]);
  65235. }
  65236. else {
  65237. arr[arr.length - 1].push(num);
  65238. }
  65239. return arr;
  65240. }, []).map(function (color) { return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(color); });
  65241. material.setColor3Array(name, colors);
  65242. }
  65243. // Color4
  65244. for (name in source.colors4) {
  65245. material.setColor4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(source.colors4[name]));
  65246. }
  65247. // Vector2
  65248. for (name in source.vectors2) {
  65249. material.setVector2(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"].FromArray(source.vectors2[name]));
  65250. }
  65251. // Vector3
  65252. for (name in source.vectors3) {
  65253. material.setVector3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(source.vectors3[name]));
  65254. }
  65255. // Vector4
  65256. for (name in source.vectors4) {
  65257. material.setVector4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector4"].FromArray(source.vectors4[name]));
  65258. }
  65259. // Matrix
  65260. for (name in source.matrices) {
  65261. material.setMatrix(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(source.matrices[name]));
  65262. }
  65263. // Matrix 3x3
  65264. for (name in source.matrices3x3) {
  65265. material.setMatrix3x3(name, source.matrices3x3[name]);
  65266. }
  65267. // Matrix 2x2
  65268. for (name in source.matrices2x2) {
  65269. material.setMatrix2x2(name, source.matrices2x2[name]);
  65270. }
  65271. // Vector2Array
  65272. for (name in source.vectors2Arrays) {
  65273. material.setArray2(name, source.vectors2Arrays[name]);
  65274. }
  65275. // Vector3Array
  65276. for (name in source.vectors3Arrays) {
  65277. material.setArray3(name, source.vectors3Arrays[name]);
  65278. }
  65279. return material;
  65280. };
  65281. return ShaderMaterial;
  65282. }(_material__WEBPACK_IMPORTED_MODULE_7__["Material"]));
  65283. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.ShaderMaterial"] = ShaderMaterial;
  65284. /***/ }),
  65285. /***/ "./Materials/standardMaterial.ts":
  65286. /*!***************************************!*\
  65287. !*** ./Materials/standardMaterial.ts ***!
  65288. \***************************************/
  65289. /*! exports provided: StandardMaterialDefines, StandardMaterial */
  65290. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65291. "use strict";
  65292. __webpack_require__.r(__webpack_exports__);
  65293. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return StandardMaterialDefines; });
  65294. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return StandardMaterial; });
  65295. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  65296. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  65297. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  65298. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  65299. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  65300. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  65301. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  65302. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  65303. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  65304. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  65305. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  65306. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  65307. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  65308. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  65309. /* harmony import */ var _Shaders_default_fragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/default.fragment */ "./Shaders/default.fragment.ts");
  65310. /* harmony import */ var _Shaders_default_vertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/default.vertex */ "./Shaders/default.vertex.ts");
  65311. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  65312. /** @hidden */
  65313. var StandardMaterialDefines = /** @class */ (function (_super) {
  65314. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterialDefines, _super);
  65315. function StandardMaterialDefines() {
  65316. var _this = _super.call(this) || this;
  65317. _this.MAINUV1 = false;
  65318. _this.MAINUV2 = false;
  65319. _this.DIFFUSE = false;
  65320. _this.DIFFUSEDIRECTUV = 0;
  65321. _this.AMBIENT = false;
  65322. _this.AMBIENTDIRECTUV = 0;
  65323. _this.OPACITY = false;
  65324. _this.OPACITYDIRECTUV = 0;
  65325. _this.OPACITYRGB = false;
  65326. _this.REFLECTION = false;
  65327. _this.EMISSIVE = false;
  65328. _this.EMISSIVEDIRECTUV = 0;
  65329. _this.SPECULAR = false;
  65330. _this.SPECULARDIRECTUV = 0;
  65331. _this.BUMP = false;
  65332. _this.BUMPDIRECTUV = 0;
  65333. _this.PARALLAX = false;
  65334. _this.PARALLAXOCCLUSION = false;
  65335. _this.SPECULAROVERALPHA = false;
  65336. _this.CLIPPLANE = false;
  65337. _this.CLIPPLANE2 = false;
  65338. _this.CLIPPLANE3 = false;
  65339. _this.CLIPPLANE4 = false;
  65340. _this.ALPHATEST = false;
  65341. _this.DEPTHPREPASS = false;
  65342. _this.ALPHAFROMDIFFUSE = false;
  65343. _this.POINTSIZE = false;
  65344. _this.FOG = false;
  65345. _this.SPECULARTERM = false;
  65346. _this.DIFFUSEFRESNEL = false;
  65347. _this.OPACITYFRESNEL = false;
  65348. _this.REFLECTIONFRESNEL = false;
  65349. _this.REFRACTIONFRESNEL = false;
  65350. _this.EMISSIVEFRESNEL = false;
  65351. _this.FRESNEL = false;
  65352. _this.NORMAL = false;
  65353. _this.UV1 = false;
  65354. _this.UV2 = false;
  65355. _this.VERTEXCOLOR = false;
  65356. _this.VERTEXALPHA = false;
  65357. _this.NUM_BONE_INFLUENCERS = 0;
  65358. _this.BonesPerMesh = 0;
  65359. _this.BONETEXTURE = false;
  65360. _this.INSTANCES = false;
  65361. _this.GLOSSINESS = false;
  65362. _this.ROUGHNESS = false;
  65363. _this.EMISSIVEASILLUMINATION = false;
  65364. _this.LINKEMISSIVEWITHDIFFUSE = false;
  65365. _this.REFLECTIONFRESNELFROMSPECULAR = false;
  65366. _this.LIGHTMAP = false;
  65367. _this.LIGHTMAPDIRECTUV = 0;
  65368. _this.OBJECTSPACE_NORMALMAP = false;
  65369. _this.USELIGHTMAPASSHADOWMAP = false;
  65370. _this.REFLECTIONMAP_3D = false;
  65371. _this.REFLECTIONMAP_SPHERICAL = false;
  65372. _this.REFLECTIONMAP_PLANAR = false;
  65373. _this.REFLECTIONMAP_CUBIC = false;
  65374. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  65375. _this.REFLECTIONMAP_PROJECTION = false;
  65376. _this.REFLECTIONMAP_SKYBOX = false;
  65377. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  65378. _this.REFLECTIONMAP_EXPLICIT = false;
  65379. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  65380. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  65381. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  65382. _this.INVERTCUBICMAP = false;
  65383. _this.LOGARITHMICDEPTH = false;
  65384. _this.REFRACTION = false;
  65385. _this.REFRACTIONMAP_3D = false;
  65386. _this.REFLECTIONOVERALPHA = false;
  65387. _this.TWOSIDEDLIGHTING = false;
  65388. _this.SHADOWFLOAT = false;
  65389. _this.MORPHTARGETS = false;
  65390. _this.MORPHTARGETS_NORMAL = false;
  65391. _this.MORPHTARGETS_TANGENT = false;
  65392. _this.NUM_MORPH_INFLUENCERS = 0;
  65393. _this.NONUNIFORMSCALING = false; // https://playground.babylonjs.com#V6DWIH
  65394. _this.PREMULTIPLYALPHA = false; // https://playground.babylonjs.com#LNVJJ7
  65395. _this.IMAGEPROCESSING = false;
  65396. _this.VIGNETTE = false;
  65397. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  65398. _this.VIGNETTEBLENDMODEOPAQUE = false;
  65399. _this.TONEMAPPING = false;
  65400. _this.TONEMAPPING_ACES = false;
  65401. _this.CONTRAST = false;
  65402. _this.COLORCURVES = false;
  65403. _this.COLORGRADING = false;
  65404. _this.COLORGRADING3D = false;
  65405. _this.SAMPLER3DGREENDEPTH = false;
  65406. _this.SAMPLER3DBGRMAP = false;
  65407. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  65408. /**
  65409. * If the reflection texture on this material is in linear color space
  65410. * @hidden
  65411. */
  65412. _this.IS_REFLECTION_LINEAR = false;
  65413. /**
  65414. * If the refraction texture on this material is in linear color space
  65415. * @hidden
  65416. */
  65417. _this.IS_REFRACTION_LINEAR = false;
  65418. _this.EXPOSURE = false;
  65419. _this.rebuild();
  65420. return _this;
  65421. }
  65422. StandardMaterialDefines.prototype.setReflectionMode = function (modeToEnable) {
  65423. var modes = [
  65424. "REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR",
  65425. "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX",
  65426. "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED",
  65427. "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"
  65428. ];
  65429. for (var _i = 0, modes_1 = modes; _i < modes_1.length; _i++) {
  65430. var mode = modes_1[_i];
  65431. this[mode] = (mode === modeToEnable);
  65432. }
  65433. };
  65434. return StandardMaterialDefines;
  65435. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  65436. /**
  65437. * This is the default material used in Babylon. It is the best trade off between quality
  65438. * and performances.
  65439. * @see http://doc.babylonjs.com/babylon101/materials
  65440. */
  65441. var StandardMaterial = /** @class */ (function (_super) {
  65442. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterial, _super);
  65443. /**
  65444. * Instantiates a new standard material.
  65445. * This is the default material used in Babylon. It is the best trade off between quality
  65446. * and performances.
  65447. * @see http://doc.babylonjs.com/babylon101/materials
  65448. * @param name Define the name of the material in the scene
  65449. * @param scene Define the scene the material belong to
  65450. */
  65451. function StandardMaterial(name, scene) {
  65452. var _this = _super.call(this, name, scene) || this;
  65453. /**
  65454. * The color of the material lit by the environmental background lighting.
  65455. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  65456. */
  65457. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  65458. /**
  65459. * The basic color of the material as viewed under a light.
  65460. */
  65461. _this.diffuseColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  65462. /**
  65463. * Define how the color and intensity of the highlight given by the light in the material.
  65464. */
  65465. _this.specularColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  65466. /**
  65467. * Define the color of the material as if self lit.
  65468. * This will be mixed in the final result even in the absence of light.
  65469. */
  65470. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  65471. /**
  65472. * Defines how sharp are the highlights in the material.
  65473. * The bigger the value the sharper giving a more glossy feeling to the result.
  65474. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  65475. */
  65476. _this.specularPower = 64;
  65477. _this._useAlphaFromDiffuseTexture = false;
  65478. _this._useEmissiveAsIllumination = false;
  65479. _this._linkEmissiveWithDiffuse = false;
  65480. _this._useSpecularOverAlpha = false;
  65481. _this._useReflectionOverAlpha = false;
  65482. _this._disableLighting = false;
  65483. _this._useObjectSpaceNormalMap = false;
  65484. _this._useParallax = false;
  65485. _this._useParallaxOcclusion = false;
  65486. /**
  65487. * 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.
  65488. */
  65489. _this.parallaxScaleBias = 0.05;
  65490. _this._roughness = 0;
  65491. /**
  65492. * In case of refraction, define the value of the indice of refraction.
  65493. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  65494. */
  65495. _this.indexOfRefraction = 0.98;
  65496. /**
  65497. * Invert the refraction texture alongside the y axis.
  65498. * It can be useful with procedural textures or probe for instance.
  65499. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  65500. */
  65501. _this.invertRefractionY = true;
  65502. /**
  65503. * Defines the alpha limits in alpha test mode.
  65504. */
  65505. _this.alphaCutOff = 0.4;
  65506. _this._useLightmapAsShadowmap = false;
  65507. _this._useReflectionFresnelFromSpecular = false;
  65508. _this._useGlossinessFromSpecularMapAlpha = false;
  65509. _this._maxSimultaneousLights = 4;
  65510. _this._invertNormalMapX = false;
  65511. _this._invertNormalMapY = false;
  65512. _this._twoSidedLighting = false;
  65513. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  65514. _this._worldViewProjectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  65515. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  65516. // Setup the default processing configuration to the scene.
  65517. _this._attachImageProcessingConfiguration(null);
  65518. _this.getRenderTargetTextures = function () {
  65519. _this._renderTargets.reset();
  65520. if (StandardMaterial.ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  65521. _this._renderTargets.push(_this._reflectionTexture);
  65522. }
  65523. if (StandardMaterial.RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  65524. _this._renderTargets.push(_this._refractionTexture);
  65525. }
  65526. return _this._renderTargets;
  65527. };
  65528. return _this;
  65529. }
  65530. Object.defineProperty(StandardMaterial.prototype, "imageProcessingConfiguration", {
  65531. /**
  65532. * Gets the image processing configuration used either in this material.
  65533. */
  65534. get: function () {
  65535. return this._imageProcessingConfiguration;
  65536. },
  65537. /**
  65538. * Sets the Default image processing configuration used either in the this material.
  65539. *
  65540. * If sets to null, the scene one is in use.
  65541. */
  65542. set: function (value) {
  65543. this._attachImageProcessingConfiguration(value);
  65544. // Ensure the effect will be rebuilt.
  65545. this._markAllSubMeshesAsTexturesDirty();
  65546. },
  65547. enumerable: true,
  65548. configurable: true
  65549. });
  65550. /**
  65551. * Attaches a new image processing configuration to the Standard Material.
  65552. * @param configuration
  65553. */
  65554. StandardMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  65555. var _this = this;
  65556. if (configuration === this._imageProcessingConfiguration) {
  65557. return;
  65558. }
  65559. // Detaches observer.
  65560. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  65561. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  65562. }
  65563. // Pick the scene configuration if needed.
  65564. if (!configuration) {
  65565. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  65566. }
  65567. else {
  65568. this._imageProcessingConfiguration = configuration;
  65569. }
  65570. // Attaches observer.
  65571. if (this._imageProcessingConfiguration) {
  65572. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  65573. _this._markAllSubMeshesAsImageProcessingDirty();
  65574. });
  65575. }
  65576. };
  65577. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurvesEnabled", {
  65578. /**
  65579. * Gets wether the color curves effect is enabled.
  65580. */
  65581. get: function () {
  65582. return this.imageProcessingConfiguration.colorCurvesEnabled;
  65583. },
  65584. /**
  65585. * Sets wether the color curves effect is enabled.
  65586. */
  65587. set: function (value) {
  65588. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  65589. },
  65590. enumerable: true,
  65591. configurable: true
  65592. });
  65593. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingEnabled", {
  65594. /**
  65595. * Gets wether the color grading effect is enabled.
  65596. */
  65597. get: function () {
  65598. return this.imageProcessingConfiguration.colorGradingEnabled;
  65599. },
  65600. /**
  65601. * Gets wether the color grading effect is enabled.
  65602. */
  65603. set: function (value) {
  65604. this.imageProcessingConfiguration.colorGradingEnabled = value;
  65605. },
  65606. enumerable: true,
  65607. configurable: true
  65608. });
  65609. Object.defineProperty(StandardMaterial.prototype, "cameraToneMappingEnabled", {
  65610. /**
  65611. * Gets wether tonemapping is enabled or not.
  65612. */
  65613. get: function () {
  65614. return this._imageProcessingConfiguration.toneMappingEnabled;
  65615. },
  65616. /**
  65617. * Sets wether tonemapping is enabled or not
  65618. */
  65619. set: function (value) {
  65620. this._imageProcessingConfiguration.toneMappingEnabled = value;
  65621. },
  65622. enumerable: true,
  65623. configurable: true
  65624. });
  65625. Object.defineProperty(StandardMaterial.prototype, "cameraExposure", {
  65626. /**
  65627. * The camera exposure used on this material.
  65628. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  65629. * This corresponds to a photographic exposure.
  65630. */
  65631. get: function () {
  65632. return this._imageProcessingConfiguration.exposure;
  65633. },
  65634. /**
  65635. * The camera exposure used on this material.
  65636. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  65637. * This corresponds to a photographic exposure.
  65638. */
  65639. set: function (value) {
  65640. this._imageProcessingConfiguration.exposure = value;
  65641. },
  65642. enumerable: true,
  65643. configurable: true
  65644. });
  65645. Object.defineProperty(StandardMaterial.prototype, "cameraContrast", {
  65646. /**
  65647. * Gets The camera contrast used on this material.
  65648. */
  65649. get: function () {
  65650. return this._imageProcessingConfiguration.contrast;
  65651. },
  65652. /**
  65653. * Sets The camera contrast used on this material.
  65654. */
  65655. set: function (value) {
  65656. this._imageProcessingConfiguration.contrast = value;
  65657. },
  65658. enumerable: true,
  65659. configurable: true
  65660. });
  65661. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingTexture", {
  65662. /**
  65663. * Gets the Color Grading 2D Lookup Texture.
  65664. */
  65665. get: function () {
  65666. return this._imageProcessingConfiguration.colorGradingTexture;
  65667. },
  65668. /**
  65669. * Sets the Color Grading 2D Lookup Texture.
  65670. */
  65671. set: function (value) {
  65672. this._imageProcessingConfiguration.colorGradingTexture = value;
  65673. },
  65674. enumerable: true,
  65675. configurable: true
  65676. });
  65677. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurves", {
  65678. /**
  65679. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  65680. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  65681. * 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;
  65682. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  65683. */
  65684. get: function () {
  65685. return this._imageProcessingConfiguration.colorCurves;
  65686. },
  65687. /**
  65688. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  65689. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  65690. * 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;
  65691. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  65692. */
  65693. set: function (value) {
  65694. this._imageProcessingConfiguration.colorCurves = value;
  65695. },
  65696. enumerable: true,
  65697. configurable: true
  65698. });
  65699. Object.defineProperty(StandardMaterial.prototype, "hasRenderTargetTextures", {
  65700. /**
  65701. * Gets a boolean indicating that current material needs to register RTT
  65702. */
  65703. get: function () {
  65704. if (StandardMaterial.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  65705. return true;
  65706. }
  65707. if (StandardMaterial.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  65708. return true;
  65709. }
  65710. return false;
  65711. },
  65712. enumerable: true,
  65713. configurable: true
  65714. });
  65715. /**
  65716. * Gets the current class name of the material e.g. "StandardMaterial"
  65717. * Mainly use in serialization.
  65718. * @returns the class name
  65719. */
  65720. StandardMaterial.prototype.getClassName = function () {
  65721. return "StandardMaterial";
  65722. };
  65723. Object.defineProperty(StandardMaterial.prototype, "useLogarithmicDepth", {
  65724. /**
  65725. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  65726. * You can try switching to logarithmic depth.
  65727. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  65728. */
  65729. get: function () {
  65730. return this._useLogarithmicDepth;
  65731. },
  65732. set: function (value) {
  65733. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  65734. this._markAllSubMeshesAsMiscDirty();
  65735. },
  65736. enumerable: true,
  65737. configurable: true
  65738. });
  65739. /**
  65740. * Specifies if the material will require alpha blending
  65741. * @returns a boolean specifying if alpha blending is needed
  65742. */
  65743. StandardMaterial.prototype.needAlphaBlending = function () {
  65744. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled;
  65745. };
  65746. /**
  65747. * Specifies if this material should be rendered in alpha test mode
  65748. * @returns a boolean specifying if an alpha test is needed.
  65749. */
  65750. StandardMaterial.prototype.needAlphaTesting = function () {
  65751. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha;
  65752. };
  65753. StandardMaterial.prototype._shouldUseAlphaFromDiffuseTexture = function () {
  65754. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture;
  65755. };
  65756. /**
  65757. * Get the texture used for alpha test purpose.
  65758. * @returns the diffuse texture in case of the standard material.
  65759. */
  65760. StandardMaterial.prototype.getAlphaTestTexture = function () {
  65761. return this._diffuseTexture;
  65762. };
  65763. /**
  65764. * Get if the submesh is ready to be used and all its information available.
  65765. * Child classes can use it to update shaders
  65766. * @param mesh defines the mesh to check
  65767. * @param subMesh defines which submesh to check
  65768. * @param useInstances specifies that instances should be used
  65769. * @returns a boolean indicating that the submesh is ready or not
  65770. */
  65771. StandardMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  65772. if (useInstances === void 0) { useInstances = false; }
  65773. if (subMesh.effect && this.isFrozen) {
  65774. if (this._wasPreviouslyReady) {
  65775. return true;
  65776. }
  65777. }
  65778. if (!subMesh._materialDefines) {
  65779. subMesh._materialDefines = new StandardMaterialDefines();
  65780. }
  65781. var scene = this.getScene();
  65782. var defines = subMesh._materialDefines;
  65783. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  65784. if (defines._renderId === scene.getRenderId()) {
  65785. return true;
  65786. }
  65787. }
  65788. var engine = scene.getEngine();
  65789. // Lights
  65790. defines._needNormals = _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  65791. // Textures
  65792. if (defines._areTexturesDirty) {
  65793. defines._needUVs = false;
  65794. defines.MAINUV1 = false;
  65795. defines.MAINUV2 = false;
  65796. if (scene.texturesEnabled) {
  65797. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  65798. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  65799. return false;
  65800. }
  65801. else {
  65802. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  65803. }
  65804. }
  65805. else {
  65806. defines.DIFFUSE = false;
  65807. }
  65808. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  65809. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  65810. return false;
  65811. }
  65812. else {
  65813. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  65814. }
  65815. }
  65816. else {
  65817. defines.AMBIENT = false;
  65818. }
  65819. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  65820. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  65821. return false;
  65822. }
  65823. else {
  65824. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  65825. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  65826. }
  65827. }
  65828. else {
  65829. defines.OPACITY = false;
  65830. }
  65831. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  65832. if (!this._reflectionTexture.isReadyOrNotBlocking()) {
  65833. return false;
  65834. }
  65835. else {
  65836. defines._needNormals = true;
  65837. defines.REFLECTION = true;
  65838. defines.ROUGHNESS = (this._roughness > 0);
  65839. defines.REFLECTIONOVERALPHA = this._useReflectionOverAlpha;
  65840. defines.INVERTCUBICMAP = (this._reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE);
  65841. defines.REFLECTIONMAP_3D = this._reflectionTexture.isCube;
  65842. switch (this._reflectionTexture.coordinatesMode) {
  65843. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  65844. defines.setReflectionMode("REFLECTIONMAP_EXPLICIT");
  65845. break;
  65846. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  65847. defines.setReflectionMode("REFLECTIONMAP_PLANAR");
  65848. break;
  65849. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  65850. defines.setReflectionMode("REFLECTIONMAP_PROJECTION");
  65851. break;
  65852. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  65853. defines.setReflectionMode("REFLECTIONMAP_SKYBOX");
  65854. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !this._reflectionTexture.getReflectionTextureMatrix().isIdentity();
  65855. break;
  65856. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  65857. defines.setReflectionMode("REFLECTIONMAP_SPHERICAL");
  65858. break;
  65859. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  65860. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
  65861. break;
  65862. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  65863. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
  65864. break;
  65865. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  65866. defines.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
  65867. break;
  65868. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  65869. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  65870. default:
  65871. defines.setReflectionMode("REFLECTIONMAP_CUBIC");
  65872. break;
  65873. }
  65874. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = this._reflectionTexture.boundingBoxSize ? true : false;
  65875. }
  65876. }
  65877. else {
  65878. defines.REFLECTION = false;
  65879. }
  65880. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  65881. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  65882. return false;
  65883. }
  65884. else {
  65885. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  65886. }
  65887. }
  65888. else {
  65889. defines.EMISSIVE = false;
  65890. }
  65891. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  65892. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  65893. return false;
  65894. }
  65895. else {
  65896. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  65897. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  65898. }
  65899. }
  65900. else {
  65901. defines.LIGHTMAP = false;
  65902. }
  65903. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  65904. if (!this._specularTexture.isReadyOrNotBlocking()) {
  65905. return false;
  65906. }
  65907. else {
  65908. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._specularTexture, defines, "SPECULAR");
  65909. defines.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha;
  65910. }
  65911. }
  65912. else {
  65913. defines.SPECULAR = false;
  65914. }
  65915. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && StandardMaterial.BumpTextureEnabled) {
  65916. // Bump texure can not be not blocking.
  65917. if (!this._bumpTexture.isReady()) {
  65918. return false;
  65919. }
  65920. else {
  65921. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  65922. defines.PARALLAX = this._useParallax;
  65923. defines.PARALLAXOCCLUSION = this._useParallaxOcclusion;
  65924. }
  65925. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  65926. }
  65927. else {
  65928. defines.BUMP = false;
  65929. }
  65930. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  65931. if (!this._refractionTexture.isReadyOrNotBlocking()) {
  65932. return false;
  65933. }
  65934. else {
  65935. defines._needUVs = true;
  65936. defines.REFRACTION = true;
  65937. defines.REFRACTIONMAP_3D = this._refractionTexture.isCube;
  65938. }
  65939. }
  65940. else {
  65941. defines.REFRACTION = false;
  65942. }
  65943. defines.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting;
  65944. }
  65945. else {
  65946. defines.DIFFUSE = false;
  65947. defines.AMBIENT = false;
  65948. defines.OPACITY = false;
  65949. defines.REFLECTION = false;
  65950. defines.EMISSIVE = false;
  65951. defines.LIGHTMAP = false;
  65952. defines.BUMP = false;
  65953. defines.REFRACTION = false;
  65954. }
  65955. defines.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture();
  65956. defines.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination;
  65957. defines.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse;
  65958. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  65959. 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);
  65960. }
  65961. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  65962. if (!this._imageProcessingConfiguration.isReady()) {
  65963. return false;
  65964. }
  65965. this._imageProcessingConfiguration.prepareDefines(defines);
  65966. defines.IS_REFLECTION_LINEAR = (this.reflectionTexture != null && !this.reflectionTexture.gammaSpace);
  65967. defines.IS_REFRACTION_LINEAR = (this.refractionTexture != null && !this.refractionTexture.gammaSpace);
  65968. }
  65969. if (defines._areFresnelDirty) {
  65970. if (StandardMaterial.FresnelEnabled) {
  65971. // Fresnel
  65972. if (this._diffuseFresnelParameters || this._opacityFresnelParameters ||
  65973. this._emissiveFresnelParameters || this._refractionFresnelParameters ||
  65974. this._reflectionFresnelParameters) {
  65975. defines.DIFFUSEFRESNEL = (this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled);
  65976. defines.OPACITYFRESNEL = (this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled);
  65977. defines.REFLECTIONFRESNEL = (this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled);
  65978. defines.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular;
  65979. defines.REFRACTIONFRESNEL = (this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled);
  65980. defines.EMISSIVEFRESNEL = (this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled);
  65981. defines._needNormals = true;
  65982. defines.FRESNEL = true;
  65983. }
  65984. }
  65985. else {
  65986. defines.FRESNEL = false;
  65987. }
  65988. }
  65989. // Misc.
  65990. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  65991. // Attribs
  65992. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true);
  65993. // Values that need to be evaluated on every frame
  65994. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  65995. // Get correct effect
  65996. if (defines.isDirty) {
  65997. defines.markAsProcessed();
  65998. // Fallbacks
  65999. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_7__["EffectFallbacks"]();
  66000. if (defines.REFLECTION) {
  66001. fallbacks.addFallback(0, "REFLECTION");
  66002. }
  66003. if (defines.SPECULAR) {
  66004. fallbacks.addFallback(0, "SPECULAR");
  66005. }
  66006. if (defines.BUMP) {
  66007. fallbacks.addFallback(0, "BUMP");
  66008. }
  66009. if (defines.PARALLAX) {
  66010. fallbacks.addFallback(1, "PARALLAX");
  66011. }
  66012. if (defines.PARALLAXOCCLUSION) {
  66013. fallbacks.addFallback(0, "PARALLAXOCCLUSION");
  66014. }
  66015. if (defines.SPECULAROVERALPHA) {
  66016. fallbacks.addFallback(0, "SPECULAROVERALPHA");
  66017. }
  66018. if (defines.FOG) {
  66019. fallbacks.addFallback(1, "FOG");
  66020. }
  66021. if (defines.POINTSIZE) {
  66022. fallbacks.addFallback(0, "POINTSIZE");
  66023. }
  66024. if (defines.LOGARITHMICDEPTH) {
  66025. fallbacks.addFallback(0, "LOGARITHMICDEPTH");
  66026. }
  66027. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  66028. if (defines.SPECULARTERM) {
  66029. fallbacks.addFallback(0, "SPECULARTERM");
  66030. }
  66031. if (defines.DIFFUSEFRESNEL) {
  66032. fallbacks.addFallback(1, "DIFFUSEFRESNEL");
  66033. }
  66034. if (defines.OPACITYFRESNEL) {
  66035. fallbacks.addFallback(2, "OPACITYFRESNEL");
  66036. }
  66037. if (defines.REFLECTIONFRESNEL) {
  66038. fallbacks.addFallback(3, "REFLECTIONFRESNEL");
  66039. }
  66040. if (defines.EMISSIVEFRESNEL) {
  66041. fallbacks.addFallback(4, "EMISSIVEFRESNEL");
  66042. }
  66043. if (defines.FRESNEL) {
  66044. fallbacks.addFallback(4, "FRESNEL");
  66045. }
  66046. //Attributes
  66047. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  66048. if (defines.NORMAL) {
  66049. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  66050. }
  66051. if (defines.UV1) {
  66052. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  66053. }
  66054. if (defines.UV2) {
  66055. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  66056. }
  66057. if (defines.VERTEXCOLOR) {
  66058. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind);
  66059. }
  66060. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  66061. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  66062. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  66063. var shaderName = "default";
  66064. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor",
  66065. "vFogInfos", "vFogColor", "pointSize",
  66066. "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  66067. "mBones",
  66068. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "normalMatrix", "lightmapMatrix", "refractionMatrix",
  66069. "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
  66070. "vReflectionPosition", "vReflectionSize",
  66071. "logarithmicDepthConstant", "vTangentSpaceParams", "alphaCutOff", "boneTextureWidth"
  66072. ];
  66073. var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler",
  66074. "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler",
  66075. "refractionCubeSampler", "refraction2DSampler", "boneSampler"];
  66076. var uniformBuffers = ["Material", "Scene"];
  66077. if (_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"]) {
  66078. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  66079. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  66080. }
  66081. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareUniformsAndSamplersList({
  66082. uniformsNames: uniforms,
  66083. uniformBuffersNames: uniformBuffers,
  66084. samplers: samplers,
  66085. defines: defines,
  66086. maxSimultaneousLights: this._maxSimultaneousLights
  66087. });
  66088. if (this.customShaderNameResolve) {
  66089. shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
  66090. }
  66091. var join = defines.toString();
  66092. var previousEffect = subMesh.effect;
  66093. var effect = scene.getEngine().createEffect(shaderName, {
  66094. attributes: attribs,
  66095. uniformsNames: uniforms,
  66096. uniformBuffersNames: uniformBuffers,
  66097. samplers: samplers,
  66098. defines: join,
  66099. fallbacks: fallbacks,
  66100. onCompiled: this.onCompiled,
  66101. onError: this.onError,
  66102. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  66103. }, engine);
  66104. if (effect) {
  66105. // Use previous effect while new one is compiling
  66106. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  66107. effect = previousEffect;
  66108. defines.markAsUnprocessed();
  66109. }
  66110. else {
  66111. scene.resetCachedMaterial();
  66112. subMesh.setEffect(effect, defines);
  66113. this.buildUniformLayout();
  66114. }
  66115. }
  66116. }
  66117. if (!subMesh.effect || !subMesh.effect.isReady()) {
  66118. return false;
  66119. }
  66120. defines._renderId = scene.getRenderId();
  66121. this._wasPreviouslyReady = true;
  66122. return true;
  66123. };
  66124. /**
  66125. * Builds the material UBO layouts.
  66126. * Used internally during the effect preparation.
  66127. */
  66128. StandardMaterial.prototype.buildUniformLayout = function () {
  66129. // Order is important !
  66130. this._uniformBuffer.addUniform("diffuseLeftColor", 4);
  66131. this._uniformBuffer.addUniform("diffuseRightColor", 4);
  66132. this._uniformBuffer.addUniform("opacityParts", 4);
  66133. this._uniformBuffer.addUniform("reflectionLeftColor", 4);
  66134. this._uniformBuffer.addUniform("reflectionRightColor", 4);
  66135. this._uniformBuffer.addUniform("refractionLeftColor", 4);
  66136. this._uniformBuffer.addUniform("refractionRightColor", 4);
  66137. this._uniformBuffer.addUniform("emissiveLeftColor", 4);
  66138. this._uniformBuffer.addUniform("emissiveRightColor", 4);
  66139. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  66140. this._uniformBuffer.addUniform("vAmbientInfos", 2);
  66141. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  66142. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  66143. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  66144. this._uniformBuffer.addUniform("vReflectionSize", 3);
  66145. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  66146. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  66147. this._uniformBuffer.addUniform("vSpecularInfos", 2);
  66148. this._uniformBuffer.addUniform("vBumpInfos", 3);
  66149. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  66150. this._uniformBuffer.addUniform("ambientMatrix", 16);
  66151. this._uniformBuffer.addUniform("opacityMatrix", 16);
  66152. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  66153. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  66154. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  66155. this._uniformBuffer.addUniform("specularMatrix", 16);
  66156. this._uniformBuffer.addUniform("bumpMatrix", 16);
  66157. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  66158. this._uniformBuffer.addUniform("refractionMatrix", 16);
  66159. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  66160. this._uniformBuffer.addUniform("vSpecularColor", 4);
  66161. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  66162. this._uniformBuffer.addUniform("vDiffuseColor", 4);
  66163. this._uniformBuffer.addUniform("pointSize", 1);
  66164. this._uniformBuffer.create();
  66165. };
  66166. /**
  66167. * Unbinds the material from the mesh
  66168. */
  66169. StandardMaterial.prototype.unbind = function () {
  66170. if (this._activeEffect) {
  66171. var needFlag = false;
  66172. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  66173. this._activeEffect.setTexture("reflection2DSampler", null);
  66174. needFlag = true;
  66175. }
  66176. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  66177. this._activeEffect.setTexture("refraction2DSampler", null);
  66178. needFlag = true;
  66179. }
  66180. if (needFlag) {
  66181. this._markAllSubMeshesAsTexturesDirty();
  66182. }
  66183. }
  66184. _super.prototype.unbind.call(this);
  66185. };
  66186. /**
  66187. * Binds the submesh to this material by preparing the effect and shader to draw
  66188. * @param world defines the world transformation matrix
  66189. * @param mesh defines the mesh containing the submesh
  66190. * @param subMesh defines the submesh to bind the material to
  66191. */
  66192. StandardMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  66193. var scene = this.getScene();
  66194. var defines = subMesh._materialDefines;
  66195. if (!defines) {
  66196. return;
  66197. }
  66198. var effect = subMesh.effect;
  66199. if (!effect) {
  66200. return;
  66201. }
  66202. this._activeEffect = effect;
  66203. // Matrices
  66204. this.bindOnlyWorldMatrix(world);
  66205. // Normal Matrix
  66206. if (defines.OBJECTSPACE_NORMALMAP) {
  66207. world.toNormalMatrix(this._normalMatrix);
  66208. this.bindOnlyNormalMatrix(this._normalMatrix);
  66209. }
  66210. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  66211. // Bones
  66212. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindBonesParameters(mesh, effect);
  66213. if (mustRebind) {
  66214. this._uniformBuffer.bindToEffect(effect, "Material");
  66215. this.bindViewProjection(effect);
  66216. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  66217. if (StandardMaterial.FresnelEnabled && defines.FRESNEL) {
  66218. // Fresnel
  66219. if (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled) {
  66220. this._uniformBuffer.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power);
  66221. this._uniformBuffer.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias);
  66222. }
  66223. if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled) {
  66224. 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);
  66225. }
  66226. if (this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled) {
  66227. this._uniformBuffer.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power);
  66228. this._uniformBuffer.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias);
  66229. }
  66230. if (this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled) {
  66231. this._uniformBuffer.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power);
  66232. this._uniformBuffer.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias);
  66233. }
  66234. if (this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled) {
  66235. this._uniformBuffer.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power);
  66236. this._uniformBuffer.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias);
  66237. }
  66238. }
  66239. // Textures
  66240. if (scene.texturesEnabled) {
  66241. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  66242. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  66243. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  66244. if (this._diffuseTexture.hasAlpha) {
  66245. effect.setFloat("alphaCutOff", this.alphaCutOff);
  66246. }
  66247. }
  66248. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  66249. this._uniformBuffer.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level);
  66250. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  66251. }
  66252. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  66253. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  66254. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  66255. }
  66256. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  66257. this._uniformBuffer.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness);
  66258. this._uniformBuffer.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix());
  66259. if (this._reflectionTexture.boundingBoxSize) {
  66260. var cubeTexture = this._reflectionTexture;
  66261. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  66262. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  66263. }
  66264. }
  66265. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  66266. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  66267. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  66268. }
  66269. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  66270. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  66271. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  66272. }
  66273. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  66274. this._uniformBuffer.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level);
  66275. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._specularTexture, this._uniformBuffer, "specular");
  66276. }
  66277. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  66278. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1.0 / this._bumpTexture.level, this.parallaxScaleBias);
  66279. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  66280. if (scene._mirroredCameraPosition) {
  66281. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  66282. }
  66283. else {
  66284. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  66285. }
  66286. }
  66287. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  66288. var depth = 1.0;
  66289. if (!this._refractionTexture.isCube) {
  66290. this._uniformBuffer.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix());
  66291. if (this._refractionTexture.depth) {
  66292. depth = this._refractionTexture.depth;
  66293. }
  66294. }
  66295. this._uniformBuffer.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, depth, this.invertRefractionY ? -1 : 1);
  66296. }
  66297. }
  66298. // Point size
  66299. if (this.pointsCloud) {
  66300. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  66301. }
  66302. if (defines.SPECULARTERM) {
  66303. this._uniformBuffer.updateColor4("vSpecularColor", this.specularColor, this.specularPower);
  66304. }
  66305. this._uniformBuffer.updateColor3("vEmissiveColor", StandardMaterial.EmissiveTextureEnabled ? this.emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].BlackReadOnly);
  66306. // Diffuse
  66307. this._uniformBuffer.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
  66308. }
  66309. // Textures
  66310. if (scene.texturesEnabled) {
  66311. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  66312. effect.setTexture("diffuseSampler", this._diffuseTexture);
  66313. }
  66314. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  66315. effect.setTexture("ambientSampler", this._ambientTexture);
  66316. }
  66317. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  66318. effect.setTexture("opacitySampler", this._opacityTexture);
  66319. }
  66320. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  66321. if (this._reflectionTexture.isCube) {
  66322. effect.setTexture("reflectionCubeSampler", this._reflectionTexture);
  66323. }
  66324. else {
  66325. effect.setTexture("reflection2DSampler", this._reflectionTexture);
  66326. }
  66327. }
  66328. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  66329. effect.setTexture("emissiveSampler", this._emissiveTexture);
  66330. }
  66331. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  66332. effect.setTexture("lightmapSampler", this._lightmapTexture);
  66333. }
  66334. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  66335. effect.setTexture("specularSampler", this._specularTexture);
  66336. }
  66337. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  66338. effect.setTexture("bumpSampler", this._bumpTexture);
  66339. }
  66340. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  66341. var depth = 1.0;
  66342. if (this._refractionTexture.isCube) {
  66343. effect.setTexture("refractionCubeSampler", this._refractionTexture);
  66344. }
  66345. else {
  66346. effect.setTexture("refraction2DSampler", this._refractionTexture);
  66347. }
  66348. }
  66349. }
  66350. // Clip plane
  66351. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindClipPlane(effect, scene);
  66352. // Colors
  66353. scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
  66354. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindEyePosition(effect, scene);
  66355. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  66356. }
  66357. if (mustRebind || !this.isFrozen) {
  66358. // Lights
  66359. if (scene.lightsEnabled && !this._disableLighting) {
  66360. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLights(scene, mesh, effect, defines, this._maxSimultaneousLights);
  66361. }
  66362. // View
  66363. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].FOGMODE_NONE || this._reflectionTexture || this._refractionTexture) {
  66364. this.bindView(effect);
  66365. }
  66366. // Fog
  66367. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindFogParameters(scene, mesh, effect);
  66368. // Morph targets
  66369. if (defines.NUM_MORPH_INFLUENCERS) {
  66370. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, effect);
  66371. }
  66372. // Log. depth
  66373. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLogDepth(defines, effect, scene);
  66374. // image processing
  66375. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  66376. this._imageProcessingConfiguration.bind(this._activeEffect);
  66377. }
  66378. }
  66379. this._uniformBuffer.update();
  66380. this._afterBind(mesh, this._activeEffect);
  66381. };
  66382. /**
  66383. * Get the list of animatables in the material.
  66384. * @returns the list of animatables object used in the material
  66385. */
  66386. StandardMaterial.prototype.getAnimatables = function () {
  66387. var results = [];
  66388. if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
  66389. results.push(this._diffuseTexture);
  66390. }
  66391. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  66392. results.push(this._ambientTexture);
  66393. }
  66394. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  66395. results.push(this._opacityTexture);
  66396. }
  66397. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  66398. results.push(this._reflectionTexture);
  66399. }
  66400. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  66401. results.push(this._emissiveTexture);
  66402. }
  66403. if (this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0) {
  66404. results.push(this._specularTexture);
  66405. }
  66406. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  66407. results.push(this._bumpTexture);
  66408. }
  66409. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  66410. results.push(this._lightmapTexture);
  66411. }
  66412. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  66413. results.push(this._refractionTexture);
  66414. }
  66415. return results;
  66416. };
  66417. /**
  66418. * Gets the active textures from the material
  66419. * @returns an array of textures
  66420. */
  66421. StandardMaterial.prototype.getActiveTextures = function () {
  66422. var activeTextures = _super.prototype.getActiveTextures.call(this);
  66423. if (this._diffuseTexture) {
  66424. activeTextures.push(this._diffuseTexture);
  66425. }
  66426. if (this._ambientTexture) {
  66427. activeTextures.push(this._ambientTexture);
  66428. }
  66429. if (this._opacityTexture) {
  66430. activeTextures.push(this._opacityTexture);
  66431. }
  66432. if (this._reflectionTexture) {
  66433. activeTextures.push(this._reflectionTexture);
  66434. }
  66435. if (this._emissiveTexture) {
  66436. activeTextures.push(this._emissiveTexture);
  66437. }
  66438. if (this._specularTexture) {
  66439. activeTextures.push(this._specularTexture);
  66440. }
  66441. if (this._bumpTexture) {
  66442. activeTextures.push(this._bumpTexture);
  66443. }
  66444. if (this._lightmapTexture) {
  66445. activeTextures.push(this._lightmapTexture);
  66446. }
  66447. if (this._refractionTexture) {
  66448. activeTextures.push(this._refractionTexture);
  66449. }
  66450. return activeTextures;
  66451. };
  66452. /**
  66453. * Specifies if the material uses a texture
  66454. * @param texture defines the texture to check against the material
  66455. * @returns a boolean specifying if the material uses the texture
  66456. */
  66457. StandardMaterial.prototype.hasTexture = function (texture) {
  66458. if (_super.prototype.hasTexture.call(this, texture)) {
  66459. return true;
  66460. }
  66461. if (this._diffuseTexture === texture) {
  66462. return true;
  66463. }
  66464. if (this._ambientTexture === texture) {
  66465. return true;
  66466. }
  66467. if (this._opacityTexture === texture) {
  66468. return true;
  66469. }
  66470. if (this._reflectionTexture === texture) {
  66471. return true;
  66472. }
  66473. if (this._emissiveTexture === texture) {
  66474. return true;
  66475. }
  66476. if (this._specularTexture === texture) {
  66477. return true;
  66478. }
  66479. if (this._bumpTexture === texture) {
  66480. return true;
  66481. }
  66482. if (this._lightmapTexture === texture) {
  66483. return true;
  66484. }
  66485. if (this._refractionTexture === texture) {
  66486. return true;
  66487. }
  66488. return false;
  66489. };
  66490. /**
  66491. * Disposes the material
  66492. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  66493. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  66494. */
  66495. StandardMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  66496. if (forceDisposeTextures) {
  66497. if (this._diffuseTexture) {
  66498. this._diffuseTexture.dispose();
  66499. }
  66500. if (this._ambientTexture) {
  66501. this._ambientTexture.dispose();
  66502. }
  66503. if (this._opacityTexture) {
  66504. this._opacityTexture.dispose();
  66505. }
  66506. if (this._reflectionTexture) {
  66507. this._reflectionTexture.dispose();
  66508. }
  66509. if (this._emissiveTexture) {
  66510. this._emissiveTexture.dispose();
  66511. }
  66512. if (this._specularTexture) {
  66513. this._specularTexture.dispose();
  66514. }
  66515. if (this._bumpTexture) {
  66516. this._bumpTexture.dispose();
  66517. }
  66518. if (this._lightmapTexture) {
  66519. this._lightmapTexture.dispose();
  66520. }
  66521. if (this._refractionTexture) {
  66522. this._refractionTexture.dispose();
  66523. }
  66524. }
  66525. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  66526. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  66527. }
  66528. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  66529. };
  66530. /**
  66531. * Makes a duplicate of the material, and gives it a new name
  66532. * @param name defines the new name for the duplicated material
  66533. * @returns the cloned material
  66534. */
  66535. StandardMaterial.prototype.clone = function (name) {
  66536. var _this = this;
  66537. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new StandardMaterial(name, _this.getScene()); }, this);
  66538. result.name = name;
  66539. result.id = name;
  66540. return result;
  66541. };
  66542. /**
  66543. * Serializes this material in a JSON representation
  66544. * @returns the serialized material object
  66545. */
  66546. StandardMaterial.prototype.serialize = function () {
  66547. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  66548. };
  66549. /**
  66550. * Creates a standard material from parsed material data
  66551. * @param source defines the JSON representation of the material
  66552. * @param scene defines the hosting scene
  66553. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66554. * @returns a new standard material
  66555. */
  66556. StandardMaterial.Parse = function (source, scene, rootUrl) {
  66557. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardMaterial(source.name, scene); }, source, scene, rootUrl);
  66558. };
  66559. Object.defineProperty(StandardMaterial, "DiffuseTextureEnabled", {
  66560. // Flags used to enable or disable a type of texture for all Standard Materials
  66561. /**
  66562. * Are diffuse textures enabled in the application.
  66563. */
  66564. get: function () {
  66565. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled;
  66566. },
  66567. set: function (value) {
  66568. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled = value;
  66569. },
  66570. enumerable: true,
  66571. configurable: true
  66572. });
  66573. Object.defineProperty(StandardMaterial, "AmbientTextureEnabled", {
  66574. /**
  66575. * Are ambient textures enabled in the application.
  66576. */
  66577. get: function () {
  66578. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled;
  66579. },
  66580. set: function (value) {
  66581. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled = value;
  66582. },
  66583. enumerable: true,
  66584. configurable: true
  66585. });
  66586. Object.defineProperty(StandardMaterial, "OpacityTextureEnabled", {
  66587. /**
  66588. * Are opacity textures enabled in the application.
  66589. */
  66590. get: function () {
  66591. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled;
  66592. },
  66593. set: function (value) {
  66594. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled = value;
  66595. },
  66596. enumerable: true,
  66597. configurable: true
  66598. });
  66599. Object.defineProperty(StandardMaterial, "ReflectionTextureEnabled", {
  66600. /**
  66601. * Are reflection textures enabled in the application.
  66602. */
  66603. get: function () {
  66604. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled;
  66605. },
  66606. set: function (value) {
  66607. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled = value;
  66608. },
  66609. enumerable: true,
  66610. configurable: true
  66611. });
  66612. Object.defineProperty(StandardMaterial, "EmissiveTextureEnabled", {
  66613. /**
  66614. * Are emissive textures enabled in the application.
  66615. */
  66616. get: function () {
  66617. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled;
  66618. },
  66619. set: function (value) {
  66620. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled = value;
  66621. },
  66622. enumerable: true,
  66623. configurable: true
  66624. });
  66625. Object.defineProperty(StandardMaterial, "SpecularTextureEnabled", {
  66626. /**
  66627. * Are specular textures enabled in the application.
  66628. */
  66629. get: function () {
  66630. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled;
  66631. },
  66632. set: function (value) {
  66633. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled = value;
  66634. },
  66635. enumerable: true,
  66636. configurable: true
  66637. });
  66638. Object.defineProperty(StandardMaterial, "BumpTextureEnabled", {
  66639. /**
  66640. * Are bump textures enabled in the application.
  66641. */
  66642. get: function () {
  66643. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled;
  66644. },
  66645. set: function (value) {
  66646. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled = value;
  66647. },
  66648. enumerable: true,
  66649. configurable: true
  66650. });
  66651. Object.defineProperty(StandardMaterial, "LightmapTextureEnabled", {
  66652. /**
  66653. * Are lightmap textures enabled in the application.
  66654. */
  66655. get: function () {
  66656. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled;
  66657. },
  66658. set: function (value) {
  66659. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled = value;
  66660. },
  66661. enumerable: true,
  66662. configurable: true
  66663. });
  66664. Object.defineProperty(StandardMaterial, "RefractionTextureEnabled", {
  66665. /**
  66666. * Are refraction textures enabled in the application.
  66667. */
  66668. get: function () {
  66669. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled;
  66670. },
  66671. set: function (value) {
  66672. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled = value;
  66673. },
  66674. enumerable: true,
  66675. configurable: true
  66676. });
  66677. Object.defineProperty(StandardMaterial, "ColorGradingTextureEnabled", {
  66678. /**
  66679. * Are color grading textures enabled in the application.
  66680. */
  66681. get: function () {
  66682. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled;
  66683. },
  66684. set: function (value) {
  66685. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled = value;
  66686. },
  66687. enumerable: true,
  66688. configurable: true
  66689. });
  66690. Object.defineProperty(StandardMaterial, "FresnelEnabled", {
  66691. /**
  66692. * Are fresnels enabled in the application.
  66693. */
  66694. get: function () {
  66695. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled;
  66696. },
  66697. set: function (value) {
  66698. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled = value;
  66699. },
  66700. enumerable: true,
  66701. configurable: true
  66702. });
  66703. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66704. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture")
  66705. ], StandardMaterial.prototype, "_diffuseTexture", void 0);
  66706. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66707. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  66708. ], StandardMaterial.prototype, "diffuseTexture", void 0);
  66709. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66710. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("ambientTexture")
  66711. ], StandardMaterial.prototype, "_ambientTexture", void 0);
  66712. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66713. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66714. ], StandardMaterial.prototype, "ambientTexture", void 0);
  66715. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66716. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("opacityTexture")
  66717. ], StandardMaterial.prototype, "_opacityTexture", void 0);
  66718. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66719. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  66720. ], StandardMaterial.prototype, "opacityTexture", void 0);
  66721. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66722. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("reflectionTexture")
  66723. ], StandardMaterial.prototype, "_reflectionTexture", void 0);
  66724. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66725. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66726. ], StandardMaterial.prototype, "reflectionTexture", void 0);
  66727. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66728. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("emissiveTexture")
  66729. ], StandardMaterial.prototype, "_emissiveTexture", void 0);
  66730. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66731. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66732. ], StandardMaterial.prototype, "emissiveTexture", void 0);
  66733. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66734. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("specularTexture")
  66735. ], StandardMaterial.prototype, "_specularTexture", void 0);
  66736. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66737. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66738. ], StandardMaterial.prototype, "specularTexture", void 0);
  66739. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66740. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("bumpTexture")
  66741. ], StandardMaterial.prototype, "_bumpTexture", void 0);
  66742. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66743. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66744. ], StandardMaterial.prototype, "bumpTexture", void 0);
  66745. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66746. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lightmapTexture")
  66747. ], StandardMaterial.prototype, "_lightmapTexture", void 0);
  66748. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66749. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66750. ], StandardMaterial.prototype, "lightmapTexture", void 0);
  66751. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66752. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("refractionTexture")
  66753. ], StandardMaterial.prototype, "_refractionTexture", void 0);
  66754. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66755. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66756. ], StandardMaterial.prototype, "refractionTexture", void 0);
  66757. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66758. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient")
  66759. ], StandardMaterial.prototype, "ambientColor", void 0);
  66760. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66761. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse")
  66762. ], StandardMaterial.prototype, "diffuseColor", void 0);
  66763. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66764. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular")
  66765. ], StandardMaterial.prototype, "specularColor", void 0);
  66766. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66767. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive")
  66768. ], StandardMaterial.prototype, "emissiveColor", void 0);
  66769. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66770. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66771. ], StandardMaterial.prototype, "specularPower", void 0);
  66772. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66773. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useAlphaFromDiffuseTexture")
  66774. ], StandardMaterial.prototype, "_useAlphaFromDiffuseTexture", void 0);
  66775. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66776. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66777. ], StandardMaterial.prototype, "useAlphaFromDiffuseTexture", void 0);
  66778. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66779. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useEmissiveAsIllumination")
  66780. ], StandardMaterial.prototype, "_useEmissiveAsIllumination", void 0);
  66781. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66782. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66783. ], StandardMaterial.prototype, "useEmissiveAsIllumination", void 0);
  66784. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66785. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("linkEmissiveWithDiffuse")
  66786. ], StandardMaterial.prototype, "_linkEmissiveWithDiffuse", void 0);
  66787. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66788. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66789. ], StandardMaterial.prototype, "linkEmissiveWithDiffuse", void 0);
  66790. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66791. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useSpecularOverAlpha")
  66792. ], StandardMaterial.prototype, "_useSpecularOverAlpha", void 0);
  66793. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66794. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66795. ], StandardMaterial.prototype, "useSpecularOverAlpha", void 0);
  66796. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66797. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionOverAlpha")
  66798. ], StandardMaterial.prototype, "_useReflectionOverAlpha", void 0);
  66799. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66800. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66801. ], StandardMaterial.prototype, "useReflectionOverAlpha", void 0);
  66802. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66803. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
  66804. ], StandardMaterial.prototype, "_disableLighting", void 0);
  66805. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66806. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  66807. ], StandardMaterial.prototype, "disableLighting", void 0);
  66808. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66809. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useObjectSpaceNormalMap")
  66810. ], StandardMaterial.prototype, "_useObjectSpaceNormalMap", void 0);
  66811. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66812. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66813. ], StandardMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  66814. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66815. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallax")
  66816. ], StandardMaterial.prototype, "_useParallax", void 0);
  66817. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66818. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66819. ], StandardMaterial.prototype, "useParallax", void 0);
  66820. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66821. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallaxOcclusion")
  66822. ], StandardMaterial.prototype, "_useParallaxOcclusion", void 0);
  66823. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66824. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66825. ], StandardMaterial.prototype, "useParallaxOcclusion", void 0);
  66826. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66827. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66828. ], StandardMaterial.prototype, "parallaxScaleBias", void 0);
  66829. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66830. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("roughness")
  66831. ], StandardMaterial.prototype, "_roughness", void 0);
  66832. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66833. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66834. ], StandardMaterial.prototype, "roughness", void 0);
  66835. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66836. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66837. ], StandardMaterial.prototype, "indexOfRefraction", void 0);
  66838. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66839. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66840. ], StandardMaterial.prototype, "invertRefractionY", void 0);
  66841. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66842. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66843. ], StandardMaterial.prototype, "alphaCutOff", void 0);
  66844. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66845. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useLightmapAsShadowmap")
  66846. ], StandardMaterial.prototype, "_useLightmapAsShadowmap", void 0);
  66847. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66848. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66849. ], StandardMaterial.prototype, "useLightmapAsShadowmap", void 0);
  66850. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66851. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("diffuseFresnelParameters")
  66852. ], StandardMaterial.prototype, "_diffuseFresnelParameters", void 0);
  66853. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66854. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66855. ], StandardMaterial.prototype, "diffuseFresnelParameters", void 0);
  66856. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66857. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("opacityFresnelParameters")
  66858. ], StandardMaterial.prototype, "_opacityFresnelParameters", void 0);
  66859. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66860. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelAndMiscDirty")
  66861. ], StandardMaterial.prototype, "opacityFresnelParameters", void 0);
  66862. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66863. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("reflectionFresnelParameters")
  66864. ], StandardMaterial.prototype, "_reflectionFresnelParameters", void 0);
  66865. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66866. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66867. ], StandardMaterial.prototype, "reflectionFresnelParameters", void 0);
  66868. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66869. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("refractionFresnelParameters")
  66870. ], StandardMaterial.prototype, "_refractionFresnelParameters", void 0);
  66871. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66872. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66873. ], StandardMaterial.prototype, "refractionFresnelParameters", void 0);
  66874. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66875. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("emissiveFresnelParameters")
  66876. ], StandardMaterial.prototype, "_emissiveFresnelParameters", void 0);
  66877. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66878. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66879. ], StandardMaterial.prototype, "emissiveFresnelParameters", void 0);
  66880. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66881. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionFresnelFromSpecular")
  66882. ], StandardMaterial.prototype, "_useReflectionFresnelFromSpecular", void 0);
  66883. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66884. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66885. ], StandardMaterial.prototype, "useReflectionFresnelFromSpecular", void 0);
  66886. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66887. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useGlossinessFromSpecularMapAlpha")
  66888. ], StandardMaterial.prototype, "_useGlossinessFromSpecularMapAlpha", void 0);
  66889. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66890. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66891. ], StandardMaterial.prototype, "useGlossinessFromSpecularMapAlpha", void 0);
  66892. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66893. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
  66894. ], StandardMaterial.prototype, "_maxSimultaneousLights", void 0);
  66895. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66896. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  66897. ], StandardMaterial.prototype, "maxSimultaneousLights", void 0);
  66898. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66899. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapX")
  66900. ], StandardMaterial.prototype, "_invertNormalMapX", void 0);
  66901. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66902. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66903. ], StandardMaterial.prototype, "invertNormalMapX", void 0);
  66904. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66905. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapY")
  66906. ], StandardMaterial.prototype, "_invertNormalMapY", void 0);
  66907. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66908. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66909. ], StandardMaterial.prototype, "invertNormalMapY", void 0);
  66910. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66911. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("twoSidedLighting")
  66912. ], StandardMaterial.prototype, "_twoSidedLighting", void 0);
  66913. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66914. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66915. ], StandardMaterial.prototype, "twoSidedLighting", void 0);
  66916. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66917. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66918. ], StandardMaterial.prototype, "useLogarithmicDepth", null);
  66919. return StandardMaterial;
  66920. }(_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  66921. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardMaterial"] = StandardMaterial;
  66922. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].DefaultMaterialFactory = function (scene) {
  66923. return new StandardMaterial("default material", scene);
  66924. };
  66925. /***/ }),
  66926. /***/ "./Materials/uniformBuffer.ts":
  66927. /*!************************************!*\
  66928. !*** ./Materials/uniformBuffer.ts ***!
  66929. \************************************/
  66930. /*! exports provided: UniformBuffer */
  66931. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66932. "use strict";
  66933. __webpack_require__.r(__webpack_exports__);
  66934. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return UniformBuffer; });
  66935. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  66936. /**
  66937. * Uniform buffer objects.
  66938. *
  66939. * Handles blocks of uniform on the GPU.
  66940. *
  66941. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  66942. *
  66943. * For more information, please refer to :
  66944. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  66945. */
  66946. var UniformBuffer = /** @class */ (function () {
  66947. /**
  66948. * Instantiates a new Uniform buffer objects.
  66949. *
  66950. * Handles blocks of uniform on the GPU.
  66951. *
  66952. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  66953. *
  66954. * For more information, please refer to :
  66955. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  66956. * @param engine Define the engine the buffer is associated with
  66957. * @param data Define the data contained in the buffer
  66958. * @param dynamic Define if the buffer is updatable
  66959. */
  66960. function UniformBuffer(engine, data, dynamic) {
  66961. this._engine = engine;
  66962. this._noUBO = !engine.supportsUniformBuffers;
  66963. this._dynamic = dynamic;
  66964. this._data = data || [];
  66965. this._uniformLocations = {};
  66966. this._uniformSizes = {};
  66967. this._uniformLocationPointer = 0;
  66968. this._needSync = false;
  66969. if (this._noUBO) {
  66970. this.updateMatrix3x3 = this._updateMatrix3x3ForEffect;
  66971. this.updateMatrix2x2 = this._updateMatrix2x2ForEffect;
  66972. this.updateFloat = this._updateFloatForEffect;
  66973. this.updateFloat2 = this._updateFloat2ForEffect;
  66974. this.updateFloat3 = this._updateFloat3ForEffect;
  66975. this.updateFloat4 = this._updateFloat4ForEffect;
  66976. this.updateMatrix = this._updateMatrixForEffect;
  66977. this.updateVector3 = this._updateVector3ForEffect;
  66978. this.updateVector4 = this._updateVector4ForEffect;
  66979. this.updateColor3 = this._updateColor3ForEffect;
  66980. this.updateColor4 = this._updateColor4ForEffect;
  66981. }
  66982. else {
  66983. this._engine._uniformBuffers.push(this);
  66984. this.updateMatrix3x3 = this._updateMatrix3x3ForUniform;
  66985. this.updateMatrix2x2 = this._updateMatrix2x2ForUniform;
  66986. this.updateFloat = this._updateFloatForUniform;
  66987. this.updateFloat2 = this._updateFloat2ForUniform;
  66988. this.updateFloat3 = this._updateFloat3ForUniform;
  66989. this.updateFloat4 = this._updateFloat4ForUniform;
  66990. this.updateMatrix = this._updateMatrixForUniform;
  66991. this.updateVector3 = this._updateVector3ForUniform;
  66992. this.updateVector4 = this._updateVector4ForUniform;
  66993. this.updateColor3 = this._updateColor3ForUniform;
  66994. this.updateColor4 = this._updateColor4ForUniform;
  66995. }
  66996. }
  66997. Object.defineProperty(UniformBuffer.prototype, "useUbo", {
  66998. /**
  66999. * Indicates if the buffer is using the WebGL2 UBO implementation,
  67000. * or just falling back on setUniformXXX calls.
  67001. */
  67002. get: function () {
  67003. return !this._noUBO;
  67004. },
  67005. enumerable: true,
  67006. configurable: true
  67007. });
  67008. Object.defineProperty(UniformBuffer.prototype, "isSync", {
  67009. /**
  67010. * Indicates if the WebGL underlying uniform buffer is in sync
  67011. * with the javascript cache data.
  67012. */
  67013. get: function () {
  67014. return !this._needSync;
  67015. },
  67016. enumerable: true,
  67017. configurable: true
  67018. });
  67019. /**
  67020. * Indicates if the WebGL underlying uniform buffer is dynamic.
  67021. * Also, a dynamic UniformBuffer will disable cache verification and always
  67022. * update the underlying WebGL uniform buffer to the GPU.
  67023. * @returns if Dynamic, otherwise false
  67024. */
  67025. UniformBuffer.prototype.isDynamic = function () {
  67026. return this._dynamic !== undefined;
  67027. };
  67028. /**
  67029. * The data cache on JS side.
  67030. * @returns the underlying data as a float array
  67031. */
  67032. UniformBuffer.prototype.getData = function () {
  67033. return this._bufferData;
  67034. };
  67035. /**
  67036. * The underlying WebGL Uniform buffer.
  67037. * @returns the webgl buffer
  67038. */
  67039. UniformBuffer.prototype.getBuffer = function () {
  67040. return this._buffer;
  67041. };
  67042. /**
  67043. * std140 layout specifies how to align data within an UBO structure.
  67044. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  67045. * for specs.
  67046. */
  67047. UniformBuffer.prototype._fillAlignment = function (size) {
  67048. // This code has been simplified because we only use floats, vectors of 1, 2, 3, 4 components
  67049. // and 4x4 matrices
  67050. // TODO : change if other types are used
  67051. var alignment;
  67052. if (size <= 2) {
  67053. alignment = size;
  67054. }
  67055. else {
  67056. alignment = 4;
  67057. }
  67058. if ((this._uniformLocationPointer % alignment) !== 0) {
  67059. var oldPointer = this._uniformLocationPointer;
  67060. this._uniformLocationPointer += alignment - (this._uniformLocationPointer % alignment);
  67061. var diff = this._uniformLocationPointer - oldPointer;
  67062. for (var i = 0; i < diff; i++) {
  67063. this._data.push(0);
  67064. }
  67065. }
  67066. };
  67067. /**
  67068. * Adds an uniform in the buffer.
  67069. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  67070. * for the layout to be correct !
  67071. * @param name Name of the uniform, as used in the uniform block in the shader.
  67072. * @param size Data size, or data directly.
  67073. */
  67074. UniformBuffer.prototype.addUniform = function (name, size) {
  67075. if (this._noUBO) {
  67076. return;
  67077. }
  67078. if (this._uniformLocations[name] !== undefined) {
  67079. // Already existing uniform
  67080. return;
  67081. }
  67082. // This function must be called in the order of the shader layout !
  67083. // size can be the size of the uniform, or data directly
  67084. var data;
  67085. if (size instanceof Array) {
  67086. data = size;
  67087. size = data.length;
  67088. }
  67089. else {
  67090. size = size;
  67091. data = [];
  67092. // Fill with zeros
  67093. for (var i = 0; i < size; i++) {
  67094. data.push(0);
  67095. }
  67096. }
  67097. this._fillAlignment(size);
  67098. this._uniformSizes[name] = size;
  67099. this._uniformLocations[name] = this._uniformLocationPointer;
  67100. this._uniformLocationPointer += size;
  67101. for (var i = 0; i < size; i++) {
  67102. this._data.push(data[i]);
  67103. }
  67104. this._needSync = true;
  67105. };
  67106. /**
  67107. * Adds a Matrix 4x4 to the uniform buffer.
  67108. * @param name Name of the uniform, as used in the uniform block in the shader.
  67109. * @param mat A 4x4 matrix.
  67110. */
  67111. UniformBuffer.prototype.addMatrix = function (name, mat) {
  67112. this.addUniform(name, Array.prototype.slice.call(mat.toArray()));
  67113. };
  67114. /**
  67115. * Adds a vec2 to the uniform buffer.
  67116. * @param name Name of the uniform, as used in the uniform block in the shader.
  67117. * @param x Define the x component value of the vec2
  67118. * @param y Define the y component value of the vec2
  67119. */
  67120. UniformBuffer.prototype.addFloat2 = function (name, x, y) {
  67121. var temp = [x, y];
  67122. this.addUniform(name, temp);
  67123. };
  67124. /**
  67125. * Adds a vec3 to the uniform buffer.
  67126. * @param name Name of the uniform, as used in the uniform block in the shader.
  67127. * @param x Define the x component value of the vec3
  67128. * @param y Define the y component value of the vec3
  67129. * @param z Define the z component value of the vec3
  67130. */
  67131. UniformBuffer.prototype.addFloat3 = function (name, x, y, z) {
  67132. var temp = [x, y, z];
  67133. this.addUniform(name, temp);
  67134. };
  67135. /**
  67136. * Adds a vec3 to the uniform buffer.
  67137. * @param name Name of the uniform, as used in the uniform block in the shader.
  67138. * @param color Define the vec3 from a Color
  67139. */
  67140. UniformBuffer.prototype.addColor3 = function (name, color) {
  67141. var temp = new Array();
  67142. color.toArray(temp);
  67143. this.addUniform(name, temp);
  67144. };
  67145. /**
  67146. * Adds a vec4 to the uniform buffer.
  67147. * @param name Name of the uniform, as used in the uniform block in the shader.
  67148. * @param color Define the rgb components from a Color
  67149. * @param alpha Define the a component of the vec4
  67150. */
  67151. UniformBuffer.prototype.addColor4 = function (name, color, alpha) {
  67152. var temp = new Array();
  67153. color.toArray(temp);
  67154. temp.push(alpha);
  67155. this.addUniform(name, temp);
  67156. };
  67157. /**
  67158. * Adds a vec3 to the uniform buffer.
  67159. * @param name Name of the uniform, as used in the uniform block in the shader.
  67160. * @param vector Define the vec3 components from a Vector
  67161. */
  67162. UniformBuffer.prototype.addVector3 = function (name, vector) {
  67163. var temp = new Array();
  67164. vector.toArray(temp);
  67165. this.addUniform(name, temp);
  67166. };
  67167. /**
  67168. * Adds a Matrix 3x3 to the uniform buffer.
  67169. * @param name Name of the uniform, as used in the uniform block in the shader.
  67170. */
  67171. UniformBuffer.prototype.addMatrix3x3 = function (name) {
  67172. this.addUniform(name, 12);
  67173. };
  67174. /**
  67175. * Adds a Matrix 2x2 to the uniform buffer.
  67176. * @param name Name of the uniform, as used in the uniform block in the shader.
  67177. */
  67178. UniformBuffer.prototype.addMatrix2x2 = function (name) {
  67179. this.addUniform(name, 8);
  67180. };
  67181. /**
  67182. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  67183. */
  67184. UniformBuffer.prototype.create = function () {
  67185. if (this._noUBO) {
  67186. return;
  67187. }
  67188. if (this._buffer) {
  67189. return; // nothing to do
  67190. }
  67191. // See spec, alignment must be filled as a vec4
  67192. this._fillAlignment(4);
  67193. this._bufferData = new Float32Array(this._data);
  67194. this._rebuild();
  67195. this._needSync = true;
  67196. };
  67197. /** @hidden */
  67198. UniformBuffer.prototype._rebuild = function () {
  67199. if (this._noUBO) {
  67200. return;
  67201. }
  67202. if (this._dynamic) {
  67203. this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData);
  67204. }
  67205. else {
  67206. this._buffer = this._engine.createUniformBuffer(this._bufferData);
  67207. }
  67208. };
  67209. /**
  67210. * Updates the WebGL Uniform Buffer on the GPU.
  67211. * If the `dynamic` flag is set to true, no cache comparison is done.
  67212. * Otherwise, the buffer will be updated only if the cache differs.
  67213. */
  67214. UniformBuffer.prototype.update = function () {
  67215. if (!this._buffer) {
  67216. this.create();
  67217. return;
  67218. }
  67219. if (!this._dynamic && !this._needSync) {
  67220. return;
  67221. }
  67222. this._engine.updateUniformBuffer(this._buffer, this._bufferData);
  67223. this._needSync = false;
  67224. };
  67225. /**
  67226. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  67227. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  67228. * @param data Define the flattened data
  67229. * @param size Define the size of the data.
  67230. */
  67231. UniformBuffer.prototype.updateUniform = function (uniformName, data, size) {
  67232. var location = this._uniformLocations[uniformName];
  67233. if (location === undefined) {
  67234. if (this._buffer) {
  67235. // Cannot add an uniform if the buffer is already created
  67236. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add an uniform after UBO has been created.");
  67237. return;
  67238. }
  67239. this.addUniform(uniformName, size);
  67240. location = this._uniformLocations[uniformName];
  67241. }
  67242. if (!this._buffer) {
  67243. this.create();
  67244. }
  67245. if (!this._dynamic) {
  67246. // Cache for static uniform buffers
  67247. var changed = false;
  67248. for (var i = 0; i < size; i++) {
  67249. if (this._bufferData[location + i] !== data[i]) {
  67250. changed = true;
  67251. this._bufferData[location + i] = data[i];
  67252. }
  67253. }
  67254. this._needSync = this._needSync || changed;
  67255. }
  67256. else {
  67257. // No cache for dynamic
  67258. for (var i = 0; i < size; i++) {
  67259. this._bufferData[location + i] = data[i];
  67260. }
  67261. }
  67262. };
  67263. // Update methods
  67264. UniformBuffer.prototype._updateMatrix3x3ForUniform = function (name, matrix) {
  67265. // To match std140, matrix must be realigned
  67266. for (var i = 0; i < 3; i++) {
  67267. UniformBuffer._tempBuffer[i * 4] = matrix[i * 3];
  67268. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 3 + 1];
  67269. UniformBuffer._tempBuffer[i * 4 + 2] = matrix[i * 3 + 2];
  67270. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  67271. }
  67272. this.updateUniform(name, UniformBuffer._tempBuffer, 12);
  67273. };
  67274. UniformBuffer.prototype._updateMatrix3x3ForEffect = function (name, matrix) {
  67275. this._currentEffect.setMatrix3x3(name, matrix);
  67276. };
  67277. UniformBuffer.prototype._updateMatrix2x2ForEffect = function (name, matrix) {
  67278. this._currentEffect.setMatrix2x2(name, matrix);
  67279. };
  67280. UniformBuffer.prototype._updateMatrix2x2ForUniform = function (name, matrix) {
  67281. // To match std140, matrix must be realigned
  67282. for (var i = 0; i < 2; i++) {
  67283. UniformBuffer._tempBuffer[i * 4] = matrix[i * 2];
  67284. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 2 + 1];
  67285. UniformBuffer._tempBuffer[i * 4 + 2] = 0.0;
  67286. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  67287. }
  67288. this.updateUniform(name, UniformBuffer._tempBuffer, 8);
  67289. };
  67290. UniformBuffer.prototype._updateFloatForEffect = function (name, x) {
  67291. this._currentEffect.setFloat(name, x);
  67292. };
  67293. UniformBuffer.prototype._updateFloatForUniform = function (name, x) {
  67294. UniformBuffer._tempBuffer[0] = x;
  67295. this.updateUniform(name, UniformBuffer._tempBuffer, 1);
  67296. };
  67297. UniformBuffer.prototype._updateFloat2ForEffect = function (name, x, y, suffix) {
  67298. if (suffix === void 0) { suffix = ""; }
  67299. this._currentEffect.setFloat2(name + suffix, x, y);
  67300. };
  67301. UniformBuffer.prototype._updateFloat2ForUniform = function (name, x, y) {
  67302. UniformBuffer._tempBuffer[0] = x;
  67303. UniformBuffer._tempBuffer[1] = y;
  67304. this.updateUniform(name, UniformBuffer._tempBuffer, 2);
  67305. };
  67306. UniformBuffer.prototype._updateFloat3ForEffect = function (name, x, y, z, suffix) {
  67307. if (suffix === void 0) { suffix = ""; }
  67308. this._currentEffect.setFloat3(name + suffix, x, y, z);
  67309. };
  67310. UniformBuffer.prototype._updateFloat3ForUniform = function (name, x, y, z) {
  67311. UniformBuffer._tempBuffer[0] = x;
  67312. UniformBuffer._tempBuffer[1] = y;
  67313. UniformBuffer._tempBuffer[2] = z;
  67314. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  67315. };
  67316. UniformBuffer.prototype._updateFloat4ForEffect = function (name, x, y, z, w, suffix) {
  67317. if (suffix === void 0) { suffix = ""; }
  67318. this._currentEffect.setFloat4(name + suffix, x, y, z, w);
  67319. };
  67320. UniformBuffer.prototype._updateFloat4ForUniform = function (name, x, y, z, w) {
  67321. UniformBuffer._tempBuffer[0] = x;
  67322. UniformBuffer._tempBuffer[1] = y;
  67323. UniformBuffer._tempBuffer[2] = z;
  67324. UniformBuffer._tempBuffer[3] = w;
  67325. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  67326. };
  67327. UniformBuffer.prototype._updateMatrixForEffect = function (name, mat) {
  67328. this._currentEffect.setMatrix(name, mat);
  67329. };
  67330. UniformBuffer.prototype._updateMatrixForUniform = function (name, mat) {
  67331. this.updateUniform(name, mat.toArray(), 16);
  67332. };
  67333. UniformBuffer.prototype._updateVector3ForEffect = function (name, vector) {
  67334. this._currentEffect.setVector3(name, vector);
  67335. };
  67336. UniformBuffer.prototype._updateVector3ForUniform = function (name, vector) {
  67337. vector.toArray(UniformBuffer._tempBuffer);
  67338. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  67339. };
  67340. UniformBuffer.prototype._updateVector4ForEffect = function (name, vector) {
  67341. this._currentEffect.setVector4(name, vector);
  67342. };
  67343. UniformBuffer.prototype._updateVector4ForUniform = function (name, vector) {
  67344. vector.toArray(UniformBuffer._tempBuffer);
  67345. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  67346. };
  67347. UniformBuffer.prototype._updateColor3ForEffect = function (name, color, suffix) {
  67348. if (suffix === void 0) { suffix = ""; }
  67349. this._currentEffect.setColor3(name + suffix, color);
  67350. };
  67351. UniformBuffer.prototype._updateColor3ForUniform = function (name, color) {
  67352. color.toArray(UniformBuffer._tempBuffer);
  67353. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  67354. };
  67355. UniformBuffer.prototype._updateColor4ForEffect = function (name, color, alpha, suffix) {
  67356. if (suffix === void 0) { suffix = ""; }
  67357. this._currentEffect.setColor4(name + suffix, color, alpha);
  67358. };
  67359. UniformBuffer.prototype._updateColor4ForUniform = function (name, color, alpha) {
  67360. color.toArray(UniformBuffer._tempBuffer);
  67361. UniformBuffer._tempBuffer[3] = alpha;
  67362. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  67363. };
  67364. /**
  67365. * Sets a sampler uniform on the effect.
  67366. * @param name Define the name of the sampler.
  67367. * @param texture Define the texture to set in the sampler
  67368. */
  67369. UniformBuffer.prototype.setTexture = function (name, texture) {
  67370. this._currentEffect.setTexture(name, texture);
  67371. };
  67372. /**
  67373. * Directly updates the value of the uniform in the cache AND on the GPU.
  67374. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  67375. * @param data Define the flattened data
  67376. */
  67377. UniformBuffer.prototype.updateUniformDirectly = function (uniformName, data) {
  67378. this.updateUniform(uniformName, data, data.length);
  67379. this.update();
  67380. };
  67381. /**
  67382. * Binds this uniform buffer to an effect.
  67383. * @param effect Define the effect to bind the buffer to
  67384. * @param name Name of the uniform block in the shader.
  67385. */
  67386. UniformBuffer.prototype.bindToEffect = function (effect, name) {
  67387. this._currentEffect = effect;
  67388. if (this._noUBO || !this._buffer) {
  67389. return;
  67390. }
  67391. effect.bindUniformBuffer(this._buffer, name);
  67392. };
  67393. /**
  67394. * Disposes the uniform buffer.
  67395. */
  67396. UniformBuffer.prototype.dispose = function () {
  67397. if (this._noUBO) {
  67398. return;
  67399. }
  67400. var uniformBuffers = this._engine._uniformBuffers;
  67401. var index = uniformBuffers.indexOf(this);
  67402. if (index !== -1) {
  67403. uniformBuffers[index] = uniformBuffers[uniformBuffers.length - 1];
  67404. uniformBuffers.pop();
  67405. }
  67406. if (!this._buffer) {
  67407. return;
  67408. }
  67409. if (this._engine._releaseBuffer(this._buffer)) {
  67410. this._buffer = null;
  67411. }
  67412. };
  67413. // Pool for avoiding memory leaks
  67414. UniformBuffer._MAX_UNIFORM_SIZE = 256;
  67415. UniformBuffer._tempBuffer = new Float32Array(UniformBuffer._MAX_UNIFORM_SIZE);
  67416. return UniformBuffer;
  67417. }());
  67418. /***/ }),
  67419. /***/ "./Maths/index.ts":
  67420. /*!************************!*\
  67421. !*** ./Maths/index.ts ***!
  67422. \************************/
  67423. /*! 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 */
  67424. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67425. "use strict";
  67426. __webpack_require__.r(__webpack_exports__);
  67427. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  67428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  67429. /* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math */ "./Maths/math.ts");
  67430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]; });
  67431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToLinearSpace"]; });
  67432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"]; });
  67433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color3"]; });
  67434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color4"]; });
  67435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]; });
  67436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]; });
  67437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]; });
  67438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Size"]; });
  67439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]; });
  67440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]; });
  67441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Plane"]; });
  67442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Viewport"]; });
  67443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Frustum"]; });
  67444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Space"]; });
  67445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Axis"]; });
  67446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"]; });
  67447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Orientation"]; });
  67448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Angle"]; });
  67449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Arc2"]; });
  67450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path2"]; });
  67451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path3D"]; });
  67452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Curve3"]; });
  67453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalVertex"]; });
  67454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalTextureVertex"]; });
  67455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Tmp"]; });
  67456. /* harmony import */ var _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  67457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"]; });
  67458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]; });
  67459. /***/ }),
  67460. /***/ "./Maths/math.scalar.ts":
  67461. /*!******************************!*\
  67462. !*** ./Maths/math.scalar.ts ***!
  67463. \******************************/
  67464. /*! exports provided: Scalar */
  67465. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67466. "use strict";
  67467. __webpack_require__.r(__webpack_exports__);
  67468. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return Scalar; });
  67469. /**
  67470. * Scalar computation library
  67471. */
  67472. var Scalar = /** @class */ (function () {
  67473. function Scalar() {
  67474. }
  67475. /**
  67476. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67477. * @param a number
  67478. * @param b number
  67479. * @param epsilon (default = 1.401298E-45)
  67480. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67481. */
  67482. Scalar.WithinEpsilon = function (a, b, epsilon) {
  67483. if (epsilon === void 0) { epsilon = 1.401298E-45; }
  67484. var num = a - b;
  67485. return -epsilon <= num && num <= epsilon;
  67486. };
  67487. /**
  67488. * Returns a string : the upper case translation of the number i to hexadecimal.
  67489. * @param i number
  67490. * @returns the upper case translation of the number i to hexadecimal.
  67491. */
  67492. Scalar.ToHex = function (i) {
  67493. var str = i.toString(16);
  67494. if (i <= 15) {
  67495. return ("0" + str).toUpperCase();
  67496. }
  67497. return str.toUpperCase();
  67498. };
  67499. /**
  67500. * Returns -1 if value is negative and +1 is value is positive.
  67501. * @param value the value
  67502. * @returns the value itself if it's equal to zero.
  67503. */
  67504. Scalar.Sign = function (value) {
  67505. value = +value; // convert to a number
  67506. if (value === 0 || isNaN(value)) {
  67507. return value;
  67508. }
  67509. return value > 0 ? 1 : -1;
  67510. };
  67511. /**
  67512. * Returns the value itself if it's between min and max.
  67513. * Returns min if the value is lower than min.
  67514. * Returns max if the value is greater than max.
  67515. * @param value the value to clmap
  67516. * @param min the min value to clamp to (default: 0)
  67517. * @param max the max value to clamp to (default: 1)
  67518. * @returns the clamped value
  67519. */
  67520. Scalar.Clamp = function (value, min, max) {
  67521. if (min === void 0) { min = 0; }
  67522. if (max === void 0) { max = 1; }
  67523. return Math.min(max, Math.max(min, value));
  67524. };
  67525. /**
  67526. * the log2 of value.
  67527. * @param value the value to compute log2 of
  67528. * @returns the log2 of value.
  67529. */
  67530. Scalar.Log2 = function (value) {
  67531. return Math.log(value) * Math.LOG2E;
  67532. };
  67533. /**
  67534. * Loops the value, so that it is never larger than length and never smaller than 0.
  67535. *
  67536. * This is similar to the modulo operator but it works with floating point numbers.
  67537. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  67538. * With t = 5 and length = 2.5, the result would be 0.0.
  67539. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  67540. * @param value the value
  67541. * @param length the length
  67542. * @returns the looped value
  67543. */
  67544. Scalar.Repeat = function (value, length) {
  67545. return value - Math.floor(value / length) * length;
  67546. };
  67547. /**
  67548. * Normalize the value between 0.0 and 1.0 using min and max values
  67549. * @param value value to normalize
  67550. * @param min max to normalize between
  67551. * @param max min to normalize between
  67552. * @returns the normalized value
  67553. */
  67554. Scalar.Normalize = function (value, min, max) {
  67555. return (value - min) / (max - min);
  67556. };
  67557. /**
  67558. * Denormalize the value from 0.0 and 1.0 using min and max values
  67559. * @param normalized value to denormalize
  67560. * @param min max to denormalize between
  67561. * @param max min to denormalize between
  67562. * @returns the denormalized value
  67563. */
  67564. Scalar.Denormalize = function (normalized, min, max) {
  67565. return (normalized * (max - min) + min);
  67566. };
  67567. /**
  67568. * Calculates the shortest difference between two given angles given in degrees.
  67569. * @param current current angle in degrees
  67570. * @param target target angle in degrees
  67571. * @returns the delta
  67572. */
  67573. Scalar.DeltaAngle = function (current, target) {
  67574. var num = Scalar.Repeat(target - current, 360.0);
  67575. if (num > 180.0) {
  67576. num -= 360.0;
  67577. }
  67578. return num;
  67579. };
  67580. /**
  67581. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  67582. * @param tx value
  67583. * @param length length
  67584. * @returns The returned value will move back and forth between 0 and length
  67585. */
  67586. Scalar.PingPong = function (tx, length) {
  67587. var t = Scalar.Repeat(tx, length * 2.0);
  67588. return length - Math.abs(t - length);
  67589. };
  67590. /**
  67591. * Interpolates between min and max with smoothing at the limits.
  67592. *
  67593. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  67594. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  67595. * @param from from
  67596. * @param to to
  67597. * @param tx value
  67598. * @returns the smooth stepped value
  67599. */
  67600. Scalar.SmoothStep = function (from, to, tx) {
  67601. var t = Scalar.Clamp(tx);
  67602. t = -2.0 * t * t * t + 3.0 * t * t;
  67603. return to * t + from * (1.0 - t);
  67604. };
  67605. /**
  67606. * Moves a value current towards target.
  67607. *
  67608. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  67609. * Negative values of maxDelta pushes the value away from target.
  67610. * @param current current value
  67611. * @param target target value
  67612. * @param maxDelta max distance to move
  67613. * @returns resulting value
  67614. */
  67615. Scalar.MoveTowards = function (current, target, maxDelta) {
  67616. var result = 0;
  67617. if (Math.abs(target - current) <= maxDelta) {
  67618. result = target;
  67619. }
  67620. else {
  67621. result = current + Scalar.Sign(target - current) * maxDelta;
  67622. }
  67623. return result;
  67624. };
  67625. /**
  67626. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67627. *
  67628. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  67629. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  67630. * @param current current value
  67631. * @param target target value
  67632. * @param maxDelta max distance to move
  67633. * @returns resulting angle
  67634. */
  67635. Scalar.MoveTowardsAngle = function (current, target, maxDelta) {
  67636. var num = Scalar.DeltaAngle(current, target);
  67637. var result = 0;
  67638. if (-maxDelta < num && num < maxDelta) {
  67639. result = target;
  67640. }
  67641. else {
  67642. target = current + num;
  67643. result = Scalar.MoveTowards(current, target, maxDelta);
  67644. }
  67645. return result;
  67646. };
  67647. /**
  67648. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  67649. * @param start start value
  67650. * @param end target value
  67651. * @param amount amount to lerp between
  67652. * @returns the lerped value
  67653. */
  67654. Scalar.Lerp = function (start, end, amount) {
  67655. return start + ((end - start) * amount);
  67656. };
  67657. /**
  67658. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67659. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  67660. * @param start start value
  67661. * @param end target value
  67662. * @param amount amount to lerp between
  67663. * @returns the lerped value
  67664. */
  67665. Scalar.LerpAngle = function (start, end, amount) {
  67666. var num = Scalar.Repeat(end - start, 360.0);
  67667. if (num > 180.0) {
  67668. num -= 360.0;
  67669. }
  67670. return start + num * Scalar.Clamp(amount);
  67671. };
  67672. /**
  67673. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  67674. * @param a start value
  67675. * @param b target value
  67676. * @param value value between a and b
  67677. * @returns the inverseLerp value
  67678. */
  67679. Scalar.InverseLerp = function (a, b, value) {
  67680. var result = 0;
  67681. if (a != b) {
  67682. result = Scalar.Clamp((value - a) / (b - a));
  67683. }
  67684. else {
  67685. result = 0.0;
  67686. }
  67687. return result;
  67688. };
  67689. /**
  67690. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  67691. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  67692. * @param value1 spline value
  67693. * @param tangent1 spline value
  67694. * @param value2 spline value
  67695. * @param tangent2 spline value
  67696. * @param amount input value
  67697. * @returns hermite result
  67698. */
  67699. Scalar.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  67700. var squared = amount * amount;
  67701. var cubed = amount * squared;
  67702. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  67703. var part2 = (-2.0 * cubed) + (3.0 * squared);
  67704. var part3 = (cubed - (2.0 * squared)) + amount;
  67705. var part4 = cubed - squared;
  67706. return (((value1 * part1) + (value2 * part2)) + (tangent1 * part3)) + (tangent2 * part4);
  67707. };
  67708. /**
  67709. * Returns a random float number between and min and max values
  67710. * @param min min value of random
  67711. * @param max max value of random
  67712. * @returns random value
  67713. */
  67714. Scalar.RandomRange = function (min, max) {
  67715. if (min === max) {
  67716. return min;
  67717. }
  67718. return ((Math.random() * (max - min)) + min);
  67719. };
  67720. /**
  67721. * This function returns percentage of a number in a given range.
  67722. *
  67723. * RangeToPercent(40,20,60) will return 0.5 (50%)
  67724. * RangeToPercent(34,0,100) will return 0.34 (34%)
  67725. * @param number to convert to percentage
  67726. * @param min min range
  67727. * @param max max range
  67728. * @returns the percentage
  67729. */
  67730. Scalar.RangeToPercent = function (number, min, max) {
  67731. return ((number - min) / (max - min));
  67732. };
  67733. /**
  67734. * This function returns number that corresponds to the percentage in a given range.
  67735. *
  67736. * PercentToRange(0.34,0,100) will return 34.
  67737. * @param percent to convert to number
  67738. * @param min min range
  67739. * @param max max range
  67740. * @returns the number
  67741. */
  67742. Scalar.PercentToRange = function (percent, min, max) {
  67743. return ((max - min) * percent + min);
  67744. };
  67745. /**
  67746. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  67747. * @param angle The angle to normalize in radian.
  67748. * @return The converted angle.
  67749. */
  67750. Scalar.NormalizeRadians = function (angle) {
  67751. // More precise but slower version kept for reference.
  67752. // angle = angle % Tools.TwoPi;
  67753. // angle = (angle + Tools.TwoPi) % Tools.TwoPi;
  67754. //if (angle > Math.PI) {
  67755. // angle -= Tools.TwoPi;
  67756. //}
  67757. angle -= (Scalar.TwoPi * Math.floor((angle + Math.PI) / Scalar.TwoPi));
  67758. return angle;
  67759. };
  67760. /**
  67761. * Two pi constants convenient for computation.
  67762. */
  67763. Scalar.TwoPi = Math.PI * 2;
  67764. return Scalar;
  67765. }());
  67766. /***/ }),
  67767. /***/ "./Maths/math.ts":
  67768. /*!***********************!*\
  67769. !*** ./Maths/math.ts ***!
  67770. \***********************/
  67771. /*! 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 */
  67772. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67773. "use strict";
  67774. __webpack_require__.r(__webpack_exports__);
  67775. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return ToGammaSpace; });
  67776. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return ToLinearSpace; });
  67777. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return Epsilon; });
  67778. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return Color3; });
  67779. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return Color4; });
  67780. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return Vector2; });
  67781. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return Vector3; });
  67782. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return Vector4; });
  67783. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return Size; });
  67784. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return Quaternion; });
  67785. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return Matrix; });
  67786. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return Plane; });
  67787. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return Viewport; });
  67788. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return Frustum; });
  67789. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return Space; });
  67790. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return Axis; });
  67791. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return BezierCurve; });
  67792. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return Orientation; });
  67793. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return Angle; });
  67794. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return Arc2; });
  67795. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return Path2; });
  67796. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return Path3D; });
  67797. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return Curve3; });
  67798. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return PositionNormalVertex; });
  67799. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return PositionNormalTextureVertex; });
  67800. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return Tmp; });
  67801. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  67802. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  67803. /**
  67804. * Constant used to convert a value to gamma space
  67805. * @ignorenaming
  67806. */
  67807. var ToGammaSpace = 1 / 2.2;
  67808. /**
  67809. * Constant used to convert a value to linear space
  67810. * @ignorenaming
  67811. */
  67812. var ToLinearSpace = 2.2;
  67813. /**
  67814. * Constant used to define the minimal number value in Babylon.js
  67815. * @ignorenaming
  67816. */
  67817. var Epsilon = 0.001;
  67818. /**
  67819. * Class used to hold a RBG color
  67820. */
  67821. var Color3 = /** @class */ (function () {
  67822. /**
  67823. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  67824. * @param r defines the red component (between 0 and 1, default is 0)
  67825. * @param g defines the green component (between 0 and 1, default is 0)
  67826. * @param b defines the blue component (between 0 and 1, default is 0)
  67827. */
  67828. function Color3(
  67829. /**
  67830. * Defines the red component (between 0 and 1, default is 0)
  67831. */
  67832. r,
  67833. /**
  67834. * Defines the green component (between 0 and 1, default is 0)
  67835. */
  67836. g,
  67837. /**
  67838. * Defines the blue component (between 0 and 1, default is 0)
  67839. */
  67840. b) {
  67841. if (r === void 0) { r = 0; }
  67842. if (g === void 0) { g = 0; }
  67843. if (b === void 0) { b = 0; }
  67844. this.r = r;
  67845. this.g = g;
  67846. this.b = b;
  67847. }
  67848. /**
  67849. * Creates a string with the Color3 current values
  67850. * @returns the string representation of the Color3 object
  67851. */
  67852. Color3.prototype.toString = function () {
  67853. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}";
  67854. };
  67855. /**
  67856. * Returns the string "Color3"
  67857. * @returns "Color3"
  67858. */
  67859. Color3.prototype.getClassName = function () {
  67860. return "Color3";
  67861. };
  67862. /**
  67863. * Compute the Color3 hash code
  67864. * @returns an unique number that can be used to hash Color3 objects
  67865. */
  67866. Color3.prototype.getHashCode = function () {
  67867. var hash = this.r || 0;
  67868. hash = (hash * 397) ^ (this.g || 0);
  67869. hash = (hash * 397) ^ (this.b || 0);
  67870. return hash;
  67871. };
  67872. // Operators
  67873. /**
  67874. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  67875. * @param array defines the array where to store the r,g,b components
  67876. * @param index defines an optional index in the target array to define where to start storing values
  67877. * @returns the current Color3 object
  67878. */
  67879. Color3.prototype.toArray = function (array, index) {
  67880. if (index === void 0) { index = 0; }
  67881. array[index] = this.r;
  67882. array[index + 1] = this.g;
  67883. array[index + 2] = this.b;
  67884. return this;
  67885. };
  67886. /**
  67887. * Returns a new Color4 object from the current Color3 and the given alpha
  67888. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  67889. * @returns a new Color4 object
  67890. */
  67891. Color3.prototype.toColor4 = function (alpha) {
  67892. if (alpha === void 0) { alpha = 1; }
  67893. return new Color4(this.r, this.g, this.b, alpha);
  67894. };
  67895. /**
  67896. * Returns a new array populated with 3 numeric elements : red, green and blue values
  67897. * @returns the new array
  67898. */
  67899. Color3.prototype.asArray = function () {
  67900. var result = new Array();
  67901. this.toArray(result, 0);
  67902. return result;
  67903. };
  67904. /**
  67905. * Returns the luminance value
  67906. * @returns a float value
  67907. */
  67908. Color3.prototype.toLuminance = function () {
  67909. return this.r * 0.3 + this.g * 0.59 + this.b * 0.11;
  67910. };
  67911. /**
  67912. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  67913. * @param otherColor defines the second operand
  67914. * @returns the new Color3 object
  67915. */
  67916. Color3.prototype.multiply = function (otherColor) {
  67917. return new Color3(this.r * otherColor.r, this.g * otherColor.g, this.b * otherColor.b);
  67918. };
  67919. /**
  67920. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  67921. * @param otherColor defines the second operand
  67922. * @param result defines the Color3 object where to store the result
  67923. * @returns the current Color3
  67924. */
  67925. Color3.prototype.multiplyToRef = function (otherColor, result) {
  67926. result.r = this.r * otherColor.r;
  67927. result.g = this.g * otherColor.g;
  67928. result.b = this.b * otherColor.b;
  67929. return this;
  67930. };
  67931. /**
  67932. * Determines equality between Color3 objects
  67933. * @param otherColor defines the second operand
  67934. * @returns true if the rgb values are equal to the given ones
  67935. */
  67936. Color3.prototype.equals = function (otherColor) {
  67937. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b;
  67938. };
  67939. /**
  67940. * Determines equality between the current Color3 object and a set of r,b,g values
  67941. * @param r defines the red component to check
  67942. * @param g defines the green component to check
  67943. * @param b defines the blue component to check
  67944. * @returns true if the rgb values are equal to the given ones
  67945. */
  67946. Color3.prototype.equalsFloats = function (r, g, b) {
  67947. return this.r === r && this.g === g && this.b === b;
  67948. };
  67949. /**
  67950. * Multiplies in place each rgb value by scale
  67951. * @param scale defines the scaling factor
  67952. * @returns the updated Color3
  67953. */
  67954. Color3.prototype.scale = function (scale) {
  67955. return new Color3(this.r * scale, this.g * scale, this.b * scale);
  67956. };
  67957. /**
  67958. * Multiplies the rgb values by scale and stores the result into "result"
  67959. * @param scale defines the scaling factor
  67960. * @param result defines the Color3 object where to store the result
  67961. * @returns the unmodified current Color3
  67962. */
  67963. Color3.prototype.scaleToRef = function (scale, result) {
  67964. result.r = this.r * scale;
  67965. result.g = this.g * scale;
  67966. result.b = this.b * scale;
  67967. return this;
  67968. };
  67969. /**
  67970. * Scale the current Color3 values by a factor and add the result to a given Color3
  67971. * @param scale defines the scale factor
  67972. * @param result defines color to store the result into
  67973. * @returns the unmodified current Color3
  67974. */
  67975. Color3.prototype.scaleAndAddToRef = function (scale, result) {
  67976. result.r += this.r * scale;
  67977. result.g += this.g * scale;
  67978. result.b += this.b * scale;
  67979. return this;
  67980. };
  67981. /**
  67982. * Clamps the rgb values by the min and max values and stores the result into "result"
  67983. * @param min defines minimum clamping value (default is 0)
  67984. * @param max defines maximum clamping value (default is 1)
  67985. * @param result defines color to store the result into
  67986. * @returns the original Color3
  67987. */
  67988. Color3.prototype.clampToRef = function (min, max, result) {
  67989. if (min === void 0) { min = 0; }
  67990. if (max === void 0) { max = 1; }
  67991. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  67992. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  67993. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  67994. return this;
  67995. };
  67996. /**
  67997. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  67998. * @param otherColor defines the second operand
  67999. * @returns the new Color3
  68000. */
  68001. Color3.prototype.add = function (otherColor) {
  68002. return new Color3(this.r + otherColor.r, this.g + otherColor.g, this.b + otherColor.b);
  68003. };
  68004. /**
  68005. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  68006. * @param otherColor defines the second operand
  68007. * @param result defines Color3 object to store the result into
  68008. * @returns the unmodified current Color3
  68009. */
  68010. Color3.prototype.addToRef = function (otherColor, result) {
  68011. result.r = this.r + otherColor.r;
  68012. result.g = this.g + otherColor.g;
  68013. result.b = this.b + otherColor.b;
  68014. return this;
  68015. };
  68016. /**
  68017. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  68018. * @param otherColor defines the second operand
  68019. * @returns the new Color3
  68020. */
  68021. Color3.prototype.subtract = function (otherColor) {
  68022. return new Color3(this.r - otherColor.r, this.g - otherColor.g, this.b - otherColor.b);
  68023. };
  68024. /**
  68025. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  68026. * @param otherColor defines the second operand
  68027. * @param result defines Color3 object to store the result into
  68028. * @returns the unmodified current Color3
  68029. */
  68030. Color3.prototype.subtractToRef = function (otherColor, result) {
  68031. result.r = this.r - otherColor.r;
  68032. result.g = this.g - otherColor.g;
  68033. result.b = this.b - otherColor.b;
  68034. return this;
  68035. };
  68036. /**
  68037. * Copy the current object
  68038. * @returns a new Color3 copied the current one
  68039. */
  68040. Color3.prototype.clone = function () {
  68041. return new Color3(this.r, this.g, this.b);
  68042. };
  68043. /**
  68044. * Copies the rgb values from the source in the current Color3
  68045. * @param source defines the source Color3 object
  68046. * @returns the updated Color3 object
  68047. */
  68048. Color3.prototype.copyFrom = function (source) {
  68049. this.r = source.r;
  68050. this.g = source.g;
  68051. this.b = source.b;
  68052. return this;
  68053. };
  68054. /**
  68055. * Updates the Color3 rgb values from the given floats
  68056. * @param r defines the red component to read from
  68057. * @param g defines the green component to read from
  68058. * @param b defines the blue component to read from
  68059. * @returns the current Color3 object
  68060. */
  68061. Color3.prototype.copyFromFloats = function (r, g, b) {
  68062. this.r = r;
  68063. this.g = g;
  68064. this.b = b;
  68065. return this;
  68066. };
  68067. /**
  68068. * Updates the Color3 rgb values from the given floats
  68069. * @param r defines the red component to read from
  68070. * @param g defines the green component to read from
  68071. * @param b defines the blue component to read from
  68072. * @returns the current Color3 object
  68073. */
  68074. Color3.prototype.set = function (r, g, b) {
  68075. return this.copyFromFloats(r, g, b);
  68076. };
  68077. /**
  68078. * Compute the Color3 hexadecimal code as a string
  68079. * @returns a string containing the hexadecimal representation of the Color3 object
  68080. */
  68081. Color3.prototype.toHexString = function () {
  68082. var intR = (this.r * 255) | 0;
  68083. var intG = (this.g * 255) | 0;
  68084. var intB = (this.b * 255) | 0;
  68085. 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);
  68086. };
  68087. /**
  68088. * Computes a new Color3 converted from the current one to linear space
  68089. * @returns a new Color3 object
  68090. */
  68091. Color3.prototype.toLinearSpace = function () {
  68092. var convertedColor = new Color3();
  68093. this.toLinearSpaceToRef(convertedColor);
  68094. return convertedColor;
  68095. };
  68096. /**
  68097. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  68098. * @param convertedColor defines the Color3 object where to store the linear space version
  68099. * @returns the unmodified Color3
  68100. */
  68101. Color3.prototype.toLinearSpaceToRef = function (convertedColor) {
  68102. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  68103. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  68104. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  68105. return this;
  68106. };
  68107. /**
  68108. * Computes a new Color3 converted from the current one to gamma space
  68109. * @returns a new Color3 object
  68110. */
  68111. Color3.prototype.toGammaSpace = function () {
  68112. var convertedColor = new Color3();
  68113. this.toGammaSpaceToRef(convertedColor);
  68114. return convertedColor;
  68115. };
  68116. /**
  68117. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  68118. * @param convertedColor defines the Color3 object where to store the gamma space version
  68119. * @returns the unmodified Color3
  68120. */
  68121. Color3.prototype.toGammaSpaceToRef = function (convertedColor) {
  68122. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  68123. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  68124. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  68125. return this;
  68126. };
  68127. /**
  68128. * Creates a new Color3 from the string containing valid hexadecimal values
  68129. * @param hex defines a string containing valid hexadecimal values
  68130. * @returns a new Color3 object
  68131. */
  68132. Color3.FromHexString = function (hex) {
  68133. if (hex.substring(0, 1) !== "#" || hex.length !== 7) {
  68134. return new Color3(0, 0, 0);
  68135. }
  68136. var r = parseInt(hex.substring(1, 3), 16);
  68137. var g = parseInt(hex.substring(3, 5), 16);
  68138. var b = parseInt(hex.substring(5, 7), 16);
  68139. return Color3.FromInts(r, g, b);
  68140. };
  68141. /**
  68142. * Creates a new Vector3 from the starting index of the given array
  68143. * @param array defines the source array
  68144. * @param offset defines an offset in the source array
  68145. * @returns a new Color3 object
  68146. */
  68147. Color3.FromArray = function (array, offset) {
  68148. if (offset === void 0) { offset = 0; }
  68149. return new Color3(array[offset], array[offset + 1], array[offset + 2]);
  68150. };
  68151. /**
  68152. * Creates a new Color3 from integer values (< 256)
  68153. * @param r defines the red component to read from (value between 0 and 255)
  68154. * @param g defines the green component to read from (value between 0 and 255)
  68155. * @param b defines the blue component to read from (value between 0 and 255)
  68156. * @returns a new Color3 object
  68157. */
  68158. Color3.FromInts = function (r, g, b) {
  68159. return new Color3(r / 255.0, g / 255.0, b / 255.0);
  68160. };
  68161. /**
  68162. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  68163. * @param start defines the start Color3 value
  68164. * @param end defines the end Color3 value
  68165. * @param amount defines the gradient value between start and end
  68166. * @returns a new Color3 object
  68167. */
  68168. Color3.Lerp = function (start, end, amount) {
  68169. var result = new Color3(0.0, 0.0, 0.0);
  68170. Color3.LerpToRef(start, end, amount, result);
  68171. return result;
  68172. };
  68173. /**
  68174. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  68175. * @param left defines the start value
  68176. * @param right defines the end value
  68177. * @param amount defines the gradient factor
  68178. * @param result defines the Color3 object where to store the result
  68179. */
  68180. Color3.LerpToRef = function (left, right, amount, result) {
  68181. result.r = left.r + ((right.r - left.r) * amount);
  68182. result.g = left.g + ((right.g - left.g) * amount);
  68183. result.b = left.b + ((right.b - left.b) * amount);
  68184. };
  68185. /**
  68186. * Returns a Color3 value containing a red color
  68187. * @returns a new Color3 object
  68188. */
  68189. Color3.Red = function () { return new Color3(1, 0, 0); };
  68190. /**
  68191. * Returns a Color3 value containing a green color
  68192. * @returns a new Color3 object
  68193. */
  68194. Color3.Green = function () { return new Color3(0, 1, 0); };
  68195. /**
  68196. * Returns a Color3 value containing a blue color
  68197. * @returns a new Color3 object
  68198. */
  68199. Color3.Blue = function () { return new Color3(0, 0, 1); };
  68200. /**
  68201. * Returns a Color3 value containing a black color
  68202. * @returns a new Color3 object
  68203. */
  68204. Color3.Black = function () { return new Color3(0, 0, 0); };
  68205. Object.defineProperty(Color3, "BlackReadOnly", {
  68206. /**
  68207. * Gets a Color3 value containing a black color that must not be updated
  68208. */
  68209. get: function () {
  68210. return Color3._BlackReadOnly;
  68211. },
  68212. enumerable: true,
  68213. configurable: true
  68214. });
  68215. /**
  68216. * Returns a Color3 value containing a white color
  68217. * @returns a new Color3 object
  68218. */
  68219. Color3.White = function () { return new Color3(1, 1, 1); };
  68220. /**
  68221. * Returns a Color3 value containing a purple color
  68222. * @returns a new Color3 object
  68223. */
  68224. Color3.Purple = function () { return new Color3(0.5, 0, 0.5); };
  68225. /**
  68226. * Returns a Color3 value containing a magenta color
  68227. * @returns a new Color3 object
  68228. */
  68229. Color3.Magenta = function () { return new Color3(1, 0, 1); };
  68230. /**
  68231. * Returns a Color3 value containing a yellow color
  68232. * @returns a new Color3 object
  68233. */
  68234. Color3.Yellow = function () { return new Color3(1, 1, 0); };
  68235. /**
  68236. * Returns a Color3 value containing a gray color
  68237. * @returns a new Color3 object
  68238. */
  68239. Color3.Gray = function () { return new Color3(0.5, 0.5, 0.5); };
  68240. /**
  68241. * Returns a Color3 value containing a teal color
  68242. * @returns a new Color3 object
  68243. */
  68244. Color3.Teal = function () { return new Color3(0, 1.0, 1.0); };
  68245. /**
  68246. * Returns a Color3 value containing a random color
  68247. * @returns a new Color3 object
  68248. */
  68249. Color3.Random = function () { return new Color3(Math.random(), Math.random(), Math.random()); };
  68250. // Statics
  68251. Color3._BlackReadOnly = Color3.Black();
  68252. return Color3;
  68253. }());
  68254. /**
  68255. * Class used to hold a RBGA color
  68256. */
  68257. var Color4 = /** @class */ (function () {
  68258. /**
  68259. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  68260. * @param r defines the red component (between 0 and 1, default is 0)
  68261. * @param g defines the green component (between 0 and 1, default is 0)
  68262. * @param b defines the blue component (between 0 and 1, default is 0)
  68263. * @param a defines the alpha component (between 0 and 1, default is 1)
  68264. */
  68265. function Color4(
  68266. /**
  68267. * Defines the red component (between 0 and 1, default is 0)
  68268. */
  68269. r,
  68270. /**
  68271. * Defines the green component (between 0 and 1, default is 0)
  68272. */
  68273. g,
  68274. /**
  68275. * Defines the blue component (between 0 and 1, default is 0)
  68276. */
  68277. b,
  68278. /**
  68279. * Defines the alpha component (between 0 and 1, default is 1)
  68280. */
  68281. a) {
  68282. if (r === void 0) { r = 0; }
  68283. if (g === void 0) { g = 0; }
  68284. if (b === void 0) { b = 0; }
  68285. if (a === void 0) { a = 1; }
  68286. this.r = r;
  68287. this.g = g;
  68288. this.b = b;
  68289. this.a = a;
  68290. }
  68291. // Operators
  68292. /**
  68293. * Adds in place the given Color4 values to the current Color4 object
  68294. * @param right defines the second operand
  68295. * @returns the current updated Color4 object
  68296. */
  68297. Color4.prototype.addInPlace = function (right) {
  68298. this.r += right.r;
  68299. this.g += right.g;
  68300. this.b += right.b;
  68301. this.a += right.a;
  68302. return this;
  68303. };
  68304. /**
  68305. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  68306. * @returns the new array
  68307. */
  68308. Color4.prototype.asArray = function () {
  68309. var result = new Array();
  68310. this.toArray(result, 0);
  68311. return result;
  68312. };
  68313. /**
  68314. * Stores from the starting index in the given array the Color4 successive values
  68315. * @param array defines the array where to store the r,g,b components
  68316. * @param index defines an optional index in the target array to define where to start storing values
  68317. * @returns the current Color4 object
  68318. */
  68319. Color4.prototype.toArray = function (array, index) {
  68320. if (index === void 0) { index = 0; }
  68321. array[index] = this.r;
  68322. array[index + 1] = this.g;
  68323. array[index + 2] = this.b;
  68324. array[index + 3] = this.a;
  68325. return this;
  68326. };
  68327. /**
  68328. * Determines equality between Color4 objects
  68329. * @param otherColor defines the second operand
  68330. * @returns true if the rgba values are equal to the given ones
  68331. */
  68332. Color4.prototype.equals = function (otherColor) {
  68333. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b && this.a === otherColor.a;
  68334. };
  68335. /**
  68336. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  68337. * @param right defines the second operand
  68338. * @returns a new Color4 object
  68339. */
  68340. Color4.prototype.add = function (right) {
  68341. return new Color4(this.r + right.r, this.g + right.g, this.b + right.b, this.a + right.a);
  68342. };
  68343. /**
  68344. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  68345. * @param right defines the second operand
  68346. * @returns a new Color4 object
  68347. */
  68348. Color4.prototype.subtract = function (right) {
  68349. return new Color4(this.r - right.r, this.g - right.g, this.b - right.b, this.a - right.a);
  68350. };
  68351. /**
  68352. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  68353. * @param right defines the second operand
  68354. * @param result defines the Color4 object where to store the result
  68355. * @returns the current Color4 object
  68356. */
  68357. Color4.prototype.subtractToRef = function (right, result) {
  68358. result.r = this.r - right.r;
  68359. result.g = this.g - right.g;
  68360. result.b = this.b - right.b;
  68361. result.a = this.a - right.a;
  68362. return this;
  68363. };
  68364. /**
  68365. * Creates a new Color4 with the current Color4 values multiplied by scale
  68366. * @param scale defines the scaling factor to apply
  68367. * @returns a new Color4 object
  68368. */
  68369. Color4.prototype.scale = function (scale) {
  68370. return new Color4(this.r * scale, this.g * scale, this.b * scale, this.a * scale);
  68371. };
  68372. /**
  68373. * Multiplies the current Color4 values by scale and stores the result in "result"
  68374. * @param scale defines the scaling factor to apply
  68375. * @param result defines the Color4 object where to store the result
  68376. * @returns the current unmodified Color4
  68377. */
  68378. Color4.prototype.scaleToRef = function (scale, result) {
  68379. result.r = this.r * scale;
  68380. result.g = this.g * scale;
  68381. result.b = this.b * scale;
  68382. result.a = this.a * scale;
  68383. return this;
  68384. };
  68385. /**
  68386. * Scale the current Color4 values by a factor and add the result to a given Color4
  68387. * @param scale defines the scale factor
  68388. * @param result defines the Color4 object where to store the result
  68389. * @returns the unmodified current Color4
  68390. */
  68391. Color4.prototype.scaleAndAddToRef = function (scale, result) {
  68392. result.r += this.r * scale;
  68393. result.g += this.g * scale;
  68394. result.b += this.b * scale;
  68395. result.a += this.a * scale;
  68396. return this;
  68397. };
  68398. /**
  68399. * Clamps the rgb values by the min and max values and stores the result into "result"
  68400. * @param min defines minimum clamping value (default is 0)
  68401. * @param max defines maximum clamping value (default is 1)
  68402. * @param result defines color to store the result into.
  68403. * @returns the cuurent Color4
  68404. */
  68405. Color4.prototype.clampToRef = function (min, max, result) {
  68406. if (min === void 0) { min = 0; }
  68407. if (max === void 0) { max = 1; }
  68408. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  68409. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  68410. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  68411. result.a = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.a, min, max);
  68412. return this;
  68413. };
  68414. /**
  68415. * Multipy an Color4 value by another and return a new Color4 object
  68416. * @param color defines the Color4 value to multiply by
  68417. * @returns a new Color4 object
  68418. */
  68419. Color4.prototype.multiply = function (color) {
  68420. return new Color4(this.r * color.r, this.g * color.g, this.b * color.b, this.a * color.a);
  68421. };
  68422. /**
  68423. * Multipy a Color4 value by another and push the result in a reference value
  68424. * @param color defines the Color4 value to multiply by
  68425. * @param result defines the Color4 to fill the result in
  68426. * @returns the result Color4
  68427. */
  68428. Color4.prototype.multiplyToRef = function (color, result) {
  68429. result.r = this.r * color.r;
  68430. result.g = this.g * color.g;
  68431. result.b = this.b * color.b;
  68432. result.a = this.a * color.a;
  68433. return result;
  68434. };
  68435. /**
  68436. * Creates a string with the Color4 current values
  68437. * @returns the string representation of the Color4 object
  68438. */
  68439. Color4.prototype.toString = function () {
  68440. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}";
  68441. };
  68442. /**
  68443. * Returns the string "Color4"
  68444. * @returns "Color4"
  68445. */
  68446. Color4.prototype.getClassName = function () {
  68447. return "Color4";
  68448. };
  68449. /**
  68450. * Compute the Color4 hash code
  68451. * @returns an unique number that can be used to hash Color4 objects
  68452. */
  68453. Color4.prototype.getHashCode = function () {
  68454. var hash = this.r || 0;
  68455. hash = (hash * 397) ^ (this.g || 0);
  68456. hash = (hash * 397) ^ (this.b || 0);
  68457. hash = (hash * 397) ^ (this.a || 0);
  68458. return hash;
  68459. };
  68460. /**
  68461. * Creates a new Color4 copied from the current one
  68462. * @returns a new Color4 object
  68463. */
  68464. Color4.prototype.clone = function () {
  68465. return new Color4(this.r, this.g, this.b, this.a);
  68466. };
  68467. /**
  68468. * Copies the given Color4 values into the current one
  68469. * @param source defines the source Color4 object
  68470. * @returns the current updated Color4 object
  68471. */
  68472. Color4.prototype.copyFrom = function (source) {
  68473. this.r = source.r;
  68474. this.g = source.g;
  68475. this.b = source.b;
  68476. this.a = source.a;
  68477. return this;
  68478. };
  68479. /**
  68480. * Copies the given float values into the current one
  68481. * @param r defines the red component to read from
  68482. * @param g defines the green component to read from
  68483. * @param b defines the blue component to read from
  68484. * @param a defines the alpha component to read from
  68485. * @returns the current updated Color4 object
  68486. */
  68487. Color4.prototype.copyFromFloats = function (r, g, b, a) {
  68488. this.r = r;
  68489. this.g = g;
  68490. this.b = b;
  68491. this.a = a;
  68492. return this;
  68493. };
  68494. /**
  68495. * Copies the given float values into the current one
  68496. * @param r defines the red component to read from
  68497. * @param g defines the green component to read from
  68498. * @param b defines the blue component to read from
  68499. * @param a defines the alpha component to read from
  68500. * @returns the current updated Color4 object
  68501. */
  68502. Color4.prototype.set = function (r, g, b, a) {
  68503. return this.copyFromFloats(r, g, b, a);
  68504. };
  68505. /**
  68506. * Compute the Color4 hexadecimal code as a string
  68507. * @returns a string containing the hexadecimal representation of the Color4 object
  68508. */
  68509. Color4.prototype.toHexString = function () {
  68510. var intR = (this.r * 255) | 0;
  68511. var intG = (this.g * 255) | 0;
  68512. var intB = (this.b * 255) | 0;
  68513. var intA = (this.a * 255) | 0;
  68514. 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);
  68515. };
  68516. /**
  68517. * Computes a new Color4 converted from the current one to linear space
  68518. * @returns a new Color4 object
  68519. */
  68520. Color4.prototype.toLinearSpace = function () {
  68521. var convertedColor = new Color4();
  68522. this.toLinearSpaceToRef(convertedColor);
  68523. return convertedColor;
  68524. };
  68525. /**
  68526. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  68527. * @param convertedColor defines the Color4 object where to store the linear space version
  68528. * @returns the unmodified Color4
  68529. */
  68530. Color4.prototype.toLinearSpaceToRef = function (convertedColor) {
  68531. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  68532. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  68533. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  68534. convertedColor.a = this.a;
  68535. return this;
  68536. };
  68537. /**
  68538. * Computes a new Color4 converted from the current one to gamma space
  68539. * @returns a new Color4 object
  68540. */
  68541. Color4.prototype.toGammaSpace = function () {
  68542. var convertedColor = new Color4();
  68543. this.toGammaSpaceToRef(convertedColor);
  68544. return convertedColor;
  68545. };
  68546. /**
  68547. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  68548. * @param convertedColor defines the Color4 object where to store the gamma space version
  68549. * @returns the unmodified Color4
  68550. */
  68551. Color4.prototype.toGammaSpaceToRef = function (convertedColor) {
  68552. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  68553. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  68554. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  68555. convertedColor.a = this.a;
  68556. return this;
  68557. };
  68558. // Statics
  68559. /**
  68560. * Creates a new Color4 from the string containing valid hexadecimal values
  68561. * @param hex defines a string containing valid hexadecimal values
  68562. * @returns a new Color4 object
  68563. */
  68564. Color4.FromHexString = function (hex) {
  68565. if (hex.substring(0, 1) !== "#" || hex.length !== 9) {
  68566. return new Color4(0.0, 0.0, 0.0, 0.0);
  68567. }
  68568. var r = parseInt(hex.substring(1, 3), 16);
  68569. var g = parseInt(hex.substring(3, 5), 16);
  68570. var b = parseInt(hex.substring(5, 7), 16);
  68571. var a = parseInt(hex.substring(7, 9), 16);
  68572. return Color4.FromInts(r, g, b, a);
  68573. };
  68574. /**
  68575. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  68576. * @param left defines the start value
  68577. * @param right defines the end value
  68578. * @param amount defines the gradient factor
  68579. * @returns a new Color4 object
  68580. */
  68581. Color4.Lerp = function (left, right, amount) {
  68582. var result = new Color4(0.0, 0.0, 0.0, 0.0);
  68583. Color4.LerpToRef(left, right, amount, result);
  68584. return result;
  68585. };
  68586. /**
  68587. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  68588. * @param left defines the start value
  68589. * @param right defines the end value
  68590. * @param amount defines the gradient factor
  68591. * @param result defines the Color4 object where to store data
  68592. */
  68593. Color4.LerpToRef = function (left, right, amount, result) {
  68594. result.r = left.r + (right.r - left.r) * amount;
  68595. result.g = left.g + (right.g - left.g) * amount;
  68596. result.b = left.b + (right.b - left.b) * amount;
  68597. result.a = left.a + (right.a - left.a) * amount;
  68598. };
  68599. /**
  68600. * Creates a new Color4 from a Color3 and an alpha value
  68601. * @param color3 defines the source Color3 to read from
  68602. * @param alpha defines the alpha component (1.0 by default)
  68603. * @returns a new Color4 object
  68604. */
  68605. Color4.FromColor3 = function (color3, alpha) {
  68606. if (alpha === void 0) { alpha = 1.0; }
  68607. return new Color4(color3.r, color3.g, color3.b, alpha);
  68608. };
  68609. /**
  68610. * Creates a new Color4 from the starting index element of the given array
  68611. * @param array defines the source array to read from
  68612. * @param offset defines the offset in the source array
  68613. * @returns a new Color4 object
  68614. */
  68615. Color4.FromArray = function (array, offset) {
  68616. if (offset === void 0) { offset = 0; }
  68617. return new Color4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  68618. };
  68619. /**
  68620. * Creates a new Color3 from integer values (< 256)
  68621. * @param r defines the red component to read from (value between 0 and 255)
  68622. * @param g defines the green component to read from (value between 0 and 255)
  68623. * @param b defines the blue component to read from (value between 0 and 255)
  68624. * @param a defines the alpha component to read from (value between 0 and 255)
  68625. * @returns a new Color3 object
  68626. */
  68627. Color4.FromInts = function (r, g, b, a) {
  68628. return new Color4(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
  68629. };
  68630. /**
  68631. * Check the content of a given array and convert it to an array containing RGBA data
  68632. * If the original array was already containing count * 4 values then it is returned directly
  68633. * @param colors defines the array to check
  68634. * @param count defines the number of RGBA data to expect
  68635. * @returns an array containing count * 4 values (RGBA)
  68636. */
  68637. Color4.CheckColors4 = function (colors, count) {
  68638. // Check if color3 was used
  68639. if (colors.length === count * 3) {
  68640. var colors4 = [];
  68641. for (var index = 0; index < colors.length; index += 3) {
  68642. var newIndex = (index / 3) * 4;
  68643. colors4[newIndex] = colors[index];
  68644. colors4[newIndex + 1] = colors[index + 1];
  68645. colors4[newIndex + 2] = colors[index + 2];
  68646. colors4[newIndex + 3] = 1.0;
  68647. }
  68648. return colors4;
  68649. }
  68650. return colors;
  68651. };
  68652. return Color4;
  68653. }());
  68654. /**
  68655. * Class representing a vector containing 2 coordinates
  68656. */
  68657. var Vector2 = /** @class */ (function () {
  68658. /**
  68659. * Creates a new Vector2 from the given x and y coordinates
  68660. * @param x defines the first coordinate
  68661. * @param y defines the second coordinate
  68662. */
  68663. function Vector2(
  68664. /** defines the first coordinate */
  68665. x,
  68666. /** defines the second coordinate */
  68667. y) {
  68668. if (x === void 0) { x = 0; }
  68669. if (y === void 0) { y = 0; }
  68670. this.x = x;
  68671. this.y = y;
  68672. }
  68673. /**
  68674. * Gets a string with the Vector2 coordinates
  68675. * @returns a string with the Vector2 coordinates
  68676. */
  68677. Vector2.prototype.toString = function () {
  68678. return "{X: " + this.x + " Y:" + this.y + "}";
  68679. };
  68680. /**
  68681. * Gets class name
  68682. * @returns the string "Vector2"
  68683. */
  68684. Vector2.prototype.getClassName = function () {
  68685. return "Vector2";
  68686. };
  68687. /**
  68688. * Gets current vector hash code
  68689. * @returns the Vector2 hash code as a number
  68690. */
  68691. Vector2.prototype.getHashCode = function () {
  68692. var hash = this.x || 0;
  68693. hash = (hash * 397) ^ (this.y || 0);
  68694. return hash;
  68695. };
  68696. // Operators
  68697. /**
  68698. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  68699. * @param array defines the source array
  68700. * @param index defines the offset in source array
  68701. * @returns the current Vector2
  68702. */
  68703. Vector2.prototype.toArray = function (array, index) {
  68704. if (index === void 0) { index = 0; }
  68705. array[index] = this.x;
  68706. array[index + 1] = this.y;
  68707. return this;
  68708. };
  68709. /**
  68710. * Copy the current vector to an array
  68711. * @returns a new array with 2 elements: the Vector2 coordinates.
  68712. */
  68713. Vector2.prototype.asArray = function () {
  68714. var result = new Array();
  68715. this.toArray(result, 0);
  68716. return result;
  68717. };
  68718. /**
  68719. * Sets the Vector2 coordinates with the given Vector2 coordinates
  68720. * @param source defines the source Vector2
  68721. * @returns the current updated Vector2
  68722. */
  68723. Vector2.prototype.copyFrom = function (source) {
  68724. this.x = source.x;
  68725. this.y = source.y;
  68726. return this;
  68727. };
  68728. /**
  68729. * Sets the Vector2 coordinates with the given floats
  68730. * @param x defines the first coordinate
  68731. * @param y defines the second coordinate
  68732. * @returns the current updated Vector2
  68733. */
  68734. Vector2.prototype.copyFromFloats = function (x, y) {
  68735. this.x = x;
  68736. this.y = y;
  68737. return this;
  68738. };
  68739. /**
  68740. * Sets the Vector2 coordinates with the given floats
  68741. * @param x defines the first coordinate
  68742. * @param y defines the second coordinate
  68743. * @returns the current updated Vector2
  68744. */
  68745. Vector2.prototype.set = function (x, y) {
  68746. return this.copyFromFloats(x, y);
  68747. };
  68748. /**
  68749. * Add another vector with the current one
  68750. * @param otherVector defines the other vector
  68751. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  68752. */
  68753. Vector2.prototype.add = function (otherVector) {
  68754. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  68755. };
  68756. /**
  68757. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  68758. * @param otherVector defines the other vector
  68759. * @param result defines the target vector
  68760. * @returns the unmodified current Vector2
  68761. */
  68762. Vector2.prototype.addToRef = function (otherVector, result) {
  68763. result.x = this.x + otherVector.x;
  68764. result.y = this.y + otherVector.y;
  68765. return this;
  68766. };
  68767. /**
  68768. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  68769. * @param otherVector defines the other vector
  68770. * @returns the current updated Vector2
  68771. */
  68772. Vector2.prototype.addInPlace = function (otherVector) {
  68773. this.x += otherVector.x;
  68774. this.y += otherVector.y;
  68775. return this;
  68776. };
  68777. /**
  68778. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  68779. * @param otherVector defines the other vector
  68780. * @returns a new Vector2
  68781. */
  68782. Vector2.prototype.addVector3 = function (otherVector) {
  68783. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  68784. };
  68785. /**
  68786. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  68787. * @param otherVector defines the other vector
  68788. * @returns a new Vector2
  68789. */
  68790. Vector2.prototype.subtract = function (otherVector) {
  68791. return new Vector2(this.x - otherVector.x, this.y - otherVector.y);
  68792. };
  68793. /**
  68794. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  68795. * @param otherVector defines the other vector
  68796. * @param result defines the target vector
  68797. * @returns the unmodified current Vector2
  68798. */
  68799. Vector2.prototype.subtractToRef = function (otherVector, result) {
  68800. result.x = this.x - otherVector.x;
  68801. result.y = this.y - otherVector.y;
  68802. return this;
  68803. };
  68804. /**
  68805. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  68806. * @param otherVector defines the other vector
  68807. * @returns the current updated Vector2
  68808. */
  68809. Vector2.prototype.subtractInPlace = function (otherVector) {
  68810. this.x -= otherVector.x;
  68811. this.y -= otherVector.y;
  68812. return this;
  68813. };
  68814. /**
  68815. * Multiplies in place the current Vector2 coordinates by the given ones
  68816. * @param otherVector defines the other vector
  68817. * @returns the current updated Vector2
  68818. */
  68819. Vector2.prototype.multiplyInPlace = function (otherVector) {
  68820. this.x *= otherVector.x;
  68821. this.y *= otherVector.y;
  68822. return this;
  68823. };
  68824. /**
  68825. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  68826. * @param otherVector defines the other vector
  68827. * @returns a new Vector2
  68828. */
  68829. Vector2.prototype.multiply = function (otherVector) {
  68830. return new Vector2(this.x * otherVector.x, this.y * otherVector.y);
  68831. };
  68832. /**
  68833. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  68834. * @param otherVector defines the other vector
  68835. * @param result defines the target vector
  68836. * @returns the unmodified current Vector2
  68837. */
  68838. Vector2.prototype.multiplyToRef = function (otherVector, result) {
  68839. result.x = this.x * otherVector.x;
  68840. result.y = this.y * otherVector.y;
  68841. return this;
  68842. };
  68843. /**
  68844. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  68845. * @param x defines the first coordinate
  68846. * @param y defines the second coordinate
  68847. * @returns a new Vector2
  68848. */
  68849. Vector2.prototype.multiplyByFloats = function (x, y) {
  68850. return new Vector2(this.x * x, this.y * y);
  68851. };
  68852. /**
  68853. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  68854. * @param otherVector defines the other vector
  68855. * @returns a new Vector2
  68856. */
  68857. Vector2.prototype.divide = function (otherVector) {
  68858. return new Vector2(this.x / otherVector.x, this.y / otherVector.y);
  68859. };
  68860. /**
  68861. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  68862. * @param otherVector defines the other vector
  68863. * @param result defines the target vector
  68864. * @returns the unmodified current Vector2
  68865. */
  68866. Vector2.prototype.divideToRef = function (otherVector, result) {
  68867. result.x = this.x / otherVector.x;
  68868. result.y = this.y / otherVector.y;
  68869. return this;
  68870. };
  68871. /**
  68872. * Divides the current Vector2 coordinates by the given ones
  68873. * @param otherVector defines the other vector
  68874. * @returns the current updated Vector2
  68875. */
  68876. Vector2.prototype.divideInPlace = function (otherVector) {
  68877. return this.divideToRef(otherVector, this);
  68878. };
  68879. /**
  68880. * Gets a new Vector2 with current Vector2 negated coordinates
  68881. * @returns a new Vector2
  68882. */
  68883. Vector2.prototype.negate = function () {
  68884. return new Vector2(-this.x, -this.y);
  68885. };
  68886. /**
  68887. * Multiply the Vector2 coordinates by scale
  68888. * @param scale defines the scaling factor
  68889. * @returns the current updated Vector2
  68890. */
  68891. Vector2.prototype.scaleInPlace = function (scale) {
  68892. this.x *= scale;
  68893. this.y *= scale;
  68894. return this;
  68895. };
  68896. /**
  68897. * Returns a new Vector2 scaled by "scale" from the current Vector2
  68898. * @param scale defines the scaling factor
  68899. * @returns a new Vector2
  68900. */
  68901. Vector2.prototype.scale = function (scale) {
  68902. var result = new Vector2(0, 0);
  68903. this.scaleToRef(scale, result);
  68904. return result;
  68905. };
  68906. /**
  68907. * Scale the current Vector2 values by a factor to a given Vector2
  68908. * @param scale defines the scale factor
  68909. * @param result defines the Vector2 object where to store the result
  68910. * @returns the unmodified current Vector2
  68911. */
  68912. Vector2.prototype.scaleToRef = function (scale, result) {
  68913. result.x = this.x * scale;
  68914. result.y = this.y * scale;
  68915. return this;
  68916. };
  68917. /**
  68918. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  68919. * @param scale defines the scale factor
  68920. * @param result defines the Vector2 object where to store the result
  68921. * @returns the unmodified current Vector2
  68922. */
  68923. Vector2.prototype.scaleAndAddToRef = function (scale, result) {
  68924. result.x += this.x * scale;
  68925. result.y += this.y * scale;
  68926. return this;
  68927. };
  68928. /**
  68929. * Gets a boolean if two vectors are equals
  68930. * @param otherVector defines the other vector
  68931. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  68932. */
  68933. Vector2.prototype.equals = function (otherVector) {
  68934. return otherVector && this.x === otherVector.x && this.y === otherVector.y;
  68935. };
  68936. /**
  68937. * Gets a boolean if two vectors are equals (using an epsilon value)
  68938. * @param otherVector defines the other vector
  68939. * @param epsilon defines the minimal distance to consider equality
  68940. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  68941. */
  68942. Vector2.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  68943. if (epsilon === void 0) { epsilon = Epsilon; }
  68944. 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);
  68945. };
  68946. /**
  68947. * Gets a new Vector2 from current Vector2 floored values
  68948. * @returns a new Vector2
  68949. */
  68950. Vector2.prototype.floor = function () {
  68951. return new Vector2(Math.floor(this.x), Math.floor(this.y));
  68952. };
  68953. /**
  68954. * Gets a new Vector2 from current Vector2 floored values
  68955. * @returns a new Vector2
  68956. */
  68957. Vector2.prototype.fract = function () {
  68958. return new Vector2(this.x - Math.floor(this.x), this.y - Math.floor(this.y));
  68959. };
  68960. // Properties
  68961. /**
  68962. * Gets the length of the vector
  68963. * @returns the vector length (float)
  68964. */
  68965. Vector2.prototype.length = function () {
  68966. return Math.sqrt(this.x * this.x + this.y * this.y);
  68967. };
  68968. /**
  68969. * Gets the vector squared length
  68970. * @returns the vector squared length (float)
  68971. */
  68972. Vector2.prototype.lengthSquared = function () {
  68973. return (this.x * this.x + this.y * this.y);
  68974. };
  68975. // Methods
  68976. /**
  68977. * Normalize the vector
  68978. * @returns the current updated Vector2
  68979. */
  68980. Vector2.prototype.normalize = function () {
  68981. var len = this.length();
  68982. if (len === 0) {
  68983. return this;
  68984. }
  68985. var num = 1.0 / len;
  68986. this.x *= num;
  68987. this.y *= num;
  68988. return this;
  68989. };
  68990. /**
  68991. * Gets a new Vector2 copied from the Vector2
  68992. * @returns a new Vector2
  68993. */
  68994. Vector2.prototype.clone = function () {
  68995. return new Vector2(this.x, this.y);
  68996. };
  68997. // Statics
  68998. /**
  68999. * Gets a new Vector2(0, 0)
  69000. * @returns a new Vector2
  69001. */
  69002. Vector2.Zero = function () {
  69003. return new Vector2(0, 0);
  69004. };
  69005. /**
  69006. * Gets a new Vector2(1, 1)
  69007. * @returns a new Vector2
  69008. */
  69009. Vector2.One = function () {
  69010. return new Vector2(1, 1);
  69011. };
  69012. /**
  69013. * Gets a new Vector2 set from the given index element of the given array
  69014. * @param array defines the data source
  69015. * @param offset defines the offset in the data source
  69016. * @returns a new Vector2
  69017. */
  69018. Vector2.FromArray = function (array, offset) {
  69019. if (offset === void 0) { offset = 0; }
  69020. return new Vector2(array[offset], array[offset + 1]);
  69021. };
  69022. /**
  69023. * Sets "result" from the given index element of the given array
  69024. * @param array defines the data source
  69025. * @param offset defines the offset in the data source
  69026. * @param result defines the target vector
  69027. */
  69028. Vector2.FromArrayToRef = function (array, offset, result) {
  69029. result.x = array[offset];
  69030. result.y = array[offset + 1];
  69031. };
  69032. /**
  69033. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  69034. * @param value1 defines 1st point of control
  69035. * @param value2 defines 2nd point of control
  69036. * @param value3 defines 3rd point of control
  69037. * @param value4 defines 4th point of control
  69038. * @param amount defines the interpolation factor
  69039. * @returns a new Vector2
  69040. */
  69041. Vector2.CatmullRom = function (value1, value2, value3, value4, amount) {
  69042. var squared = amount * amount;
  69043. var cubed = amount * squared;
  69044. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  69045. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  69046. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  69047. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  69048. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  69049. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  69050. return new Vector2(x, y);
  69051. };
  69052. /**
  69053. * 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".
  69054. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  69055. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  69056. * @param value defines the value to clamp
  69057. * @param min defines the lower limit
  69058. * @param max defines the upper limit
  69059. * @returns a new Vector2
  69060. */
  69061. Vector2.Clamp = function (value, min, max) {
  69062. var x = value.x;
  69063. x = (x > max.x) ? max.x : x;
  69064. x = (x < min.x) ? min.x : x;
  69065. var y = value.y;
  69066. y = (y > max.y) ? max.y : y;
  69067. y = (y < min.y) ? min.y : y;
  69068. return new Vector2(x, y);
  69069. };
  69070. /**
  69071. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  69072. * @param value1 defines the 1st control point
  69073. * @param tangent1 defines the outgoing tangent
  69074. * @param value2 defines the 2nd control point
  69075. * @param tangent2 defines the incoming tangent
  69076. * @param amount defines the interpolation factor
  69077. * @returns a new Vector2
  69078. */
  69079. Vector2.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  69080. var squared = amount * amount;
  69081. var cubed = amount * squared;
  69082. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  69083. var part2 = (-2.0 * cubed) + (3.0 * squared);
  69084. var part3 = (cubed - (2.0 * squared)) + amount;
  69085. var part4 = cubed - squared;
  69086. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  69087. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  69088. return new Vector2(x, y);
  69089. };
  69090. /**
  69091. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  69092. * @param start defines the start vector
  69093. * @param end defines the end vector
  69094. * @param amount defines the interpolation factor
  69095. * @returns a new Vector2
  69096. */
  69097. Vector2.Lerp = function (start, end, amount) {
  69098. var x = start.x + ((end.x - start.x) * amount);
  69099. var y = start.y + ((end.y - start.y) * amount);
  69100. return new Vector2(x, y);
  69101. };
  69102. /**
  69103. * Gets the dot product of the vector "left" and the vector "right"
  69104. * @param left defines first vector
  69105. * @param right defines second vector
  69106. * @returns the dot product (float)
  69107. */
  69108. Vector2.Dot = function (left, right) {
  69109. return left.x * right.x + left.y * right.y;
  69110. };
  69111. /**
  69112. * Returns a new Vector2 equal to the normalized given vector
  69113. * @param vector defines the vector to normalize
  69114. * @returns a new Vector2
  69115. */
  69116. Vector2.Normalize = function (vector) {
  69117. var newVector = vector.clone();
  69118. newVector.normalize();
  69119. return newVector;
  69120. };
  69121. /**
  69122. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  69123. * @param left defines 1st vector
  69124. * @param right defines 2nd vector
  69125. * @returns a new Vector2
  69126. */
  69127. Vector2.Minimize = function (left, right) {
  69128. var x = (left.x < right.x) ? left.x : right.x;
  69129. var y = (left.y < right.y) ? left.y : right.y;
  69130. return new Vector2(x, y);
  69131. };
  69132. /**
  69133. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  69134. * @param left defines 1st vector
  69135. * @param right defines 2nd vector
  69136. * @returns a new Vector2
  69137. */
  69138. Vector2.Maximize = function (left, right) {
  69139. var x = (left.x > right.x) ? left.x : right.x;
  69140. var y = (left.y > right.y) ? left.y : right.y;
  69141. return new Vector2(x, y);
  69142. };
  69143. /**
  69144. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  69145. * @param vector defines the vector to transform
  69146. * @param transformation defines the matrix to apply
  69147. * @returns a new Vector2
  69148. */
  69149. Vector2.Transform = function (vector, transformation) {
  69150. var r = Vector2.Zero();
  69151. Vector2.TransformToRef(vector, transformation, r);
  69152. return r;
  69153. };
  69154. /**
  69155. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  69156. * @param vector defines the vector to transform
  69157. * @param transformation defines the matrix to apply
  69158. * @param result defines the target vector
  69159. */
  69160. Vector2.TransformToRef = function (vector, transformation, result) {
  69161. var m = transformation.m;
  69162. var x = (vector.x * m[0]) + (vector.y * m[4]) + m[12];
  69163. var y = (vector.x * m[1]) + (vector.y * m[5]) + m[13];
  69164. result.x = x;
  69165. result.y = y;
  69166. };
  69167. /**
  69168. * Determines if a given vector is included in a triangle
  69169. * @param p defines the vector to test
  69170. * @param p0 defines 1st triangle point
  69171. * @param p1 defines 2nd triangle point
  69172. * @param p2 defines 3rd triangle point
  69173. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  69174. */
  69175. Vector2.PointInTriangle = function (p, p0, p1, p2) {
  69176. var a = 1 / 2 * (-p1.y * p2.x + p0.y * (-p1.x + p2.x) + p0.x * (p1.y - p2.y) + p1.x * p2.y);
  69177. var sign = a < 0 ? -1 : 1;
  69178. var s = (p0.y * p2.x - p0.x * p2.y + (p2.y - p0.y) * p.x + (p0.x - p2.x) * p.y) * sign;
  69179. var t = (p0.x * p1.y - p0.y * p1.x + (p0.y - p1.y) * p.x + (p1.x - p0.x) * p.y) * sign;
  69180. return s > 0 && t > 0 && (s + t) < 2 * a * sign;
  69181. };
  69182. /**
  69183. * Gets the distance between the vectors "value1" and "value2"
  69184. * @param value1 defines first vector
  69185. * @param value2 defines second vector
  69186. * @returns the distance between vectors
  69187. */
  69188. Vector2.Distance = function (value1, value2) {
  69189. return Math.sqrt(Vector2.DistanceSquared(value1, value2));
  69190. };
  69191. /**
  69192. * Returns the squared distance between the vectors "value1" and "value2"
  69193. * @param value1 defines first vector
  69194. * @param value2 defines second vector
  69195. * @returns the squared distance between vectors
  69196. */
  69197. Vector2.DistanceSquared = function (value1, value2) {
  69198. var x = value1.x - value2.x;
  69199. var y = value1.y - value2.y;
  69200. return (x * x) + (y * y);
  69201. };
  69202. /**
  69203. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  69204. * @param value1 defines first vector
  69205. * @param value2 defines second vector
  69206. * @returns a new Vector2
  69207. */
  69208. Vector2.Center = function (value1, value2) {
  69209. var center = value1.add(value2);
  69210. center.scaleInPlace(0.5);
  69211. return center;
  69212. };
  69213. /**
  69214. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  69215. * @param p defines the middle point
  69216. * @param segA defines one point of the segment
  69217. * @param segB defines the other point of the segment
  69218. * @returns the shortest distance
  69219. */
  69220. Vector2.DistanceOfPointFromSegment = function (p, segA, segB) {
  69221. var l2 = Vector2.DistanceSquared(segA, segB);
  69222. if (l2 === 0.0) {
  69223. return Vector2.Distance(p, segA);
  69224. }
  69225. var v = segB.subtract(segA);
  69226. var t = Math.max(0, Math.min(1, Vector2.Dot(p.subtract(segA), v) / l2));
  69227. var proj = segA.add(v.multiplyByFloats(t, t));
  69228. return Vector2.Distance(p, proj);
  69229. };
  69230. return Vector2;
  69231. }());
  69232. /**
  69233. * Classed used to store (x,y,z) vector representation
  69234. * A Vector3 is the main object used in 3D geometry
  69235. * It can represent etiher the coordinates of a point the space, either a direction
  69236. * Reminder: js uses a left handed forward facing system
  69237. */
  69238. var Vector3 = /** @class */ (function () {
  69239. /**
  69240. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  69241. * @param x defines the first coordinates (on X axis)
  69242. * @param y defines the second coordinates (on Y axis)
  69243. * @param z defines the third coordinates (on Z axis)
  69244. */
  69245. function Vector3(
  69246. /**
  69247. * Defines the first coordinates (on X axis)
  69248. */
  69249. x,
  69250. /**
  69251. * Defines the second coordinates (on Y axis)
  69252. */
  69253. y,
  69254. /**
  69255. * Defines the third coordinates (on Z axis)
  69256. */
  69257. z) {
  69258. if (x === void 0) { x = 0; }
  69259. if (y === void 0) { y = 0; }
  69260. if (z === void 0) { z = 0; }
  69261. this.x = x;
  69262. this.y = y;
  69263. this.z = z;
  69264. }
  69265. /**
  69266. * Creates a string representation of the Vector3
  69267. * @returns a string with the Vector3 coordinates.
  69268. */
  69269. Vector3.prototype.toString = function () {
  69270. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + "}";
  69271. };
  69272. /**
  69273. * Gets the class name
  69274. * @returns the string "Vector3"
  69275. */
  69276. Vector3.prototype.getClassName = function () {
  69277. return "Vector3";
  69278. };
  69279. /**
  69280. * Creates the Vector3 hash code
  69281. * @returns a number which tends to be unique between Vector3 instances
  69282. */
  69283. Vector3.prototype.getHashCode = function () {
  69284. var hash = this.x || 0;
  69285. hash = (hash * 397) ^ (this.y || 0);
  69286. hash = (hash * 397) ^ (this.z || 0);
  69287. return hash;
  69288. };
  69289. // Operators
  69290. /**
  69291. * Creates an array containing three elements : the coordinates of the Vector3
  69292. * @returns a new array of numbers
  69293. */
  69294. Vector3.prototype.asArray = function () {
  69295. var result = [];
  69296. this.toArray(result, 0);
  69297. return result;
  69298. };
  69299. /**
  69300. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  69301. * @param array defines the destination array
  69302. * @param index defines the offset in the destination array
  69303. * @returns the current Vector3
  69304. */
  69305. Vector3.prototype.toArray = function (array, index) {
  69306. if (index === void 0) { index = 0; }
  69307. array[index] = this.x;
  69308. array[index + 1] = this.y;
  69309. array[index + 2] = this.z;
  69310. return this;
  69311. };
  69312. /**
  69313. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  69314. * @returns a new Quaternion object, computed from the Vector3 coordinates
  69315. */
  69316. Vector3.prototype.toQuaternion = function () {
  69317. return Quaternion.RotationYawPitchRoll(this.y, this.x, this.z);
  69318. };
  69319. /**
  69320. * Adds the given vector to the current Vector3
  69321. * @param otherVector defines the second operand
  69322. * @returns the current updated Vector3
  69323. */
  69324. Vector3.prototype.addInPlace = function (otherVector) {
  69325. return this.addInPlaceFromFloats(otherVector.x, otherVector.y, otherVector.z);
  69326. };
  69327. /**
  69328. * Adds the given coordinates to the current Vector3
  69329. * @param x defines the x coordinate of the operand
  69330. * @param y defines the y coordinate of the operand
  69331. * @param z defines the z coordinate of the operand
  69332. * @returns the current updated Vector3
  69333. */
  69334. Vector3.prototype.addInPlaceFromFloats = function (x, y, z) {
  69335. this.x += x;
  69336. this.y += y;
  69337. this.z += z;
  69338. return this;
  69339. };
  69340. /**
  69341. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  69342. * @param otherVector defines the second operand
  69343. * @returns the resulting Vector3
  69344. */
  69345. Vector3.prototype.add = function (otherVector) {
  69346. return new Vector3(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  69347. };
  69348. /**
  69349. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  69350. * @param otherVector defines the second operand
  69351. * @param result defines the Vector3 object where to store the result
  69352. * @returns the current Vector3
  69353. */
  69354. Vector3.prototype.addToRef = function (otherVector, result) {
  69355. return result.copyFromFloats(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  69356. };
  69357. /**
  69358. * Subtract the given vector from the current Vector3
  69359. * @param otherVector defines the second operand
  69360. * @returns the current updated Vector3
  69361. */
  69362. Vector3.prototype.subtractInPlace = function (otherVector) {
  69363. this.x -= otherVector.x;
  69364. this.y -= otherVector.y;
  69365. this.z -= otherVector.z;
  69366. return this;
  69367. };
  69368. /**
  69369. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  69370. * @param otherVector defines the second operand
  69371. * @returns the resulting Vector3
  69372. */
  69373. Vector3.prototype.subtract = function (otherVector) {
  69374. return new Vector3(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z);
  69375. };
  69376. /**
  69377. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  69378. * @param otherVector defines the second operand
  69379. * @param result defines the Vector3 object where to store the result
  69380. * @returns the current Vector3
  69381. */
  69382. Vector3.prototype.subtractToRef = function (otherVector, result) {
  69383. return this.subtractFromFloatsToRef(otherVector.x, otherVector.y, otherVector.z, result);
  69384. };
  69385. /**
  69386. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  69387. * @param x defines the x coordinate of the operand
  69388. * @param y defines the y coordinate of the operand
  69389. * @param z defines the z coordinate of the operand
  69390. * @returns the resulting Vector3
  69391. */
  69392. Vector3.prototype.subtractFromFloats = function (x, y, z) {
  69393. return new Vector3(this.x - x, this.y - y, this.z - z);
  69394. };
  69395. /**
  69396. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  69397. * @param x defines the x coordinate of the operand
  69398. * @param y defines the y coordinate of the operand
  69399. * @param z defines the z coordinate of the operand
  69400. * @param result defines the Vector3 object where to store the result
  69401. * @returns the current Vector3
  69402. */
  69403. Vector3.prototype.subtractFromFloatsToRef = function (x, y, z, result) {
  69404. return result.copyFromFloats(this.x - x, this.y - y, this.z - z);
  69405. };
  69406. /**
  69407. * Gets a new Vector3 set with the current Vector3 negated coordinates
  69408. * @returns a new Vector3
  69409. */
  69410. Vector3.prototype.negate = function () {
  69411. return new Vector3(-this.x, -this.y, -this.z);
  69412. };
  69413. /**
  69414. * Multiplies the Vector3 coordinates by the float "scale"
  69415. * @param scale defines the multiplier factor
  69416. * @returns the current updated Vector3
  69417. */
  69418. Vector3.prototype.scaleInPlace = function (scale) {
  69419. this.x *= scale;
  69420. this.y *= scale;
  69421. this.z *= scale;
  69422. return this;
  69423. };
  69424. /**
  69425. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  69426. * @param scale defines the multiplier factor
  69427. * @returns a new Vector3
  69428. */
  69429. Vector3.prototype.scale = function (scale) {
  69430. return new Vector3(this.x * scale, this.y * scale, this.z * scale);
  69431. };
  69432. /**
  69433. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  69434. * @param scale defines the multiplier factor
  69435. * @param result defines the Vector3 object where to store the result
  69436. * @returns the current Vector3
  69437. */
  69438. Vector3.prototype.scaleToRef = function (scale, result) {
  69439. return result.copyFromFloats(this.x * scale, this.y * scale, this.z * scale);
  69440. };
  69441. /**
  69442. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  69443. * @param scale defines the scale factor
  69444. * @param result defines the Vector3 object where to store the result
  69445. * @returns the unmodified current Vector3
  69446. */
  69447. Vector3.prototype.scaleAndAddToRef = function (scale, result) {
  69448. return result.addInPlaceFromFloats(this.x * scale, this.y * scale, this.z * scale);
  69449. };
  69450. /**
  69451. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  69452. * @param otherVector defines the second operand
  69453. * @returns true if both vectors are equals
  69454. */
  69455. Vector3.prototype.equals = function (otherVector) {
  69456. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z;
  69457. };
  69458. /**
  69459. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  69460. * @param otherVector defines the second operand
  69461. * @param epsilon defines the minimal distance to define values as equals
  69462. * @returns true if both vectors are distant less than epsilon
  69463. */
  69464. Vector3.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  69465. if (epsilon === void 0) { epsilon = Epsilon; }
  69466. 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);
  69467. };
  69468. /**
  69469. * Returns true if the current Vector3 coordinates equals the given floats
  69470. * @param x defines the x coordinate of the operand
  69471. * @param y defines the y coordinate of the operand
  69472. * @param z defines the z coordinate of the operand
  69473. * @returns true if both vectors are equals
  69474. */
  69475. Vector3.prototype.equalsToFloats = function (x, y, z) {
  69476. return this.x === x && this.y === y && this.z === z;
  69477. };
  69478. /**
  69479. * Multiplies the current Vector3 coordinates by the given ones
  69480. * @param otherVector defines the second operand
  69481. * @returns the current updated Vector3
  69482. */
  69483. Vector3.prototype.multiplyInPlace = function (otherVector) {
  69484. this.x *= otherVector.x;
  69485. this.y *= otherVector.y;
  69486. this.z *= otherVector.z;
  69487. return this;
  69488. };
  69489. /**
  69490. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  69491. * @param otherVector defines the second operand
  69492. * @returns the new Vector3
  69493. */
  69494. Vector3.prototype.multiply = function (otherVector) {
  69495. return this.multiplyByFloats(otherVector.x, otherVector.y, otherVector.z);
  69496. };
  69497. /**
  69498. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  69499. * @param otherVector defines the second operand
  69500. * @param result defines the Vector3 object where to store the result
  69501. * @returns the current Vector3
  69502. */
  69503. Vector3.prototype.multiplyToRef = function (otherVector, result) {
  69504. return result.copyFromFloats(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z);
  69505. };
  69506. /**
  69507. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  69508. * @param x defines the x coordinate of the operand
  69509. * @param y defines the y coordinate of the operand
  69510. * @param z defines the z coordinate of the operand
  69511. * @returns the new Vector3
  69512. */
  69513. Vector3.prototype.multiplyByFloats = function (x, y, z) {
  69514. return new Vector3(this.x * x, this.y * y, this.z * z);
  69515. };
  69516. /**
  69517. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  69518. * @param otherVector defines the second operand
  69519. * @returns the new Vector3
  69520. */
  69521. Vector3.prototype.divide = function (otherVector) {
  69522. return new Vector3(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  69523. };
  69524. /**
  69525. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  69526. * @param otherVector defines the second operand
  69527. * @param result defines the Vector3 object where to store the result
  69528. * @returns the current Vector3
  69529. */
  69530. Vector3.prototype.divideToRef = function (otherVector, result) {
  69531. return result.copyFromFloats(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  69532. };
  69533. /**
  69534. * Divides the current Vector3 coordinates by the given ones.
  69535. * @param otherVector defines the second operand
  69536. * @returns the current updated Vector3
  69537. */
  69538. Vector3.prototype.divideInPlace = function (otherVector) {
  69539. return this.divideToRef(otherVector, this);
  69540. };
  69541. /**
  69542. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  69543. * @param other defines the second operand
  69544. * @returns the current updated Vector3
  69545. */
  69546. Vector3.prototype.minimizeInPlace = function (other) {
  69547. return this.minimizeInPlaceFromFloats(other.x, other.y, other.z);
  69548. };
  69549. /**
  69550. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  69551. * @param other defines the second operand
  69552. * @returns the current updated Vector3
  69553. */
  69554. Vector3.prototype.maximizeInPlace = function (other) {
  69555. return this.maximizeInPlaceFromFloats(other.x, other.y, other.z);
  69556. };
  69557. /**
  69558. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  69559. * @param x defines the x coordinate of the operand
  69560. * @param y defines the y coordinate of the operand
  69561. * @param z defines the z coordinate of the operand
  69562. * @returns the current updated Vector3
  69563. */
  69564. Vector3.prototype.minimizeInPlaceFromFloats = function (x, y, z) {
  69565. if (x < this.x) {
  69566. this.x = x;
  69567. }
  69568. if (y < this.y) {
  69569. this.y = y;
  69570. }
  69571. if (z < this.z) {
  69572. this.z = z;
  69573. }
  69574. return this;
  69575. };
  69576. /**
  69577. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  69578. * @param x defines the x coordinate of the operand
  69579. * @param y defines the y coordinate of the operand
  69580. * @param z defines the z coordinate of the operand
  69581. * @returns the current updated Vector3
  69582. */
  69583. Vector3.prototype.maximizeInPlaceFromFloats = function (x, y, z) {
  69584. if (x > this.x) {
  69585. this.x = x;
  69586. }
  69587. if (y > this.y) {
  69588. this.y = y;
  69589. }
  69590. if (z > this.z) {
  69591. this.z = z;
  69592. }
  69593. return this;
  69594. };
  69595. /**
  69596. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  69597. * Check if is non uniform within a certain amount of decimal places to account for this
  69598. * @param epsilon the amount the values can differ
  69599. * @returns if the the vector is non uniform to a certain number of decimal places
  69600. */
  69601. Vector3.prototype.isNonUniformWithinEpsilon = function (epsilon) {
  69602. var absX = Math.abs(this.x);
  69603. var absY = Math.abs(this.y);
  69604. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absY, epsilon)) {
  69605. return true;
  69606. }
  69607. var absZ = Math.abs(this.z);
  69608. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absZ, epsilon)) {
  69609. return true;
  69610. }
  69611. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absY, absZ, epsilon)) {
  69612. return true;
  69613. }
  69614. return false;
  69615. };
  69616. Object.defineProperty(Vector3.prototype, "isNonUniform", {
  69617. /**
  69618. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  69619. */
  69620. get: function () {
  69621. var absX = Math.abs(this.x);
  69622. var absY = Math.abs(this.y);
  69623. if (absX !== absY) {
  69624. return true;
  69625. }
  69626. var absZ = Math.abs(this.z);
  69627. if (absX !== absZ) {
  69628. return true;
  69629. }
  69630. if (absY !== absZ) {
  69631. return true;
  69632. }
  69633. return false;
  69634. },
  69635. enumerable: true,
  69636. configurable: true
  69637. });
  69638. /**
  69639. * Gets a new Vector3 from current Vector3 floored values
  69640. * @returns a new Vector3
  69641. */
  69642. Vector3.prototype.floor = function () {
  69643. return new Vector3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
  69644. };
  69645. /**
  69646. * Gets a new Vector3 from current Vector3 floored values
  69647. * @returns a new Vector3
  69648. */
  69649. Vector3.prototype.fract = function () {
  69650. return new Vector3(this.x - Math.floor(this.x), this.y - Math.floor(this.y), this.z - Math.floor(this.z));
  69651. };
  69652. // Properties
  69653. /**
  69654. * Gets the length of the Vector3
  69655. * @returns the length of the Vecto3
  69656. */
  69657. Vector3.prototype.length = function () {
  69658. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  69659. };
  69660. /**
  69661. * Gets the squared length of the Vector3
  69662. * @returns squared length of the Vector3
  69663. */
  69664. Vector3.prototype.lengthSquared = function () {
  69665. return (this.x * this.x + this.y * this.y + this.z * this.z);
  69666. };
  69667. /**
  69668. * Normalize the current Vector3.
  69669. * Please note that this is an in place operation.
  69670. * @returns the current updated Vector3
  69671. */
  69672. Vector3.prototype.normalize = function () {
  69673. return this.normalizeFromLength(this.length());
  69674. };
  69675. /**
  69676. * Reorders the x y z properties of the vector in place
  69677. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  69678. * @returns the current updated vector
  69679. */
  69680. Vector3.prototype.reorderInPlace = function (order) {
  69681. var _this = this;
  69682. order = order.toLowerCase();
  69683. if (order === "xyz") {
  69684. return this;
  69685. }
  69686. MathTmp.Vector3[0].copyFrom(this);
  69687. ["x", "y", "z"].forEach(function (val, i) {
  69688. _this[val] = MathTmp.Vector3[0][order[i]];
  69689. });
  69690. return this;
  69691. };
  69692. /**
  69693. * Rotates the vector around 0,0,0 by a quaternion
  69694. * @param quaternion the rotation quaternion
  69695. * @param result vector to store the result
  69696. * @returns the resulting vector
  69697. */
  69698. Vector3.prototype.rotateByQuaternionToRef = function (quaternion, result) {
  69699. quaternion.toRotationMatrix(MathTmp.Matrix[0]);
  69700. Vector3.TransformCoordinatesToRef(this, MathTmp.Matrix[0], result);
  69701. return result;
  69702. };
  69703. /**
  69704. * Rotates a vector around a given point
  69705. * @param quaternion the rotation quaternion
  69706. * @param point the point to rotate around
  69707. * @param result vector to store the result
  69708. * @returns the resulting vector
  69709. */
  69710. Vector3.prototype.rotateByQuaternionAroundPointToRef = function (quaternion, point, result) {
  69711. this.subtractToRef(point, MathTmp.Vector3[0]);
  69712. MathTmp.Vector3[0].rotateByQuaternionToRef(quaternion, MathTmp.Vector3[0]);
  69713. point.addToRef(MathTmp.Vector3[0], result);
  69714. return result;
  69715. };
  69716. /**
  69717. * Normalize the current Vector3 with the given input length.
  69718. * Please note that this is an in place operation.
  69719. * @param len the length of the vector
  69720. * @returns the current updated Vector3
  69721. */
  69722. Vector3.prototype.normalizeFromLength = function (len) {
  69723. if (len === 0 || len === 1.0) {
  69724. return this;
  69725. }
  69726. return this.scaleInPlace(1.0 / len);
  69727. };
  69728. /**
  69729. * Normalize the current Vector3 to a new vector
  69730. * @returns the new Vector3
  69731. */
  69732. Vector3.prototype.normalizeToNew = function () {
  69733. var normalized = new Vector3(0, 0, 0);
  69734. this.normalizeToRef(normalized);
  69735. return normalized;
  69736. };
  69737. /**
  69738. * Normalize the current Vector3 to the reference
  69739. * @param reference define the Vector3 to update
  69740. * @returns the updated Vector3
  69741. */
  69742. Vector3.prototype.normalizeToRef = function (reference) {
  69743. var len = this.length();
  69744. if (len === 0 || len === 1.0) {
  69745. return reference.copyFromFloats(this.x, this.y, this.z);
  69746. }
  69747. return this.scaleToRef(1.0 / len, reference);
  69748. };
  69749. /**
  69750. * Creates a new Vector3 copied from the current Vector3
  69751. * @returns the new Vector3
  69752. */
  69753. Vector3.prototype.clone = function () {
  69754. return new Vector3(this.x, this.y, this.z);
  69755. };
  69756. /**
  69757. * Copies the given vector coordinates to the current Vector3 ones
  69758. * @param source defines the source Vector3
  69759. * @returns the current updated Vector3
  69760. */
  69761. Vector3.prototype.copyFrom = function (source) {
  69762. return this.copyFromFloats(source.x, source.y, source.z);
  69763. };
  69764. /**
  69765. * Copies the given floats to the current Vector3 coordinates
  69766. * @param x defines the x coordinate of the operand
  69767. * @param y defines the y coordinate of the operand
  69768. * @param z defines the z coordinate of the operand
  69769. * @returns the current updated Vector3
  69770. */
  69771. Vector3.prototype.copyFromFloats = function (x, y, z) {
  69772. this.x = x;
  69773. this.y = y;
  69774. this.z = z;
  69775. return this;
  69776. };
  69777. /**
  69778. * Copies the given floats to the current Vector3 coordinates
  69779. * @param x defines the x coordinate of the operand
  69780. * @param y defines the y coordinate of the operand
  69781. * @param z defines the z coordinate of the operand
  69782. * @returns the current updated Vector3
  69783. */
  69784. Vector3.prototype.set = function (x, y, z) {
  69785. return this.copyFromFloats(x, y, z);
  69786. };
  69787. /**
  69788. * Copies the given float to the current Vector3 coordinates
  69789. * @param v defines the x, y and z coordinates of the operand
  69790. * @returns the current updated Vector3
  69791. */
  69792. Vector3.prototype.setAll = function (v) {
  69793. this.x = this.y = this.z = v;
  69794. return this;
  69795. };
  69796. // Statics
  69797. /**
  69798. * Get the clip factor between two vectors
  69799. * @param vector0 defines the first operand
  69800. * @param vector1 defines the second operand
  69801. * @param axis defines the axis to use
  69802. * @param size defines the size along the axis
  69803. * @returns the clip factor
  69804. */
  69805. Vector3.GetClipFactor = function (vector0, vector1, axis, size) {
  69806. var d0 = Vector3.Dot(vector0, axis) - size;
  69807. var d1 = Vector3.Dot(vector1, axis) - size;
  69808. var s = d0 / (d0 - d1);
  69809. return s;
  69810. };
  69811. /**
  69812. * Get angle between two vectors
  69813. * @param vector0 angle between vector0 and vector1
  69814. * @param vector1 angle between vector0 and vector1
  69815. * @param normal direction of the normal
  69816. * @return the angle between vector0 and vector1
  69817. */
  69818. Vector3.GetAngleBetweenVectors = function (vector0, vector1, normal) {
  69819. var v0 = vector0.normalizeToRef(MathTmp.Vector3[1]);
  69820. var v1 = vector1.normalizeToRef(MathTmp.Vector3[2]);
  69821. var dot = Vector3.Dot(v0, v1);
  69822. var n = MathTmp.Vector3[3];
  69823. Vector3.CrossToRef(v0, v1, n);
  69824. if (Vector3.Dot(n, normal) > 0) {
  69825. return Math.acos(dot);
  69826. }
  69827. return -Math.acos(dot);
  69828. };
  69829. /**
  69830. * Returns a new Vector3 set from the index "offset" of the given array
  69831. * @param array defines the source array
  69832. * @param offset defines the offset in the source array
  69833. * @returns the new Vector3
  69834. */
  69835. Vector3.FromArray = function (array, offset) {
  69836. if (offset === void 0) { offset = 0; }
  69837. return new Vector3(array[offset], array[offset + 1], array[offset + 2]);
  69838. };
  69839. /**
  69840. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  69841. * This function is deprecated. Use FromArray instead
  69842. * @param array defines the source array
  69843. * @param offset defines the offset in the source array
  69844. * @returns the new Vector3
  69845. */
  69846. Vector3.FromFloatArray = function (array, offset) {
  69847. return Vector3.FromArray(array, offset);
  69848. };
  69849. /**
  69850. * Sets the given vector "result" with the element values from the index "offset" of the given array
  69851. * @param array defines the source array
  69852. * @param offset defines the offset in the source array
  69853. * @param result defines the Vector3 where to store the result
  69854. */
  69855. Vector3.FromArrayToRef = function (array, offset, result) {
  69856. result.x = array[offset];
  69857. result.y = array[offset + 1];
  69858. result.z = array[offset + 2];
  69859. };
  69860. /**
  69861. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  69862. * This function is deprecated. Use FromArrayToRef instead.
  69863. * @param array defines the source array
  69864. * @param offset defines the offset in the source array
  69865. * @param result defines the Vector3 where to store the result
  69866. */
  69867. Vector3.FromFloatArrayToRef = function (array, offset, result) {
  69868. return Vector3.FromArrayToRef(array, offset, result);
  69869. };
  69870. /**
  69871. * Sets the given vector "result" with the given floats.
  69872. * @param x defines the x coordinate of the source
  69873. * @param y defines the y coordinate of the source
  69874. * @param z defines the z coordinate of the source
  69875. * @param result defines the Vector3 where to store the result
  69876. */
  69877. Vector3.FromFloatsToRef = function (x, y, z, result) {
  69878. result.copyFromFloats(x, y, z);
  69879. };
  69880. /**
  69881. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  69882. * @returns a new empty Vector3
  69883. */
  69884. Vector3.Zero = function () {
  69885. return new Vector3(0.0, 0.0, 0.0);
  69886. };
  69887. /**
  69888. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  69889. * @returns a new unit Vector3
  69890. */
  69891. Vector3.One = function () {
  69892. return new Vector3(1.0, 1.0, 1.0);
  69893. };
  69894. /**
  69895. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  69896. * @returns a new up Vector3
  69897. */
  69898. Vector3.Up = function () {
  69899. return new Vector3(0.0, 1.0, 0.0);
  69900. };
  69901. Object.defineProperty(Vector3, "UpReadOnly", {
  69902. /**
  69903. * Gets a up Vector3 that must not be updated
  69904. */
  69905. get: function () {
  69906. return Vector3._UpReadOnly;
  69907. },
  69908. enumerable: true,
  69909. configurable: true
  69910. });
  69911. /**
  69912. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  69913. * @returns a new down Vector3
  69914. */
  69915. Vector3.Down = function () {
  69916. return new Vector3(0.0, -1.0, 0.0);
  69917. };
  69918. /**
  69919. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  69920. * @returns a new forward Vector3
  69921. */
  69922. Vector3.Forward = function () {
  69923. return new Vector3(0.0, 0.0, 1.0);
  69924. };
  69925. /**
  69926. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  69927. * @returns a new forward Vector3
  69928. */
  69929. Vector3.Backward = function () {
  69930. return new Vector3(0.0, 0.0, -1.0);
  69931. };
  69932. /**
  69933. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  69934. * @returns a new right Vector3
  69935. */
  69936. Vector3.Right = function () {
  69937. return new Vector3(1.0, 0.0, 0.0);
  69938. };
  69939. /**
  69940. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  69941. * @returns a new left Vector3
  69942. */
  69943. Vector3.Left = function () {
  69944. return new Vector3(-1.0, 0.0, 0.0);
  69945. };
  69946. /**
  69947. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  69948. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69949. * @param vector defines the Vector3 to transform
  69950. * @param transformation defines the transformation matrix
  69951. * @returns the transformed Vector3
  69952. */
  69953. Vector3.TransformCoordinates = function (vector, transformation) {
  69954. var result = Vector3.Zero();
  69955. Vector3.TransformCoordinatesToRef(vector, transformation, result);
  69956. return result;
  69957. };
  69958. /**
  69959. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  69960. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69961. * @param vector defines the Vector3 to transform
  69962. * @param transformation defines the transformation matrix
  69963. * @param result defines the Vector3 where to store the result
  69964. */
  69965. Vector3.TransformCoordinatesToRef = function (vector, transformation, result) {
  69966. Vector3.TransformCoordinatesFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  69967. };
  69968. /**
  69969. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  69970. * This method computes tranformed coordinates only, not transformed direction vectors
  69971. * @param x define the x coordinate of the source vector
  69972. * @param y define the y coordinate of the source vector
  69973. * @param z define the z coordinate of the source vector
  69974. * @param transformation defines the transformation matrix
  69975. * @param result defines the Vector3 where to store the result
  69976. */
  69977. Vector3.TransformCoordinatesFromFloatsToRef = function (x, y, z, transformation, result) {
  69978. var m = transformation.m;
  69979. var rx = x * m[0] + y * m[4] + z * m[8] + m[12];
  69980. var ry = x * m[1] + y * m[5] + z * m[9] + m[13];
  69981. var rz = x * m[2] + y * m[6] + z * m[10] + m[14];
  69982. var rw = 1 / (x * m[3] + y * m[7] + z * m[11] + m[15]);
  69983. result.x = rx * rw;
  69984. result.y = ry * rw;
  69985. result.z = rz * rw;
  69986. };
  69987. /**
  69988. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  69989. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69990. * @param vector defines the Vector3 to transform
  69991. * @param transformation defines the transformation matrix
  69992. * @returns the new Vector3
  69993. */
  69994. Vector3.TransformNormal = function (vector, transformation) {
  69995. var result = Vector3.Zero();
  69996. Vector3.TransformNormalToRef(vector, transformation, result);
  69997. return result;
  69998. };
  69999. /**
  70000. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  70001. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70002. * @param vector defines the Vector3 to transform
  70003. * @param transformation defines the transformation matrix
  70004. * @param result defines the Vector3 where to store the result
  70005. */
  70006. Vector3.TransformNormalToRef = function (vector, transformation, result) {
  70007. this.TransformNormalFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  70008. };
  70009. /**
  70010. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  70011. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70012. * @param x define the x coordinate of the source vector
  70013. * @param y define the y coordinate of the source vector
  70014. * @param z define the z coordinate of the source vector
  70015. * @param transformation defines the transformation matrix
  70016. * @param result defines the Vector3 where to store the result
  70017. */
  70018. Vector3.TransformNormalFromFloatsToRef = function (x, y, z, transformation, result) {
  70019. var m = transformation.m;
  70020. result.x = x * m[0] + y * m[4] + z * m[8];
  70021. result.y = x * m[1] + y * m[5] + z * m[9];
  70022. result.z = x * m[2] + y * m[6] + z * m[10];
  70023. };
  70024. /**
  70025. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  70026. * @param value1 defines the first control point
  70027. * @param value2 defines the second control point
  70028. * @param value3 defines the third control point
  70029. * @param value4 defines the fourth control point
  70030. * @param amount defines the amount on the spline to use
  70031. * @returns the new Vector3
  70032. */
  70033. Vector3.CatmullRom = function (value1, value2, value3, value4, amount) {
  70034. var squared = amount * amount;
  70035. var cubed = amount * squared;
  70036. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  70037. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  70038. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  70039. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  70040. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  70041. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  70042. var z = 0.5 * ((((2.0 * value2.z) + ((-value1.z + value3.z) * amount)) +
  70043. (((((2.0 * value1.z) - (5.0 * value2.z)) + (4.0 * value3.z)) - value4.z) * squared)) +
  70044. ((((-value1.z + (3.0 * value2.z)) - (3.0 * value3.z)) + value4.z) * cubed));
  70045. return new Vector3(x, y, z);
  70046. };
  70047. /**
  70048. * 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"
  70049. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70050. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70051. * @param value defines the current value
  70052. * @param min defines the lower range value
  70053. * @param max defines the upper range value
  70054. * @returns the new Vector3
  70055. */
  70056. Vector3.Clamp = function (value, min, max) {
  70057. var v = new Vector3();
  70058. Vector3.ClampToRef(value, min, max, v);
  70059. return v;
  70060. };
  70061. /**
  70062. * 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"
  70063. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70064. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70065. * @param value defines the current value
  70066. * @param min defines the lower range value
  70067. * @param max defines the upper range value
  70068. * @param result defines the Vector3 where to store the result
  70069. */
  70070. Vector3.ClampToRef = function (value, min, max, result) {
  70071. var x = value.x;
  70072. x = (x > max.x) ? max.x : x;
  70073. x = (x < min.x) ? min.x : x;
  70074. var y = value.y;
  70075. y = (y > max.y) ? max.y : y;
  70076. y = (y < min.y) ? min.y : y;
  70077. var z = value.z;
  70078. z = (z > max.z) ? max.z : z;
  70079. z = (z < min.z) ? min.z : z;
  70080. result.copyFromFloats(x, y, z);
  70081. };
  70082. /**
  70083. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  70084. * @param value1 defines the first control point
  70085. * @param tangent1 defines the first tangent vector
  70086. * @param value2 defines the second control point
  70087. * @param tangent2 defines the second tangent vector
  70088. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  70089. * @returns the new Vector3
  70090. */
  70091. Vector3.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  70092. var squared = amount * amount;
  70093. var cubed = amount * squared;
  70094. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  70095. var part2 = (-2.0 * cubed) + (3.0 * squared);
  70096. var part3 = (cubed - (2.0 * squared)) + amount;
  70097. var part4 = cubed - squared;
  70098. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  70099. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  70100. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  70101. return new Vector3(x, y, z);
  70102. };
  70103. /**
  70104. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  70105. * @param start defines the start value
  70106. * @param end defines the end value
  70107. * @param amount max defines amount between both (between 0 and 1)
  70108. * @returns the new Vector3
  70109. */
  70110. Vector3.Lerp = function (start, end, amount) {
  70111. var result = new Vector3(0, 0, 0);
  70112. Vector3.LerpToRef(start, end, amount, result);
  70113. return result;
  70114. };
  70115. /**
  70116. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  70117. * @param start defines the start value
  70118. * @param end defines the end value
  70119. * @param amount max defines amount between both (between 0 and 1)
  70120. * @param result defines the Vector3 where to store the result
  70121. */
  70122. Vector3.LerpToRef = function (start, end, amount, result) {
  70123. result.x = start.x + ((end.x - start.x) * amount);
  70124. result.y = start.y + ((end.y - start.y) * amount);
  70125. result.z = start.z + ((end.z - start.z) * amount);
  70126. };
  70127. /**
  70128. * Returns the dot product (float) between the vectors "left" and "right"
  70129. * @param left defines the left operand
  70130. * @param right defines the right operand
  70131. * @returns the dot product
  70132. */
  70133. Vector3.Dot = function (left, right) {
  70134. return (left.x * right.x + left.y * right.y + left.z * right.z);
  70135. };
  70136. /**
  70137. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  70138. * The cross product is then orthogonal to both "left" and "right"
  70139. * @param left defines the left operand
  70140. * @param right defines the right operand
  70141. * @returns the cross product
  70142. */
  70143. Vector3.Cross = function (left, right) {
  70144. var result = Vector3.Zero();
  70145. Vector3.CrossToRef(left, right, result);
  70146. return result;
  70147. };
  70148. /**
  70149. * Sets the given vector "result" with the cross product of "left" and "right"
  70150. * The cross product is then orthogonal to both "left" and "right"
  70151. * @param left defines the left operand
  70152. * @param right defines the right operand
  70153. * @param result defines the Vector3 where to store the result
  70154. */
  70155. Vector3.CrossToRef = function (left, right, result) {
  70156. var x = left.y * right.z - left.z * right.y;
  70157. var y = left.z * right.x - left.x * right.z;
  70158. var z = left.x * right.y - left.y * right.x;
  70159. result.copyFromFloats(x, y, z);
  70160. };
  70161. /**
  70162. * Returns a new Vector3 as the normalization of the given vector
  70163. * @param vector defines the Vector3 to normalize
  70164. * @returns the new Vector3
  70165. */
  70166. Vector3.Normalize = function (vector) {
  70167. var result = Vector3.Zero();
  70168. Vector3.NormalizeToRef(vector, result);
  70169. return result;
  70170. };
  70171. /**
  70172. * Sets the given vector "result" with the normalization of the given first vector
  70173. * @param vector defines the Vector3 to normalize
  70174. * @param result defines the Vector3 where to store the result
  70175. */
  70176. Vector3.NormalizeToRef = function (vector, result) {
  70177. vector.normalizeToRef(result);
  70178. };
  70179. /**
  70180. * Project a Vector3 onto screen space
  70181. * @param vector defines the Vector3 to project
  70182. * @param world defines the world matrix to use
  70183. * @param transform defines the transform (view x projection) matrix to use
  70184. * @param viewport defines the screen viewport to use
  70185. * @returns the new Vector3
  70186. */
  70187. Vector3.Project = function (vector, world, transform, viewport) {
  70188. var cw = viewport.width;
  70189. var ch = viewport.height;
  70190. var cx = viewport.x;
  70191. var cy = viewport.y;
  70192. var viewportMatrix = MathTmp.Matrix[1];
  70193. 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);
  70194. var matrix = MathTmp.Matrix[0];
  70195. world.multiplyToRef(transform, matrix);
  70196. matrix.multiplyToRef(viewportMatrix, matrix);
  70197. return Vector3.TransformCoordinates(vector, matrix);
  70198. };
  70199. /** @hidden */
  70200. Vector3._UnprojectFromInvertedMatrixToRef = function (source, matrix, result) {
  70201. Vector3.TransformCoordinatesToRef(source, matrix, result);
  70202. var m = matrix.m;
  70203. var num = source.x * m[3] + source.y * m[7] + source.z * m[11] + m[15];
  70204. if (_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(num, 1.0)) {
  70205. result.scaleInPlace(1.0 / num);
  70206. }
  70207. };
  70208. /**
  70209. * Unproject from screen space to object space
  70210. * @param source defines the screen space Vector3 to use
  70211. * @param viewportWidth defines the current width of the viewport
  70212. * @param viewportHeight defines the current height of the viewport
  70213. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70214. * @param transform defines the transform (view x projection) matrix to use
  70215. * @returns the new Vector3
  70216. */
  70217. Vector3.UnprojectFromTransform = function (source, viewportWidth, viewportHeight, world, transform) {
  70218. var matrix = MathTmp.Matrix[0];
  70219. world.multiplyToRef(transform, matrix);
  70220. matrix.invert();
  70221. source.x = source.x / viewportWidth * 2 - 1;
  70222. source.y = -(source.y / viewportHeight * 2 - 1);
  70223. var vector = new Vector3();
  70224. Vector3._UnprojectFromInvertedMatrixToRef(source, matrix, vector);
  70225. return vector;
  70226. };
  70227. /**
  70228. * Unproject from screen space to object space
  70229. * @param source defines the screen space Vector3 to use
  70230. * @param viewportWidth defines the current width of the viewport
  70231. * @param viewportHeight defines the current height of the viewport
  70232. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70233. * @param view defines the view matrix to use
  70234. * @param projection defines the projection matrix to use
  70235. * @returns the new Vector3
  70236. */
  70237. Vector3.Unproject = function (source, viewportWidth, viewportHeight, world, view, projection) {
  70238. var result = Vector3.Zero();
  70239. Vector3.UnprojectToRef(source, viewportWidth, viewportHeight, world, view, projection, result);
  70240. return result;
  70241. };
  70242. /**
  70243. * Unproject from screen space to object space
  70244. * @param source defines the screen space Vector3 to use
  70245. * @param viewportWidth defines the current width of the viewport
  70246. * @param viewportHeight defines the current height of the viewport
  70247. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70248. * @param view defines the view matrix to use
  70249. * @param projection defines the projection matrix to use
  70250. * @param result defines the Vector3 where to store the result
  70251. */
  70252. Vector3.UnprojectToRef = function (source, viewportWidth, viewportHeight, world, view, projection, result) {
  70253. Vector3.UnprojectFloatsToRef(source.x, source.y, source.z, viewportWidth, viewportHeight, world, view, projection, result);
  70254. };
  70255. /**
  70256. * Unproject from screen space to object space
  70257. * @param sourceX defines the screen space x coordinate to use
  70258. * @param sourceY defines the screen space y coordinate to use
  70259. * @param sourceZ defines the screen space z coordinate to use
  70260. * @param viewportWidth defines the current width of the viewport
  70261. * @param viewportHeight defines the current height of the viewport
  70262. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70263. * @param view defines the view matrix to use
  70264. * @param projection defines the projection matrix to use
  70265. * @param result defines the Vector3 where to store the result
  70266. */
  70267. Vector3.UnprojectFloatsToRef = function (sourceX, sourceY, sourceZ, viewportWidth, viewportHeight, world, view, projection, result) {
  70268. var matrix = MathTmp.Matrix[0];
  70269. world.multiplyToRef(view, matrix);
  70270. matrix.multiplyToRef(projection, matrix);
  70271. matrix.invert();
  70272. var screenSource = MathTmp.Vector3[0];
  70273. screenSource.x = sourceX / viewportWidth * 2 - 1;
  70274. screenSource.y = -(sourceY / viewportHeight * 2 - 1);
  70275. screenSource.z = 2 * sourceZ - 1.0;
  70276. Vector3._UnprojectFromInvertedMatrixToRef(screenSource, matrix, result);
  70277. };
  70278. /**
  70279. * Gets the minimal coordinate values between two Vector3
  70280. * @param left defines the first operand
  70281. * @param right defines the second operand
  70282. * @returns the new Vector3
  70283. */
  70284. Vector3.Minimize = function (left, right) {
  70285. var min = left.clone();
  70286. min.minimizeInPlace(right);
  70287. return min;
  70288. };
  70289. /**
  70290. * Gets the maximal coordinate values between two Vector3
  70291. * @param left defines the first operand
  70292. * @param right defines the second operand
  70293. * @returns the new Vector3
  70294. */
  70295. Vector3.Maximize = function (left, right) {
  70296. var max = left.clone();
  70297. max.maximizeInPlace(right);
  70298. return max;
  70299. };
  70300. /**
  70301. * Returns the distance between the vectors "value1" and "value2"
  70302. * @param value1 defines the first operand
  70303. * @param value2 defines the second operand
  70304. * @returns the distance
  70305. */
  70306. Vector3.Distance = function (value1, value2) {
  70307. return Math.sqrt(Vector3.DistanceSquared(value1, value2));
  70308. };
  70309. /**
  70310. * Returns the squared distance between the vectors "value1" and "value2"
  70311. * @param value1 defines the first operand
  70312. * @param value2 defines the second operand
  70313. * @returns the squared distance
  70314. */
  70315. Vector3.DistanceSquared = function (value1, value2) {
  70316. var x = value1.x - value2.x;
  70317. var y = value1.y - value2.y;
  70318. var z = value1.z - value2.z;
  70319. return (x * x) + (y * y) + (z * z);
  70320. };
  70321. /**
  70322. * Returns a new Vector3 located at the center between "value1" and "value2"
  70323. * @param value1 defines the first operand
  70324. * @param value2 defines the second operand
  70325. * @returns the new Vector3
  70326. */
  70327. Vector3.Center = function (value1, value2) {
  70328. var center = value1.add(value2);
  70329. center.scaleInPlace(0.5);
  70330. return center;
  70331. };
  70332. /**
  70333. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  70334. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  70335. * to something in order to rotate it from its local system to the given target system
  70336. * Note: axis1, axis2 and axis3 are normalized during this operation
  70337. * @param axis1 defines the first axis
  70338. * @param axis2 defines the second axis
  70339. * @param axis3 defines the third axis
  70340. * @returns a new Vector3
  70341. */
  70342. Vector3.RotationFromAxis = function (axis1, axis2, axis3) {
  70343. var rotation = Vector3.Zero();
  70344. Vector3.RotationFromAxisToRef(axis1, axis2, axis3, rotation);
  70345. return rotation;
  70346. };
  70347. /**
  70348. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  70349. * @param axis1 defines the first axis
  70350. * @param axis2 defines the second axis
  70351. * @param axis3 defines the third axis
  70352. * @param ref defines the Vector3 where to store the result
  70353. */
  70354. Vector3.RotationFromAxisToRef = function (axis1, axis2, axis3, ref) {
  70355. var quat = MathTmp.Quaternion[0];
  70356. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  70357. quat.toEulerAnglesToRef(ref);
  70358. };
  70359. Vector3._UpReadOnly = Vector3.Up();
  70360. return Vector3;
  70361. }());
  70362. /**
  70363. * Vector4 class created for EulerAngle class conversion to Quaternion
  70364. */
  70365. var Vector4 = /** @class */ (function () {
  70366. /**
  70367. * Creates a Vector4 object from the given floats.
  70368. * @param x x value of the vector
  70369. * @param y y value of the vector
  70370. * @param z z value of the vector
  70371. * @param w w value of the vector
  70372. */
  70373. function Vector4(
  70374. /** x value of the vector */
  70375. x,
  70376. /** y value of the vector */
  70377. y,
  70378. /** z value of the vector */
  70379. z,
  70380. /** w value of the vector */
  70381. w) {
  70382. this.x = x;
  70383. this.y = y;
  70384. this.z = z;
  70385. this.w = w;
  70386. }
  70387. /**
  70388. * Returns the string with the Vector4 coordinates.
  70389. * @returns a string containing all the vector values
  70390. */
  70391. Vector4.prototype.toString = function () {
  70392. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  70393. };
  70394. /**
  70395. * Returns the string "Vector4".
  70396. * @returns "Vector4"
  70397. */
  70398. Vector4.prototype.getClassName = function () {
  70399. return "Vector4";
  70400. };
  70401. /**
  70402. * Returns the Vector4 hash code.
  70403. * @returns a unique hash code
  70404. */
  70405. Vector4.prototype.getHashCode = function () {
  70406. var hash = this.x || 0;
  70407. hash = (hash * 397) ^ (this.y || 0);
  70408. hash = (hash * 397) ^ (this.z || 0);
  70409. hash = (hash * 397) ^ (this.w || 0);
  70410. return hash;
  70411. };
  70412. // Operators
  70413. /**
  70414. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  70415. * @returns the resulting array
  70416. */
  70417. Vector4.prototype.asArray = function () {
  70418. var result = new Array();
  70419. this.toArray(result, 0);
  70420. return result;
  70421. };
  70422. /**
  70423. * Populates the given array from the given index with the Vector4 coordinates.
  70424. * @param array array to populate
  70425. * @param index index of the array to start at (default: 0)
  70426. * @returns the Vector4.
  70427. */
  70428. Vector4.prototype.toArray = function (array, index) {
  70429. if (index === undefined) {
  70430. index = 0;
  70431. }
  70432. array[index] = this.x;
  70433. array[index + 1] = this.y;
  70434. array[index + 2] = this.z;
  70435. array[index + 3] = this.w;
  70436. return this;
  70437. };
  70438. /**
  70439. * Adds the given vector to the current Vector4.
  70440. * @param otherVector the vector to add
  70441. * @returns the updated Vector4.
  70442. */
  70443. Vector4.prototype.addInPlace = function (otherVector) {
  70444. this.x += otherVector.x;
  70445. this.y += otherVector.y;
  70446. this.z += otherVector.z;
  70447. this.w += otherVector.w;
  70448. return this;
  70449. };
  70450. /**
  70451. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  70452. * @param otherVector the vector to add
  70453. * @returns the resulting vector
  70454. */
  70455. Vector4.prototype.add = function (otherVector) {
  70456. return new Vector4(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z, this.w + otherVector.w);
  70457. };
  70458. /**
  70459. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  70460. * @param otherVector the vector to add
  70461. * @param result the vector to store the result
  70462. * @returns the current Vector4.
  70463. */
  70464. Vector4.prototype.addToRef = function (otherVector, result) {
  70465. result.x = this.x + otherVector.x;
  70466. result.y = this.y + otherVector.y;
  70467. result.z = this.z + otherVector.z;
  70468. result.w = this.w + otherVector.w;
  70469. return this;
  70470. };
  70471. /**
  70472. * Subtract in place the given vector from the current Vector4.
  70473. * @param otherVector the vector to subtract
  70474. * @returns the updated Vector4.
  70475. */
  70476. Vector4.prototype.subtractInPlace = function (otherVector) {
  70477. this.x -= otherVector.x;
  70478. this.y -= otherVector.y;
  70479. this.z -= otherVector.z;
  70480. this.w -= otherVector.w;
  70481. return this;
  70482. };
  70483. /**
  70484. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  70485. * @param otherVector the vector to add
  70486. * @returns the new vector with the result
  70487. */
  70488. Vector4.prototype.subtract = function (otherVector) {
  70489. return new Vector4(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z, this.w - otherVector.w);
  70490. };
  70491. /**
  70492. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  70493. * @param otherVector the vector to subtract
  70494. * @param result the vector to store the result
  70495. * @returns the current Vector4.
  70496. */
  70497. Vector4.prototype.subtractToRef = function (otherVector, result) {
  70498. result.x = this.x - otherVector.x;
  70499. result.y = this.y - otherVector.y;
  70500. result.z = this.z - otherVector.z;
  70501. result.w = this.w - otherVector.w;
  70502. return this;
  70503. };
  70504. /**
  70505. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70506. */
  70507. /**
  70508. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70509. * @param x value to subtract
  70510. * @param y value to subtract
  70511. * @param z value to subtract
  70512. * @param w value to subtract
  70513. * @returns new vector containing the result
  70514. */
  70515. Vector4.prototype.subtractFromFloats = function (x, y, z, w) {
  70516. return new Vector4(this.x - x, this.y - y, this.z - z, this.w - w);
  70517. };
  70518. /**
  70519. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70520. * @param x value to subtract
  70521. * @param y value to subtract
  70522. * @param z value to subtract
  70523. * @param w value to subtract
  70524. * @param result the vector to store the result in
  70525. * @returns the current Vector4.
  70526. */
  70527. Vector4.prototype.subtractFromFloatsToRef = function (x, y, z, w, result) {
  70528. result.x = this.x - x;
  70529. result.y = this.y - y;
  70530. result.z = this.z - z;
  70531. result.w = this.w - w;
  70532. return this;
  70533. };
  70534. /**
  70535. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  70536. * @returns a new vector with the negated values
  70537. */
  70538. Vector4.prototype.negate = function () {
  70539. return new Vector4(-this.x, -this.y, -this.z, -this.w);
  70540. };
  70541. /**
  70542. * Multiplies the current Vector4 coordinates by scale (float).
  70543. * @param scale the number to scale with
  70544. * @returns the updated Vector4.
  70545. */
  70546. Vector4.prototype.scaleInPlace = function (scale) {
  70547. this.x *= scale;
  70548. this.y *= scale;
  70549. this.z *= scale;
  70550. this.w *= scale;
  70551. return this;
  70552. };
  70553. /**
  70554. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  70555. * @param scale the number to scale with
  70556. * @returns a new vector with the result
  70557. */
  70558. Vector4.prototype.scale = function (scale) {
  70559. return new Vector4(this.x * scale, this.y * scale, this.z * scale, this.w * scale);
  70560. };
  70561. /**
  70562. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  70563. * @param scale the number to scale with
  70564. * @param result a vector to store the result in
  70565. * @returns the current Vector4.
  70566. */
  70567. Vector4.prototype.scaleToRef = function (scale, result) {
  70568. result.x = this.x * scale;
  70569. result.y = this.y * scale;
  70570. result.z = this.z * scale;
  70571. result.w = this.w * scale;
  70572. return this;
  70573. };
  70574. /**
  70575. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  70576. * @param scale defines the scale factor
  70577. * @param result defines the Vector4 object where to store the result
  70578. * @returns the unmodified current Vector4
  70579. */
  70580. Vector4.prototype.scaleAndAddToRef = function (scale, result) {
  70581. result.x += this.x * scale;
  70582. result.y += this.y * scale;
  70583. result.z += this.z * scale;
  70584. result.w += this.w * scale;
  70585. return this;
  70586. };
  70587. /**
  70588. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  70589. * @param otherVector the vector to compare against
  70590. * @returns true if they are equal
  70591. */
  70592. Vector4.prototype.equals = function (otherVector) {
  70593. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z && this.w === otherVector.w;
  70594. };
  70595. /**
  70596. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  70597. * @param otherVector vector to compare against
  70598. * @param epsilon (Default: very small number)
  70599. * @returns true if they are equal
  70600. */
  70601. Vector4.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  70602. if (epsilon === void 0) { epsilon = Epsilon; }
  70603. return otherVector
  70604. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.x, otherVector.x, epsilon)
  70605. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.y, otherVector.y, epsilon)
  70606. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.z, otherVector.z, epsilon)
  70607. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.w, otherVector.w, epsilon);
  70608. };
  70609. /**
  70610. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  70611. * @param x x value to compare against
  70612. * @param y y value to compare against
  70613. * @param z z value to compare against
  70614. * @param w w value to compare against
  70615. * @returns true if equal
  70616. */
  70617. Vector4.prototype.equalsToFloats = function (x, y, z, w) {
  70618. return this.x === x && this.y === y && this.z === z && this.w === w;
  70619. };
  70620. /**
  70621. * Multiplies in place the current Vector4 by the given one.
  70622. * @param otherVector vector to multiple with
  70623. * @returns the updated Vector4.
  70624. */
  70625. Vector4.prototype.multiplyInPlace = function (otherVector) {
  70626. this.x *= otherVector.x;
  70627. this.y *= otherVector.y;
  70628. this.z *= otherVector.z;
  70629. this.w *= otherVector.w;
  70630. return this;
  70631. };
  70632. /**
  70633. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  70634. * @param otherVector vector to multiple with
  70635. * @returns resulting new vector
  70636. */
  70637. Vector4.prototype.multiply = function (otherVector) {
  70638. return new Vector4(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z, this.w * otherVector.w);
  70639. };
  70640. /**
  70641. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  70642. * @param otherVector vector to multiple with
  70643. * @param result vector to store the result
  70644. * @returns the current Vector4.
  70645. */
  70646. Vector4.prototype.multiplyToRef = function (otherVector, result) {
  70647. result.x = this.x * otherVector.x;
  70648. result.y = this.y * otherVector.y;
  70649. result.z = this.z * otherVector.z;
  70650. result.w = this.w * otherVector.w;
  70651. return this;
  70652. };
  70653. /**
  70654. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  70655. * @param x x value multiply with
  70656. * @param y y value multiply with
  70657. * @param z z value multiply with
  70658. * @param w w value multiply with
  70659. * @returns resulting new vector
  70660. */
  70661. Vector4.prototype.multiplyByFloats = function (x, y, z, w) {
  70662. return new Vector4(this.x * x, this.y * y, this.z * z, this.w * w);
  70663. };
  70664. /**
  70665. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  70666. * @param otherVector vector to devide with
  70667. * @returns resulting new vector
  70668. */
  70669. Vector4.prototype.divide = function (otherVector) {
  70670. return new Vector4(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z, this.w / otherVector.w);
  70671. };
  70672. /**
  70673. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  70674. * @param otherVector vector to devide with
  70675. * @param result vector to store the result
  70676. * @returns the current Vector4.
  70677. */
  70678. Vector4.prototype.divideToRef = function (otherVector, result) {
  70679. result.x = this.x / otherVector.x;
  70680. result.y = this.y / otherVector.y;
  70681. result.z = this.z / otherVector.z;
  70682. result.w = this.w / otherVector.w;
  70683. return this;
  70684. };
  70685. /**
  70686. * Divides the current Vector3 coordinates by the given ones.
  70687. * @param otherVector vector to devide with
  70688. * @returns the updated Vector3.
  70689. */
  70690. Vector4.prototype.divideInPlace = function (otherVector) {
  70691. return this.divideToRef(otherVector, this);
  70692. };
  70693. /**
  70694. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  70695. * @param other defines the second operand
  70696. * @returns the current updated Vector4
  70697. */
  70698. Vector4.prototype.minimizeInPlace = function (other) {
  70699. if (other.x < this.x) {
  70700. this.x = other.x;
  70701. }
  70702. if (other.y < this.y) {
  70703. this.y = other.y;
  70704. }
  70705. if (other.z < this.z) {
  70706. this.z = other.z;
  70707. }
  70708. if (other.w < this.w) {
  70709. this.w = other.w;
  70710. }
  70711. return this;
  70712. };
  70713. /**
  70714. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  70715. * @param other defines the second operand
  70716. * @returns the current updated Vector4
  70717. */
  70718. Vector4.prototype.maximizeInPlace = function (other) {
  70719. if (other.x > this.x) {
  70720. this.x = other.x;
  70721. }
  70722. if (other.y > this.y) {
  70723. this.y = other.y;
  70724. }
  70725. if (other.z > this.z) {
  70726. this.z = other.z;
  70727. }
  70728. if (other.w > this.w) {
  70729. this.w = other.w;
  70730. }
  70731. return this;
  70732. };
  70733. /**
  70734. * Gets a new Vector4 from current Vector4 floored values
  70735. * @returns a new Vector4
  70736. */
  70737. Vector4.prototype.floor = function () {
  70738. return new Vector4(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z), Math.floor(this.w));
  70739. };
  70740. /**
  70741. * Gets a new Vector4 from current Vector3 floored values
  70742. * @returns a new Vector4
  70743. */
  70744. Vector4.prototype.fract = function () {
  70745. 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));
  70746. };
  70747. // Properties
  70748. /**
  70749. * Returns the Vector4 length (float).
  70750. * @returns the length
  70751. */
  70752. Vector4.prototype.length = function () {
  70753. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  70754. };
  70755. /**
  70756. * Returns the Vector4 squared length (float).
  70757. * @returns the length squared
  70758. */
  70759. Vector4.prototype.lengthSquared = function () {
  70760. return (this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  70761. };
  70762. // Methods
  70763. /**
  70764. * Normalizes in place the Vector4.
  70765. * @returns the updated Vector4.
  70766. */
  70767. Vector4.prototype.normalize = function () {
  70768. var len = this.length();
  70769. if (len === 0) {
  70770. return this;
  70771. }
  70772. return this.scaleInPlace(1.0 / len);
  70773. };
  70774. /**
  70775. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  70776. * @returns this converted to a new vector3
  70777. */
  70778. Vector4.prototype.toVector3 = function () {
  70779. return new Vector3(this.x, this.y, this.z);
  70780. };
  70781. /**
  70782. * Returns a new Vector4 copied from the current one.
  70783. * @returns the new cloned vector
  70784. */
  70785. Vector4.prototype.clone = function () {
  70786. return new Vector4(this.x, this.y, this.z, this.w);
  70787. };
  70788. /**
  70789. * Updates the current Vector4 with the given one coordinates.
  70790. * @param source the source vector to copy from
  70791. * @returns the updated Vector4.
  70792. */
  70793. Vector4.prototype.copyFrom = function (source) {
  70794. this.x = source.x;
  70795. this.y = source.y;
  70796. this.z = source.z;
  70797. this.w = source.w;
  70798. return this;
  70799. };
  70800. /**
  70801. * Updates the current Vector4 coordinates with the given floats.
  70802. * @param x float to copy from
  70803. * @param y float to copy from
  70804. * @param z float to copy from
  70805. * @param w float to copy from
  70806. * @returns the updated Vector4.
  70807. */
  70808. Vector4.prototype.copyFromFloats = function (x, y, z, w) {
  70809. this.x = x;
  70810. this.y = y;
  70811. this.z = z;
  70812. this.w = w;
  70813. return this;
  70814. };
  70815. /**
  70816. * Updates the current Vector4 coordinates with the given floats.
  70817. * @param x float to set from
  70818. * @param y float to set from
  70819. * @param z float to set from
  70820. * @param w float to set from
  70821. * @returns the updated Vector4.
  70822. */
  70823. Vector4.prototype.set = function (x, y, z, w) {
  70824. return this.copyFromFloats(x, y, z, w);
  70825. };
  70826. /**
  70827. * Copies the given float to the current Vector3 coordinates
  70828. * @param v defines the x, y, z and w coordinates of the operand
  70829. * @returns the current updated Vector3
  70830. */
  70831. Vector4.prototype.setAll = function (v) {
  70832. this.x = this.y = this.z = this.w = v;
  70833. return this;
  70834. };
  70835. // Statics
  70836. /**
  70837. * Returns a new Vector4 set from the starting index of the given array.
  70838. * @param array the array to pull values from
  70839. * @param offset the offset into the array to start at
  70840. * @returns the new vector
  70841. */
  70842. Vector4.FromArray = function (array, offset) {
  70843. if (!offset) {
  70844. offset = 0;
  70845. }
  70846. return new Vector4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  70847. };
  70848. /**
  70849. * Updates the given vector "result" from the starting index of the given array.
  70850. * @param array the array to pull values from
  70851. * @param offset the offset into the array to start at
  70852. * @param result the vector to store the result in
  70853. */
  70854. Vector4.FromArrayToRef = function (array, offset, result) {
  70855. result.x = array[offset];
  70856. result.y = array[offset + 1];
  70857. result.z = array[offset + 2];
  70858. result.w = array[offset + 3];
  70859. };
  70860. /**
  70861. * Updates the given vector "result" from the starting index of the given Float32Array.
  70862. * @param array the array to pull values from
  70863. * @param offset the offset into the array to start at
  70864. * @param result the vector to store the result in
  70865. */
  70866. Vector4.FromFloatArrayToRef = function (array, offset, result) {
  70867. Vector4.FromArrayToRef(array, offset, result);
  70868. };
  70869. /**
  70870. * Updates the given vector "result" coordinates from the given floats.
  70871. * @param x float to set from
  70872. * @param y float to set from
  70873. * @param z float to set from
  70874. * @param w float to set from
  70875. * @param result the vector to the floats in
  70876. */
  70877. Vector4.FromFloatsToRef = function (x, y, z, w, result) {
  70878. result.x = x;
  70879. result.y = y;
  70880. result.z = z;
  70881. result.w = w;
  70882. };
  70883. /**
  70884. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  70885. * @returns the new vector
  70886. */
  70887. Vector4.Zero = function () {
  70888. return new Vector4(0.0, 0.0, 0.0, 0.0);
  70889. };
  70890. /**
  70891. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  70892. * @returns the new vector
  70893. */
  70894. Vector4.One = function () {
  70895. return new Vector4(1.0, 1.0, 1.0, 1.0);
  70896. };
  70897. /**
  70898. * Returns a new normalized Vector4 from the given one.
  70899. * @param vector the vector to normalize
  70900. * @returns the vector
  70901. */
  70902. Vector4.Normalize = function (vector) {
  70903. var result = Vector4.Zero();
  70904. Vector4.NormalizeToRef(vector, result);
  70905. return result;
  70906. };
  70907. /**
  70908. * Updates the given vector "result" from the normalization of the given one.
  70909. * @param vector the vector to normalize
  70910. * @param result the vector to store the result in
  70911. */
  70912. Vector4.NormalizeToRef = function (vector, result) {
  70913. result.copyFrom(vector);
  70914. result.normalize();
  70915. };
  70916. /**
  70917. * Returns a vector with the minimum values from the left and right vectors
  70918. * @param left left vector to minimize
  70919. * @param right right vector to minimize
  70920. * @returns a new vector with the minimum of the left and right vector values
  70921. */
  70922. Vector4.Minimize = function (left, right) {
  70923. var min = left.clone();
  70924. min.minimizeInPlace(right);
  70925. return min;
  70926. };
  70927. /**
  70928. * Returns a vector with the maximum values from the left and right vectors
  70929. * @param left left vector to maximize
  70930. * @param right right vector to maximize
  70931. * @returns a new vector with the maximum of the left and right vector values
  70932. */
  70933. Vector4.Maximize = function (left, right) {
  70934. var max = left.clone();
  70935. max.maximizeInPlace(right);
  70936. return max;
  70937. };
  70938. /**
  70939. * Returns the distance (float) between the vectors "value1" and "value2".
  70940. * @param value1 value to calulate the distance between
  70941. * @param value2 value to calulate the distance between
  70942. * @return the distance between the two vectors
  70943. */
  70944. Vector4.Distance = function (value1, value2) {
  70945. return Math.sqrt(Vector4.DistanceSquared(value1, value2));
  70946. };
  70947. /**
  70948. * Returns the squared distance (float) between the vectors "value1" and "value2".
  70949. * @param value1 value to calulate the distance between
  70950. * @param value2 value to calulate the distance between
  70951. * @return the distance between the two vectors squared
  70952. */
  70953. Vector4.DistanceSquared = function (value1, value2) {
  70954. var x = value1.x - value2.x;
  70955. var y = value1.y - value2.y;
  70956. var z = value1.z - value2.z;
  70957. var w = value1.w - value2.w;
  70958. return (x * x) + (y * y) + (z * z) + (w * w);
  70959. };
  70960. /**
  70961. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  70962. * @param value1 value to calulate the center between
  70963. * @param value2 value to calulate the center between
  70964. * @return the center between the two vectors
  70965. */
  70966. Vector4.Center = function (value1, value2) {
  70967. var center = value1.add(value2);
  70968. center.scaleInPlace(0.5);
  70969. return center;
  70970. };
  70971. /**
  70972. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  70973. * This methods computes transformed normalized direction vectors only.
  70974. * @param vector the vector to transform
  70975. * @param transformation the transformation matrix to apply
  70976. * @returns the new vector
  70977. */
  70978. Vector4.TransformNormal = function (vector, transformation) {
  70979. var result = Vector4.Zero();
  70980. Vector4.TransformNormalToRef(vector, transformation, result);
  70981. return result;
  70982. };
  70983. /**
  70984. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  70985. * This methods computes transformed normalized direction vectors only.
  70986. * @param vector the vector to transform
  70987. * @param transformation the transformation matrix to apply
  70988. * @param result the vector to store the result in
  70989. */
  70990. Vector4.TransformNormalToRef = function (vector, transformation, result) {
  70991. var m = transformation.m;
  70992. var x = (vector.x * m[0]) + (vector.y * m[4]) + (vector.z * m[8]);
  70993. var y = (vector.x * m[1]) + (vector.y * m[5]) + (vector.z * m[9]);
  70994. var z = (vector.x * m[2]) + (vector.y * m[6]) + (vector.z * m[10]);
  70995. result.x = x;
  70996. result.y = y;
  70997. result.z = z;
  70998. result.w = vector.w;
  70999. };
  71000. /**
  71001. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  71002. * This methods computes transformed normalized direction vectors only.
  71003. * @param x value to transform
  71004. * @param y value to transform
  71005. * @param z value to transform
  71006. * @param w value to transform
  71007. * @param transformation the transformation matrix to apply
  71008. * @param result the vector to store the results in
  71009. */
  71010. Vector4.TransformNormalFromFloatsToRef = function (x, y, z, w, transformation, result) {
  71011. var m = transformation.m;
  71012. result.x = (x * m[0]) + (y * m[4]) + (z * m[8]);
  71013. result.y = (x * m[1]) + (y * m[5]) + (z * m[9]);
  71014. result.z = (x * m[2]) + (y * m[6]) + (z * m[10]);
  71015. result.w = w;
  71016. };
  71017. /**
  71018. * Creates a new Vector4 from a Vector3
  71019. * @param source defines the source data
  71020. * @param w defines the 4th component (default is 0)
  71021. * @returns a new Vector4
  71022. */
  71023. Vector4.FromVector3 = function (source, w) {
  71024. if (w === void 0) { w = 0; }
  71025. return new Vector4(source.x, source.y, source.z, w);
  71026. };
  71027. return Vector4;
  71028. }());
  71029. /**
  71030. * Size containing widht and height
  71031. */
  71032. var Size = /** @class */ (function () {
  71033. /**
  71034. * Creates a Size object from the given width and height (floats).
  71035. * @param width width of the new size
  71036. * @param height height of the new size
  71037. */
  71038. function Size(width, height) {
  71039. this.width = width;
  71040. this.height = height;
  71041. }
  71042. /**
  71043. * Returns a string with the Size width and height
  71044. * @returns a string with the Size width and height
  71045. */
  71046. Size.prototype.toString = function () {
  71047. return "{W: " + this.width + ", H: " + this.height + "}";
  71048. };
  71049. /**
  71050. * "Size"
  71051. * @returns the string "Size"
  71052. */
  71053. Size.prototype.getClassName = function () {
  71054. return "Size";
  71055. };
  71056. /**
  71057. * Returns the Size hash code.
  71058. * @returns a hash code for a unique width and height
  71059. */
  71060. Size.prototype.getHashCode = function () {
  71061. var hash = this.width || 0;
  71062. hash = (hash * 397) ^ (this.height || 0);
  71063. return hash;
  71064. };
  71065. /**
  71066. * Updates the current size from the given one.
  71067. * @param src the given size
  71068. */
  71069. Size.prototype.copyFrom = function (src) {
  71070. this.width = src.width;
  71071. this.height = src.height;
  71072. };
  71073. /**
  71074. * Updates in place the current Size from the given floats.
  71075. * @param width width of the new size
  71076. * @param height height of the new size
  71077. * @returns the updated Size.
  71078. */
  71079. Size.prototype.copyFromFloats = function (width, height) {
  71080. this.width = width;
  71081. this.height = height;
  71082. return this;
  71083. };
  71084. /**
  71085. * Updates in place the current Size from the given floats.
  71086. * @param width width to set
  71087. * @param height height to set
  71088. * @returns the updated Size.
  71089. */
  71090. Size.prototype.set = function (width, height) {
  71091. return this.copyFromFloats(width, height);
  71092. };
  71093. /**
  71094. * Multiplies the width and height by numbers
  71095. * @param w factor to multiple the width by
  71096. * @param h factor to multiple the height by
  71097. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  71098. */
  71099. Size.prototype.multiplyByFloats = function (w, h) {
  71100. return new Size(this.width * w, this.height * h);
  71101. };
  71102. /**
  71103. * Clones the size
  71104. * @returns a new Size copied from the given one.
  71105. */
  71106. Size.prototype.clone = function () {
  71107. return new Size(this.width, this.height);
  71108. };
  71109. /**
  71110. * True if the current Size and the given one width and height are strictly equal.
  71111. * @param other the other size to compare against
  71112. * @returns True if the current Size and the given one width and height are strictly equal.
  71113. */
  71114. Size.prototype.equals = function (other) {
  71115. if (!other) {
  71116. return false;
  71117. }
  71118. return (this.width === other.width) && (this.height === other.height);
  71119. };
  71120. Object.defineProperty(Size.prototype, "surface", {
  71121. /**
  71122. * The surface of the Size : width * height (float).
  71123. */
  71124. get: function () {
  71125. return this.width * this.height;
  71126. },
  71127. enumerable: true,
  71128. configurable: true
  71129. });
  71130. /**
  71131. * Create a new size of zero
  71132. * @returns a new Size set to (0.0, 0.0)
  71133. */
  71134. Size.Zero = function () {
  71135. return new Size(0.0, 0.0);
  71136. };
  71137. /**
  71138. * Sums the width and height of two sizes
  71139. * @param otherSize size to add to this size
  71140. * @returns a new Size set as the addition result of the current Size and the given one.
  71141. */
  71142. Size.prototype.add = function (otherSize) {
  71143. var r = new Size(this.width + otherSize.width, this.height + otherSize.height);
  71144. return r;
  71145. };
  71146. /**
  71147. * Subtracts the width and height of two
  71148. * @param otherSize size to subtract to this size
  71149. * @returns a new Size set as the subtraction result of the given one from the current Size.
  71150. */
  71151. Size.prototype.subtract = function (otherSize) {
  71152. var r = new Size(this.width - otherSize.width, this.height - otherSize.height);
  71153. return r;
  71154. };
  71155. /**
  71156. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  71157. * @param start starting size to lerp between
  71158. * @param end end size to lerp between
  71159. * @param amount amount to lerp between the start and end values
  71160. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  71161. */
  71162. Size.Lerp = function (start, end, amount) {
  71163. var w = start.width + ((end.width - start.width) * amount);
  71164. var h = start.height + ((end.height - start.height) * amount);
  71165. return new Size(w, h);
  71166. };
  71167. return Size;
  71168. }());
  71169. /**
  71170. * Class used to store quaternion data
  71171. * @see https://en.wikipedia.org/wiki/Quaternion
  71172. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  71173. */
  71174. var Quaternion = /** @class */ (function () {
  71175. /**
  71176. * Creates a new Quaternion from the given floats
  71177. * @param x defines the first component (0 by default)
  71178. * @param y defines the second component (0 by default)
  71179. * @param z defines the third component (0 by default)
  71180. * @param w defines the fourth component (1.0 by default)
  71181. */
  71182. function Quaternion(
  71183. /** defines the first component (0 by default) */
  71184. x,
  71185. /** defines the second component (0 by default) */
  71186. y,
  71187. /** defines the third component (0 by default) */
  71188. z,
  71189. /** defines the fourth component (1.0 by default) */
  71190. w) {
  71191. if (x === void 0) { x = 0.0; }
  71192. if (y === void 0) { y = 0.0; }
  71193. if (z === void 0) { z = 0.0; }
  71194. if (w === void 0) { w = 1.0; }
  71195. this.x = x;
  71196. this.y = y;
  71197. this.z = z;
  71198. this.w = w;
  71199. }
  71200. /**
  71201. * Gets a string representation for the current quaternion
  71202. * @returns a string with the Quaternion coordinates
  71203. */
  71204. Quaternion.prototype.toString = function () {
  71205. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  71206. };
  71207. /**
  71208. * Gets the class name of the quaternion
  71209. * @returns the string "Quaternion"
  71210. */
  71211. Quaternion.prototype.getClassName = function () {
  71212. return "Quaternion";
  71213. };
  71214. /**
  71215. * Gets a hash code for this quaternion
  71216. * @returns the quaternion hash code
  71217. */
  71218. Quaternion.prototype.getHashCode = function () {
  71219. var hash = this.x || 0;
  71220. hash = (hash * 397) ^ (this.y || 0);
  71221. hash = (hash * 397) ^ (this.z || 0);
  71222. hash = (hash * 397) ^ (this.w || 0);
  71223. return hash;
  71224. };
  71225. /**
  71226. * Copy the quaternion to an array
  71227. * @returns a new array populated with 4 elements from the quaternion coordinates
  71228. */
  71229. Quaternion.prototype.asArray = function () {
  71230. return [this.x, this.y, this.z, this.w];
  71231. };
  71232. /**
  71233. * Check if two quaternions are equals
  71234. * @param otherQuaternion defines the second operand
  71235. * @return true if the current quaternion and the given one coordinates are strictly equals
  71236. */
  71237. Quaternion.prototype.equals = function (otherQuaternion) {
  71238. return otherQuaternion && this.x === otherQuaternion.x && this.y === otherQuaternion.y && this.z === otherQuaternion.z && this.w === otherQuaternion.w;
  71239. };
  71240. /**
  71241. * Clone the current quaternion
  71242. * @returns a new quaternion copied from the current one
  71243. */
  71244. Quaternion.prototype.clone = function () {
  71245. return new Quaternion(this.x, this.y, this.z, this.w);
  71246. };
  71247. /**
  71248. * Copy a quaternion to the current one
  71249. * @param other defines the other quaternion
  71250. * @returns the updated current quaternion
  71251. */
  71252. Quaternion.prototype.copyFrom = function (other) {
  71253. this.x = other.x;
  71254. this.y = other.y;
  71255. this.z = other.z;
  71256. this.w = other.w;
  71257. return this;
  71258. };
  71259. /**
  71260. * Updates the current quaternion with the given float coordinates
  71261. * @param x defines the x coordinate
  71262. * @param y defines the y coordinate
  71263. * @param z defines the z coordinate
  71264. * @param w defines the w coordinate
  71265. * @returns the updated current quaternion
  71266. */
  71267. Quaternion.prototype.copyFromFloats = function (x, y, z, w) {
  71268. this.x = x;
  71269. this.y = y;
  71270. this.z = z;
  71271. this.w = w;
  71272. return this;
  71273. };
  71274. /**
  71275. * Updates the current quaternion from the given float coordinates
  71276. * @param x defines the x coordinate
  71277. * @param y defines the y coordinate
  71278. * @param z defines the z coordinate
  71279. * @param w defines the w coordinate
  71280. * @returns the updated current quaternion
  71281. */
  71282. Quaternion.prototype.set = function (x, y, z, w) {
  71283. return this.copyFromFloats(x, y, z, w);
  71284. };
  71285. /**
  71286. * Adds two quaternions
  71287. * @param other defines the second operand
  71288. * @returns a new quaternion as the addition result of the given one and the current quaternion
  71289. */
  71290. Quaternion.prototype.add = function (other) {
  71291. return new Quaternion(this.x + other.x, this.y + other.y, this.z + other.z, this.w + other.w);
  71292. };
  71293. /**
  71294. * Add a quaternion to the current one
  71295. * @param other defines the quaternion to add
  71296. * @returns the current quaternion
  71297. */
  71298. Quaternion.prototype.addInPlace = function (other) {
  71299. this.x += other.x;
  71300. this.y += other.y;
  71301. this.z += other.z;
  71302. this.w += other.w;
  71303. return this;
  71304. };
  71305. /**
  71306. * Subtract two quaternions
  71307. * @param other defines the second operand
  71308. * @returns a new quaternion as the subtraction result of the given one from the current one
  71309. */
  71310. Quaternion.prototype.subtract = function (other) {
  71311. return new Quaternion(this.x - other.x, this.y - other.y, this.z - other.z, this.w - other.w);
  71312. };
  71313. /**
  71314. * Multiplies the current quaternion by a scale factor
  71315. * @param value defines the scale factor
  71316. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  71317. */
  71318. Quaternion.prototype.scale = function (value) {
  71319. return new Quaternion(this.x * value, this.y * value, this.z * value, this.w * value);
  71320. };
  71321. /**
  71322. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  71323. * @param scale defines the scale factor
  71324. * @param result defines the Quaternion object where to store the result
  71325. * @returns the unmodified current quaternion
  71326. */
  71327. Quaternion.prototype.scaleToRef = function (scale, result) {
  71328. result.x = this.x * scale;
  71329. result.y = this.y * scale;
  71330. result.z = this.z * scale;
  71331. result.w = this.w * scale;
  71332. return this;
  71333. };
  71334. /**
  71335. * Multiplies in place the current quaternion by a scale factor
  71336. * @param value defines the scale factor
  71337. * @returns the current modified quaternion
  71338. */
  71339. Quaternion.prototype.scaleInPlace = function (value) {
  71340. this.x *= value;
  71341. this.y *= value;
  71342. this.z *= value;
  71343. this.w *= value;
  71344. return this;
  71345. };
  71346. /**
  71347. * Scale the current quaternion values by a factor and add the result to a given quaternion
  71348. * @param scale defines the scale factor
  71349. * @param result defines the Quaternion object where to store the result
  71350. * @returns the unmodified current quaternion
  71351. */
  71352. Quaternion.prototype.scaleAndAddToRef = function (scale, result) {
  71353. result.x += this.x * scale;
  71354. result.y += this.y * scale;
  71355. result.z += this.z * scale;
  71356. result.w += this.w * scale;
  71357. return this;
  71358. };
  71359. /**
  71360. * Multiplies two quaternions
  71361. * @param q1 defines the second operand
  71362. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  71363. */
  71364. Quaternion.prototype.multiply = function (q1) {
  71365. var result = new Quaternion(0, 0, 0, 1.0);
  71366. this.multiplyToRef(q1, result);
  71367. return result;
  71368. };
  71369. /**
  71370. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  71371. * @param q1 defines the second operand
  71372. * @param result defines the target quaternion
  71373. * @returns the current quaternion
  71374. */
  71375. Quaternion.prototype.multiplyToRef = function (q1, result) {
  71376. var x = this.x * q1.w + this.y * q1.z - this.z * q1.y + this.w * q1.x;
  71377. var y = -this.x * q1.z + this.y * q1.w + this.z * q1.x + this.w * q1.y;
  71378. var z = this.x * q1.y - this.y * q1.x + this.z * q1.w + this.w * q1.z;
  71379. var w = -this.x * q1.x - this.y * q1.y - this.z * q1.z + this.w * q1.w;
  71380. result.copyFromFloats(x, y, z, w);
  71381. return this;
  71382. };
  71383. /**
  71384. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  71385. * @param q1 defines the second operand
  71386. * @returns the currentupdated quaternion
  71387. */
  71388. Quaternion.prototype.multiplyInPlace = function (q1) {
  71389. this.multiplyToRef(q1, this);
  71390. return this;
  71391. };
  71392. /**
  71393. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  71394. * @param ref defines the target quaternion
  71395. * @returns the current quaternion
  71396. */
  71397. Quaternion.prototype.conjugateToRef = function (ref) {
  71398. ref.copyFromFloats(-this.x, -this.y, -this.z, this.w);
  71399. return this;
  71400. };
  71401. /**
  71402. * Conjugates in place (1-q) the current quaternion
  71403. * @returns the current updated quaternion
  71404. */
  71405. Quaternion.prototype.conjugateInPlace = function () {
  71406. this.x *= -1;
  71407. this.y *= -1;
  71408. this.z *= -1;
  71409. return this;
  71410. };
  71411. /**
  71412. * Conjugates in place (1-q) the current quaternion
  71413. * @returns a new quaternion
  71414. */
  71415. Quaternion.prototype.conjugate = function () {
  71416. var result = new Quaternion(-this.x, -this.y, -this.z, this.w);
  71417. return result;
  71418. };
  71419. /**
  71420. * Gets length of current quaternion
  71421. * @returns the quaternion length (float)
  71422. */
  71423. Quaternion.prototype.length = function () {
  71424. return Math.sqrt((this.x * this.x) + (this.y * this.y) + (this.z * this.z) + (this.w * this.w));
  71425. };
  71426. /**
  71427. * Normalize in place the current quaternion
  71428. * @returns the current updated quaternion
  71429. */
  71430. Quaternion.prototype.normalize = function () {
  71431. var length = 1.0 / this.length();
  71432. this.x *= length;
  71433. this.y *= length;
  71434. this.z *= length;
  71435. this.w *= length;
  71436. return this;
  71437. };
  71438. /**
  71439. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  71440. * @param order is a reserved parameter and is ignore for now
  71441. * @returns a new Vector3 containing the Euler angles
  71442. */
  71443. Quaternion.prototype.toEulerAngles = function (order) {
  71444. if (order === void 0) { order = "YZX"; }
  71445. var result = Vector3.Zero();
  71446. this.toEulerAnglesToRef(result);
  71447. return result;
  71448. };
  71449. /**
  71450. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  71451. * @param result defines the vector which will be filled with the Euler angles
  71452. * @param order is a reserved parameter and is ignore for now
  71453. * @returns the current unchanged quaternion
  71454. */
  71455. Quaternion.prototype.toEulerAnglesToRef = function (result) {
  71456. var qz = this.z;
  71457. var qx = this.x;
  71458. var qy = this.y;
  71459. var qw = this.w;
  71460. var sqw = qw * qw;
  71461. var sqz = qz * qz;
  71462. var sqx = qx * qx;
  71463. var sqy = qy * qy;
  71464. var zAxisY = qy * qz - qx * qw;
  71465. var limit = .4999999;
  71466. if (zAxisY < -limit) {
  71467. result.y = 2 * Math.atan2(qy, qw);
  71468. result.x = Math.PI / 2;
  71469. result.z = 0;
  71470. }
  71471. else if (zAxisY > limit) {
  71472. result.y = 2 * Math.atan2(qy, qw);
  71473. result.x = -Math.PI / 2;
  71474. result.z = 0;
  71475. }
  71476. else {
  71477. result.z = Math.atan2(2.0 * (qx * qy + qz * qw), (-sqz - sqx + sqy + sqw));
  71478. result.x = Math.asin(-2.0 * (qz * qy - qx * qw));
  71479. result.y = Math.atan2(2.0 * (qz * qx + qy * qw), (sqz - sqx - sqy + sqw));
  71480. }
  71481. return this;
  71482. };
  71483. /**
  71484. * Updates the given rotation matrix with the current quaternion values
  71485. * @param result defines the target matrix
  71486. * @returns the current unchanged quaternion
  71487. */
  71488. Quaternion.prototype.toRotationMatrix = function (result) {
  71489. Matrix.FromQuaternionToRef(this, result);
  71490. return this;
  71491. };
  71492. /**
  71493. * Updates the current quaternion from the given rotation matrix values
  71494. * @param matrix defines the source matrix
  71495. * @returns the current updated quaternion
  71496. */
  71497. Quaternion.prototype.fromRotationMatrix = function (matrix) {
  71498. Quaternion.FromRotationMatrixToRef(matrix, this);
  71499. return this;
  71500. };
  71501. // Statics
  71502. /**
  71503. * Creates a new quaternion from a rotation matrix
  71504. * @param matrix defines the source matrix
  71505. * @returns a new quaternion created from the given rotation matrix values
  71506. */
  71507. Quaternion.FromRotationMatrix = function (matrix) {
  71508. var result = new Quaternion();
  71509. Quaternion.FromRotationMatrixToRef(matrix, result);
  71510. return result;
  71511. };
  71512. /**
  71513. * Updates the given quaternion with the given rotation matrix values
  71514. * @param matrix defines the source matrix
  71515. * @param result defines the target quaternion
  71516. */
  71517. Quaternion.FromRotationMatrixToRef = function (matrix, result) {
  71518. var data = matrix.m;
  71519. var m11 = data[0], m12 = data[4], m13 = data[8];
  71520. var m21 = data[1], m22 = data[5], m23 = data[9];
  71521. var m31 = data[2], m32 = data[6], m33 = data[10];
  71522. var trace = m11 + m22 + m33;
  71523. var s;
  71524. if (trace > 0) {
  71525. s = 0.5 / Math.sqrt(trace + 1.0);
  71526. result.w = 0.25 / s;
  71527. result.x = (m32 - m23) * s;
  71528. result.y = (m13 - m31) * s;
  71529. result.z = (m21 - m12) * s;
  71530. }
  71531. else if (m11 > m22 && m11 > m33) {
  71532. s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
  71533. result.w = (m32 - m23) / s;
  71534. result.x = 0.25 * s;
  71535. result.y = (m12 + m21) / s;
  71536. result.z = (m13 + m31) / s;
  71537. }
  71538. else if (m22 > m33) {
  71539. s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
  71540. result.w = (m13 - m31) / s;
  71541. result.x = (m12 + m21) / s;
  71542. result.y = 0.25 * s;
  71543. result.z = (m23 + m32) / s;
  71544. }
  71545. else {
  71546. s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
  71547. result.w = (m21 - m12) / s;
  71548. result.x = (m13 + m31) / s;
  71549. result.y = (m23 + m32) / s;
  71550. result.z = 0.25 * s;
  71551. }
  71552. };
  71553. /**
  71554. * Returns the dot product (float) between the quaternions "left" and "right"
  71555. * @param left defines the left operand
  71556. * @param right defines the right operand
  71557. * @returns the dot product
  71558. */
  71559. Quaternion.Dot = function (left, right) {
  71560. return (left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w);
  71561. };
  71562. /**
  71563. * Checks if the two quaternions are close to each other
  71564. * @param quat0 defines the first quaternion to check
  71565. * @param quat1 defines the second quaternion to check
  71566. * @returns true if the two quaternions are close to each other
  71567. */
  71568. Quaternion.AreClose = function (quat0, quat1) {
  71569. var dot = Quaternion.Dot(quat0, quat1);
  71570. return dot >= 0;
  71571. };
  71572. /**
  71573. * Creates an empty quaternion
  71574. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  71575. */
  71576. Quaternion.Zero = function () {
  71577. return new Quaternion(0.0, 0.0, 0.0, 0.0);
  71578. };
  71579. /**
  71580. * Inverse a given quaternion
  71581. * @param q defines the source quaternion
  71582. * @returns a new quaternion as the inverted current quaternion
  71583. */
  71584. Quaternion.Inverse = function (q) {
  71585. return new Quaternion(-q.x, -q.y, -q.z, q.w);
  71586. };
  71587. /**
  71588. * Inverse a given quaternion
  71589. * @param q defines the source quaternion
  71590. * @param result the quaternion the result will be stored in
  71591. * @returns the result quaternion
  71592. */
  71593. Quaternion.InverseToRef = function (q, result) {
  71594. result.set(-q.x, -q.y, -q.z, q.w);
  71595. return result;
  71596. };
  71597. /**
  71598. * Creates an identity quaternion
  71599. * @returns the identity quaternion
  71600. */
  71601. Quaternion.Identity = function () {
  71602. return new Quaternion(0.0, 0.0, 0.0, 1.0);
  71603. };
  71604. /**
  71605. * Gets a boolean indicating if the given quaternion is identity
  71606. * @param quaternion defines the quaternion to check
  71607. * @returns true if the quaternion is identity
  71608. */
  71609. Quaternion.IsIdentity = function (quaternion) {
  71610. return quaternion && quaternion.x === 0 && quaternion.y === 0 && quaternion.z === 0 && quaternion.w === 1;
  71611. };
  71612. /**
  71613. * Creates a quaternion from a rotation around an axis
  71614. * @param axis defines the axis to use
  71615. * @param angle defines the angle to use
  71616. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  71617. */
  71618. Quaternion.RotationAxis = function (axis, angle) {
  71619. return Quaternion.RotationAxisToRef(axis, angle, new Quaternion());
  71620. };
  71621. /**
  71622. * Creates a rotation around an axis and stores it into the given quaternion
  71623. * @param axis defines the axis to use
  71624. * @param angle defines the angle to use
  71625. * @param result defines the target quaternion
  71626. * @returns the target quaternion
  71627. */
  71628. Quaternion.RotationAxisToRef = function (axis, angle, result) {
  71629. var sin = Math.sin(angle / 2);
  71630. axis.normalize();
  71631. result.w = Math.cos(angle / 2);
  71632. result.x = axis.x * sin;
  71633. result.y = axis.y * sin;
  71634. result.z = axis.z * sin;
  71635. return result;
  71636. };
  71637. /**
  71638. * Creates a new quaternion from data stored into an array
  71639. * @param array defines the data source
  71640. * @param offset defines the offset in the source array where the data starts
  71641. * @returns a new quaternion
  71642. */
  71643. Quaternion.FromArray = function (array, offset) {
  71644. if (!offset) {
  71645. offset = 0;
  71646. }
  71647. return new Quaternion(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  71648. };
  71649. /**
  71650. * Create a quaternion from Euler rotation angles
  71651. * @param x Pitch
  71652. * @param y Yaw
  71653. * @param z Roll
  71654. * @returns the new Quaternion
  71655. */
  71656. Quaternion.FromEulerAngles = function (x, y, z) {
  71657. var q = new Quaternion();
  71658. Quaternion.RotationYawPitchRollToRef(y, x, z, q);
  71659. return q;
  71660. };
  71661. /**
  71662. * Updates a quaternion from Euler rotation angles
  71663. * @param x Pitch
  71664. * @param y Yaw
  71665. * @param z Roll
  71666. * @param result the quaternion to store the result
  71667. * @returns the updated quaternion
  71668. */
  71669. Quaternion.FromEulerAnglesToRef = function (x, y, z, result) {
  71670. Quaternion.RotationYawPitchRollToRef(y, x, z, result);
  71671. return result;
  71672. };
  71673. /**
  71674. * Create a quaternion from Euler rotation vector
  71675. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71676. * @returns the new Quaternion
  71677. */
  71678. Quaternion.FromEulerVector = function (vec) {
  71679. var q = new Quaternion();
  71680. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, q);
  71681. return q;
  71682. };
  71683. /**
  71684. * Updates a quaternion from Euler rotation vector
  71685. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71686. * @param result the quaternion to store the result
  71687. * @returns the updated quaternion
  71688. */
  71689. Quaternion.FromEulerVectorToRef = function (vec, result) {
  71690. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, result);
  71691. return result;
  71692. };
  71693. /**
  71694. * Creates a new quaternion from the given Euler float angles (y, x, z)
  71695. * @param yaw defines the rotation around Y axis
  71696. * @param pitch defines the rotation around X axis
  71697. * @param roll defines the rotation around Z axis
  71698. * @returns the new quaternion
  71699. */
  71700. Quaternion.RotationYawPitchRoll = function (yaw, pitch, roll) {
  71701. var q = new Quaternion();
  71702. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, q);
  71703. return q;
  71704. };
  71705. /**
  71706. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  71707. * @param yaw defines the rotation around Y axis
  71708. * @param pitch defines the rotation around X axis
  71709. * @param roll defines the rotation around Z axis
  71710. * @param result defines the target quaternion
  71711. */
  71712. Quaternion.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  71713. // Produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
  71714. var halfRoll = roll * 0.5;
  71715. var halfPitch = pitch * 0.5;
  71716. var halfYaw = yaw * 0.5;
  71717. var sinRoll = Math.sin(halfRoll);
  71718. var cosRoll = Math.cos(halfRoll);
  71719. var sinPitch = Math.sin(halfPitch);
  71720. var cosPitch = Math.cos(halfPitch);
  71721. var sinYaw = Math.sin(halfYaw);
  71722. var cosYaw = Math.cos(halfYaw);
  71723. result.x = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);
  71724. result.y = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);
  71725. result.z = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);
  71726. result.w = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);
  71727. };
  71728. /**
  71729. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  71730. * @param alpha defines the rotation around first axis
  71731. * @param beta defines the rotation around second axis
  71732. * @param gamma defines the rotation around third axis
  71733. * @returns the new quaternion
  71734. */
  71735. Quaternion.RotationAlphaBetaGamma = function (alpha, beta, gamma) {
  71736. var result = new Quaternion();
  71737. Quaternion.RotationAlphaBetaGammaToRef(alpha, beta, gamma, result);
  71738. return result;
  71739. };
  71740. /**
  71741. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  71742. * @param alpha defines the rotation around first axis
  71743. * @param beta defines the rotation around second axis
  71744. * @param gamma defines the rotation around third axis
  71745. * @param result defines the target quaternion
  71746. */
  71747. Quaternion.RotationAlphaBetaGammaToRef = function (alpha, beta, gamma, result) {
  71748. // Produces a quaternion from Euler angles in the z-x-z orientation
  71749. var halfGammaPlusAlpha = (gamma + alpha) * 0.5;
  71750. var halfGammaMinusAlpha = (gamma - alpha) * 0.5;
  71751. var halfBeta = beta * 0.5;
  71752. result.x = Math.cos(halfGammaMinusAlpha) * Math.sin(halfBeta);
  71753. result.y = Math.sin(halfGammaMinusAlpha) * Math.sin(halfBeta);
  71754. result.z = Math.sin(halfGammaPlusAlpha) * Math.cos(halfBeta);
  71755. result.w = Math.cos(halfGammaPlusAlpha) * Math.cos(halfBeta);
  71756. };
  71757. /**
  71758. * 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)
  71759. * @param axis1 defines the first axis
  71760. * @param axis2 defines the second axis
  71761. * @param axis3 defines the third axis
  71762. * @returns the new quaternion
  71763. */
  71764. Quaternion.RotationQuaternionFromAxis = function (axis1, axis2, axis3) {
  71765. var quat = new Quaternion(0.0, 0.0, 0.0, 0.0);
  71766. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  71767. return quat;
  71768. };
  71769. /**
  71770. * 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
  71771. * @param axis1 defines the first axis
  71772. * @param axis2 defines the second axis
  71773. * @param axis3 defines the third axis
  71774. * @param ref defines the target quaternion
  71775. */
  71776. Quaternion.RotationQuaternionFromAxisToRef = function (axis1, axis2, axis3, ref) {
  71777. var rotMat = MathTmp.Matrix[0];
  71778. Matrix.FromXYZAxesToRef(axis1.normalize(), axis2.normalize(), axis3.normalize(), rotMat);
  71779. Quaternion.FromRotationMatrixToRef(rotMat, ref);
  71780. };
  71781. /**
  71782. * Interpolates between two quaternions
  71783. * @param left defines first quaternion
  71784. * @param right defines second quaternion
  71785. * @param amount defines the gradient to use
  71786. * @returns the new interpolated quaternion
  71787. */
  71788. Quaternion.Slerp = function (left, right, amount) {
  71789. var result = Quaternion.Identity();
  71790. Quaternion.SlerpToRef(left, right, amount, result);
  71791. return result;
  71792. };
  71793. /**
  71794. * Interpolates between two quaternions and stores it into a target quaternion
  71795. * @param left defines first quaternion
  71796. * @param right defines second quaternion
  71797. * @param amount defines the gradient to use
  71798. * @param result defines the target quaternion
  71799. */
  71800. Quaternion.SlerpToRef = function (left, right, amount, result) {
  71801. var num2;
  71802. var num3;
  71803. var num4 = (((left.x * right.x) + (left.y * right.y)) + (left.z * right.z)) + (left.w * right.w);
  71804. var flag = false;
  71805. if (num4 < 0) {
  71806. flag = true;
  71807. num4 = -num4;
  71808. }
  71809. if (num4 > 0.999999) {
  71810. num3 = 1 - amount;
  71811. num2 = flag ? -amount : amount;
  71812. }
  71813. else {
  71814. var num5 = Math.acos(num4);
  71815. var num6 = (1.0 / Math.sin(num5));
  71816. num3 = (Math.sin((1.0 - amount) * num5)) * num6;
  71817. num2 = flag ? ((-Math.sin(amount * num5)) * num6) : ((Math.sin(amount * num5)) * num6);
  71818. }
  71819. result.x = (num3 * left.x) + (num2 * right.x);
  71820. result.y = (num3 * left.y) + (num2 * right.y);
  71821. result.z = (num3 * left.z) + (num2 * right.z);
  71822. result.w = (num3 * left.w) + (num2 * right.w);
  71823. };
  71824. /**
  71825. * Interpolate between two quaternions using Hermite interpolation
  71826. * @param value1 defines first quaternion
  71827. * @param tangent1 defines the incoming tangent
  71828. * @param value2 defines second quaternion
  71829. * @param tangent2 defines the outgoing tangent
  71830. * @param amount defines the target quaternion
  71831. * @returns the new interpolated quaternion
  71832. */
  71833. Quaternion.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  71834. var squared = amount * amount;
  71835. var cubed = amount * squared;
  71836. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  71837. var part2 = (-2.0 * cubed) + (3.0 * squared);
  71838. var part3 = (cubed - (2.0 * squared)) + amount;
  71839. var part4 = cubed - squared;
  71840. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  71841. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  71842. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  71843. var w = (((value1.w * part1) + (value2.w * part2)) + (tangent1.w * part3)) + (tangent2.w * part4);
  71844. return new Quaternion(x, y, z, w);
  71845. };
  71846. return Quaternion;
  71847. }());
  71848. /**
  71849. * Class used to store matrix data (4x4)
  71850. */
  71851. var Matrix = /** @class */ (function () {
  71852. /**
  71853. * Creates an empty matrix (filled with zeros)
  71854. */
  71855. function Matrix() {
  71856. this._isIdentity = false;
  71857. this._isIdentityDirty = true;
  71858. this._isIdentity3x2 = true;
  71859. this._isIdentity3x2Dirty = true;
  71860. this._m = new Float32Array(16);
  71861. this._updateIdentityStatus(false);
  71862. }
  71863. Object.defineProperty(Matrix.prototype, "m", {
  71864. /**
  71865. * Gets the internal data of the matrix
  71866. */
  71867. get: function () { return this._m; },
  71868. enumerable: true,
  71869. configurable: true
  71870. });
  71871. /** @hidden */
  71872. Matrix.prototype._markAsUpdated = function () {
  71873. this.updateFlag = Matrix._updateFlagSeed++;
  71874. this._isIdentity = false;
  71875. this._isIdentity3x2 = false;
  71876. this._isIdentityDirty = true;
  71877. this._isIdentity3x2Dirty = true;
  71878. };
  71879. /** @hidden */
  71880. Matrix.prototype._updateIdentityStatus = function (isIdentity, isIdentityDirty, isIdentity3x2, isIdentity3x2Dirty) {
  71881. if (isIdentityDirty === void 0) { isIdentityDirty = false; }
  71882. if (isIdentity3x2 === void 0) { isIdentity3x2 = false; }
  71883. if (isIdentity3x2Dirty === void 0) { isIdentity3x2Dirty = true; }
  71884. this.updateFlag = Matrix._updateFlagSeed++;
  71885. this._isIdentity = isIdentity;
  71886. this._isIdentity3x2 = isIdentity || isIdentity3x2;
  71887. this._isIdentityDirty = this._isIdentity ? false : isIdentityDirty;
  71888. this._isIdentity3x2Dirty = this._isIdentity3x2 ? false : isIdentity3x2Dirty;
  71889. };
  71890. // Properties
  71891. /**
  71892. * Check if the current matrix is identity
  71893. * @returns true is the matrix is the identity matrix
  71894. */
  71895. Matrix.prototype.isIdentity = function () {
  71896. if (this._isIdentityDirty) {
  71897. this._isIdentityDirty = false;
  71898. var m = this._m;
  71899. this._isIdentity = (m[0] === 1.0 && m[1] === 0.0 && m[2] === 0.0 && m[3] === 0.0 &&
  71900. m[4] === 0.0 && m[5] === 1.0 && m[6] === 0.0 && m[7] === 0.0 &&
  71901. m[8] === 0.0 && m[9] === 0.0 && m[10] === 1.0 && m[11] === 0.0 &&
  71902. m[12] === 0.0 && m[13] === 0.0 && m[14] === 0.0 && m[15] === 1.0);
  71903. }
  71904. return this._isIdentity;
  71905. };
  71906. /**
  71907. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  71908. * @returns true is the matrix is the identity matrix
  71909. */
  71910. Matrix.prototype.isIdentityAs3x2 = function () {
  71911. if (this._isIdentity3x2Dirty) {
  71912. this._isIdentity3x2Dirty = false;
  71913. if (this._m[0] !== 1.0 || this._m[5] !== 1.0 || this._m[15] !== 1.0) {
  71914. this._isIdentity3x2 = false;
  71915. }
  71916. else if (this._m[1] !== 0.0 || this._m[2] !== 0.0 || this._m[3] !== 0.0 ||
  71917. this._m[4] !== 0.0 || this._m[6] !== 0.0 || this._m[7] !== 0.0 ||
  71918. this._m[8] !== 0.0 || this._m[9] !== 0.0 || this._m[10] !== 0.0 || this._m[11] !== 0.0 ||
  71919. this._m[12] !== 0.0 || this._m[13] !== 0.0 || this._m[14] !== 0.0) {
  71920. this._isIdentity3x2 = false;
  71921. }
  71922. else {
  71923. this._isIdentity3x2 = true;
  71924. }
  71925. }
  71926. return this._isIdentity3x2;
  71927. };
  71928. /**
  71929. * Gets the determinant of the matrix
  71930. * @returns the matrix determinant
  71931. */
  71932. Matrix.prototype.determinant = function () {
  71933. if (this._isIdentity === true) {
  71934. return 1;
  71935. }
  71936. var m = this._m;
  71937. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  71938. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  71939. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  71940. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  71941. // https://en.wikipedia.org/wiki/Laplace_expansion
  71942. // to compute the deterrminant of a 4x4 Matrix we compute the cofactors of any row or column,
  71943. // then we multiply each Cofactor by its corresponding matrix value and sum them all to get the determinant
  71944. // Cofactor(i, j) = sign(i,j) * det(Minor(i, j))
  71945. // where
  71946. // - sign(i,j) = (i+j) % 2 === 0 ? 1 : -1
  71947. // - Minor(i, j) is the 3x3 matrix we get by removing row i and column j from current Matrix
  71948. //
  71949. // Here we do that for the 1st row.
  71950. var det_22_33 = m22 * m33 - m32 * m23;
  71951. var det_21_33 = m21 * m33 - m31 * m23;
  71952. var det_21_32 = m21 * m32 - m31 * m22;
  71953. var det_20_33 = m20 * m33 - m30 * m23;
  71954. var det_20_32 = m20 * m32 - m22 * m30;
  71955. var det_20_31 = m20 * m31 - m30 * m21;
  71956. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  71957. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  71958. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  71959. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  71960. return m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  71961. };
  71962. // Methods
  71963. /**
  71964. * Returns the matrix as a Float32Array
  71965. * @returns the matrix underlying array
  71966. */
  71967. Matrix.prototype.toArray = function () {
  71968. return this._m;
  71969. };
  71970. /**
  71971. * Returns the matrix as a Float32Array
  71972. * @returns the matrix underlying array.
  71973. */
  71974. Matrix.prototype.asArray = function () {
  71975. return this._m;
  71976. };
  71977. /**
  71978. * Inverts the current matrix in place
  71979. * @returns the current inverted matrix
  71980. */
  71981. Matrix.prototype.invert = function () {
  71982. this.invertToRef(this);
  71983. return this;
  71984. };
  71985. /**
  71986. * Sets all the matrix elements to zero
  71987. * @returns the current matrix
  71988. */
  71989. Matrix.prototype.reset = function () {
  71990. 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);
  71991. this._updateIdentityStatus(false);
  71992. return this;
  71993. };
  71994. /**
  71995. * Adds the current matrix with a second one
  71996. * @param other defines the matrix to add
  71997. * @returns a new matrix as the addition of the current matrix and the given one
  71998. */
  71999. Matrix.prototype.add = function (other) {
  72000. var result = new Matrix();
  72001. this.addToRef(other, result);
  72002. return result;
  72003. };
  72004. /**
  72005. * Sets the given matrix "result" to the addition of the current matrix and the given one
  72006. * @param other defines the matrix to add
  72007. * @param result defines the target matrix
  72008. * @returns the current matrix
  72009. */
  72010. Matrix.prototype.addToRef = function (other, result) {
  72011. var m = this._m;
  72012. var resultM = result._m;
  72013. var otherM = other.m;
  72014. for (var index = 0; index < 16; index++) {
  72015. resultM[index] = m[index] + otherM[index];
  72016. }
  72017. result._markAsUpdated();
  72018. return this;
  72019. };
  72020. /**
  72021. * Adds in place the given matrix to the current matrix
  72022. * @param other defines the second operand
  72023. * @returns the current updated matrix
  72024. */
  72025. Matrix.prototype.addToSelf = function (other) {
  72026. var m = this._m;
  72027. var otherM = other.m;
  72028. for (var index = 0; index < 16; index++) {
  72029. m[index] += otherM[index];
  72030. }
  72031. this._markAsUpdated();
  72032. return this;
  72033. };
  72034. /**
  72035. * Sets the given matrix to the current inverted Matrix
  72036. * @param other defines the target matrix
  72037. * @returns the unmodified current matrix
  72038. */
  72039. Matrix.prototype.invertToRef = function (other) {
  72040. if (this._isIdentity === true) {
  72041. Matrix.IdentityToRef(other);
  72042. return this;
  72043. }
  72044. // the inverse of a Matrix is the transpose of cofactor matrix divided by the determinant
  72045. var m = this._m;
  72046. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  72047. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  72048. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  72049. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  72050. var det_22_33 = m22 * m33 - m32 * m23;
  72051. var det_21_33 = m21 * m33 - m31 * m23;
  72052. var det_21_32 = m21 * m32 - m31 * m22;
  72053. var det_20_33 = m20 * m33 - m30 * m23;
  72054. var det_20_32 = m20 * m32 - m22 * m30;
  72055. var det_20_31 = m20 * m31 - m30 * m21;
  72056. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  72057. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  72058. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  72059. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  72060. var det = m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  72061. if (det === 0) {
  72062. // not invertible
  72063. other.copyFrom(this);
  72064. return this;
  72065. }
  72066. var detInv = 1 / det;
  72067. var det_12_33 = m12 * m33 - m32 * m13;
  72068. var det_11_33 = m11 * m33 - m31 * m13;
  72069. var det_11_32 = m11 * m32 - m31 * m12;
  72070. var det_10_33 = m10 * m33 - m30 * m13;
  72071. var det_10_32 = m10 * m32 - m30 * m12;
  72072. var det_10_31 = m10 * m31 - m30 * m11;
  72073. var det_12_23 = m12 * m23 - m22 * m13;
  72074. var det_11_23 = m11 * m23 - m21 * m13;
  72075. var det_11_22 = m11 * m22 - m21 * m12;
  72076. var det_10_23 = m10 * m23 - m20 * m13;
  72077. var det_10_22 = m10 * m22 - m20 * m12;
  72078. var det_10_21 = m10 * m21 - m20 * m11;
  72079. var cofact_10 = -(m01 * det_22_33 - m02 * det_21_33 + m03 * det_21_32);
  72080. var cofact_11 = +(m00 * det_22_33 - m02 * det_20_33 + m03 * det_20_32);
  72081. var cofact_12 = -(m00 * det_21_33 - m01 * det_20_33 + m03 * det_20_31);
  72082. var cofact_13 = +(m00 * det_21_32 - m01 * det_20_32 + m02 * det_20_31);
  72083. var cofact_20 = +(m01 * det_12_33 - m02 * det_11_33 + m03 * det_11_32);
  72084. var cofact_21 = -(m00 * det_12_33 - m02 * det_10_33 + m03 * det_10_32);
  72085. var cofact_22 = +(m00 * det_11_33 - m01 * det_10_33 + m03 * det_10_31);
  72086. var cofact_23 = -(m00 * det_11_32 - m01 * det_10_32 + m02 * det_10_31);
  72087. var cofact_30 = -(m01 * det_12_23 - m02 * det_11_23 + m03 * det_11_22);
  72088. var cofact_31 = +(m00 * det_12_23 - m02 * det_10_23 + m03 * det_10_22);
  72089. var cofact_32 = -(m00 * det_11_23 - m01 * det_10_23 + m03 * det_10_21);
  72090. var cofact_33 = +(m00 * det_11_22 - m01 * det_10_22 + m02 * det_10_21);
  72091. 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);
  72092. return this;
  72093. };
  72094. /**
  72095. * add a value at the specified position in the current Matrix
  72096. * @param index the index of the value within the matrix. between 0 and 15.
  72097. * @param value the value to be added
  72098. * @returns the current updated matrix
  72099. */
  72100. Matrix.prototype.addAtIndex = function (index, value) {
  72101. this._m[index] += value;
  72102. this._markAsUpdated();
  72103. return this;
  72104. };
  72105. /**
  72106. * mutiply the specified position in the current Matrix by a value
  72107. * @param index the index of the value within the matrix. between 0 and 15.
  72108. * @param value the value to be added
  72109. * @returns the current updated matrix
  72110. */
  72111. Matrix.prototype.multiplyAtIndex = function (index, value) {
  72112. this._m[index] *= value;
  72113. this._markAsUpdated();
  72114. return this;
  72115. };
  72116. /**
  72117. * Inserts the translation vector (using 3 floats) in the current matrix
  72118. * @param x defines the 1st component of the translation
  72119. * @param y defines the 2nd component of the translation
  72120. * @param z defines the 3rd component of the translation
  72121. * @returns the current updated matrix
  72122. */
  72123. Matrix.prototype.setTranslationFromFloats = function (x, y, z) {
  72124. this._m[12] = x;
  72125. this._m[13] = y;
  72126. this._m[14] = z;
  72127. this._markAsUpdated();
  72128. return this;
  72129. };
  72130. /**
  72131. * Inserts the translation vector in the current matrix
  72132. * @param vector3 defines the translation to insert
  72133. * @returns the current updated matrix
  72134. */
  72135. Matrix.prototype.setTranslation = function (vector3) {
  72136. return this.setTranslationFromFloats(vector3.x, vector3.y, vector3.z);
  72137. };
  72138. /**
  72139. * Gets the translation value of the current matrix
  72140. * @returns a new Vector3 as the extracted translation from the matrix
  72141. */
  72142. Matrix.prototype.getTranslation = function () {
  72143. return new Vector3(this._m[12], this._m[13], this._m[14]);
  72144. };
  72145. /**
  72146. * Fill a Vector3 with the extracted translation from the matrix
  72147. * @param result defines the Vector3 where to store the translation
  72148. * @returns the current matrix
  72149. */
  72150. Matrix.prototype.getTranslationToRef = function (result) {
  72151. result.x = this._m[12];
  72152. result.y = this._m[13];
  72153. result.z = this._m[14];
  72154. return this;
  72155. };
  72156. /**
  72157. * Remove rotation and scaling part from the matrix
  72158. * @returns the updated matrix
  72159. */
  72160. Matrix.prototype.removeRotationAndScaling = function () {
  72161. var m = this.m;
  72162. 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);
  72163. this._updateIdentityStatus(m[12] === 0 && m[13] === 0 && m[14] === 0 && m[15] === 1);
  72164. return this;
  72165. };
  72166. /**
  72167. * Multiply two matrices
  72168. * @param other defines the second operand
  72169. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  72170. */
  72171. Matrix.prototype.multiply = function (other) {
  72172. var result = new Matrix();
  72173. this.multiplyToRef(other, result);
  72174. return result;
  72175. };
  72176. /**
  72177. * Copy the current matrix from the given one
  72178. * @param other defines the source matrix
  72179. * @returns the current updated matrix
  72180. */
  72181. Matrix.prototype.copyFrom = function (other) {
  72182. other.copyToArray(this._m);
  72183. var o = other;
  72184. this._updateIdentityStatus(o._isIdentity, o._isIdentityDirty, o._isIdentity3x2, o._isIdentity3x2Dirty);
  72185. return this;
  72186. };
  72187. /**
  72188. * Populates the given array from the starting index with the current matrix values
  72189. * @param array defines the target array
  72190. * @param offset defines the offset in the target array where to start storing values
  72191. * @returns the current matrix
  72192. */
  72193. Matrix.prototype.copyToArray = function (array, offset) {
  72194. if (offset === void 0) { offset = 0; }
  72195. for (var index = 0; index < 16; index++) {
  72196. array[offset + index] = this._m[index];
  72197. }
  72198. return this;
  72199. };
  72200. /**
  72201. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  72202. * @param other defines the second operand
  72203. * @param result defines the matrix where to store the multiplication
  72204. * @returns the current matrix
  72205. */
  72206. Matrix.prototype.multiplyToRef = function (other, result) {
  72207. if (this._isIdentity) {
  72208. result.copyFrom(other);
  72209. return this;
  72210. }
  72211. if (other._isIdentity) {
  72212. result.copyFrom(this);
  72213. return this;
  72214. }
  72215. this.multiplyToArray(other, result._m, 0);
  72216. result._markAsUpdated();
  72217. return this;
  72218. };
  72219. /**
  72220. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  72221. * @param other defines the second operand
  72222. * @param result defines the array where to store the multiplication
  72223. * @param offset defines the offset in the target array where to start storing values
  72224. * @returns the current matrix
  72225. */
  72226. Matrix.prototype.multiplyToArray = function (other, result, offset) {
  72227. var m = this._m;
  72228. var otherM = other.m;
  72229. var tm0 = m[0], tm1 = m[1], tm2 = m[2], tm3 = m[3];
  72230. var tm4 = m[4], tm5 = m[5], tm6 = m[6], tm7 = m[7];
  72231. var tm8 = m[8], tm9 = m[9], tm10 = m[10], tm11 = m[11];
  72232. var tm12 = m[12], tm13 = m[13], tm14 = m[14], tm15 = m[15];
  72233. var om0 = otherM[0], om1 = otherM[1], om2 = otherM[2], om3 = otherM[3];
  72234. var om4 = otherM[4], om5 = otherM[5], om6 = otherM[6], om7 = otherM[7];
  72235. var om8 = otherM[8], om9 = otherM[9], om10 = otherM[10], om11 = otherM[11];
  72236. var om12 = otherM[12], om13 = otherM[13], om14 = otherM[14], om15 = otherM[15];
  72237. result[offset] = tm0 * om0 + tm1 * om4 + tm2 * om8 + tm3 * om12;
  72238. result[offset + 1] = tm0 * om1 + tm1 * om5 + tm2 * om9 + tm3 * om13;
  72239. result[offset + 2] = tm0 * om2 + tm1 * om6 + tm2 * om10 + tm3 * om14;
  72240. result[offset + 3] = tm0 * om3 + tm1 * om7 + tm2 * om11 + tm3 * om15;
  72241. result[offset + 4] = tm4 * om0 + tm5 * om4 + tm6 * om8 + tm7 * om12;
  72242. result[offset + 5] = tm4 * om1 + tm5 * om5 + tm6 * om9 + tm7 * om13;
  72243. result[offset + 6] = tm4 * om2 + tm5 * om6 + tm6 * om10 + tm7 * om14;
  72244. result[offset + 7] = tm4 * om3 + tm5 * om7 + tm6 * om11 + tm7 * om15;
  72245. result[offset + 8] = tm8 * om0 + tm9 * om4 + tm10 * om8 + tm11 * om12;
  72246. result[offset + 9] = tm8 * om1 + tm9 * om5 + tm10 * om9 + tm11 * om13;
  72247. result[offset + 10] = tm8 * om2 + tm9 * om6 + tm10 * om10 + tm11 * om14;
  72248. result[offset + 11] = tm8 * om3 + tm9 * om7 + tm10 * om11 + tm11 * om15;
  72249. result[offset + 12] = tm12 * om0 + tm13 * om4 + tm14 * om8 + tm15 * om12;
  72250. result[offset + 13] = tm12 * om1 + tm13 * om5 + tm14 * om9 + tm15 * om13;
  72251. result[offset + 14] = tm12 * om2 + tm13 * om6 + tm14 * om10 + tm15 * om14;
  72252. result[offset + 15] = tm12 * om3 + tm13 * om7 + tm14 * om11 + tm15 * om15;
  72253. return this;
  72254. };
  72255. /**
  72256. * Check equality between this matrix and a second one
  72257. * @param value defines the second matrix to compare
  72258. * @returns true is the current matrix and the given one values are strictly equal
  72259. */
  72260. Matrix.prototype.equals = function (value) {
  72261. var other = value;
  72262. if (!other) {
  72263. return false;
  72264. }
  72265. if (this._isIdentity || other._isIdentity) {
  72266. if (!this._isIdentityDirty && !other._isIdentityDirty) {
  72267. return this._isIdentity && other._isIdentity;
  72268. }
  72269. }
  72270. var m = this.m;
  72271. var om = other.m;
  72272. return (m[0] === om[0] && m[1] === om[1] && m[2] === om[2] && m[3] === om[3] &&
  72273. m[4] === om[4] && m[5] === om[5] && m[6] === om[6] && m[7] === om[7] &&
  72274. m[8] === om[8] && m[9] === om[9] && m[10] === om[10] && m[11] === om[11] &&
  72275. m[12] === om[12] && m[13] === om[13] && m[14] === om[14] && m[15] === om[15]);
  72276. };
  72277. /**
  72278. * Clone the current matrix
  72279. * @returns a new matrix from the current matrix
  72280. */
  72281. Matrix.prototype.clone = function () {
  72282. var matrix = new Matrix();
  72283. matrix.copyFrom(this);
  72284. return matrix;
  72285. };
  72286. /**
  72287. * Returns the name of the current matrix class
  72288. * @returns the string "Matrix"
  72289. */
  72290. Matrix.prototype.getClassName = function () {
  72291. return "Matrix";
  72292. };
  72293. /**
  72294. * Gets the hash code of the current matrix
  72295. * @returns the hash code
  72296. */
  72297. Matrix.prototype.getHashCode = function () {
  72298. var hash = this._m[0] || 0;
  72299. for (var i = 1; i < 16; i++) {
  72300. hash = (hash * 397) ^ (this._m[i] || 0);
  72301. }
  72302. return hash;
  72303. };
  72304. /**
  72305. * Decomposes the current Matrix into a translation, rotation and scaling components
  72306. * @param scale defines the scale vector3 given as a reference to update
  72307. * @param rotation defines the rotation quaternion given as a reference to update
  72308. * @param translation defines the translation vector3 given as a reference to update
  72309. * @returns true if operation was successful
  72310. */
  72311. Matrix.prototype.decompose = function (scale, rotation, translation) {
  72312. if (this._isIdentity) {
  72313. if (translation) {
  72314. translation.setAll(0);
  72315. }
  72316. if (scale) {
  72317. scale.setAll(1);
  72318. }
  72319. if (rotation) {
  72320. rotation.copyFromFloats(0, 0, 0, 1);
  72321. }
  72322. return true;
  72323. }
  72324. var m = this._m;
  72325. if (translation) {
  72326. translation.copyFromFloats(m[12], m[13], m[14]);
  72327. }
  72328. scale = scale || MathTmp.Vector3[0];
  72329. scale.x = Math.sqrt(m[0] * m[0] + m[1] * m[1] + m[2] * m[2]);
  72330. scale.y = Math.sqrt(m[4] * m[4] + m[5] * m[5] + m[6] * m[6]);
  72331. scale.z = Math.sqrt(m[8] * m[8] + m[9] * m[9] + m[10] * m[10]);
  72332. if (this.determinant() <= 0) {
  72333. scale.y *= -1;
  72334. }
  72335. if (scale.x === 0 || scale.y === 0 || scale.z === 0) {
  72336. if (rotation) {
  72337. rotation.copyFromFloats(0.0, 0.0, 0.0, 1.0);
  72338. }
  72339. return false;
  72340. }
  72341. if (rotation) {
  72342. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  72343. 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]);
  72344. Quaternion.FromRotationMatrixToRef(MathTmp.Matrix[0], rotation);
  72345. }
  72346. return true;
  72347. };
  72348. /**
  72349. * Gets specific row of the matrix
  72350. * @param index defines the number of the row to get
  72351. * @returns the index-th row of the current matrix as a new Vector4
  72352. */
  72353. Matrix.prototype.getRow = function (index) {
  72354. if (index < 0 || index > 3) {
  72355. return null;
  72356. }
  72357. var i = index * 4;
  72358. return new Vector4(this._m[i + 0], this._m[i + 1], this._m[i + 2], this._m[i + 3]);
  72359. };
  72360. /**
  72361. * Sets the index-th row of the current matrix to the vector4 values
  72362. * @param index defines the number of the row to set
  72363. * @param row defines the target vector4
  72364. * @returns the updated current matrix
  72365. */
  72366. Matrix.prototype.setRow = function (index, row) {
  72367. return this.setRowFromFloats(index, row.x, row.y, row.z, row.w);
  72368. };
  72369. /**
  72370. * Compute the transpose of the matrix
  72371. * @returns the new transposed matrix
  72372. */
  72373. Matrix.prototype.transpose = function () {
  72374. return Matrix.Transpose(this);
  72375. };
  72376. /**
  72377. * Compute the transpose of the matrix and store it in a given matrix
  72378. * @param result defines the target matrix
  72379. * @returns the current matrix
  72380. */
  72381. Matrix.prototype.transposeToRef = function (result) {
  72382. Matrix.TransposeToRef(this, result);
  72383. return this;
  72384. };
  72385. /**
  72386. * Sets the index-th row of the current matrix with the given 4 x float values
  72387. * @param index defines the row index
  72388. * @param x defines the x component to set
  72389. * @param y defines the y component to set
  72390. * @param z defines the z component to set
  72391. * @param w defines the w component to set
  72392. * @returns the updated current matrix
  72393. */
  72394. Matrix.prototype.setRowFromFloats = function (index, x, y, z, w) {
  72395. if (index < 0 || index > 3) {
  72396. return this;
  72397. }
  72398. var i = index * 4;
  72399. this._m[i + 0] = x;
  72400. this._m[i + 1] = y;
  72401. this._m[i + 2] = z;
  72402. this._m[i + 3] = w;
  72403. this._markAsUpdated();
  72404. return this;
  72405. };
  72406. /**
  72407. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  72408. * @param scale defines the scale factor
  72409. * @returns a new matrix
  72410. */
  72411. Matrix.prototype.scale = function (scale) {
  72412. var result = new Matrix();
  72413. this.scaleToRef(scale, result);
  72414. return result;
  72415. };
  72416. /**
  72417. * Scale the current matrix values by a factor to a given result matrix
  72418. * @param scale defines the scale factor
  72419. * @param result defines the matrix to store the result
  72420. * @returns the current matrix
  72421. */
  72422. Matrix.prototype.scaleToRef = function (scale, result) {
  72423. for (var index = 0; index < 16; index++) {
  72424. result._m[index] = this._m[index] * scale;
  72425. }
  72426. result._markAsUpdated();
  72427. return this;
  72428. };
  72429. /**
  72430. * Scale the current matrix values by a factor and add the result to a given matrix
  72431. * @param scale defines the scale factor
  72432. * @param result defines the Matrix to store the result
  72433. * @returns the current matrix
  72434. */
  72435. Matrix.prototype.scaleAndAddToRef = function (scale, result) {
  72436. for (var index = 0; index < 16; index++) {
  72437. result._m[index] += this._m[index] * scale;
  72438. }
  72439. result._markAsUpdated();
  72440. return this;
  72441. };
  72442. /**
  72443. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  72444. * @param ref matrix to store the result
  72445. */
  72446. Matrix.prototype.toNormalMatrix = function (ref) {
  72447. var tmp = MathTmp.Matrix[0];
  72448. this.invertToRef(tmp);
  72449. tmp.transposeToRef(ref);
  72450. var m = ref._m;
  72451. 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);
  72452. };
  72453. /**
  72454. * Gets only rotation part of the current matrix
  72455. * @returns a new matrix sets to the extracted rotation matrix from the current one
  72456. */
  72457. Matrix.prototype.getRotationMatrix = function () {
  72458. var result = new Matrix();
  72459. this.getRotationMatrixToRef(result);
  72460. return result;
  72461. };
  72462. /**
  72463. * Extracts the rotation matrix from the current one and sets it as the given "result"
  72464. * @param result defines the target matrix to store data to
  72465. * @returns the current matrix
  72466. */
  72467. Matrix.prototype.getRotationMatrixToRef = function (result) {
  72468. var scale = MathTmp.Vector3[0];
  72469. if (!this.decompose(scale)) {
  72470. Matrix.IdentityToRef(result);
  72471. return this;
  72472. }
  72473. var m = this._m;
  72474. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  72475. 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);
  72476. return this;
  72477. };
  72478. /**
  72479. * Toggles model matrix from being right handed to left handed in place and vice versa
  72480. */
  72481. Matrix.prototype.toggleModelMatrixHandInPlace = function () {
  72482. var m = this._m;
  72483. m[2] *= -1;
  72484. m[6] *= -1;
  72485. m[8] *= -1;
  72486. m[9] *= -1;
  72487. m[14] *= -1;
  72488. this._markAsUpdated();
  72489. };
  72490. /**
  72491. * Toggles projection matrix from being right handed to left handed in place and vice versa
  72492. */
  72493. Matrix.prototype.toggleProjectionMatrixHandInPlace = function () {
  72494. var m = this._m;
  72495. m[8] *= -1;
  72496. m[9] *= -1;
  72497. m[10] *= -1;
  72498. m[11] *= -1;
  72499. this._markAsUpdated();
  72500. };
  72501. // Statics
  72502. /**
  72503. * Creates a matrix from an array
  72504. * @param array defines the source array
  72505. * @param offset defines an offset in the source array
  72506. * @returns a new Matrix set from the starting index of the given array
  72507. */
  72508. Matrix.FromArray = function (array, offset) {
  72509. if (offset === void 0) { offset = 0; }
  72510. var result = new Matrix();
  72511. Matrix.FromArrayToRef(array, offset, result);
  72512. return result;
  72513. };
  72514. /**
  72515. * Copy the content of an array into a given matrix
  72516. * @param array defines the source array
  72517. * @param offset defines an offset in the source array
  72518. * @param result defines the target matrix
  72519. */
  72520. Matrix.FromArrayToRef = function (array, offset, result) {
  72521. for (var index = 0; index < 16; index++) {
  72522. result._m[index] = array[index + offset];
  72523. }
  72524. result._markAsUpdated();
  72525. };
  72526. /**
  72527. * Stores an array into a matrix after having multiplied each component by a given factor
  72528. * @param array defines the source array
  72529. * @param offset defines the offset in the source array
  72530. * @param scale defines the scaling factor
  72531. * @param result defines the target matrix
  72532. */
  72533. Matrix.FromFloat32ArrayToRefScaled = function (array, offset, scale, result) {
  72534. for (var index = 0; index < 16; index++) {
  72535. result._m[index] = array[index + offset] * scale;
  72536. }
  72537. result._markAsUpdated();
  72538. };
  72539. Object.defineProperty(Matrix, "IdentityReadOnly", {
  72540. /**
  72541. * Gets an identity matrix that must not be updated
  72542. */
  72543. get: function () {
  72544. return Matrix._identityReadOnly;
  72545. },
  72546. enumerable: true,
  72547. configurable: true
  72548. });
  72549. /**
  72550. * Stores a list of values (16) inside a given matrix
  72551. * @param initialM11 defines 1st value of 1st row
  72552. * @param initialM12 defines 2nd value of 1st row
  72553. * @param initialM13 defines 3rd value of 1st row
  72554. * @param initialM14 defines 4th value of 1st row
  72555. * @param initialM21 defines 1st value of 2nd row
  72556. * @param initialM22 defines 2nd value of 2nd row
  72557. * @param initialM23 defines 3rd value of 2nd row
  72558. * @param initialM24 defines 4th value of 2nd row
  72559. * @param initialM31 defines 1st value of 3rd row
  72560. * @param initialM32 defines 2nd value of 3rd row
  72561. * @param initialM33 defines 3rd value of 3rd row
  72562. * @param initialM34 defines 4th value of 3rd row
  72563. * @param initialM41 defines 1st value of 4th row
  72564. * @param initialM42 defines 2nd value of 4th row
  72565. * @param initialM43 defines 3rd value of 4th row
  72566. * @param initialM44 defines 4th value of 4th row
  72567. * @param result defines the target matrix
  72568. */
  72569. Matrix.FromValuesToRef = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44, result) {
  72570. var m = result._m;
  72571. m[0] = initialM11;
  72572. m[1] = initialM12;
  72573. m[2] = initialM13;
  72574. m[3] = initialM14;
  72575. m[4] = initialM21;
  72576. m[5] = initialM22;
  72577. m[6] = initialM23;
  72578. m[7] = initialM24;
  72579. m[8] = initialM31;
  72580. m[9] = initialM32;
  72581. m[10] = initialM33;
  72582. m[11] = initialM34;
  72583. m[12] = initialM41;
  72584. m[13] = initialM42;
  72585. m[14] = initialM43;
  72586. m[15] = initialM44;
  72587. result._markAsUpdated();
  72588. };
  72589. /**
  72590. * Creates new matrix from a list of values (16)
  72591. * @param initialM11 defines 1st value of 1st row
  72592. * @param initialM12 defines 2nd value of 1st row
  72593. * @param initialM13 defines 3rd value of 1st row
  72594. * @param initialM14 defines 4th value of 1st row
  72595. * @param initialM21 defines 1st value of 2nd row
  72596. * @param initialM22 defines 2nd value of 2nd row
  72597. * @param initialM23 defines 3rd value of 2nd row
  72598. * @param initialM24 defines 4th value of 2nd row
  72599. * @param initialM31 defines 1st value of 3rd row
  72600. * @param initialM32 defines 2nd value of 3rd row
  72601. * @param initialM33 defines 3rd value of 3rd row
  72602. * @param initialM34 defines 4th value of 3rd row
  72603. * @param initialM41 defines 1st value of 4th row
  72604. * @param initialM42 defines 2nd value of 4th row
  72605. * @param initialM43 defines 3rd value of 4th row
  72606. * @param initialM44 defines 4th value of 4th row
  72607. * @returns the new matrix
  72608. */
  72609. Matrix.FromValues = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44) {
  72610. var result = new Matrix();
  72611. var m = result._m;
  72612. m[0] = initialM11;
  72613. m[1] = initialM12;
  72614. m[2] = initialM13;
  72615. m[3] = initialM14;
  72616. m[4] = initialM21;
  72617. m[5] = initialM22;
  72618. m[6] = initialM23;
  72619. m[7] = initialM24;
  72620. m[8] = initialM31;
  72621. m[9] = initialM32;
  72622. m[10] = initialM33;
  72623. m[11] = initialM34;
  72624. m[12] = initialM41;
  72625. m[13] = initialM42;
  72626. m[14] = initialM43;
  72627. m[15] = initialM44;
  72628. result._markAsUpdated();
  72629. return result;
  72630. };
  72631. /**
  72632. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72633. * @param scale defines the scale vector3
  72634. * @param rotation defines the rotation quaternion
  72635. * @param translation defines the translation vector3
  72636. * @returns a new matrix
  72637. */
  72638. Matrix.Compose = function (scale, rotation, translation) {
  72639. var result = new Matrix();
  72640. Matrix.ComposeToRef(scale, rotation, translation, result);
  72641. return result;
  72642. };
  72643. /**
  72644. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72645. * @param scale defines the scale vector3
  72646. * @param rotation defines the rotation quaternion
  72647. * @param translation defines the translation vector3
  72648. * @param result defines the target matrix
  72649. */
  72650. Matrix.ComposeToRef = function (scale, rotation, translation, result) {
  72651. Matrix.ScalingToRef(scale.x, scale.y, scale.z, MathTmp.Matrix[1]);
  72652. rotation.toRotationMatrix(MathTmp.Matrix[0]);
  72653. MathTmp.Matrix[1].multiplyToRef(MathTmp.Matrix[0], result);
  72654. result.setTranslation(translation);
  72655. };
  72656. /**
  72657. * Creates a new identity matrix
  72658. * @returns a new identity matrix
  72659. */
  72660. Matrix.Identity = function () {
  72661. 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);
  72662. identity._updateIdentityStatus(true);
  72663. return identity;
  72664. };
  72665. /**
  72666. * Creates a new identity matrix and stores the result in a given matrix
  72667. * @param result defines the target matrix
  72668. */
  72669. Matrix.IdentityToRef = function (result) {
  72670. 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);
  72671. result._updateIdentityStatus(true);
  72672. };
  72673. /**
  72674. * Creates a new zero matrix
  72675. * @returns a new zero matrix
  72676. */
  72677. Matrix.Zero = function () {
  72678. 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);
  72679. zero._updateIdentityStatus(false);
  72680. return zero;
  72681. };
  72682. /**
  72683. * Creates a new rotation matrix for "angle" radians around the X axis
  72684. * @param angle defines the angle (in radians) to use
  72685. * @return the new matrix
  72686. */
  72687. Matrix.RotationX = function (angle) {
  72688. var result = new Matrix();
  72689. Matrix.RotationXToRef(angle, result);
  72690. return result;
  72691. };
  72692. /**
  72693. * Creates a new matrix as the invert of a given matrix
  72694. * @param source defines the source matrix
  72695. * @returns the new matrix
  72696. */
  72697. Matrix.Invert = function (source) {
  72698. var result = new Matrix();
  72699. source.invertToRef(result);
  72700. return result;
  72701. };
  72702. /**
  72703. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  72704. * @param angle defines the angle (in radians) to use
  72705. * @param result defines the target matrix
  72706. */
  72707. Matrix.RotationXToRef = function (angle, result) {
  72708. var s = Math.sin(angle);
  72709. var c = Math.cos(angle);
  72710. 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);
  72711. result._updateIdentityStatus(c === 1 && s === 0);
  72712. };
  72713. /**
  72714. * Creates a new rotation matrix for "angle" radians around the Y axis
  72715. * @param angle defines the angle (in radians) to use
  72716. * @return the new matrix
  72717. */
  72718. Matrix.RotationY = function (angle) {
  72719. var result = new Matrix();
  72720. Matrix.RotationYToRef(angle, result);
  72721. return result;
  72722. };
  72723. /**
  72724. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  72725. * @param angle defines the angle (in radians) to use
  72726. * @param result defines the target matrix
  72727. */
  72728. Matrix.RotationYToRef = function (angle, result) {
  72729. var s = Math.sin(angle);
  72730. var c = Math.cos(angle);
  72731. 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);
  72732. result._updateIdentityStatus(c === 1 && s === 0);
  72733. };
  72734. /**
  72735. * Creates a new rotation matrix for "angle" radians around the Z axis
  72736. * @param angle defines the angle (in radians) to use
  72737. * @return the new matrix
  72738. */
  72739. Matrix.RotationZ = function (angle) {
  72740. var result = new Matrix();
  72741. Matrix.RotationZToRef(angle, result);
  72742. return result;
  72743. };
  72744. /**
  72745. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  72746. * @param angle defines the angle (in radians) to use
  72747. * @param result defines the target matrix
  72748. */
  72749. Matrix.RotationZToRef = function (angle, result) {
  72750. var s = Math.sin(angle);
  72751. var c = Math.cos(angle);
  72752. 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);
  72753. result._updateIdentityStatus(c === 1 && s === 0);
  72754. };
  72755. /**
  72756. * Creates a new rotation matrix for "angle" radians around the given axis
  72757. * @param axis defines the axis to use
  72758. * @param angle defines the angle (in radians) to use
  72759. * @return the new matrix
  72760. */
  72761. Matrix.RotationAxis = function (axis, angle) {
  72762. var result = new Matrix();
  72763. Matrix.RotationAxisToRef(axis, angle, result);
  72764. return result;
  72765. };
  72766. /**
  72767. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  72768. * @param axis defines the axis to use
  72769. * @param angle defines the angle (in radians) to use
  72770. * @param result defines the target matrix
  72771. */
  72772. Matrix.RotationAxisToRef = function (axis, angle, result) {
  72773. var s = Math.sin(-angle);
  72774. var c = Math.cos(-angle);
  72775. var c1 = 1 - c;
  72776. axis.normalize();
  72777. var m = result._m;
  72778. m[0] = (axis.x * axis.x) * c1 + c;
  72779. m[1] = (axis.x * axis.y) * c1 - (axis.z * s);
  72780. m[2] = (axis.x * axis.z) * c1 + (axis.y * s);
  72781. m[3] = 0.0;
  72782. m[4] = (axis.y * axis.x) * c1 + (axis.z * s);
  72783. m[5] = (axis.y * axis.y) * c1 + c;
  72784. m[6] = (axis.y * axis.z) * c1 - (axis.x * s);
  72785. m[7] = 0.0;
  72786. m[8] = (axis.z * axis.x) * c1 - (axis.y * s);
  72787. m[9] = (axis.z * axis.y) * c1 + (axis.x * s);
  72788. m[10] = (axis.z * axis.z) * c1 + c;
  72789. m[11] = 0.0;
  72790. m[12] = 0.0;
  72791. m[13] = 0.0;
  72792. m[14] = 0.0;
  72793. m[15] = 1.0;
  72794. result._markAsUpdated();
  72795. };
  72796. /**
  72797. * Creates a rotation matrix
  72798. * @param yaw defines the yaw angle in radians (Y axis)
  72799. * @param pitch defines the pitch angle in radians (X axis)
  72800. * @param roll defines the roll angle in radians (X axis)
  72801. * @returns the new rotation matrix
  72802. */
  72803. Matrix.RotationYawPitchRoll = function (yaw, pitch, roll) {
  72804. var result = new Matrix();
  72805. Matrix.RotationYawPitchRollToRef(yaw, pitch, roll, result);
  72806. return result;
  72807. };
  72808. /**
  72809. * Creates a rotation matrix and stores it in a given matrix
  72810. * @param yaw defines the yaw angle in radians (Y axis)
  72811. * @param pitch defines the pitch angle in radians (X axis)
  72812. * @param roll defines the roll angle in radians (X axis)
  72813. * @param result defines the target matrix
  72814. */
  72815. Matrix.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  72816. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, MathTmp.Quaternion[0]);
  72817. MathTmp.Quaternion[0].toRotationMatrix(result);
  72818. };
  72819. /**
  72820. * Creates a scaling matrix
  72821. * @param x defines the scale factor on X axis
  72822. * @param y defines the scale factor on Y axis
  72823. * @param z defines the scale factor on Z axis
  72824. * @returns the new matrix
  72825. */
  72826. Matrix.Scaling = function (x, y, z) {
  72827. var result = new Matrix();
  72828. Matrix.ScalingToRef(x, y, z, result);
  72829. return result;
  72830. };
  72831. /**
  72832. * Creates a scaling matrix and stores it in a given matrix
  72833. * @param x defines the scale factor on X axis
  72834. * @param y defines the scale factor on Y axis
  72835. * @param z defines the scale factor on Z axis
  72836. * @param result defines the target matrix
  72837. */
  72838. Matrix.ScalingToRef = function (x, y, z, result) {
  72839. 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);
  72840. result._updateIdentityStatus(x === 1 && y === 1 && z === 1);
  72841. };
  72842. /**
  72843. * Creates a translation matrix
  72844. * @param x defines the translation on X axis
  72845. * @param y defines the translation on Y axis
  72846. * @param z defines the translationon Z axis
  72847. * @returns the new matrix
  72848. */
  72849. Matrix.Translation = function (x, y, z) {
  72850. var result = new Matrix();
  72851. Matrix.TranslationToRef(x, y, z, result);
  72852. return result;
  72853. };
  72854. /**
  72855. * Creates a translation matrix and stores it in a given matrix
  72856. * @param x defines the translation on X axis
  72857. * @param y defines the translation on Y axis
  72858. * @param z defines the translationon Z axis
  72859. * @param result defines the target matrix
  72860. */
  72861. Matrix.TranslationToRef = function (x, y, z, result) {
  72862. 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);
  72863. result._updateIdentityStatus(x === 0 && y === 0 && z === 0);
  72864. };
  72865. /**
  72866. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72867. * @param startValue defines the start value
  72868. * @param endValue defines the end value
  72869. * @param gradient defines the gradient factor
  72870. * @returns the new matrix
  72871. */
  72872. Matrix.Lerp = function (startValue, endValue, gradient) {
  72873. var result = new Matrix();
  72874. Matrix.LerpToRef(startValue, endValue, gradient, result);
  72875. return result;
  72876. };
  72877. /**
  72878. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72879. * @param startValue defines the start value
  72880. * @param endValue defines the end value
  72881. * @param gradient defines the gradient factor
  72882. * @param result defines the Matrix object where to store data
  72883. */
  72884. Matrix.LerpToRef = function (startValue, endValue, gradient, result) {
  72885. var resultM = result._m;
  72886. var startM = startValue.m;
  72887. var endM = endValue.m;
  72888. for (var index = 0; index < 16; index++) {
  72889. resultM[index] = startM[index] * (1.0 - gradient) + endM[index] * gradient;
  72890. }
  72891. result._markAsUpdated();
  72892. };
  72893. /**
  72894. * Builds a new matrix whose values are computed by:
  72895. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72896. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72897. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72898. * @param startValue defines the first matrix
  72899. * @param endValue defines the second matrix
  72900. * @param gradient defines the gradient between the two matrices
  72901. * @returns the new matrix
  72902. */
  72903. Matrix.DecomposeLerp = function (startValue, endValue, gradient) {
  72904. var result = new Matrix();
  72905. Matrix.DecomposeLerpToRef(startValue, endValue, gradient, result);
  72906. return result;
  72907. };
  72908. /**
  72909. * Update a matrix to values which are computed by:
  72910. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72911. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72912. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72913. * @param startValue defines the first matrix
  72914. * @param endValue defines the second matrix
  72915. * @param gradient defines the gradient between the two matrices
  72916. * @param result defines the target matrix
  72917. */
  72918. Matrix.DecomposeLerpToRef = function (startValue, endValue, gradient, result) {
  72919. var startScale = MathTmp.Vector3[0];
  72920. var startRotation = MathTmp.Quaternion[0];
  72921. var startTranslation = MathTmp.Vector3[1];
  72922. startValue.decompose(startScale, startRotation, startTranslation);
  72923. var endScale = MathTmp.Vector3[2];
  72924. var endRotation = MathTmp.Quaternion[1];
  72925. var endTranslation = MathTmp.Vector3[3];
  72926. endValue.decompose(endScale, endRotation, endTranslation);
  72927. var resultScale = MathTmp.Vector3[4];
  72928. Vector3.LerpToRef(startScale, endScale, gradient, resultScale);
  72929. var resultRotation = MathTmp.Quaternion[2];
  72930. Quaternion.SlerpToRef(startRotation, endRotation, gradient, resultRotation);
  72931. var resultTranslation = MathTmp.Vector3[5];
  72932. Vector3.LerpToRef(startTranslation, endTranslation, gradient, resultTranslation);
  72933. Matrix.ComposeToRef(resultScale, resultRotation, resultTranslation, result);
  72934. };
  72935. /**
  72936. * 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"
  72937. * This function works in left handed mode
  72938. * @param eye defines the final position of the entity
  72939. * @param target defines where the entity should look at
  72940. * @param up defines the up vector for the entity
  72941. * @returns the new matrix
  72942. */
  72943. Matrix.LookAtLH = function (eye, target, up) {
  72944. var result = new Matrix();
  72945. Matrix.LookAtLHToRef(eye, target, up, result);
  72946. return result;
  72947. };
  72948. /**
  72949. * 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".
  72950. * This function works in left handed mode
  72951. * @param eye defines the final position of the entity
  72952. * @param target defines where the entity should look at
  72953. * @param up defines the up vector for the entity
  72954. * @param result defines the target matrix
  72955. */
  72956. Matrix.LookAtLHToRef = function (eye, target, up, result) {
  72957. var xAxis = MathTmp.Vector3[0];
  72958. var yAxis = MathTmp.Vector3[1];
  72959. var zAxis = MathTmp.Vector3[2];
  72960. // Z axis
  72961. target.subtractToRef(eye, zAxis);
  72962. zAxis.normalize();
  72963. // X axis
  72964. Vector3.CrossToRef(up, zAxis, xAxis);
  72965. var xSquareLength = xAxis.lengthSquared();
  72966. if (xSquareLength === 0) {
  72967. xAxis.x = 1.0;
  72968. }
  72969. else {
  72970. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  72971. }
  72972. // Y axis
  72973. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  72974. yAxis.normalize();
  72975. // Eye angles
  72976. var ex = -Vector3.Dot(xAxis, eye);
  72977. var ey = -Vector3.Dot(yAxis, eye);
  72978. var ez = -Vector3.Dot(zAxis, eye);
  72979. 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);
  72980. };
  72981. /**
  72982. * 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"
  72983. * This function works in right handed mode
  72984. * @param eye defines the final position of the entity
  72985. * @param target defines where the entity should look at
  72986. * @param up defines the up vector for the entity
  72987. * @returns the new matrix
  72988. */
  72989. Matrix.LookAtRH = function (eye, target, up) {
  72990. var result = new Matrix();
  72991. Matrix.LookAtRHToRef(eye, target, up, result);
  72992. return result;
  72993. };
  72994. /**
  72995. * 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".
  72996. * This function works in right handed mode
  72997. * @param eye defines the final position of the entity
  72998. * @param target defines where the entity should look at
  72999. * @param up defines the up vector for the entity
  73000. * @param result defines the target matrix
  73001. */
  73002. Matrix.LookAtRHToRef = function (eye, target, up, result) {
  73003. var xAxis = MathTmp.Vector3[0];
  73004. var yAxis = MathTmp.Vector3[1];
  73005. var zAxis = MathTmp.Vector3[2];
  73006. // Z axis
  73007. eye.subtractToRef(target, zAxis);
  73008. zAxis.normalize();
  73009. // X axis
  73010. Vector3.CrossToRef(up, zAxis, xAxis);
  73011. var xSquareLength = xAxis.lengthSquared();
  73012. if (xSquareLength === 0) {
  73013. xAxis.x = 1.0;
  73014. }
  73015. else {
  73016. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  73017. }
  73018. // Y axis
  73019. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  73020. yAxis.normalize();
  73021. // Eye angles
  73022. var ex = -Vector3.Dot(xAxis, eye);
  73023. var ey = -Vector3.Dot(yAxis, eye);
  73024. var ez = -Vector3.Dot(zAxis, eye);
  73025. 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);
  73026. };
  73027. /**
  73028. * Create a left-handed orthographic projection matrix
  73029. * @param width defines the viewport width
  73030. * @param height defines the viewport height
  73031. * @param znear defines the near clip plane
  73032. * @param zfar defines the far clip plane
  73033. * @returns a new matrix as a left-handed orthographic projection matrix
  73034. */
  73035. Matrix.OrthoLH = function (width, height, znear, zfar) {
  73036. var matrix = new Matrix();
  73037. Matrix.OrthoLHToRef(width, height, znear, zfar, matrix);
  73038. return matrix;
  73039. };
  73040. /**
  73041. * Store a left-handed orthographic projection to a given matrix
  73042. * @param width defines the viewport width
  73043. * @param height defines the viewport height
  73044. * @param znear defines the near clip plane
  73045. * @param zfar defines the far clip plane
  73046. * @param result defines the target matrix
  73047. */
  73048. Matrix.OrthoLHToRef = function (width, height, znear, zfar, result) {
  73049. var n = znear;
  73050. var f = zfar;
  73051. var a = 2.0 / width;
  73052. var b = 2.0 / height;
  73053. var c = 2.0 / (f - n);
  73054. var d = -(f + n) / (f - n);
  73055. 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);
  73056. result._updateIdentityStatus(a === 1 && b === 1 && c === 1 && d === 0);
  73057. };
  73058. /**
  73059. * Create a left-handed orthographic projection matrix
  73060. * @param left defines the viewport left coordinate
  73061. * @param right defines the viewport right coordinate
  73062. * @param bottom defines the viewport bottom coordinate
  73063. * @param top defines the viewport top coordinate
  73064. * @param znear defines the near clip plane
  73065. * @param zfar defines the far clip plane
  73066. * @returns a new matrix as a left-handed orthographic projection matrix
  73067. */
  73068. Matrix.OrthoOffCenterLH = function (left, right, bottom, top, znear, zfar) {
  73069. var matrix = new Matrix();
  73070. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, matrix);
  73071. return matrix;
  73072. };
  73073. /**
  73074. * Stores a left-handed orthographic projection into a given matrix
  73075. * @param left defines the viewport left coordinate
  73076. * @param right defines the viewport right coordinate
  73077. * @param bottom defines the viewport bottom coordinate
  73078. * @param top defines the viewport top coordinate
  73079. * @param znear defines the near clip plane
  73080. * @param zfar defines the far clip plane
  73081. * @param result defines the target matrix
  73082. */
  73083. Matrix.OrthoOffCenterLHToRef = function (left, right, bottom, top, znear, zfar, result) {
  73084. var n = znear;
  73085. var f = zfar;
  73086. var a = 2.0 / (right - left);
  73087. var b = 2.0 / (top - bottom);
  73088. var c = 2.0 / (f - n);
  73089. var d = -(f + n) / (f - n);
  73090. var i0 = (left + right) / (left - right);
  73091. var i1 = (top + bottom) / (bottom - top);
  73092. 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);
  73093. result._markAsUpdated();
  73094. };
  73095. /**
  73096. * Creates a right-handed orthographic projection matrix
  73097. * @param left defines the viewport left coordinate
  73098. * @param right defines the viewport right coordinate
  73099. * @param bottom defines the viewport bottom coordinate
  73100. * @param top defines the viewport top coordinate
  73101. * @param znear defines the near clip plane
  73102. * @param zfar defines the far clip plane
  73103. * @returns a new matrix as a right-handed orthographic projection matrix
  73104. */
  73105. Matrix.OrthoOffCenterRH = function (left, right, bottom, top, znear, zfar) {
  73106. var matrix = new Matrix();
  73107. Matrix.OrthoOffCenterRHToRef(left, right, bottom, top, znear, zfar, matrix);
  73108. return matrix;
  73109. };
  73110. /**
  73111. * Stores a right-handed orthographic projection into a given matrix
  73112. * @param left defines the viewport left coordinate
  73113. * @param right defines the viewport right coordinate
  73114. * @param bottom defines the viewport bottom coordinate
  73115. * @param top defines the viewport top coordinate
  73116. * @param znear defines the near clip plane
  73117. * @param zfar defines the far clip plane
  73118. * @param result defines the target matrix
  73119. */
  73120. Matrix.OrthoOffCenterRHToRef = function (left, right, bottom, top, znear, zfar, result) {
  73121. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, result);
  73122. result._m[10] *= -1; // No need to call _markAsUpdated as previous function already called it and let _isIdentityDirty to true
  73123. };
  73124. /**
  73125. * Creates a left-handed perspective projection matrix
  73126. * @param width defines the viewport width
  73127. * @param height defines the viewport height
  73128. * @param znear defines the near clip plane
  73129. * @param zfar defines the far clip plane
  73130. * @returns a new matrix as a left-handed perspective projection matrix
  73131. */
  73132. Matrix.PerspectiveLH = function (width, height, znear, zfar) {
  73133. var matrix = new Matrix();
  73134. var n = znear;
  73135. var f = zfar;
  73136. var a = 2.0 * n / width;
  73137. var b = 2.0 * n / height;
  73138. var c = (f + n) / (f - n);
  73139. var d = -2.0 * f * n / (f - n);
  73140. 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);
  73141. matrix._updateIdentityStatus(false);
  73142. return matrix;
  73143. };
  73144. /**
  73145. * Creates a left-handed perspective projection matrix
  73146. * @param fov defines the horizontal field of view
  73147. * @param aspect defines the aspect ratio
  73148. * @param znear defines the near clip plane
  73149. * @param zfar defines the far clip plane
  73150. * @returns a new matrix as a left-handed perspective projection matrix
  73151. */
  73152. Matrix.PerspectiveFovLH = function (fov, aspect, znear, zfar) {
  73153. var matrix = new Matrix();
  73154. Matrix.PerspectiveFovLHToRef(fov, aspect, znear, zfar, matrix);
  73155. return matrix;
  73156. };
  73157. /**
  73158. * Stores a left-handed perspective projection into a given matrix
  73159. * @param fov defines the horizontal field of view
  73160. * @param aspect defines the aspect ratio
  73161. * @param znear defines the near clip plane
  73162. * @param zfar defines the far clip plane
  73163. * @param result defines the target matrix
  73164. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73165. */
  73166. Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  73167. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  73168. var n = znear;
  73169. var f = zfar;
  73170. var t = 1.0 / (Math.tan(fov * 0.5));
  73171. var a = isVerticalFovFixed ? (t / aspect) : t;
  73172. var b = isVerticalFovFixed ? t : (t * aspect);
  73173. var c = (f + n) / (f - n);
  73174. var d = -2.0 * f * n / (f - n);
  73175. 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);
  73176. result._updateIdentityStatus(false);
  73177. };
  73178. /**
  73179. * Creates a right-handed perspective projection matrix
  73180. * @param fov defines the horizontal field of view
  73181. * @param aspect defines the aspect ratio
  73182. * @param znear defines the near clip plane
  73183. * @param zfar defines the far clip plane
  73184. * @returns a new matrix as a right-handed perspective projection matrix
  73185. */
  73186. Matrix.PerspectiveFovRH = function (fov, aspect, znear, zfar) {
  73187. var matrix = new Matrix();
  73188. Matrix.PerspectiveFovRHToRef(fov, aspect, znear, zfar, matrix);
  73189. return matrix;
  73190. };
  73191. /**
  73192. * Stores a right-handed perspective projection into a given matrix
  73193. * @param fov defines the horizontal field of view
  73194. * @param aspect defines the aspect ratio
  73195. * @param znear defines the near clip plane
  73196. * @param zfar defines the far clip plane
  73197. * @param result defines the target matrix
  73198. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73199. */
  73200. Matrix.PerspectiveFovRHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  73201. //alternatively this could be expressed as:
  73202. // m = PerspectiveFovLHToRef
  73203. // m[10] *= -1.0;
  73204. // m[11] *= -1.0;
  73205. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  73206. var n = znear;
  73207. var f = zfar;
  73208. var t = 1.0 / (Math.tan(fov * 0.5));
  73209. var a = isVerticalFovFixed ? (t / aspect) : t;
  73210. var b = isVerticalFovFixed ? t : (t * aspect);
  73211. var c = -(f + n) / (f - n);
  73212. var d = -2 * f * n / (f - n);
  73213. 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);
  73214. result._updateIdentityStatus(false);
  73215. };
  73216. /**
  73217. * Stores a perspective projection for WebVR info a given matrix
  73218. * @param fov defines the field of view
  73219. * @param znear defines the near clip plane
  73220. * @param zfar defines the far clip plane
  73221. * @param result defines the target matrix
  73222. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  73223. */
  73224. Matrix.PerspectiveFovWebVRToRef = function (fov, znear, zfar, result, rightHanded) {
  73225. if (rightHanded === void 0) { rightHanded = false; }
  73226. var rightHandedFactor = rightHanded ? -1 : 1;
  73227. var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);
  73228. var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);
  73229. var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);
  73230. var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);
  73231. var xScale = 2.0 / (leftTan + rightTan);
  73232. var yScale = 2.0 / (upTan + downTan);
  73233. var m = result._m;
  73234. m[0] = xScale;
  73235. m[1] = m[2] = m[3] = m[4] = 0.0;
  73236. m[5] = yScale;
  73237. m[6] = m[7] = 0.0;
  73238. m[8] = ((leftTan - rightTan) * xScale * 0.5);
  73239. m[9] = -((upTan - downTan) * yScale * 0.5);
  73240. m[10] = -zfar / (znear - zfar);
  73241. m[11] = 1.0 * rightHandedFactor;
  73242. m[12] = m[13] = m[15] = 0.0;
  73243. m[14] = -(2.0 * zfar * znear) / (zfar - znear);
  73244. result._markAsUpdated();
  73245. };
  73246. /**
  73247. * Computes a complete transformation matrix
  73248. * @param viewport defines the viewport to use
  73249. * @param world defines the world matrix
  73250. * @param view defines the view matrix
  73251. * @param projection defines the projection matrix
  73252. * @param zmin defines the near clip plane
  73253. * @param zmax defines the far clip plane
  73254. * @returns the transformation matrix
  73255. */
  73256. Matrix.GetFinalMatrix = function (viewport, world, view, projection, zmin, zmax) {
  73257. var cw = viewport.width;
  73258. var ch = viewport.height;
  73259. var cx = viewport.x;
  73260. var cy = viewport.y;
  73261. 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);
  73262. var matrix = MathTmp.Matrix[0];
  73263. world.multiplyToRef(view, matrix);
  73264. matrix.multiplyToRef(projection, matrix);
  73265. return matrix.multiply(viewportMatrix);
  73266. };
  73267. /**
  73268. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  73269. * @param matrix defines the matrix to use
  73270. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  73271. */
  73272. Matrix.GetAsMatrix2x2 = function (matrix) {
  73273. var m = matrix.m;
  73274. return new Float32Array([m[0], m[1], m[4], m[5]]);
  73275. };
  73276. /**
  73277. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  73278. * @param matrix defines the matrix to use
  73279. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  73280. */
  73281. Matrix.GetAsMatrix3x3 = function (matrix) {
  73282. var m = matrix.m;
  73283. return new Float32Array([
  73284. m[0], m[1], m[2],
  73285. m[4], m[5], m[6],
  73286. m[8], m[9], m[10]
  73287. ]);
  73288. };
  73289. /**
  73290. * Compute the transpose of a given matrix
  73291. * @param matrix defines the matrix to transpose
  73292. * @returns the new matrix
  73293. */
  73294. Matrix.Transpose = function (matrix) {
  73295. var result = new Matrix();
  73296. Matrix.TransposeToRef(matrix, result);
  73297. return result;
  73298. };
  73299. /**
  73300. * Compute the transpose of a matrix and store it in a target matrix
  73301. * @param matrix defines the matrix to transpose
  73302. * @param result defines the target matrix
  73303. */
  73304. Matrix.TransposeToRef = function (matrix, result) {
  73305. var rm = result._m;
  73306. var mm = matrix.m;
  73307. rm[0] = mm[0];
  73308. rm[1] = mm[4];
  73309. rm[2] = mm[8];
  73310. rm[3] = mm[12];
  73311. rm[4] = mm[1];
  73312. rm[5] = mm[5];
  73313. rm[6] = mm[9];
  73314. rm[7] = mm[13];
  73315. rm[8] = mm[2];
  73316. rm[9] = mm[6];
  73317. rm[10] = mm[10];
  73318. rm[11] = mm[14];
  73319. rm[12] = mm[3];
  73320. rm[13] = mm[7];
  73321. rm[14] = mm[11];
  73322. rm[15] = mm[15];
  73323. // identity-ness does not change when transposing
  73324. result._updateIdentityStatus(matrix._isIdentity, matrix._isIdentityDirty);
  73325. };
  73326. /**
  73327. * Computes a reflection matrix from a plane
  73328. * @param plane defines the reflection plane
  73329. * @returns a new matrix
  73330. */
  73331. Matrix.Reflection = function (plane) {
  73332. var matrix = new Matrix();
  73333. Matrix.ReflectionToRef(plane, matrix);
  73334. return matrix;
  73335. };
  73336. /**
  73337. * Computes a reflection matrix from a plane
  73338. * @param plane defines the reflection plane
  73339. * @param result defines the target matrix
  73340. */
  73341. Matrix.ReflectionToRef = function (plane, result) {
  73342. plane.normalize();
  73343. var x = plane.normal.x;
  73344. var y = plane.normal.y;
  73345. var z = plane.normal.z;
  73346. var temp = -2 * x;
  73347. var temp2 = -2 * y;
  73348. var temp3 = -2 * z;
  73349. 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);
  73350. };
  73351. /**
  73352. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  73353. * @param xaxis defines the value of the 1st axis
  73354. * @param yaxis defines the value of the 2nd axis
  73355. * @param zaxis defines the value of the 3rd axis
  73356. * @param result defines the target matrix
  73357. */
  73358. Matrix.FromXYZAxesToRef = function (xaxis, yaxis, zaxis, result) {
  73359. 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);
  73360. };
  73361. /**
  73362. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  73363. * @param quat defines the quaternion to use
  73364. * @param result defines the target matrix
  73365. */
  73366. Matrix.FromQuaternionToRef = function (quat, result) {
  73367. var xx = quat.x * quat.x;
  73368. var yy = quat.y * quat.y;
  73369. var zz = quat.z * quat.z;
  73370. var xy = quat.x * quat.y;
  73371. var zw = quat.z * quat.w;
  73372. var zx = quat.z * quat.x;
  73373. var yw = quat.y * quat.w;
  73374. var yz = quat.y * quat.z;
  73375. var xw = quat.x * quat.w;
  73376. result._m[0] = 1.0 - (2.0 * (yy + zz));
  73377. result._m[1] = 2.0 * (xy + zw);
  73378. result._m[2] = 2.0 * (zx - yw);
  73379. result._m[3] = 0.0;
  73380. result._m[4] = 2.0 * (xy - zw);
  73381. result._m[5] = 1.0 - (2.0 * (zz + xx));
  73382. result._m[6] = 2.0 * (yz + xw);
  73383. result._m[7] = 0.0;
  73384. result._m[8] = 2.0 * (zx + yw);
  73385. result._m[9] = 2.0 * (yz - xw);
  73386. result._m[10] = 1.0 - (2.0 * (yy + xx));
  73387. result._m[11] = 0.0;
  73388. result._m[12] = 0.0;
  73389. result._m[13] = 0.0;
  73390. result._m[14] = 0.0;
  73391. result._m[15] = 1.0;
  73392. result._markAsUpdated();
  73393. };
  73394. Matrix._updateFlagSeed = 0;
  73395. Matrix._identityReadOnly = Matrix.Identity();
  73396. return Matrix;
  73397. }());
  73398. /**
  73399. * Represens a plane by the equation ax + by + cz + d = 0
  73400. */
  73401. var Plane = /** @class */ (function () {
  73402. /**
  73403. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73404. * @param a a component of the plane
  73405. * @param b b component of the plane
  73406. * @param c c component of the plane
  73407. * @param d d component of the plane
  73408. */
  73409. function Plane(a, b, c, d) {
  73410. this.normal = new Vector3(a, b, c);
  73411. this.d = d;
  73412. }
  73413. /**
  73414. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73415. */
  73416. Plane.prototype.asArray = function () {
  73417. return [this.normal.x, this.normal.y, this.normal.z, this.d];
  73418. };
  73419. // Methods
  73420. /**
  73421. * @returns a new plane copied from the current Plane.
  73422. */
  73423. Plane.prototype.clone = function () {
  73424. return new Plane(this.normal.x, this.normal.y, this.normal.z, this.d);
  73425. };
  73426. /**
  73427. * @returns the string "Plane".
  73428. */
  73429. Plane.prototype.getClassName = function () {
  73430. return "Plane";
  73431. };
  73432. /**
  73433. * @returns the Plane hash code.
  73434. */
  73435. Plane.prototype.getHashCode = function () {
  73436. var hash = this.normal.getHashCode();
  73437. hash = (hash * 397) ^ (this.d || 0);
  73438. return hash;
  73439. };
  73440. /**
  73441. * Normalize the current Plane in place.
  73442. * @returns the updated Plane.
  73443. */
  73444. Plane.prototype.normalize = function () {
  73445. var norm = (Math.sqrt((this.normal.x * this.normal.x) + (this.normal.y * this.normal.y) + (this.normal.z * this.normal.z)));
  73446. var magnitude = 0.0;
  73447. if (norm !== 0) {
  73448. magnitude = 1.0 / norm;
  73449. }
  73450. this.normal.x *= magnitude;
  73451. this.normal.y *= magnitude;
  73452. this.normal.z *= magnitude;
  73453. this.d *= magnitude;
  73454. return this;
  73455. };
  73456. /**
  73457. * Applies a transformation the plane and returns the result
  73458. * @param transformation the transformation matrix to be applied to the plane
  73459. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73460. */
  73461. Plane.prototype.transform = function (transformation) {
  73462. var transposedMatrix = MathTmp.Matrix[0];
  73463. Matrix.TransposeToRef(transformation, transposedMatrix);
  73464. var m = transposedMatrix.m;
  73465. var x = this.normal.x;
  73466. var y = this.normal.y;
  73467. var z = this.normal.z;
  73468. var d = this.d;
  73469. var normalX = x * m[0] + y * m[1] + z * m[2] + d * m[3];
  73470. var normalY = x * m[4] + y * m[5] + z * m[6] + d * m[7];
  73471. var normalZ = x * m[8] + y * m[9] + z * m[10] + d * m[11];
  73472. var finalD = x * m[12] + y * m[13] + z * m[14] + d * m[15];
  73473. return new Plane(normalX, normalY, normalZ, finalD);
  73474. };
  73475. /**
  73476. * Calcualtte the dot product between the point and the plane normal
  73477. * @param point point to calculate the dot product with
  73478. * @returns the dot product (float) of the point coordinates and the plane normal.
  73479. */
  73480. Plane.prototype.dotCoordinate = function (point) {
  73481. return ((((this.normal.x * point.x) + (this.normal.y * point.y)) + (this.normal.z * point.z)) + this.d);
  73482. };
  73483. /**
  73484. * Updates the current Plane from the plane defined by the three given points.
  73485. * @param point1 one of the points used to contruct the plane
  73486. * @param point2 one of the points used to contruct the plane
  73487. * @param point3 one of the points used to contruct the plane
  73488. * @returns the updated Plane.
  73489. */
  73490. Plane.prototype.copyFromPoints = function (point1, point2, point3) {
  73491. var x1 = point2.x - point1.x;
  73492. var y1 = point2.y - point1.y;
  73493. var z1 = point2.z - point1.z;
  73494. var x2 = point3.x - point1.x;
  73495. var y2 = point3.y - point1.y;
  73496. var z2 = point3.z - point1.z;
  73497. var yz = (y1 * z2) - (z1 * y2);
  73498. var xz = (z1 * x2) - (x1 * z2);
  73499. var xy = (x1 * y2) - (y1 * x2);
  73500. var pyth = (Math.sqrt((yz * yz) + (xz * xz) + (xy * xy)));
  73501. var invPyth;
  73502. if (pyth !== 0) {
  73503. invPyth = 1.0 / pyth;
  73504. }
  73505. else {
  73506. invPyth = 0.0;
  73507. }
  73508. this.normal.x = yz * invPyth;
  73509. this.normal.y = xz * invPyth;
  73510. this.normal.z = xy * invPyth;
  73511. this.d = -((this.normal.x * point1.x) + (this.normal.y * point1.y) + (this.normal.z * point1.z));
  73512. return this;
  73513. };
  73514. /**
  73515. * Checks if the plane is facing a given direction
  73516. * @param direction the direction to check if the plane is facing
  73517. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73518. * @returns True is the vector "direction" is the same side than the plane normal.
  73519. */
  73520. Plane.prototype.isFrontFacingTo = function (direction, epsilon) {
  73521. var dot = Vector3.Dot(this.normal, direction);
  73522. return (dot <= epsilon);
  73523. };
  73524. /**
  73525. * Calculates the distance to a point
  73526. * @param point point to calculate distance to
  73527. * @returns the signed distance (float) from the given point to the Plane.
  73528. */
  73529. Plane.prototype.signedDistanceTo = function (point) {
  73530. return Vector3.Dot(point, this.normal) + this.d;
  73531. };
  73532. // Statics
  73533. /**
  73534. * Creates a plane from an array
  73535. * @param array the array to create a plane from
  73536. * @returns a new Plane from the given array.
  73537. */
  73538. Plane.FromArray = function (array) {
  73539. return new Plane(array[0], array[1], array[2], array[3]);
  73540. };
  73541. /**
  73542. * Creates a plane from three points
  73543. * @param point1 point used to create the plane
  73544. * @param point2 point used to create the plane
  73545. * @param point3 point used to create the plane
  73546. * @returns a new Plane defined by the three given points.
  73547. */
  73548. Plane.FromPoints = function (point1, point2, point3) {
  73549. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  73550. result.copyFromPoints(point1, point2, point3);
  73551. return result;
  73552. };
  73553. /**
  73554. * Creates a plane from an origin point and a normal
  73555. * @param origin origin of the plane to be constructed
  73556. * @param normal normal of the plane to be constructed
  73557. * @returns a new Plane the normal vector to this plane at the given origin point.
  73558. * Note : the vector "normal" is updated because normalized.
  73559. */
  73560. Plane.FromPositionAndNormal = function (origin, normal) {
  73561. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  73562. normal.normalize();
  73563. result.normal = normal;
  73564. result.d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  73565. return result;
  73566. };
  73567. /**
  73568. * Calculates the distance from a plane and a point
  73569. * @param origin origin of the plane to be constructed
  73570. * @param normal normal of the plane to be constructed
  73571. * @param point point to calculate distance to
  73572. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73573. */
  73574. Plane.SignedDistanceToPlaneFromPositionAndNormal = function (origin, normal, point) {
  73575. var d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  73576. return Vector3.Dot(point, normal) + d;
  73577. };
  73578. return Plane;
  73579. }());
  73580. /**
  73581. * Class used to represent a viewport on screen
  73582. */
  73583. var Viewport = /** @class */ (function () {
  73584. /**
  73585. * Creates a Viewport object located at (x, y) and sized (width, height)
  73586. * @param x defines viewport left coordinate
  73587. * @param y defines viewport top coordinate
  73588. * @param width defines the viewport width
  73589. * @param height defines the viewport height
  73590. */
  73591. function Viewport(
  73592. /** viewport left coordinate */
  73593. x,
  73594. /** viewport top coordinate */
  73595. y,
  73596. /**viewport width */
  73597. width,
  73598. /** viewport height */
  73599. height) {
  73600. this.x = x;
  73601. this.y = y;
  73602. this.width = width;
  73603. this.height = height;
  73604. }
  73605. /**
  73606. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  73607. * @param renderWidth defines the rendering width
  73608. * @param renderHeight defines the rendering height
  73609. * @returns a new Viewport
  73610. */
  73611. Viewport.prototype.toGlobal = function (renderWidth, renderHeight) {
  73612. return new Viewport(this.x * renderWidth, this.y * renderHeight, this.width * renderWidth, this.height * renderHeight);
  73613. };
  73614. /**
  73615. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  73616. * @param renderWidth defines the rendering width
  73617. * @param renderHeight defines the rendering height
  73618. * @param ref defines the target viewport
  73619. * @returns the current viewport
  73620. */
  73621. Viewport.prototype.toGlobalToRef = function (renderWidth, renderHeight, ref) {
  73622. ref.x = this.x * renderWidth;
  73623. ref.y = this.y * renderHeight;
  73624. ref.width = this.width * renderWidth;
  73625. ref.height = this.height * renderHeight;
  73626. return this;
  73627. };
  73628. /**
  73629. * Returns a new Viewport copied from the current one
  73630. * @returns a new Viewport
  73631. */
  73632. Viewport.prototype.clone = function () {
  73633. return new Viewport(this.x, this.y, this.width, this.height);
  73634. };
  73635. return Viewport;
  73636. }());
  73637. /**
  73638. * Reprasents a camera frustum
  73639. */
  73640. var Frustum = /** @class */ (function () {
  73641. function Frustum() {
  73642. }
  73643. /**
  73644. * Gets the planes representing the frustum
  73645. * @param transform matrix to be applied to the returned planes
  73646. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  73647. */
  73648. Frustum.GetPlanes = function (transform) {
  73649. var frustumPlanes = [];
  73650. for (var index = 0; index < 6; index++) {
  73651. frustumPlanes.push(new Plane(0.0, 0.0, 0.0, 0.0));
  73652. }
  73653. Frustum.GetPlanesToRef(transform, frustumPlanes);
  73654. return frustumPlanes;
  73655. };
  73656. /**
  73657. * Gets the near frustum plane transformed by the transform matrix
  73658. * @param transform transformation matrix to be applied to the resulting frustum plane
  73659. * @param frustumPlane the resuling frustum plane
  73660. */
  73661. Frustum.GetNearPlaneToRef = function (transform, frustumPlane) {
  73662. var m = transform.m;
  73663. frustumPlane.normal.x = m[3] + m[2];
  73664. frustumPlane.normal.y = m[7] + m[6];
  73665. frustumPlane.normal.z = m[11] + m[10];
  73666. frustumPlane.d = m[15] + m[14];
  73667. frustumPlane.normalize();
  73668. };
  73669. /**
  73670. * Gets the far frustum plane transformed by the transform matrix
  73671. * @param transform transformation matrix to be applied to the resulting frustum plane
  73672. * @param frustumPlane the resuling frustum plane
  73673. */
  73674. Frustum.GetFarPlaneToRef = function (transform, frustumPlane) {
  73675. var m = transform.m;
  73676. frustumPlane.normal.x = m[3] - m[2];
  73677. frustumPlane.normal.y = m[7] - m[6];
  73678. frustumPlane.normal.z = m[11] - m[10];
  73679. frustumPlane.d = m[15] - m[14];
  73680. frustumPlane.normalize();
  73681. };
  73682. /**
  73683. * Gets the left frustum plane transformed by the transform matrix
  73684. * @param transform transformation matrix to be applied to the resulting frustum plane
  73685. * @param frustumPlane the resuling frustum plane
  73686. */
  73687. Frustum.GetLeftPlaneToRef = function (transform, frustumPlane) {
  73688. var m = transform.m;
  73689. frustumPlane.normal.x = m[3] + m[0];
  73690. frustumPlane.normal.y = m[7] + m[4];
  73691. frustumPlane.normal.z = m[11] + m[8];
  73692. frustumPlane.d = m[15] + m[12];
  73693. frustumPlane.normalize();
  73694. };
  73695. /**
  73696. * Gets the right frustum plane transformed by the transform matrix
  73697. * @param transform transformation matrix to be applied to the resulting frustum plane
  73698. * @param frustumPlane the resuling frustum plane
  73699. */
  73700. Frustum.GetRightPlaneToRef = function (transform, frustumPlane) {
  73701. var m = transform.m;
  73702. frustumPlane.normal.x = m[3] - m[0];
  73703. frustumPlane.normal.y = m[7] - m[4];
  73704. frustumPlane.normal.z = m[11] - m[8];
  73705. frustumPlane.d = m[15] - m[12];
  73706. frustumPlane.normalize();
  73707. };
  73708. /**
  73709. * Gets the top frustum plane transformed by the transform matrix
  73710. * @param transform transformation matrix to be applied to the resulting frustum plane
  73711. * @param frustumPlane the resuling frustum plane
  73712. */
  73713. Frustum.GetTopPlaneToRef = function (transform, frustumPlane) {
  73714. var m = transform.m;
  73715. frustumPlane.normal.x = m[3] - m[1];
  73716. frustumPlane.normal.y = m[7] - m[5];
  73717. frustumPlane.normal.z = m[11] - m[9];
  73718. frustumPlane.d = m[15] - m[13];
  73719. frustumPlane.normalize();
  73720. };
  73721. /**
  73722. * Gets the bottom frustum plane transformed by the transform matrix
  73723. * @param transform transformation matrix to be applied to the resulting frustum plane
  73724. * @param frustumPlane the resuling frustum plane
  73725. */
  73726. Frustum.GetBottomPlaneToRef = function (transform, frustumPlane) {
  73727. var m = transform.m;
  73728. frustumPlane.normal.x = m[3] + m[1];
  73729. frustumPlane.normal.y = m[7] + m[5];
  73730. frustumPlane.normal.z = m[11] + m[9];
  73731. frustumPlane.d = m[15] + m[13];
  73732. frustumPlane.normalize();
  73733. };
  73734. /**
  73735. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  73736. * @param transform transformation matrix to be applied to the resulting frustum planes
  73737. * @param frustumPlanes the resuling frustum planes
  73738. */
  73739. Frustum.GetPlanesToRef = function (transform, frustumPlanes) {
  73740. // Near
  73741. Frustum.GetNearPlaneToRef(transform, frustumPlanes[0]);
  73742. // Far
  73743. Frustum.GetFarPlaneToRef(transform, frustumPlanes[1]);
  73744. // Left
  73745. Frustum.GetLeftPlaneToRef(transform, frustumPlanes[2]);
  73746. // Right
  73747. Frustum.GetRightPlaneToRef(transform, frustumPlanes[3]);
  73748. // Top
  73749. Frustum.GetTopPlaneToRef(transform, frustumPlanes[4]);
  73750. // Bottom
  73751. Frustum.GetBottomPlaneToRef(transform, frustumPlanes[5]);
  73752. };
  73753. return Frustum;
  73754. }());
  73755. /** Defines supported spaces */
  73756. var Space;
  73757. (function (Space) {
  73758. /** Local (object) space */
  73759. Space[Space["LOCAL"] = 0] = "LOCAL";
  73760. /** World space */
  73761. Space[Space["WORLD"] = 1] = "WORLD";
  73762. /** Bone space */
  73763. Space[Space["BONE"] = 2] = "BONE";
  73764. })(Space || (Space = {}));
  73765. /** Defines the 3 main axes */
  73766. var Axis = /** @class */ (function () {
  73767. function Axis() {
  73768. }
  73769. /** X axis */
  73770. Axis.X = new Vector3(1.0, 0.0, 0.0);
  73771. /** Y axis */
  73772. Axis.Y = new Vector3(0.0, 1.0, 0.0);
  73773. /** Z axis */
  73774. Axis.Z = new Vector3(0.0, 0.0, 1.0);
  73775. return Axis;
  73776. }());
  73777. /** Class used to represent a Bezier curve */
  73778. var BezierCurve = /** @class */ (function () {
  73779. function BezierCurve() {
  73780. }
  73781. /**
  73782. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  73783. * @param t defines the time
  73784. * @param x1 defines the left coordinate on X axis
  73785. * @param y1 defines the left coordinate on Y axis
  73786. * @param x2 defines the right coordinate on X axis
  73787. * @param y2 defines the right coordinate on Y axis
  73788. * @returns the interpolated value
  73789. */
  73790. BezierCurve.Interpolate = function (t, x1, y1, x2, y2) {
  73791. // Extract X (which is equal to time here)
  73792. var f0 = 1 - 3 * x2 + 3 * x1;
  73793. var f1 = 3 * x2 - 6 * x1;
  73794. var f2 = 3 * x1;
  73795. var refinedT = t;
  73796. for (var i = 0; i < 5; i++) {
  73797. var refinedT2 = refinedT * refinedT;
  73798. var refinedT3 = refinedT2 * refinedT;
  73799. var x = f0 * refinedT3 + f1 * refinedT2 + f2 * refinedT;
  73800. var slope = 1.0 / (3.0 * f0 * refinedT2 + 2.0 * f1 * refinedT + f2);
  73801. refinedT -= (x - t) * slope;
  73802. refinedT = Math.min(1, Math.max(0, refinedT));
  73803. }
  73804. // Resolve cubic bezier for the given x
  73805. return 3 * Math.pow(1 - refinedT, 2) * refinedT * y1 +
  73806. 3 * (1 - refinedT) * Math.pow(refinedT, 2) * y2 +
  73807. Math.pow(refinedT, 3);
  73808. };
  73809. return BezierCurve;
  73810. }());
  73811. /**
  73812. * Defines potential orientation for back face culling
  73813. */
  73814. var Orientation;
  73815. (function (Orientation) {
  73816. /**
  73817. * Clockwise
  73818. */
  73819. Orientation[Orientation["CW"] = 0] = "CW";
  73820. /** Counter clockwise */
  73821. Orientation[Orientation["CCW"] = 1] = "CCW";
  73822. })(Orientation || (Orientation = {}));
  73823. /**
  73824. * Defines angle representation
  73825. */
  73826. var Angle = /** @class */ (function () {
  73827. /**
  73828. * Creates an Angle object of "radians" radians (float).
  73829. * @param radians the angle in radians
  73830. */
  73831. function Angle(radians) {
  73832. this._radians = radians;
  73833. if (this._radians < 0.0) {
  73834. this._radians += (2.0 * Math.PI);
  73835. }
  73836. }
  73837. /**
  73838. * Get value in degrees
  73839. * @returns the Angle value in degrees (float)
  73840. */
  73841. Angle.prototype.degrees = function () {
  73842. return this._radians * 180.0 / Math.PI;
  73843. };
  73844. /**
  73845. * Get value in radians
  73846. * @returns the Angle value in radians (float)
  73847. */
  73848. Angle.prototype.radians = function () {
  73849. return this._radians;
  73850. };
  73851. /**
  73852. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  73853. * @param a defines first vector
  73854. * @param b defines second vector
  73855. * @returns a new Angle
  73856. */
  73857. Angle.BetweenTwoPoints = function (a, b) {
  73858. var delta = b.subtract(a);
  73859. var theta = Math.atan2(delta.y, delta.x);
  73860. return new Angle(theta);
  73861. };
  73862. /**
  73863. * Gets a new Angle object from the given float in radians
  73864. * @param radians defines the angle value in radians
  73865. * @returns a new Angle
  73866. */
  73867. Angle.FromRadians = function (radians) {
  73868. return new Angle(radians);
  73869. };
  73870. /**
  73871. * Gets a new Angle object from the given float in degrees
  73872. * @param degrees defines the angle value in degrees
  73873. * @returns a new Angle
  73874. */
  73875. Angle.FromDegrees = function (degrees) {
  73876. return new Angle(degrees * Math.PI / 180.0);
  73877. };
  73878. return Angle;
  73879. }());
  73880. /**
  73881. * This represents an arc in a 2d space.
  73882. */
  73883. var Arc2 = /** @class */ (function () {
  73884. /**
  73885. * Creates an Arc object from the three given points : start, middle and end.
  73886. * @param startPoint Defines the start point of the arc
  73887. * @param midPoint Defines the midlle point of the arc
  73888. * @param endPoint Defines the end point of the arc
  73889. */
  73890. function Arc2(
  73891. /** Defines the start point of the arc */
  73892. startPoint,
  73893. /** Defines the mid point of the arc */
  73894. midPoint,
  73895. /** Defines the end point of the arc */
  73896. endPoint) {
  73897. this.startPoint = startPoint;
  73898. this.midPoint = midPoint;
  73899. this.endPoint = endPoint;
  73900. var temp = Math.pow(midPoint.x, 2) + Math.pow(midPoint.y, 2);
  73901. var startToMid = (Math.pow(startPoint.x, 2) + Math.pow(startPoint.y, 2) - temp) / 2.;
  73902. var midToEnd = (temp - Math.pow(endPoint.x, 2) - Math.pow(endPoint.y, 2)) / 2.;
  73903. var det = (startPoint.x - midPoint.x) * (midPoint.y - endPoint.y) - (midPoint.x - endPoint.x) * (startPoint.y - midPoint.y);
  73904. 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);
  73905. this.radius = this.centerPoint.subtract(this.startPoint).length();
  73906. this.startAngle = Angle.BetweenTwoPoints(this.centerPoint, this.startPoint);
  73907. var a1 = this.startAngle.degrees();
  73908. var a2 = Angle.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees();
  73909. var a3 = Angle.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
  73910. // angles correction
  73911. if (a2 - a1 > +180.0) {
  73912. a2 -= 360.0;
  73913. }
  73914. if (a2 - a1 < -180.0) {
  73915. a2 += 360.0;
  73916. }
  73917. if (a3 - a2 > +180.0) {
  73918. a3 -= 360.0;
  73919. }
  73920. if (a3 - a2 < -180.0) {
  73921. a3 += 360.0;
  73922. }
  73923. this.orientation = (a2 - a1) < 0 ? Orientation.CW : Orientation.CCW;
  73924. this.angle = Angle.FromDegrees(this.orientation === Orientation.CW ? a1 - a3 : a3 - a1);
  73925. }
  73926. return Arc2;
  73927. }());
  73928. /**
  73929. * Represents a 2D path made up of multiple 2D points
  73930. */
  73931. var Path2 = /** @class */ (function () {
  73932. /**
  73933. * Creates a Path2 object from the starting 2D coordinates x and y.
  73934. * @param x the starting points x value
  73935. * @param y the starting points y value
  73936. */
  73937. function Path2(x, y) {
  73938. this._points = new Array();
  73939. this._length = 0.0;
  73940. /**
  73941. * If the path start and end point are the same
  73942. */
  73943. this.closed = false;
  73944. this._points.push(new Vector2(x, y));
  73945. }
  73946. /**
  73947. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  73948. * @param x the added points x value
  73949. * @param y the added points y value
  73950. * @returns the updated Path2.
  73951. */
  73952. Path2.prototype.addLineTo = function (x, y) {
  73953. if (this.closed) {
  73954. return this;
  73955. }
  73956. var newPoint = new Vector2(x, y);
  73957. var previousPoint = this._points[this._points.length - 1];
  73958. this._points.push(newPoint);
  73959. this._length += newPoint.subtract(previousPoint).length();
  73960. return this;
  73961. };
  73962. /**
  73963. * 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.
  73964. * @param midX middle point x value
  73965. * @param midY middle point y value
  73966. * @param endX end point x value
  73967. * @param endY end point y value
  73968. * @param numberOfSegments (default: 36)
  73969. * @returns the updated Path2.
  73970. */
  73971. Path2.prototype.addArcTo = function (midX, midY, endX, endY, numberOfSegments) {
  73972. if (numberOfSegments === void 0) { numberOfSegments = 36; }
  73973. if (this.closed) {
  73974. return this;
  73975. }
  73976. var startPoint = this._points[this._points.length - 1];
  73977. var midPoint = new Vector2(midX, midY);
  73978. var endPoint = new Vector2(endX, endY);
  73979. var arc = new Arc2(startPoint, midPoint, endPoint);
  73980. var increment = arc.angle.radians() / numberOfSegments;
  73981. if (arc.orientation === Orientation.CW) {
  73982. increment *= -1;
  73983. }
  73984. var currentAngle = arc.startAngle.radians() + increment;
  73985. for (var i = 0; i < numberOfSegments; i++) {
  73986. var x = Math.cos(currentAngle) * arc.radius + arc.centerPoint.x;
  73987. var y = Math.sin(currentAngle) * arc.radius + arc.centerPoint.y;
  73988. this.addLineTo(x, y);
  73989. currentAngle += increment;
  73990. }
  73991. return this;
  73992. };
  73993. /**
  73994. * Closes the Path2.
  73995. * @returns the Path2.
  73996. */
  73997. Path2.prototype.close = function () {
  73998. this.closed = true;
  73999. return this;
  74000. };
  74001. /**
  74002. * Gets the sum of the distance between each sequential point in the path
  74003. * @returns the Path2 total length (float).
  74004. */
  74005. Path2.prototype.length = function () {
  74006. var result = this._length;
  74007. if (!this.closed) {
  74008. var lastPoint = this._points[this._points.length - 1];
  74009. var firstPoint = this._points[0];
  74010. result += (firstPoint.subtract(lastPoint).length());
  74011. }
  74012. return result;
  74013. };
  74014. /**
  74015. * Gets the points which construct the path
  74016. * @returns the Path2 internal array of points.
  74017. */
  74018. Path2.prototype.getPoints = function () {
  74019. return this._points;
  74020. };
  74021. /**
  74022. * Retreives the point at the distance aways from the starting point
  74023. * @param normalizedLengthPosition the length along the path to retreive the point from
  74024. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  74025. */
  74026. Path2.prototype.getPointAtLengthPosition = function (normalizedLengthPosition) {
  74027. if (normalizedLengthPosition < 0 || normalizedLengthPosition > 1) {
  74028. return Vector2.Zero();
  74029. }
  74030. var lengthPosition = normalizedLengthPosition * this.length();
  74031. var previousOffset = 0;
  74032. for (var i = 0; i < this._points.length; i++) {
  74033. var j = (i + 1) % this._points.length;
  74034. var a = this._points[i];
  74035. var b = this._points[j];
  74036. var bToA = b.subtract(a);
  74037. var nextOffset = (bToA.length() + previousOffset);
  74038. if (lengthPosition >= previousOffset && lengthPosition <= nextOffset) {
  74039. var dir = bToA.normalize();
  74040. var localOffset = lengthPosition - previousOffset;
  74041. return new Vector2(a.x + (dir.x * localOffset), a.y + (dir.y * localOffset));
  74042. }
  74043. previousOffset = nextOffset;
  74044. }
  74045. return Vector2.Zero();
  74046. };
  74047. /**
  74048. * Creates a new path starting from an x and y position
  74049. * @param x starting x value
  74050. * @param y starting y value
  74051. * @returns a new Path2 starting at the coordinates (x, y).
  74052. */
  74053. Path2.StartingAt = function (x, y) {
  74054. return new Path2(x, y);
  74055. };
  74056. return Path2;
  74057. }());
  74058. /**
  74059. * Represents a 3D path made up of multiple 3D points
  74060. */
  74061. var Path3D = /** @class */ (function () {
  74062. /**
  74063. * new Path3D(path, normal, raw)
  74064. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  74065. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  74066. * @param path an array of Vector3, the curve axis of the Path3D
  74067. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  74068. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  74069. */
  74070. function Path3D(
  74071. /**
  74072. * an array of Vector3, the curve axis of the Path3D
  74073. */
  74074. path, firstNormal, raw) {
  74075. if (firstNormal === void 0) { firstNormal = null; }
  74076. this.path = path;
  74077. this._curve = new Array();
  74078. this._distances = new Array();
  74079. this._tangents = new Array();
  74080. this._normals = new Array();
  74081. this._binormals = new Array();
  74082. for (var p = 0; p < path.length; p++) {
  74083. this._curve[p] = path[p].clone(); // hard copy
  74084. }
  74085. this._raw = raw || false;
  74086. this._compute(firstNormal);
  74087. }
  74088. /**
  74089. * Returns the Path3D array of successive Vector3 designing its curve.
  74090. * @returns the Path3D array of successive Vector3 designing its curve.
  74091. */
  74092. Path3D.prototype.getCurve = function () {
  74093. return this._curve;
  74094. };
  74095. /**
  74096. * Returns an array populated with tangent vectors on each Path3D curve point.
  74097. * @returns an array populated with tangent vectors on each Path3D curve point.
  74098. */
  74099. Path3D.prototype.getTangents = function () {
  74100. return this._tangents;
  74101. };
  74102. /**
  74103. * Returns an array populated with normal vectors on each Path3D curve point.
  74104. * @returns an array populated with normal vectors on each Path3D curve point.
  74105. */
  74106. Path3D.prototype.getNormals = function () {
  74107. return this._normals;
  74108. };
  74109. /**
  74110. * Returns an array populated with binormal vectors on each Path3D curve point.
  74111. * @returns an array populated with binormal vectors on each Path3D curve point.
  74112. */
  74113. Path3D.prototype.getBinormals = function () {
  74114. return this._binormals;
  74115. };
  74116. /**
  74117. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  74118. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  74119. */
  74120. Path3D.prototype.getDistances = function () {
  74121. return this._distances;
  74122. };
  74123. /**
  74124. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  74125. * @param path path which all values are copied into the curves points
  74126. * @param firstNormal which should be projected onto the curve
  74127. * @returns the same object updated.
  74128. */
  74129. Path3D.prototype.update = function (path, firstNormal) {
  74130. if (firstNormal === void 0) { firstNormal = null; }
  74131. for (var p = 0; p < path.length; p++) {
  74132. this._curve[p].x = path[p].x;
  74133. this._curve[p].y = path[p].y;
  74134. this._curve[p].z = path[p].z;
  74135. }
  74136. this._compute(firstNormal);
  74137. return this;
  74138. };
  74139. // private function compute() : computes tangents, normals and binormals
  74140. Path3D.prototype._compute = function (firstNormal) {
  74141. var l = this._curve.length;
  74142. // first and last tangents
  74143. this._tangents[0] = this._getFirstNonNullVector(0);
  74144. if (!this._raw) {
  74145. this._tangents[0].normalize();
  74146. }
  74147. this._tangents[l - 1] = this._curve[l - 1].subtract(this._curve[l - 2]);
  74148. if (!this._raw) {
  74149. this._tangents[l - 1].normalize();
  74150. }
  74151. // normals and binormals at first point : arbitrary vector with _normalVector()
  74152. var tg0 = this._tangents[0];
  74153. var pp0 = this._normalVector(tg0, firstNormal);
  74154. this._normals[0] = pp0;
  74155. if (!this._raw) {
  74156. this._normals[0].normalize();
  74157. }
  74158. this._binormals[0] = Vector3.Cross(tg0, this._normals[0]);
  74159. if (!this._raw) {
  74160. this._binormals[0].normalize();
  74161. }
  74162. this._distances[0] = 0.0;
  74163. // normals and binormals : next points
  74164. var prev; // previous vector (segment)
  74165. var cur; // current vector (segment)
  74166. var curTang; // current tangent
  74167. // previous normal
  74168. var prevBinor; // previous binormal
  74169. for (var i = 1; i < l; i++) {
  74170. // tangents
  74171. prev = this._getLastNonNullVector(i);
  74172. if (i < l - 1) {
  74173. cur = this._getFirstNonNullVector(i);
  74174. this._tangents[i] = prev.add(cur);
  74175. this._tangents[i].normalize();
  74176. }
  74177. this._distances[i] = this._distances[i - 1] + prev.length();
  74178. // normals and binormals
  74179. // http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html
  74180. curTang = this._tangents[i];
  74181. prevBinor = this._binormals[i - 1];
  74182. this._normals[i] = Vector3.Cross(prevBinor, curTang);
  74183. if (!this._raw) {
  74184. this._normals[i].normalize();
  74185. }
  74186. this._binormals[i] = Vector3.Cross(curTang, this._normals[i]);
  74187. if (!this._raw) {
  74188. this._binormals[i].normalize();
  74189. }
  74190. }
  74191. };
  74192. // private function getFirstNonNullVector(index)
  74193. // returns the first non null vector from index : curve[index + N].subtract(curve[index])
  74194. Path3D.prototype._getFirstNonNullVector = function (index) {
  74195. var i = 1;
  74196. var nNVector = this._curve[index + i].subtract(this._curve[index]);
  74197. while (nNVector.length() === 0 && index + i + 1 < this._curve.length) {
  74198. i++;
  74199. nNVector = this._curve[index + i].subtract(this._curve[index]);
  74200. }
  74201. return nNVector;
  74202. };
  74203. // private function getLastNonNullVector(index)
  74204. // returns the last non null vector from index : curve[index].subtract(curve[index - N])
  74205. Path3D.prototype._getLastNonNullVector = function (index) {
  74206. var i = 1;
  74207. var nLVector = this._curve[index].subtract(this._curve[index - i]);
  74208. while (nLVector.length() === 0 && index > i + 1) {
  74209. i++;
  74210. nLVector = this._curve[index].subtract(this._curve[index - i]);
  74211. }
  74212. return nLVector;
  74213. };
  74214. // private function normalVector(v0, vt, va) :
  74215. // returns an arbitrary point in the plane defined by the point v0 and the vector vt orthogonal to this plane
  74216. // if va is passed, it returns the va projection on the plane orthogonal to vt at the point v0
  74217. Path3D.prototype._normalVector = function (vt, va) {
  74218. var normal0;
  74219. var tgl = vt.length();
  74220. if (tgl === 0.0) {
  74221. tgl = 1.0;
  74222. }
  74223. if (va === undefined || va === null) {
  74224. var point;
  74225. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.y) / tgl, 1.0, Epsilon)) { // search for a point in the plane
  74226. point = new Vector3(0.0, -1.0, 0.0);
  74227. }
  74228. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.x) / tgl, 1.0, Epsilon)) {
  74229. point = new Vector3(1.0, 0.0, 0.0);
  74230. }
  74231. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.z) / tgl, 1.0, Epsilon)) {
  74232. point = new Vector3(0.0, 0.0, 1.0);
  74233. }
  74234. else {
  74235. point = Vector3.Zero();
  74236. }
  74237. normal0 = Vector3.Cross(vt, point);
  74238. }
  74239. else {
  74240. normal0 = Vector3.Cross(vt, va);
  74241. Vector3.CrossToRef(normal0, vt, normal0);
  74242. }
  74243. normal0.normalize();
  74244. return normal0;
  74245. };
  74246. return Path3D;
  74247. }());
  74248. /**
  74249. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  74250. * A Curve3 is designed from a series of successive Vector3.
  74251. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  74252. */
  74253. var Curve3 = /** @class */ (function () {
  74254. /**
  74255. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  74256. * A Curve3 is designed from a series of successive Vector3.
  74257. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  74258. * @param points points which make up the curve
  74259. */
  74260. function Curve3(points) {
  74261. this._length = 0.0;
  74262. this._points = points;
  74263. this._length = this._computeLength(points);
  74264. }
  74265. /**
  74266. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  74267. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  74268. * @param v1 (Vector3) the control point
  74269. * @param v2 (Vector3) the end point of the Quadratic Bezier
  74270. * @param nbPoints (integer) the wanted number of points in the curve
  74271. * @returns the created Curve3
  74272. */
  74273. Curve3.CreateQuadraticBezier = function (v0, v1, v2, nbPoints) {
  74274. nbPoints = nbPoints > 2 ? nbPoints : 3;
  74275. var bez = new Array();
  74276. var equation = function (t, val0, val1, val2) {
  74277. var res = (1.0 - t) * (1.0 - t) * val0 + 2.0 * t * (1.0 - t) * val1 + t * t * val2;
  74278. return res;
  74279. };
  74280. for (var i = 0; i <= nbPoints; i++) {
  74281. 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)));
  74282. }
  74283. return new Curve3(bez);
  74284. };
  74285. /**
  74286. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  74287. * @param v0 (Vector3) the origin point of the Cubic Bezier
  74288. * @param v1 (Vector3) the first control point
  74289. * @param v2 (Vector3) the second control point
  74290. * @param v3 (Vector3) the end point of the Cubic Bezier
  74291. * @param nbPoints (integer) the wanted number of points in the curve
  74292. * @returns the created Curve3
  74293. */
  74294. Curve3.CreateCubicBezier = function (v0, v1, v2, v3, nbPoints) {
  74295. nbPoints = nbPoints > 3 ? nbPoints : 4;
  74296. var bez = new Array();
  74297. var equation = function (t, val0, val1, val2, val3) {
  74298. 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;
  74299. return res;
  74300. };
  74301. for (var i = 0; i <= nbPoints; i++) {
  74302. 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)));
  74303. }
  74304. return new Curve3(bez);
  74305. };
  74306. /**
  74307. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  74308. * @param p1 (Vector3) the origin point of the Hermite Spline
  74309. * @param t1 (Vector3) the tangent vector at the origin point
  74310. * @param p2 (Vector3) the end point of the Hermite Spline
  74311. * @param t2 (Vector3) the tangent vector at the end point
  74312. * @param nbPoints (integer) the wanted number of points in the curve
  74313. * @returns the created Curve3
  74314. */
  74315. Curve3.CreateHermiteSpline = function (p1, t1, p2, t2, nbPoints) {
  74316. var hermite = new Array();
  74317. var step = 1.0 / nbPoints;
  74318. for (var i = 0; i <= nbPoints; i++) {
  74319. hermite.push(Vector3.Hermite(p1, t1, p2, t2, i * step));
  74320. }
  74321. return new Curve3(hermite);
  74322. };
  74323. /**
  74324. * Returns a Curve3 object along a CatmullRom Spline curve :
  74325. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  74326. * @param nbPoints (integer) the wanted number of points between each curve control points
  74327. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  74328. * @returns the created Curve3
  74329. */
  74330. Curve3.CreateCatmullRomSpline = function (points, nbPoints, closed) {
  74331. var catmullRom = new Array();
  74332. var step = 1.0 / nbPoints;
  74333. var amount = 0.0;
  74334. if (closed) {
  74335. var pointsCount = points.length;
  74336. for (var i = 0; i < pointsCount; i++) {
  74337. amount = 0;
  74338. for (var c = 0; c < nbPoints; c++) {
  74339. catmullRom.push(Vector3.CatmullRom(points[i % pointsCount], points[(i + 1) % pointsCount], points[(i + 2) % pointsCount], points[(i + 3) % pointsCount], amount));
  74340. amount += step;
  74341. }
  74342. }
  74343. catmullRom.push(catmullRom[0]);
  74344. }
  74345. else {
  74346. var totalPoints = new Array();
  74347. totalPoints.push(points[0].clone());
  74348. Array.prototype.push.apply(totalPoints, points);
  74349. totalPoints.push(points[points.length - 1].clone());
  74350. for (var i = 0; i < totalPoints.length - 3; i++) {
  74351. amount = 0;
  74352. for (var c = 0; c < nbPoints; c++) {
  74353. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  74354. amount += step;
  74355. }
  74356. }
  74357. i--;
  74358. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  74359. }
  74360. return new Curve3(catmullRom);
  74361. };
  74362. /**
  74363. * @returns the Curve3 stored array of successive Vector3
  74364. */
  74365. Curve3.prototype.getPoints = function () {
  74366. return this._points;
  74367. };
  74368. /**
  74369. * @returns the computed length (float) of the curve.
  74370. */
  74371. Curve3.prototype.length = function () {
  74372. return this._length;
  74373. };
  74374. /**
  74375. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  74376. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  74377. * curveA and curveB keep unchanged.
  74378. * @param curve the curve to continue from this curve
  74379. * @returns the newly constructed curve
  74380. */
  74381. Curve3.prototype.continue = function (curve) {
  74382. var lastPoint = this._points[this._points.length - 1];
  74383. var continuedPoints = this._points.slice();
  74384. var curvePoints = curve.getPoints();
  74385. for (var i = 1; i < curvePoints.length; i++) {
  74386. continuedPoints.push(curvePoints[i].subtract(curvePoints[0]).add(lastPoint));
  74387. }
  74388. var continuedCurve = new Curve3(continuedPoints);
  74389. return continuedCurve;
  74390. };
  74391. Curve3.prototype._computeLength = function (path) {
  74392. var l = 0;
  74393. for (var i = 1; i < path.length; i++) {
  74394. l += (path[i].subtract(path[i - 1])).length();
  74395. }
  74396. return l;
  74397. };
  74398. return Curve3;
  74399. }());
  74400. // Vertex formats
  74401. /**
  74402. * Contains position and normal vectors for a vertex
  74403. */
  74404. var PositionNormalVertex = /** @class */ (function () {
  74405. /**
  74406. * Creates a PositionNormalVertex
  74407. * @param position the position of the vertex (defaut: 0,0,0)
  74408. * @param normal the normal of the vertex (defaut: 0,1,0)
  74409. */
  74410. function PositionNormalVertex(
  74411. /** the position of the vertex (defaut: 0,0,0) */
  74412. position,
  74413. /** the normal of the vertex (defaut: 0,1,0) */
  74414. normal) {
  74415. if (position === void 0) { position = Vector3.Zero(); }
  74416. if (normal === void 0) { normal = Vector3.Up(); }
  74417. this.position = position;
  74418. this.normal = normal;
  74419. }
  74420. /**
  74421. * Clones the PositionNormalVertex
  74422. * @returns the cloned PositionNormalVertex
  74423. */
  74424. PositionNormalVertex.prototype.clone = function () {
  74425. return new PositionNormalVertex(this.position.clone(), this.normal.clone());
  74426. };
  74427. return PositionNormalVertex;
  74428. }());
  74429. /**
  74430. * Contains position, normal and uv vectors for a vertex
  74431. */
  74432. var PositionNormalTextureVertex = /** @class */ (function () {
  74433. /**
  74434. * Creates a PositionNormalTextureVertex
  74435. * @param position the position of the vertex (defaut: 0,0,0)
  74436. * @param normal the normal of the vertex (defaut: 0,1,0)
  74437. * @param uv the uv of the vertex (default: 0,0)
  74438. */
  74439. function PositionNormalTextureVertex(
  74440. /** the position of the vertex (defaut: 0,0,0) */
  74441. position,
  74442. /** the normal of the vertex (defaut: 0,1,0) */
  74443. normal,
  74444. /** the uv of the vertex (default: 0,0) */
  74445. uv) {
  74446. if (position === void 0) { position = Vector3.Zero(); }
  74447. if (normal === void 0) { normal = Vector3.Up(); }
  74448. if (uv === void 0) { uv = Vector2.Zero(); }
  74449. this.position = position;
  74450. this.normal = normal;
  74451. this.uv = uv;
  74452. }
  74453. /**
  74454. * Clones the PositionNormalTextureVertex
  74455. * @returns the cloned PositionNormalTextureVertex
  74456. */
  74457. PositionNormalTextureVertex.prototype.clone = function () {
  74458. return new PositionNormalTextureVertex(this.position.clone(), this.normal.clone(), this.uv.clone());
  74459. };
  74460. return PositionNormalTextureVertex;
  74461. }());
  74462. // Temporary pre-allocated objects for engine internal use
  74463. // usage in any internal function :
  74464. // var tmp = Tmp.Vector3[0]; <= gets access to the first pre-created Vector3
  74465. // There's a Tmp array per object type : int, float, Vector2, Vector3, Vector4, Quaternion, Matrix
  74466. /**
  74467. * @hidden
  74468. */
  74469. var Tmp = /** @class */ (function () {
  74470. function Tmp() {
  74471. }
  74472. Tmp.Color3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Color3.Black);
  74473. Tmp.Color4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, function () { return new Color4(0, 0, 0, 0); });
  74474. Tmp.Vector2 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector2.Zero); // 3 temp Vector2 at once should be enough
  74475. Tmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(13, Vector3.Zero); // 13 temp Vector3 at once should be enough
  74476. Tmp.Vector4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector4.Zero); // 3 temp Vector4 at once should be enough
  74477. Tmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Quaternion.Zero); // 2 temp Quaternion at once should be enough
  74478. Tmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, Matrix.Identity); // 8 temp Matrices at once should be enough
  74479. return Tmp;
  74480. }());
  74481. /**
  74482. * @hidden
  74483. * Same as Tmp but not exported to keep it only for math functions to avoid conflicts
  74484. */
  74485. var MathTmp = /** @class */ (function () {
  74486. function MathTmp() {
  74487. }
  74488. MathTmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, Vector3.Zero);
  74489. MathTmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Matrix.Identity);
  74490. MathTmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Quaternion.Zero);
  74491. return MathTmp;
  74492. }());
  74493. /***/ }),
  74494. /***/ "./Maths/sphericalPolynomial.ts":
  74495. /*!**************************************!*\
  74496. !*** ./Maths/sphericalPolynomial.ts ***!
  74497. \**************************************/
  74498. /*! exports provided: SphericalPolynomial, SphericalHarmonics */
  74499. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74500. "use strict";
  74501. __webpack_require__.r(__webpack_exports__);
  74502. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return SphericalPolynomial; });
  74503. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return SphericalHarmonics; });
  74504. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  74505. /**
  74506. * Class representing spherical polynomial coefficients to the 3rd degree
  74507. */
  74508. var SphericalPolynomial = /** @class */ (function () {
  74509. function SphericalPolynomial() {
  74510. /**
  74511. * The x coefficients of the spherical polynomial
  74512. */
  74513. this.x = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74514. /**
  74515. * The y coefficients of the spherical polynomial
  74516. */
  74517. this.y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74518. /**
  74519. * The z coefficients of the spherical polynomial
  74520. */
  74521. this.z = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74522. /**
  74523. * The xx coefficients of the spherical polynomial
  74524. */
  74525. this.xx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74526. /**
  74527. * The yy coefficients of the spherical polynomial
  74528. */
  74529. this.yy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74530. /**
  74531. * The zz coefficients of the spherical polynomial
  74532. */
  74533. this.zz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74534. /**
  74535. * The xy coefficients of the spherical polynomial
  74536. */
  74537. this.xy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74538. /**
  74539. * The yz coefficients of the spherical polynomial
  74540. */
  74541. this.yz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74542. /**
  74543. * The zx coefficients of the spherical polynomial
  74544. */
  74545. this.zx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74546. }
  74547. /**
  74548. * Adds an ambient color to the spherical polynomial
  74549. * @param color the color to add
  74550. */
  74551. SphericalPolynomial.prototype.addAmbient = function (color) {
  74552. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  74553. this.xx = this.xx.add(colorVector);
  74554. this.yy = this.yy.add(colorVector);
  74555. this.zz = this.zz.add(colorVector);
  74556. };
  74557. /**
  74558. * Scales the spherical polynomial by the given amount
  74559. * @param scale the amount to scale
  74560. */
  74561. SphericalPolynomial.prototype.scale = function (scale) {
  74562. this.x = this.x.scale(scale);
  74563. this.y = this.y.scale(scale);
  74564. this.z = this.z.scale(scale);
  74565. this.xx = this.xx.scale(scale);
  74566. this.yy = this.yy.scale(scale);
  74567. this.zz = this.zz.scale(scale);
  74568. this.yz = this.yz.scale(scale);
  74569. this.zx = this.zx.scale(scale);
  74570. this.xy = this.xy.scale(scale);
  74571. };
  74572. /**
  74573. * Gets the spherical polynomial from harmonics
  74574. * @param harmonics the spherical harmonics
  74575. * @returns the spherical polynomial
  74576. */
  74577. SphericalPolynomial.FromHarmonics = function (harmonics) {
  74578. var result = new SphericalPolynomial();
  74579. result.x = harmonics.l11.scale(1.02333);
  74580. result.y = harmonics.l1_1.scale(1.02333);
  74581. result.z = harmonics.l10.scale(1.02333);
  74582. result.xx = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).add(harmonics.lL22.scale(0.429043));
  74583. result.yy = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).subtract(harmonics.lL22.scale(0.429043));
  74584. result.zz = harmonics.l00.scale(0.886277).add(harmonics.l20.scale(0.495417));
  74585. result.yz = harmonics.l2_1.scale(0.858086);
  74586. result.zx = harmonics.l21.scale(0.858086);
  74587. result.xy = harmonics.l2_2.scale(0.858086);
  74588. result.scale(1.0 / Math.PI);
  74589. return result;
  74590. };
  74591. /**
  74592. * Constructs a spherical polynomial from an array.
  74593. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  74594. * @returns the spherical polynomial
  74595. */
  74596. SphericalPolynomial.FromArray = function (data) {
  74597. var sp = new SphericalPolynomial();
  74598. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sp.x);
  74599. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sp.y);
  74600. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sp.z);
  74601. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sp.xx);
  74602. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sp.yy);
  74603. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sp.zz);
  74604. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sp.yz);
  74605. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sp.zx);
  74606. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sp.xy);
  74607. return sp;
  74608. };
  74609. return SphericalPolynomial;
  74610. }());
  74611. /**
  74612. * Class representing spherical harmonics coefficients to the 3rd degree
  74613. */
  74614. var SphericalHarmonics = /** @class */ (function () {
  74615. function SphericalHarmonics() {
  74616. /**
  74617. * The l0,0 coefficients of the spherical harmonics
  74618. */
  74619. this.l00 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74620. /**
  74621. * The l1,-1 coefficients of the spherical harmonics
  74622. */
  74623. this.l1_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74624. /**
  74625. * The l1,0 coefficients of the spherical harmonics
  74626. */
  74627. this.l10 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74628. /**
  74629. * The l1,1 coefficients of the spherical harmonics
  74630. */
  74631. this.l11 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74632. /**
  74633. * The l2,-2 coefficients of the spherical harmonics
  74634. */
  74635. this.l2_2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74636. /**
  74637. * The l2,-1 coefficients of the spherical harmonics
  74638. */
  74639. this.l2_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74640. /**
  74641. * The l2,0 coefficients of the spherical harmonics
  74642. */
  74643. this.l20 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74644. /**
  74645. * The l2,1 coefficients of the spherical harmonics
  74646. */
  74647. this.l21 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74648. /**
  74649. * The l2,2 coefficients of the spherical harmonics
  74650. */
  74651. this.lL22 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74652. }
  74653. /**
  74654. * Adds a light to the spherical harmonics
  74655. * @param direction the direction of the light
  74656. * @param color the color of the light
  74657. * @param deltaSolidAngle the delta solid angle of the light
  74658. */
  74659. SphericalHarmonics.prototype.addLight = function (direction, color, deltaSolidAngle) {
  74660. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  74661. var c = colorVector.scale(deltaSolidAngle);
  74662. this.l00 = this.l00.add(c.scale(0.282095));
  74663. this.l1_1 = this.l1_1.add(c.scale(0.488603 * direction.y));
  74664. this.l10 = this.l10.add(c.scale(0.488603 * direction.z));
  74665. this.l11 = this.l11.add(c.scale(0.488603 * direction.x));
  74666. this.l2_2 = this.l2_2.add(c.scale(1.092548 * direction.x * direction.y));
  74667. this.l2_1 = this.l2_1.add(c.scale(1.092548 * direction.y * direction.z));
  74668. this.l21 = this.l21.add(c.scale(1.092548 * direction.x * direction.z));
  74669. this.l20 = this.l20.add(c.scale(0.315392 * (3.0 * direction.z * direction.z - 1.0)));
  74670. this.lL22 = this.lL22.add(c.scale(0.546274 * (direction.x * direction.x - direction.y * direction.y)));
  74671. };
  74672. /**
  74673. * Scales the spherical harmonics by the given amount
  74674. * @param scale the amount to scale
  74675. */
  74676. SphericalHarmonics.prototype.scale = function (scale) {
  74677. this.l00 = this.l00.scale(scale);
  74678. this.l1_1 = this.l1_1.scale(scale);
  74679. this.l10 = this.l10.scale(scale);
  74680. this.l11 = this.l11.scale(scale);
  74681. this.l2_2 = this.l2_2.scale(scale);
  74682. this.l2_1 = this.l2_1.scale(scale);
  74683. this.l20 = this.l20.scale(scale);
  74684. this.l21 = this.l21.scale(scale);
  74685. this.lL22 = this.lL22.scale(scale);
  74686. };
  74687. /**
  74688. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  74689. *
  74690. * ```
  74691. * E_lm = A_l * L_lm
  74692. * ```
  74693. *
  74694. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  74695. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  74696. * the scaling factors are given in equation 9.
  74697. */
  74698. SphericalHarmonics.prototype.convertIncidentRadianceToIrradiance = function () {
  74699. // Constant (Band 0)
  74700. this.l00 = this.l00.scale(3.141593);
  74701. // Linear (Band 1)
  74702. this.l1_1 = this.l1_1.scale(2.094395);
  74703. this.l10 = this.l10.scale(2.094395);
  74704. this.l11 = this.l11.scale(2.094395);
  74705. // Quadratic (Band 2)
  74706. this.l2_2 = this.l2_2.scale(0.785398);
  74707. this.l2_1 = this.l2_1.scale(0.785398);
  74708. this.l20 = this.l20.scale(0.785398);
  74709. this.l21 = this.l21.scale(0.785398);
  74710. this.lL22 = this.lL22.scale(0.785398);
  74711. };
  74712. /**
  74713. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  74714. *
  74715. * ```
  74716. * L = (1/pi) * E * rho
  74717. * ```
  74718. *
  74719. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  74720. */
  74721. SphericalHarmonics.prototype.convertIrradianceToLambertianRadiance = function () {
  74722. this.scale(1.0 / Math.PI);
  74723. // The resultant SH now represents outgoing radiance, so includes the Lambert 1/pi normalisation factor but without albedo (rho) applied
  74724. // (The pixel shader must apply albedo after texture fetches, etc).
  74725. };
  74726. /**
  74727. * Gets the spherical harmonics from polynomial
  74728. * @param polynomial the spherical polynomial
  74729. * @returns the spherical harmonics
  74730. */
  74731. SphericalHarmonics.FromPolynomial = function (polynomial) {
  74732. var result = new SphericalHarmonics();
  74733. result.l00 = polynomial.xx.scale(0.376127).add(polynomial.yy.scale(0.376127)).add(polynomial.zz.scale(0.376126));
  74734. result.l1_1 = polynomial.y.scale(0.977204);
  74735. result.l10 = polynomial.z.scale(0.977204);
  74736. result.l11 = polynomial.x.scale(0.977204);
  74737. result.l2_2 = polynomial.xy.scale(1.16538);
  74738. result.l2_1 = polynomial.yz.scale(1.16538);
  74739. result.l20 = polynomial.zz.scale(1.34567).subtract(polynomial.xx.scale(0.672834)).subtract(polynomial.yy.scale(0.672834));
  74740. result.l21 = polynomial.zx.scale(1.16538);
  74741. result.lL22 = polynomial.xx.scale(1.16538).subtract(polynomial.yy.scale(1.16538));
  74742. result.scale(Math.PI);
  74743. return result;
  74744. };
  74745. /**
  74746. * Constructs a spherical harmonics from an array.
  74747. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  74748. * @returns the spherical harmonics
  74749. */
  74750. SphericalHarmonics.FromArray = function (data) {
  74751. var sh = new SphericalHarmonics();
  74752. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sh.l00);
  74753. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sh.l1_1);
  74754. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sh.l10);
  74755. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sh.l11);
  74756. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sh.l2_2);
  74757. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sh.l2_1);
  74758. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sh.l20);
  74759. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sh.l21);
  74760. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sh.lL22);
  74761. return sh;
  74762. };
  74763. return SphericalHarmonics;
  74764. }());
  74765. /***/ }),
  74766. /***/ "./Meshes/Builders/boxBuilder.ts":
  74767. /*!***************************************!*\
  74768. !*** ./Meshes/Builders/boxBuilder.ts ***!
  74769. \***************************************/
  74770. /*! exports provided: BoxBuilder */
  74771. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74772. "use strict";
  74773. __webpack_require__.r(__webpack_exports__);
  74774. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return BoxBuilder; });
  74775. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  74776. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  74777. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  74778. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox = function (options) {
  74779. var normalsSource = [
  74780. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1),
  74781. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1),
  74782. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0),
  74783. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0),
  74784. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0),
  74785. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)
  74786. ];
  74787. var indices = [];
  74788. var positions = [];
  74789. var normals = [];
  74790. var uvs = [];
  74791. var width = options.width || options.size || 1;
  74792. var height = options.height || options.size || 1;
  74793. var depth = options.depth || options.size || 1;
  74794. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  74795. var faceUV = options.faceUV || new Array(6);
  74796. var faceColors = options.faceColors;
  74797. var colors = [];
  74798. // default face colors and UV if undefined
  74799. for (var f = 0; f < 6; f++) {
  74800. if (faceUV[f] === undefined) {
  74801. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  74802. }
  74803. if (faceColors && faceColors[f] === undefined) {
  74804. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  74805. }
  74806. }
  74807. var scaleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](width / 2, height / 2, depth / 2);
  74808. // Create each face in turn.
  74809. for (var index = 0; index < normalsSource.length; index++) {
  74810. var normal = normalsSource[index];
  74811. // Get two vectors perpendicular to the face normal and to each other.
  74812. var side1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normal.y, normal.z, normal.x);
  74813. var side2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(normal, side1);
  74814. // Six indices (two triangles) per face.
  74815. var verticesLength = positions.length / 3;
  74816. indices.push(verticesLength);
  74817. indices.push(verticesLength + 1);
  74818. indices.push(verticesLength + 2);
  74819. indices.push(verticesLength);
  74820. indices.push(verticesLength + 2);
  74821. indices.push(verticesLength + 3);
  74822. // Four vertices per face.
  74823. var vertex = normal.subtract(side1).subtract(side2).multiply(scaleVector);
  74824. positions.push(vertex.x, vertex.y, vertex.z);
  74825. normals.push(normal.x, normal.y, normal.z);
  74826. uvs.push(faceUV[index].z, faceUV[index].w);
  74827. if (faceColors) {
  74828. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  74829. }
  74830. vertex = normal.subtract(side1).add(side2).multiply(scaleVector);
  74831. positions.push(vertex.x, vertex.y, vertex.z);
  74832. normals.push(normal.x, normal.y, normal.z);
  74833. uvs.push(faceUV[index].x, faceUV[index].w);
  74834. if (faceColors) {
  74835. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  74836. }
  74837. vertex = normal.add(side1).add(side2).multiply(scaleVector);
  74838. positions.push(vertex.x, vertex.y, vertex.z);
  74839. normals.push(normal.x, normal.y, normal.z);
  74840. uvs.push(faceUV[index].x, faceUV[index].y);
  74841. if (faceColors) {
  74842. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  74843. }
  74844. vertex = normal.add(side1).subtract(side2).multiply(scaleVector);
  74845. positions.push(vertex.x, vertex.y, vertex.z);
  74846. normals.push(normal.x, normal.y, normal.z);
  74847. uvs.push(faceUV[index].z, faceUV[index].y);
  74848. if (faceColors) {
  74849. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  74850. }
  74851. }
  74852. // sides
  74853. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  74854. // Result
  74855. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  74856. vertexData.indices = indices;
  74857. vertexData.positions = positions;
  74858. vertexData.normals = normals;
  74859. vertexData.uvs = uvs;
  74860. if (faceColors) {
  74861. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  74862. vertexData.colors = totalColors;
  74863. }
  74864. return vertexData;
  74865. };
  74866. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateBox = function (name, size, scene, updatable, sideOrientation) {
  74867. if (scene === void 0) { scene = null; }
  74868. var options = {
  74869. size: size,
  74870. sideOrientation: sideOrientation,
  74871. updatable: updatable
  74872. };
  74873. return BoxBuilder.CreateBox(name, options, scene);
  74874. };
  74875. /**
  74876. * Class containing static functions to help procedurally build meshes
  74877. */
  74878. var BoxBuilder = /** @class */ (function () {
  74879. function BoxBuilder() {
  74880. }
  74881. /**
  74882. * Creates a box mesh
  74883. * * The parameter `size` sets the size (float) of each box side (default 1)
  74884. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  74885. * * 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)
  74886. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  74887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74888. * * 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
  74889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74890. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  74891. * @param name defines the name of the mesh
  74892. * @param options defines the options used to create the mesh
  74893. * @param scene defines the hosting scene
  74894. * @returns the box mesh
  74895. */
  74896. BoxBuilder.CreateBox = function (name, options, scene) {
  74897. if (scene === void 0) { scene = null; }
  74898. var box = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  74899. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  74900. box._originalBuilderSideOrientation = options.sideOrientation;
  74901. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox(options);
  74902. vertexData.applyToMesh(box, options.updatable);
  74903. return box;
  74904. };
  74905. return BoxBuilder;
  74906. }());
  74907. /***/ }),
  74908. /***/ "./Meshes/Builders/cylinderBuilder.ts":
  74909. /*!********************************************!*\
  74910. !*** ./Meshes/Builders/cylinderBuilder.ts ***!
  74911. \********************************************/
  74912. /*! exports provided: CylinderBuilder */
  74913. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74914. "use strict";
  74915. __webpack_require__.r(__webpack_exports__);
  74916. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return CylinderBuilder; });
  74917. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  74918. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  74919. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  74920. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  74921. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder = function (options) {
  74922. var height = options.height || 2;
  74923. var diameterTop = (options.diameterTop === 0) ? 0 : options.diameterTop || options.diameter || 1;
  74924. var diameterBottom = (options.diameterBottom === 0) ? 0 : options.diameterBottom || options.diameter || 1;
  74925. var tessellation = options.tessellation || 24;
  74926. var subdivisions = options.subdivisions || 1;
  74927. var hasRings = options.hasRings ? true : false;
  74928. var enclose = options.enclose ? true : false;
  74929. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  74930. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  74931. var faceUV = options.faceUV || new Array(3);
  74932. var faceColors = options.faceColors;
  74933. // default face colors and UV if undefined
  74934. var quadNb = (arc !== 1 && enclose) ? 2 : 0;
  74935. var ringNb = (hasRings) ? subdivisions : 1;
  74936. var surfaceNb = 2 + (1 + quadNb) * ringNb;
  74937. var f;
  74938. for (f = 0; f < surfaceNb; f++) {
  74939. if (faceColors && faceColors[f] === undefined) {
  74940. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  74941. }
  74942. }
  74943. for (f = 0; f < surfaceNb; f++) {
  74944. if (faceUV && faceUV[f] === undefined) {
  74945. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  74946. }
  74947. }
  74948. var indices = new Array();
  74949. var positions = new Array();
  74950. var normals = new Array();
  74951. var uvs = new Array();
  74952. var colors = new Array();
  74953. var angle_step = Math.PI * 2 * arc / tessellation;
  74954. var angle;
  74955. var h;
  74956. var radius;
  74957. var tan = (diameterBottom - diameterTop) / 2 / height;
  74958. var ringVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74959. var ringNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74960. var ringFirstVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74961. var ringFirstNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74962. var quadNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74963. var Y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Y;
  74964. // positions, normals, uvs
  74965. var i;
  74966. var j;
  74967. var r;
  74968. var ringIdx = 1;
  74969. var s = 1; // surface index
  74970. var cs = 0;
  74971. var v = 0;
  74972. for (i = 0; i <= subdivisions; i++) {
  74973. h = i / subdivisions;
  74974. radius = (h * (diameterTop - diameterBottom) + diameterBottom) / 2;
  74975. ringIdx = (hasRings && i !== 0 && i !== subdivisions) ? 2 : 1;
  74976. for (r = 0; r < ringIdx; r++) {
  74977. if (hasRings) {
  74978. s += r;
  74979. }
  74980. if (enclose) {
  74981. s += 2 * r;
  74982. }
  74983. for (j = 0; j <= tessellation; j++) {
  74984. angle = j * angle_step;
  74985. // position
  74986. ringVertex.x = Math.cos(-angle) * radius;
  74987. ringVertex.y = -height / 2 + h * height;
  74988. ringVertex.z = Math.sin(-angle) * radius;
  74989. // normal
  74990. if (diameterTop === 0 && i === subdivisions) {
  74991. // if no top cap, reuse former normals
  74992. ringNormal.x = normals[normals.length - (tessellation + 1) * 3];
  74993. ringNormal.y = normals[normals.length - (tessellation + 1) * 3 + 1];
  74994. ringNormal.z = normals[normals.length - (tessellation + 1) * 3 + 2];
  74995. }
  74996. else {
  74997. ringNormal.x = ringVertex.x;
  74998. ringNormal.z = ringVertex.z;
  74999. ringNormal.y = Math.sqrt(ringNormal.x * ringNormal.x + ringNormal.z * ringNormal.z) * tan;
  75000. ringNormal.normalize();
  75001. }
  75002. // keep first ring vertex values for enclose
  75003. if (j === 0) {
  75004. ringFirstVertex.copyFrom(ringVertex);
  75005. ringFirstNormal.copyFrom(ringNormal);
  75006. }
  75007. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  75008. normals.push(ringNormal.x, ringNormal.y, ringNormal.z);
  75009. if (hasRings) {
  75010. v = (cs !== s) ? faceUV[s].y : faceUV[s].w;
  75011. }
  75012. else {
  75013. v = faceUV[s].y + (faceUV[s].w - faceUV[s].y) * h;
  75014. }
  75015. uvs.push(faceUV[s].x + (faceUV[s].z - faceUV[s].x) * j / tessellation, v);
  75016. if (faceColors) {
  75017. colors.push(faceColors[s].r, faceColors[s].g, faceColors[s].b, faceColors[s].a);
  75018. }
  75019. }
  75020. // if enclose, add four vertices and their dedicated normals
  75021. if (arc !== 1 && enclose) {
  75022. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  75023. positions.push(0, ringVertex.y, 0);
  75024. positions.push(0, ringVertex.y, 0);
  75025. positions.push(ringFirstVertex.x, ringFirstVertex.y, ringFirstVertex.z);
  75026. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(Y, ringNormal, quadNormal);
  75027. quadNormal.normalize();
  75028. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  75029. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(ringFirstNormal, Y, quadNormal);
  75030. quadNormal.normalize();
  75031. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  75032. if (hasRings) {
  75033. v = (cs !== s) ? faceUV[s + 1].y : faceUV[s + 1].w;
  75034. }
  75035. else {
  75036. v = faceUV[s + 1].y + (faceUV[s + 1].w - faceUV[s + 1].y) * h;
  75037. }
  75038. uvs.push(faceUV[s + 1].x, v);
  75039. uvs.push(faceUV[s + 1].z, v);
  75040. if (hasRings) {
  75041. v = (cs !== s) ? faceUV[s + 2].y : faceUV[s + 2].w;
  75042. }
  75043. else {
  75044. v = faceUV[s + 2].y + (faceUV[s + 2].w - faceUV[s + 2].y) * h;
  75045. }
  75046. uvs.push(faceUV[s + 2].x, v);
  75047. uvs.push(faceUV[s + 2].z, v);
  75048. if (faceColors) {
  75049. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  75050. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  75051. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  75052. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  75053. }
  75054. }
  75055. if (cs !== s) {
  75056. cs = s;
  75057. }
  75058. }
  75059. }
  75060. // indices
  75061. var e = (arc !== 1 && enclose) ? tessellation + 4 : tessellation; // correction of number of iteration if enclose
  75062. var s;
  75063. i = 0;
  75064. for (s = 0; s < subdivisions; s++) {
  75065. var i0 = 0;
  75066. var i1 = 0;
  75067. var i2 = 0;
  75068. var i3 = 0;
  75069. for (j = 0; j < tessellation; j++) {
  75070. i0 = i * (e + 1) + j;
  75071. i1 = (i + 1) * (e + 1) + j;
  75072. i2 = i * (e + 1) + (j + 1);
  75073. i3 = (i + 1) * (e + 1) + (j + 1);
  75074. indices.push(i0, i1, i2);
  75075. indices.push(i3, i2, i1);
  75076. }
  75077. if (arc !== 1 && enclose) { // if enclose, add two quads
  75078. indices.push(i0 + 2, i1 + 2, i2 + 2);
  75079. indices.push(i3 + 2, i2 + 2, i1 + 2);
  75080. indices.push(i0 + 4, i1 + 4, i2 + 4);
  75081. indices.push(i3 + 4, i2 + 4, i1 + 4);
  75082. }
  75083. i = (hasRings) ? (i + 2) : (i + 1);
  75084. }
  75085. // Caps
  75086. var createCylinderCap = function (isTop) {
  75087. var radius = isTop ? diameterTop / 2 : diameterBottom / 2;
  75088. if (radius === 0) {
  75089. return;
  75090. }
  75091. // Cap positions, normals & uvs
  75092. var angle;
  75093. var circleVector;
  75094. var i;
  75095. var u = (isTop) ? faceUV[surfaceNb - 1] : faceUV[0];
  75096. var c = null;
  75097. if (faceColors) {
  75098. c = (isTop) ? faceColors[surfaceNb - 1] : faceColors[0];
  75099. }
  75100. // cap center
  75101. var vbase = positions.length / 3;
  75102. var offset = isTop ? height / 2 : -height / 2;
  75103. var center = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, offset, 0);
  75104. positions.push(center.x, center.y, center.z);
  75105. normals.push(0, isTop ? 1 : -1, 0);
  75106. uvs.push(u.x + (u.z - u.x) * 0.5, u.y + (u.w - u.y) * 0.5);
  75107. if (c) {
  75108. colors.push(c.r, c.g, c.b, c.a);
  75109. }
  75110. var textureScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0.5, 0.5);
  75111. for (i = 0; i <= tessellation; i++) {
  75112. angle = Math.PI * 2 * i * arc / tessellation;
  75113. var cos = Math.cos(-angle);
  75114. var sin = Math.sin(-angle);
  75115. circleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](cos * radius, offset, sin * radius);
  75116. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](cos * textureScale.x + 0.5, sin * textureScale.y + 0.5);
  75117. positions.push(circleVector.x, circleVector.y, circleVector.z);
  75118. normals.push(0, isTop ? 1 : -1, 0);
  75119. uvs.push(u.x + (u.z - u.x) * textureCoordinate.x, u.y + (u.w - u.y) * textureCoordinate.y);
  75120. if (c) {
  75121. colors.push(c.r, c.g, c.b, c.a);
  75122. }
  75123. }
  75124. // Cap indices
  75125. for (i = 0; i < tessellation; i++) {
  75126. if (!isTop) {
  75127. indices.push(vbase);
  75128. indices.push(vbase + (i + 1));
  75129. indices.push(vbase + (i + 2));
  75130. }
  75131. else {
  75132. indices.push(vbase);
  75133. indices.push(vbase + (i + 2));
  75134. indices.push(vbase + (i + 1));
  75135. }
  75136. }
  75137. };
  75138. // add caps to geometry
  75139. createCylinderCap(false);
  75140. createCylinderCap(true);
  75141. // Sides
  75142. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  75143. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  75144. vertexData.indices = indices;
  75145. vertexData.positions = positions;
  75146. vertexData.normals = normals;
  75147. vertexData.uvs = uvs;
  75148. if (faceColors) {
  75149. vertexData.colors = colors;
  75150. }
  75151. return vertexData;
  75152. };
  75153. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  75154. if (scene === undefined || !(scene instanceof _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"])) {
  75155. if (scene !== undefined) {
  75156. sideOrientation = updatable || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DEFAULTSIDE;
  75157. updatable = scene;
  75158. }
  75159. scene = subdivisions;
  75160. subdivisions = 1;
  75161. }
  75162. var options = {
  75163. height: height,
  75164. diameterTop: diameterTop,
  75165. diameterBottom: diameterBottom,
  75166. tessellation: tessellation,
  75167. subdivisions: subdivisions,
  75168. sideOrientation: sideOrientation,
  75169. updatable: updatable
  75170. };
  75171. return CylinderBuilder.CreateCylinder(name, options, scene);
  75172. };
  75173. /**
  75174. * Class containing static functions to help procedurally build meshes
  75175. */
  75176. var CylinderBuilder = /** @class */ (function () {
  75177. function CylinderBuilder() {
  75178. }
  75179. /**
  75180. * Creates a cylinder or a cone mesh
  75181. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  75182. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  75183. * * 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.
  75184. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  75185. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  75186. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  75187. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  75188. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  75189. * * 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).
  75190. * * 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
  75191. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  75192. * * 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
  75193. * * 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.
  75194. * * If `enclose` is false, a ring surface is one element.
  75195. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  75196. * * 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
  75197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  75198. * * 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
  75199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  75200. * @param name defines the name of the mesh
  75201. * @param options defines the options used to create the mesh
  75202. * @param scene defines the hosting scene
  75203. * @returns the cylinder mesh
  75204. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  75205. */
  75206. CylinderBuilder.CreateCylinder = function (name, options, scene) {
  75207. var cylinder = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  75208. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  75209. cylinder._originalBuilderSideOrientation = options.sideOrientation;
  75210. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder(options);
  75211. vertexData.applyToMesh(cylinder, options.updatable);
  75212. return cylinder;
  75213. };
  75214. return CylinderBuilder;
  75215. }());
  75216. /***/ }),
  75217. /***/ "./Meshes/Builders/decalBuilder.ts":
  75218. /*!*****************************************!*\
  75219. !*** ./Meshes/Builders/decalBuilder.ts ***!
  75220. \*****************************************/
  75221. /*! exports provided: DecalBuilder */
  75222. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75223. "use strict";
  75224. __webpack_require__.r(__webpack_exports__);
  75225. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return DecalBuilder; });
  75226. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  75227. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  75228. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  75229. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  75230. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  75231. var options = {
  75232. position: position,
  75233. normal: normal,
  75234. size: size,
  75235. angle: angle
  75236. };
  75237. return DecalBuilder.CreateDecal(name, sourceMesh, options);
  75238. };
  75239. /**
  75240. * Class containing static functions to help procedurally build meshes
  75241. */
  75242. var DecalBuilder = /** @class */ (function () {
  75243. function DecalBuilder() {
  75244. }
  75245. /**
  75246. * Creates a decal mesh.
  75247. * 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
  75248. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  75249. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  75250. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  75251. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  75252. * @param name defines the name of the mesh
  75253. * @param sourceMesh defines the mesh where the decal must be applied
  75254. * @param options defines the options used to create the mesh
  75255. * @param scene defines the hosting scene
  75256. * @returns the decal mesh
  75257. * @see https://doc.babylonjs.com/how_to/decals
  75258. */
  75259. DecalBuilder.CreateDecal = function (name, sourceMesh, options) {
  75260. var indices = sourceMesh.getIndices();
  75261. var positions = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  75262. var normals = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  75263. var position = options.position || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75264. var normal = options.normal || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up();
  75265. var size = options.size || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  75266. var angle = options.angle || 0;
  75267. // Getting correct rotation
  75268. if (!normal) {
  75269. var target = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1);
  75270. var camera = sourceMesh.getScene().activeCamera;
  75271. var cameraWorldTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(target, camera.getWorldMatrix());
  75272. normal = camera.globalPosition.subtract(cameraWorldTarget);
  75273. }
  75274. var yaw = -Math.atan2(normal.z, normal.x) - Math.PI / 2;
  75275. var len = Math.sqrt(normal.x * normal.x + normal.z * normal.z);
  75276. var pitch = Math.atan2(normal.y, len);
  75277. // Matrix
  75278. 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));
  75279. var inverseDecalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Invert(decalWorldMatrix);
  75280. var meshWorldMatrix = sourceMesh.getWorldMatrix();
  75281. var transformMatrix = meshWorldMatrix.multiply(inverseDecalWorldMatrix);
  75282. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  75283. vertexData.indices = [];
  75284. vertexData.positions = [];
  75285. vertexData.normals = [];
  75286. vertexData.uvs = [];
  75287. var currentVertexDataIndex = 0;
  75288. var extractDecalVector3 = function (indexId) {
  75289. var result = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]();
  75290. if (!indices || !positions || !normals) {
  75291. return result;
  75292. }
  75293. var vertexId = indices[indexId];
  75294. result.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](positions[vertexId * 3], positions[vertexId * 3 + 1], positions[vertexId * 3 + 2]);
  75295. // Send vector to decal local world
  75296. result.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(result.position, transformMatrix);
  75297. // Get normal
  75298. result.normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normals[vertexId * 3], normals[vertexId * 3 + 1], normals[vertexId * 3 + 2]);
  75299. result.normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result.normal, transformMatrix);
  75300. return result;
  75301. }; // Inspired by https://github.com/mrdoob/three.js/blob/eee231960882f6f3b6113405f524956145148146/examples/js/geometries/DecalGeometry.js
  75302. var clip = function (vertices, axis) {
  75303. if (vertices.length === 0) {
  75304. return vertices;
  75305. }
  75306. var clipSize = 0.5 * Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(size, axis));
  75307. var clipVertices = function (v0, v1) {
  75308. var clipFactor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetClipFactor(v0.position, v1.position, axis, clipSize);
  75309. 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));
  75310. };
  75311. var result = new Array();
  75312. for (var index = 0; index < vertices.length; index += 3) {
  75313. var v1Out;
  75314. var v2Out;
  75315. var v3Out;
  75316. var total = 0;
  75317. var nV1 = null;
  75318. var nV2 = null;
  75319. var nV3 = null;
  75320. var nV4 = null;
  75321. var d1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index].position, axis) - clipSize;
  75322. var d2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 1].position, axis) - clipSize;
  75323. var d3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 2].position, axis) - clipSize;
  75324. v1Out = d1 > 0;
  75325. v2Out = d2 > 0;
  75326. v3Out = d3 > 0;
  75327. total = (v1Out ? 1 : 0) + (v2Out ? 1 : 0) + (v3Out ? 1 : 0);
  75328. switch (total) {
  75329. case 0:
  75330. result.push(vertices[index]);
  75331. result.push(vertices[index + 1]);
  75332. result.push(vertices[index + 2]);
  75333. break;
  75334. case 1:
  75335. if (v1Out) {
  75336. nV1 = vertices[index + 1];
  75337. nV2 = vertices[index + 2];
  75338. nV3 = clipVertices(vertices[index], nV1);
  75339. nV4 = clipVertices(vertices[index], nV2);
  75340. }
  75341. if (v2Out) {
  75342. nV1 = vertices[index];
  75343. nV2 = vertices[index + 2];
  75344. nV3 = clipVertices(vertices[index + 1], nV1);
  75345. nV4 = clipVertices(vertices[index + 1], nV2);
  75346. result.push(nV3);
  75347. result.push(nV2.clone());
  75348. result.push(nV1.clone());
  75349. result.push(nV2.clone());
  75350. result.push(nV3.clone());
  75351. result.push(nV4);
  75352. break;
  75353. }
  75354. if (v3Out) {
  75355. nV1 = vertices[index];
  75356. nV2 = vertices[index + 1];
  75357. nV3 = clipVertices(vertices[index + 2], nV1);
  75358. nV4 = clipVertices(vertices[index + 2], nV2);
  75359. }
  75360. if (nV1 && nV2 && nV3 && nV4) {
  75361. result.push(nV1.clone());
  75362. result.push(nV2.clone());
  75363. result.push(nV3);
  75364. result.push(nV4);
  75365. result.push(nV3.clone());
  75366. result.push(nV2.clone());
  75367. }
  75368. break;
  75369. case 2:
  75370. if (!v1Out) {
  75371. nV1 = vertices[index].clone();
  75372. nV2 = clipVertices(nV1, vertices[index + 1]);
  75373. nV3 = clipVertices(nV1, vertices[index + 2]);
  75374. result.push(nV1);
  75375. result.push(nV2);
  75376. result.push(nV3);
  75377. }
  75378. if (!v2Out) {
  75379. nV1 = vertices[index + 1].clone();
  75380. nV2 = clipVertices(nV1, vertices[index + 2]);
  75381. nV3 = clipVertices(nV1, vertices[index]);
  75382. result.push(nV1);
  75383. result.push(nV2);
  75384. result.push(nV3);
  75385. }
  75386. if (!v3Out) {
  75387. nV1 = vertices[index + 2].clone();
  75388. nV2 = clipVertices(nV1, vertices[index]);
  75389. nV3 = clipVertices(nV1, vertices[index + 1]);
  75390. result.push(nV1);
  75391. result.push(nV2);
  75392. result.push(nV3);
  75393. }
  75394. break;
  75395. case 3:
  75396. break;
  75397. }
  75398. }
  75399. return result;
  75400. };
  75401. for (var index = 0; index < indices.length; index += 3) {
  75402. var faceVertices = new Array();
  75403. faceVertices.push(extractDecalVector3(index));
  75404. faceVertices.push(extractDecalVector3(index + 1));
  75405. faceVertices.push(extractDecalVector3(index + 2));
  75406. // Clip
  75407. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0));
  75408. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0));
  75409. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0));
  75410. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0));
  75411. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1));
  75412. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1));
  75413. if (faceVertices.length === 0) {
  75414. continue;
  75415. }
  75416. // Add UVs and get back to world
  75417. for (var vIndex = 0; vIndex < faceVertices.length; vIndex++) {
  75418. var vertex = faceVertices[vIndex];
  75419. //TODO check for Int32Array | Uint32Array | Uint16Array
  75420. vertexData.indices.push(currentVertexDataIndex);
  75421. vertex.position.toArray(vertexData.positions, currentVertexDataIndex * 3);
  75422. vertex.normal.toArray(vertexData.normals, currentVertexDataIndex * 3);
  75423. vertexData.uvs.push(0.5 + vertex.position.x / size.x);
  75424. vertexData.uvs.push(0.5 + vertex.position.y / size.y);
  75425. currentVertexDataIndex++;
  75426. }
  75427. }
  75428. // Return mesh
  75429. var decal = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, sourceMesh.getScene());
  75430. vertexData.applyToMesh(decal);
  75431. decal.position = position.clone();
  75432. decal.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pitch, yaw, angle);
  75433. return decal;
  75434. };
  75435. return DecalBuilder;
  75436. }());
  75437. /***/ }),
  75438. /***/ "./Meshes/Builders/discBuilder.ts":
  75439. /*!****************************************!*\
  75440. !*** ./Meshes/Builders/discBuilder.ts ***!
  75441. \****************************************/
  75442. /*! exports provided: DiscBuilder */
  75443. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75444. "use strict";
  75445. __webpack_require__.r(__webpack_exports__);
  75446. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return DiscBuilder; });
  75447. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  75448. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  75449. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc = function (options) {
  75450. var positions = new Array();
  75451. var indices = new Array();
  75452. var normals = new Array();
  75453. var uvs = new Array();
  75454. var radius = options.radius || 0.5;
  75455. var tessellation = options.tessellation || 64;
  75456. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  75457. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  75458. // positions and uvs
  75459. positions.push(0, 0, 0); // disc center first
  75460. uvs.push(0.5, 0.5);
  75461. var theta = Math.PI * 2 * arc;
  75462. var step = theta / tessellation;
  75463. for (var a = 0; a < theta; a += step) {
  75464. var x = Math.cos(a);
  75465. var y = Math.sin(a);
  75466. var u = (x + 1) / 2;
  75467. var v = (1 - y) / 2;
  75468. positions.push(radius * x, radius * y, 0);
  75469. uvs.push(u, v);
  75470. }
  75471. if (arc === 1) {
  75472. positions.push(positions[3], positions[4], positions[5]); // close the circle
  75473. uvs.push(uvs[2], uvs[3]);
  75474. }
  75475. //indices
  75476. var vertexNb = positions.length / 3;
  75477. for (var i = 1; i < vertexNb - 1; i++) {
  75478. indices.push(i + 1, 0, i);
  75479. }
  75480. // result
  75481. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ComputeNormals(positions, indices, normals);
  75482. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  75483. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  75484. vertexData.indices = indices;
  75485. vertexData.positions = positions;
  75486. vertexData.normals = normals;
  75487. vertexData.uvs = uvs;
  75488. return vertexData;
  75489. };
  75490. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  75491. if (scene === void 0) { scene = null; }
  75492. var options = {
  75493. radius: radius,
  75494. tessellation: tessellation,
  75495. sideOrientation: sideOrientation,
  75496. updatable: updatable
  75497. };
  75498. return DiscBuilder.CreateDisc(name, options, scene);
  75499. };
  75500. /**
  75501. * Class containing static functions to help procedurally build meshes
  75502. */
  75503. var DiscBuilder = /** @class */ (function () {
  75504. function DiscBuilder() {
  75505. }
  75506. /**
  75507. * Creates a plane polygonal mesh. By default, this is a disc
  75508. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  75509. * * 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
  75510. * * 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
  75511. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  75512. * * 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
  75513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  75514. * @param name defines the name of the mesh
  75515. * @param options defines the options used to create the mesh
  75516. * @param scene defines the hosting scene
  75517. * @returns the plane polygonal mesh
  75518. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  75519. */
  75520. DiscBuilder.CreateDisc = function (name, options, scene) {
  75521. if (scene === void 0) { scene = null; }
  75522. var disc = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  75523. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  75524. disc._originalBuilderSideOrientation = options.sideOrientation;
  75525. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc(options);
  75526. vertexData.applyToMesh(disc, options.updatable);
  75527. return disc;
  75528. };
  75529. return DiscBuilder;
  75530. }());
  75531. /***/ }),
  75532. /***/ "./Meshes/Builders/groundBuilder.ts":
  75533. /*!******************************************!*\
  75534. !*** ./Meshes/Builders/groundBuilder.ts ***!
  75535. \******************************************/
  75536. /*! exports provided: GroundBuilder */
  75537. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75538. "use strict";
  75539. __webpack_require__.r(__webpack_exports__);
  75540. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return GroundBuilder; });
  75541. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  75542. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  75543. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  75544. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../groundMesh */ "./Meshes/groundMesh.ts");
  75545. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  75546. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround = function (options) {
  75547. var indices = [];
  75548. var positions = [];
  75549. var normals = [];
  75550. var uvs = [];
  75551. var row, col;
  75552. var width = options.width || 1;
  75553. var height = options.height || 1;
  75554. var subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  75555. var subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  75556. for (row = 0; row <= subdivisionsY; row++) {
  75557. for (col = 0; col <= subdivisionsX; col++) {
  75558. var position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]((col * width) / subdivisionsX - (width / 2.0), 0, ((subdivisionsY - row) * height) / subdivisionsY - (height / 2.0));
  75559. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  75560. positions.push(position.x, position.y, position.z);
  75561. normals.push(normal.x, normal.y, normal.z);
  75562. uvs.push(col / subdivisionsX, 1.0 - row / subdivisionsY);
  75563. }
  75564. }
  75565. for (row = 0; row < subdivisionsY; row++) {
  75566. for (col = 0; col < subdivisionsX; col++) {
  75567. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  75568. indices.push(col + 1 + row * (subdivisionsX + 1));
  75569. indices.push(col + row * (subdivisionsX + 1));
  75570. indices.push(col + (row + 1) * (subdivisionsX + 1));
  75571. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  75572. indices.push(col + row * (subdivisionsX + 1));
  75573. }
  75574. }
  75575. // Result
  75576. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  75577. vertexData.indices = indices;
  75578. vertexData.positions = positions;
  75579. vertexData.normals = normals;
  75580. vertexData.uvs = uvs;
  75581. return vertexData;
  75582. };
  75583. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround = function (options) {
  75584. var xmin = (options.xmin !== undefined && options.xmin !== null) ? options.xmin : -1.0;
  75585. var zmin = (options.zmin !== undefined && options.zmin !== null) ? options.zmin : -1.0;
  75586. var xmax = (options.xmax !== undefined && options.xmax !== null) ? options.xmax : 1.0;
  75587. var zmax = (options.zmax !== undefined && options.zmax !== null) ? options.zmax : 1.0;
  75588. var subdivisions = options.subdivisions || { w: 1, h: 1 };
  75589. var precision = options.precision || { w: 1, h: 1 };
  75590. var indices = new Array();
  75591. var positions = new Array();
  75592. var normals = new Array();
  75593. var uvs = new Array();
  75594. var row, col, tileRow, tileCol;
  75595. subdivisions.h = (subdivisions.h < 1) ? 1 : subdivisions.h;
  75596. subdivisions.w = (subdivisions.w < 1) ? 1 : subdivisions.w;
  75597. precision.w = (precision.w < 1) ? 1 : precision.w;
  75598. precision.h = (precision.h < 1) ? 1 : precision.h;
  75599. var tileSize = {
  75600. 'w': (xmax - xmin) / subdivisions.w,
  75601. 'h': (zmax - zmin) / subdivisions.h
  75602. };
  75603. function applyTile(xTileMin, zTileMin, xTileMax, zTileMax) {
  75604. // Indices
  75605. var base = positions.length / 3;
  75606. var rowLength = precision.w + 1;
  75607. for (row = 0; row < precision.h; row++) {
  75608. for (col = 0; col < precision.w; col++) {
  75609. var square = [
  75610. base + col + row * rowLength,
  75611. base + (col + 1) + row * rowLength,
  75612. base + (col + 1) + (row + 1) * rowLength,
  75613. base + col + (row + 1) * rowLength
  75614. ];
  75615. indices.push(square[1]);
  75616. indices.push(square[2]);
  75617. indices.push(square[3]);
  75618. indices.push(square[0]);
  75619. indices.push(square[1]);
  75620. indices.push(square[3]);
  75621. }
  75622. }
  75623. // Position, normals and uvs
  75624. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75625. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  75626. for (row = 0; row <= precision.h; row++) {
  75627. position.z = (row * (zTileMax - zTileMin)) / precision.h + zTileMin;
  75628. for (col = 0; col <= precision.w; col++) {
  75629. position.x = (col * (xTileMax - xTileMin)) / precision.w + xTileMin;
  75630. position.y = 0;
  75631. positions.push(position.x, position.y, position.z);
  75632. normals.push(normal.x, normal.y, normal.z);
  75633. uvs.push(col / precision.w, row / precision.h);
  75634. }
  75635. }
  75636. }
  75637. for (tileRow = 0; tileRow < subdivisions.h; tileRow++) {
  75638. for (tileCol = 0; tileCol < subdivisions.w; tileCol++) {
  75639. applyTile(xmin + tileCol * tileSize.w, zmin + tileRow * tileSize.h, xmin + (tileCol + 1) * tileSize.w, zmin + (tileRow + 1) * tileSize.h);
  75640. }
  75641. }
  75642. // Result
  75643. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  75644. vertexData.indices = indices;
  75645. vertexData.positions = positions;
  75646. vertexData.normals = normals;
  75647. vertexData.uvs = uvs;
  75648. return vertexData;
  75649. };
  75650. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap = function (options) {
  75651. var indices = [];
  75652. var positions = [];
  75653. var normals = [];
  75654. var uvs = [];
  75655. var row, col;
  75656. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  75657. var alphaFilter = options.alphaFilter || 0.0;
  75658. // Vertices
  75659. for (row = 0; row <= options.subdivisions; row++) {
  75660. for (col = 0; col <= options.subdivisions; col++) {
  75661. 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));
  75662. // Compute height
  75663. var heightMapX = (((position.x + options.width / 2) / options.width) * (options.bufferWidth - 1)) | 0;
  75664. var heightMapY = ((1.0 - (position.z + options.height / 2) / options.height) * (options.bufferHeight - 1)) | 0;
  75665. var pos = (heightMapX + heightMapY * options.bufferWidth) * 4;
  75666. var r = options.buffer[pos] / 255.0;
  75667. var g = options.buffer[pos + 1] / 255.0;
  75668. var b = options.buffer[pos + 2] / 255.0;
  75669. var a = options.buffer[pos + 3] / 255.0;
  75670. var gradient = r * filter.r + g * filter.g + b * filter.b;
  75671. // If our alpha channel is not within our filter then we will assign a 'special' height
  75672. // Then when building the indices, we will ignore any vertex that is using the special height
  75673. if (a >= alphaFilter) {
  75674. position.y = options.minHeight + (options.maxHeight - options.minHeight) * gradient;
  75675. }
  75676. else {
  75677. position.y = options.minHeight - _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; // We can't have a height below minHeight, normally.
  75678. }
  75679. // Add vertex
  75680. positions.push(position.x, position.y, position.z);
  75681. normals.push(0, 0, 0);
  75682. uvs.push(col / options.subdivisions, 1.0 - row / options.subdivisions);
  75683. }
  75684. }
  75685. // Indices
  75686. for (row = 0; row < options.subdivisions; row++) {
  75687. for (col = 0; col < options.subdivisions; col++) {
  75688. // Calculate Indices
  75689. var idx1 = (col + 1 + (row + 1) * (options.subdivisions + 1));
  75690. var idx2 = (col + 1 + row * (options.subdivisions + 1));
  75691. var idx3 = (col + row * (options.subdivisions + 1));
  75692. var idx4 = (col + (row + 1) * (options.subdivisions + 1));
  75693. // Check that all indices are visible (based on our special height)
  75694. // Only display the vertex if all Indices are visible
  75695. // Positions are stored x,y,z for each vertex, hence the * 3 and + 1 for height
  75696. var isVisibleIdx1 = positions[idx1 * 3 + 1] >= options.minHeight;
  75697. var isVisibleIdx2 = positions[idx2 * 3 + 1] >= options.minHeight;
  75698. var isVisibleIdx3 = positions[idx3 * 3 + 1] >= options.minHeight;
  75699. if (isVisibleIdx1 && isVisibleIdx2 && isVisibleIdx3) {
  75700. indices.push(idx1);
  75701. indices.push(idx2);
  75702. indices.push(idx3);
  75703. }
  75704. var isVisibleIdx4 = positions[idx4 * 3 + 1] >= options.minHeight;
  75705. if (isVisibleIdx4 && isVisibleIdx1 && isVisibleIdx3) {
  75706. indices.push(idx4);
  75707. indices.push(idx1);
  75708. indices.push(idx3);
  75709. }
  75710. }
  75711. }
  75712. // Normals
  75713. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  75714. // Result
  75715. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  75716. vertexData.indices = indices;
  75717. vertexData.positions = positions;
  75718. vertexData.normals = normals;
  75719. vertexData.uvs = uvs;
  75720. return vertexData;
  75721. };
  75722. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  75723. var options = {
  75724. width: width,
  75725. height: height,
  75726. subdivisions: subdivisions,
  75727. updatable: updatable
  75728. };
  75729. return GroundBuilder.CreateGround(name, options, scene);
  75730. };
  75731. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  75732. var options = {
  75733. xmin: xmin,
  75734. zmin: zmin,
  75735. xmax: xmax,
  75736. zmax: zmax,
  75737. subdivisions: subdivisions,
  75738. precision: precision,
  75739. updatable: updatable
  75740. };
  75741. return GroundBuilder.CreateTiledGround(name, options, scene);
  75742. };
  75743. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  75744. var options = {
  75745. width: width,
  75746. height: height,
  75747. subdivisions: subdivisions,
  75748. minHeight: minHeight,
  75749. maxHeight: maxHeight,
  75750. updatable: updatable,
  75751. onReady: onReady,
  75752. alphaFilter: alphaFilter
  75753. };
  75754. return GroundBuilder.CreateGroundFromHeightMap(name, url, options, scene);
  75755. };
  75756. /**
  75757. * Class containing static functions to help procedurally build meshes
  75758. */
  75759. var GroundBuilder = /** @class */ (function () {
  75760. function GroundBuilder() {
  75761. }
  75762. /**
  75763. * Creates a ground mesh
  75764. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  75765. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  75766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  75767. * @param name defines the name of the mesh
  75768. * @param options defines the options used to create the mesh
  75769. * @param scene defines the hosting scene
  75770. * @returns the ground mesh
  75771. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  75772. */
  75773. GroundBuilder.CreateGround = function (name, options, scene) {
  75774. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  75775. ground._setReady(false);
  75776. ground._subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  75777. ground._subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  75778. ground._width = options.width || 1;
  75779. ground._height = options.height || 1;
  75780. ground._maxX = ground._width / 2;
  75781. ground._maxZ = ground._height / 2;
  75782. ground._minX = -ground._maxX;
  75783. ground._minZ = -ground._maxZ;
  75784. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround(options);
  75785. vertexData.applyToMesh(ground, options.updatable);
  75786. ground._setReady(true);
  75787. return ground;
  75788. };
  75789. /**
  75790. * Creates a tiled ground mesh
  75791. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  75792. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  75793. * * 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
  75794. * * 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
  75795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  75796. * @param name defines the name of the mesh
  75797. * @param options defines the options used to create the mesh
  75798. * @param scene defines the hosting scene
  75799. * @returns the tiled ground mesh
  75800. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  75801. */
  75802. GroundBuilder.CreateTiledGround = function (name, options, scene) {
  75803. var tiledGround = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  75804. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround(options);
  75805. vertexData.applyToMesh(tiledGround, options.updatable);
  75806. return tiledGround;
  75807. };
  75808. /**
  75809. * Creates a ground mesh from a height map
  75810. * * The parameter `url` sets the URL of the height map image resource.
  75811. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  75812. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  75813. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  75814. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  75815. * * 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.
  75816. * * 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).
  75817. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  75818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  75819. * @param name defines the name of the mesh
  75820. * @param url defines the url to the height map
  75821. * @param options defines the options used to create the mesh
  75822. * @param scene defines the hosting scene
  75823. * @returns the ground mesh
  75824. * @see https://doc.babylonjs.com/babylon101/height_map
  75825. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  75826. */
  75827. GroundBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  75828. var width = options.width || 10.0;
  75829. var height = options.height || 10.0;
  75830. var subdivisions = options.subdivisions || 1 | 0;
  75831. var minHeight = options.minHeight || 0.0;
  75832. var maxHeight = options.maxHeight || 1.0;
  75833. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  75834. var alphaFilter = options.alphaFilter || 0.0;
  75835. var updatable = options.updatable;
  75836. var onReady = options.onReady;
  75837. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  75838. ground._subdivisionsX = subdivisions;
  75839. ground._subdivisionsY = subdivisions;
  75840. ground._width = width;
  75841. ground._height = height;
  75842. ground._maxX = ground._width / 2.0;
  75843. ground._maxZ = ground._height / 2.0;
  75844. ground._minX = -ground._maxX;
  75845. ground._minZ = -ground._maxZ;
  75846. ground._setReady(false);
  75847. var onload = function (img) {
  75848. // Getting height map data
  75849. var canvas = document.createElement("canvas");
  75850. var context = canvas.getContext("2d");
  75851. if (!context) {
  75852. throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");
  75853. }
  75854. if (scene.isDisposed) {
  75855. return;
  75856. }
  75857. var bufferWidth = img.width;
  75858. var bufferHeight = img.height;
  75859. canvas.width = bufferWidth;
  75860. canvas.height = bufferHeight;
  75861. context.drawImage(img, 0, 0);
  75862. // Create VertexData from map data
  75863. // Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  75864. var buffer = context.getImageData(0, 0, bufferWidth, bufferHeight).data;
  75865. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap({
  75866. width: width, height: height,
  75867. subdivisions: subdivisions,
  75868. minHeight: minHeight, maxHeight: maxHeight, colorFilter: filter,
  75869. buffer: buffer, bufferWidth: bufferWidth, bufferHeight: bufferHeight,
  75870. alphaFilter: alphaFilter
  75871. });
  75872. vertexData.applyToMesh(ground, updatable);
  75873. //execute ready callback, if set
  75874. if (onReady) {
  75875. onReady(ground);
  75876. }
  75877. ground._setReady(true);
  75878. };
  75879. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  75880. return ground;
  75881. };
  75882. return GroundBuilder;
  75883. }());
  75884. /***/ }),
  75885. /***/ "./Meshes/Builders/icoSphereBuilder.ts":
  75886. /*!*********************************************!*\
  75887. !*** ./Meshes/Builders/icoSphereBuilder.ts ***!
  75888. \*********************************************/
  75889. /*! exports provided: IcoSphereBuilder */
  75890. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75891. "use strict";
  75892. __webpack_require__.r(__webpack_exports__);
  75893. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return IcoSphereBuilder; });
  75894. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  75895. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  75896. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  75897. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere = function (options) {
  75898. var sideOrientation = options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  75899. var radius = options.radius || 1;
  75900. var flat = (options.flat === undefined) ? true : options.flat;
  75901. var subdivisions = options.subdivisions || 4;
  75902. var radiusX = options.radiusX || radius;
  75903. var radiusY = options.radiusY || radius;
  75904. var radiusZ = options.radiusZ || radius;
  75905. var t = (1 + Math.sqrt(5)) / 2;
  75906. // 12 vertex x,y,z
  75907. var ico_vertices = [
  75908. -1, t, -0, 1, t, 0, -1, -t, 0, 1, -t, 0,
  75909. 0, -1, -t, 0, 1, -t, 0, -1, t, 0, 1, t,
  75910. t, 0, 1, t, 0, -1, -t, 0, 1, -t, 0, -1 // v8-11
  75911. ];
  75912. // index of 3 vertex makes a face of icopshere
  75913. var ico_indices = [
  75914. 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 12, 22, 23,
  75915. 1, 5, 20, 5, 11, 4, 23, 22, 13, 22, 18, 6, 7, 1, 8,
  75916. 14, 21, 4, 14, 4, 2, 16, 13, 6, 15, 6, 19, 3, 8, 9,
  75917. 4, 21, 5, 13, 17, 23, 6, 13, 22, 19, 6, 18, 9, 8, 1
  75918. ];
  75919. // vertex for uv have aliased position, not for UV
  75920. var vertices_unalias_id = [
  75921. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
  75922. // vertex alias
  75923. 0,
  75924. 2,
  75925. 3,
  75926. 3,
  75927. 3,
  75928. 4,
  75929. 7,
  75930. 8,
  75931. 9,
  75932. 9,
  75933. 10,
  75934. 11 // 23: B + 12
  75935. ];
  75936. // uv as integer step (not pixels !)
  75937. var ico_vertexuv = [
  75938. 5, 1, 3, 1, 6, 4, 0, 0,
  75939. 5, 3, 4, 2, 2, 2, 4, 0,
  75940. 2, 0, 1, 1, 6, 0, 6, 2,
  75941. // vertex alias (for same vertex on different faces)
  75942. 0, 4,
  75943. 3, 3,
  75944. 4, 4,
  75945. 3, 1,
  75946. 4, 2,
  75947. 4, 4,
  75948. 0, 2,
  75949. 1, 1,
  75950. 2, 2,
  75951. 3, 3,
  75952. 1, 3,
  75953. 2, 4 // 23: B + 12
  75954. ];
  75955. // Vertices[0, 1, ...9, A, B] : position on UV plane
  75956. // '+' indicate duplicate position to be fixed (3,9:0,2,3,4,7,8,A,B)
  75957. // First island of uv mapping
  75958. // v = 4h 3+ 2
  75959. // v = 3h 9+ 4
  75960. // v = 2h 9+ 5 B
  75961. // v = 1h 9 1 0
  75962. // v = 0h 3 8 7 A
  75963. // u = 0 1 2 3 4 5 6 *a
  75964. // Second island of uv mapping
  75965. // v = 4h 0+ B+ 4+
  75966. // v = 3h A+ 2+
  75967. // v = 2h 7+ 6 3+
  75968. // v = 1h 8+ 3+
  75969. // v = 0h
  75970. // u = 0 1 2 3 4 5 6 *a
  75971. // Face layout on texture UV mapping
  75972. // ============
  75973. // \ 4 /\ 16 / ======
  75974. // \ / \ / /\ 11 /
  75975. // \/ 7 \/ / \ /
  75976. // ======= / 10 \/
  75977. // /\ 17 /\ =======
  75978. // / \ / \ \ 15 /\
  75979. // / 8 \/ 12 \ \ / \
  75980. // ============ \/ 6 \
  75981. // \ 18 /\ ============
  75982. // \ / \ \ 5 /\ 0 /
  75983. // \/ 13 \ \ / \ /
  75984. // ======= \/ 1 \/
  75985. // =============
  75986. // /\ 19 /\ 2 /\
  75987. // / \ / \ / \
  75988. // / 14 \/ 9 \/ 3 \
  75989. // ===================
  75990. // uv step is u:1 or 0.5, v:cos(30)=sqrt(3)/2, ratio approx is 84/97
  75991. var ustep = 138 / 1024;
  75992. var vstep = 239 / 1024;
  75993. var uoffset = 60 / 1024;
  75994. var voffset = 26 / 1024;
  75995. // Second island should have margin, not to touch the first island
  75996. // avoid any borderline artefact in pixel rounding
  75997. var island_u_offset = -40 / 1024;
  75998. var island_v_offset = +20 / 1024;
  75999. // face is either island 0 or 1 :
  76000. // second island is for faces : [4, 7, 8, 12, 13, 16, 17, 18]
  76001. var island = [
  76002. 0, 0, 0, 0, 1,
  76003. 0, 0, 1, 1, 0,
  76004. 0, 0, 1, 1, 0,
  76005. 0, 1, 1, 1, 0 // 15 - 19
  76006. ];
  76007. var indices = new Array();
  76008. var positions = new Array();
  76009. var normals = new Array();
  76010. var uvs = new Array();
  76011. var current_indice = 0;
  76012. // prepare array of 3 vector (empty) (to be worked in place, shared for each face)
  76013. var face_vertex_pos = new Array(3);
  76014. var face_vertex_uv = new Array(3);
  76015. var v012;
  76016. for (v012 = 0; v012 < 3; v012++) {
  76017. face_vertex_pos[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76018. face_vertex_uv[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  76019. }
  76020. // create all with normals
  76021. for (var face = 0; face < 20; face++) {
  76022. // 3 vertex per face
  76023. for (v012 = 0; v012 < 3; v012++) {
  76024. // look up vertex 0,1,2 to its index in 0 to 11 (or 23 including alias)
  76025. var v_id = ico_indices[3 * face + v012];
  76026. // vertex have 3D position (x,y,z)
  76027. 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]);
  76028. // Normalize to get normal, then scale to radius
  76029. face_vertex_pos[v012].normalize().scaleInPlace(radius);
  76030. // uv Coordinates from vertex ID
  76031. 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);
  76032. }
  76033. // Subdivide the face (interpolate pos, norm, uv)
  76034. // - pos is linear interpolation, then projected to sphere (converge polyhedron to sphere)
  76035. // - norm is linear interpolation of vertex corner normal
  76036. // (to be checked if better to re-calc from face vertex, or if approximation is OK ??? )
  76037. // - uv is linear interpolation
  76038. //
  76039. // Topology is as below for sub-divide by 2
  76040. // vertex shown as v0,v1,v2
  76041. // interp index is i1 to progress in range [v0,v1[
  76042. // interp index is i2 to progress in range [v0,v2[
  76043. // face index as (i1,i2) for /\ : (i1,i2),(i1+1,i2),(i1,i2+1)
  76044. // and (i1,i2)' for \/ : (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  76045. //
  76046. //
  76047. // i2 v2
  76048. // ^ ^
  76049. // / / \
  76050. // / / \
  76051. // / / \
  76052. // / / (0,1) \
  76053. // / #---------\
  76054. // / / \ (0,0)'/ \
  76055. // / / \ / \
  76056. // / / \ / \
  76057. // / / (0,0) \ / (1,0) \
  76058. // / #---------#---------\
  76059. // v0 v1
  76060. //
  76061. // --------------------> i1
  76062. //
  76063. // interp of (i1,i2):
  76064. // along i2 : x0=lerp(v0,v2, i2/S) <---> x1=lerp(v1,v2, i2/S)
  76065. // along i1 : lerp(x0,x1, i1/(S-i2))
  76066. //
  76067. // centroid of triangle is needed to get help normal computation
  76068. // (c1,c2) are used for centroid location
  76069. var interp_vertex = function (i1, i2, c1, c2) {
  76070. // vertex is interpolated from
  76071. // - face_vertex_pos[0..2]
  76072. // - face_vertex_uv[0..2]
  76073. var pos_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], i2 / subdivisions);
  76074. var pos_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], i2 / subdivisions);
  76075. var pos_interp = (subdivisions === i2) ? face_vertex_pos[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(pos_x0, pos_x1, i1 / (subdivisions - i2));
  76076. pos_interp.normalize();
  76077. var vertex_normal;
  76078. if (flat) {
  76079. // in flat mode, recalculate normal as face centroid normal
  76080. var centroid_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], c2 / subdivisions);
  76081. var centroid_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], c2 / subdivisions);
  76082. vertex_normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(centroid_x0, centroid_x1, c1 / (subdivisions - c2));
  76083. }
  76084. else {
  76085. // in smooth mode, recalculate normal from each single vertex position
  76086. vertex_normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pos_interp.x, pos_interp.y, pos_interp.z);
  76087. }
  76088. // Vertex normal need correction due to X,Y,Z radius scaling
  76089. vertex_normal.x /= radiusX;
  76090. vertex_normal.y /= radiusY;
  76091. vertex_normal.z /= radiusZ;
  76092. vertex_normal.normalize();
  76093. var uv_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[0], face_vertex_uv[2], i2 / subdivisions);
  76094. var uv_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[1], face_vertex_uv[2], i2 / subdivisions);
  76095. var uv_interp = (subdivisions === i2) ? face_vertex_uv[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(uv_x0, uv_x1, i1 / (subdivisions - i2));
  76096. positions.push(pos_interp.x * radiusX, pos_interp.y * radiusY, pos_interp.z * radiusZ);
  76097. normals.push(vertex_normal.x, vertex_normal.y, vertex_normal.z);
  76098. uvs.push(uv_interp.x, uv_interp.y);
  76099. // push each vertex has member of a face
  76100. // Same vertex can bleong to multiple face, it is pushed multiple time (duplicate vertex are present)
  76101. indices.push(current_indice);
  76102. current_indice++;
  76103. };
  76104. for (var i2 = 0; i2 < subdivisions; i2++) {
  76105. for (var i1 = 0; i1 + i2 < subdivisions; i1++) {
  76106. // face : (i1,i2) for /\ :
  76107. // interp for : (i1,i2),(i1+1,i2),(i1,i2+1)
  76108. interp_vertex(i1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  76109. interp_vertex(i1 + 1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  76110. interp_vertex(i1, i2 + 1, i1 + 1.0 / 3, i2 + 1.0 / 3);
  76111. if (i1 + i2 + 1 < subdivisions) {
  76112. // face : (i1,i2)' for \/ :
  76113. // interp for (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  76114. interp_vertex(i1 + 1, i2, i1 + 2.0 / 3, i2 + 2.0 / 3);
  76115. interp_vertex(i1 + 1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  76116. interp_vertex(i1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  76117. }
  76118. }
  76119. }
  76120. }
  76121. // Sides
  76122. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  76123. // Result
  76124. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76125. vertexData.indices = indices;
  76126. vertexData.positions = positions;
  76127. vertexData.normals = normals;
  76128. vertexData.uvs = uvs;
  76129. return vertexData;
  76130. };
  76131. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateIcoSphere = function (name, options, scene) {
  76132. return IcoSphereBuilder.CreateIcoSphere(name, options, scene);
  76133. };
  76134. /**
  76135. * Class containing static functions to help procedurally build meshes
  76136. */
  76137. var IcoSphereBuilder = /** @class */ (function () {
  76138. function IcoSphereBuilder() {
  76139. }
  76140. /**
  76141. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  76142. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  76143. * * 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`)
  76144. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  76145. * * 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
  76146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76147. * * 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
  76148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76149. * @param name defines the name of the mesh
  76150. * @param options defines the options used to create the mesh
  76151. * @param scene defines the hosting scene
  76152. * @returns the icosahedron mesh
  76153. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  76154. */
  76155. IcoSphereBuilder.CreateIcoSphere = function (name, options, scene) {
  76156. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  76157. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76158. sphere._originalBuilderSideOrientation = options.sideOrientation;
  76159. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere(options);
  76160. vertexData.applyToMesh(sphere, options.updatable);
  76161. return sphere;
  76162. };
  76163. return IcoSphereBuilder;
  76164. }());
  76165. /***/ }),
  76166. /***/ "./Meshes/Builders/index.ts":
  76167. /*!**********************************!*\
  76168. !*** ./Meshes/Builders/index.ts ***!
  76169. \**********************************/
  76170. /*! exports provided: BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, DiscBuilder, RibbonBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  76171. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76172. "use strict";
  76173. __webpack_require__.r(__webpack_exports__);
  76174. /* harmony import */ var _boxBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  76175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _boxBuilder__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  76176. /* harmony import */ var _discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./discBuilder */ "./Meshes/Builders/discBuilder.ts");
  76177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"]; });
  76178. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  76179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"]; });
  76180. /* harmony import */ var _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  76181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"]; });
  76182. /* harmony import */ var _cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  76183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"]; });
  76184. /* harmony import */ var _torusBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  76185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"]; });
  76186. /* harmony import */ var _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  76187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"]; });
  76188. /* harmony import */ var _linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  76189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"]; });
  76190. /* harmony import */ var _polygonBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  76191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"]; });
  76192. /* harmony import */ var _shapeBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  76193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"]; });
  76194. /* harmony import */ var _latheBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  76195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"]; });
  76196. /* harmony import */ var _planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  76197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"]; });
  76198. /* harmony import */ var _groundBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  76199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"]; });
  76200. /* harmony import */ var _tubeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  76201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"]; });
  76202. /* harmony import */ var _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  76203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"]; });
  76204. /* harmony import */ var _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  76205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"]; });
  76206. /* harmony import */ var _decalBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  76207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _decalBuilder__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"]; });
  76208. /***/ }),
  76209. /***/ "./Meshes/Builders/latheBuilder.ts":
  76210. /*!*****************************************!*\
  76211. !*** ./Meshes/Builders/latheBuilder.ts ***!
  76212. \*****************************************/
  76213. /*! exports provided: LatheBuilder */
  76214. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76215. "use strict";
  76216. __webpack_require__.r(__webpack_exports__);
  76217. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return LatheBuilder; });
  76218. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76219. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76220. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  76221. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  76222. var options = {
  76223. shape: shape,
  76224. radius: radius,
  76225. tessellation: tessellation,
  76226. sideOrientation: sideOrientation,
  76227. updatable: updatable
  76228. };
  76229. return LatheBuilder.CreateLathe(name, options, scene);
  76230. };
  76231. /**
  76232. * Class containing static functions to help procedurally build meshes
  76233. */
  76234. var LatheBuilder = /** @class */ (function () {
  76235. function LatheBuilder() {
  76236. }
  76237. /**
  76238. * Creates lathe mesh.
  76239. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  76240. * * 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
  76241. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  76242. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  76243. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  76244. * * 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
  76245. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  76246. * * 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
  76247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76248. * * 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
  76249. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  76250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76251. * @param name defines the name of the mesh
  76252. * @param options defines the options used to create the mesh
  76253. * @param scene defines the hosting scene
  76254. * @returns the lathe mesh
  76255. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  76256. */
  76257. LatheBuilder.CreateLathe = function (name, options, scene) {
  76258. var arc = options.arc ? ((options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc) : 1.0;
  76259. var closed = (options.closed === undefined) ? true : options.closed;
  76260. var shape = options.shape;
  76261. var radius = options.radius || 1;
  76262. var tessellation = options.tessellation || 64;
  76263. var clip = options.clip || 0;
  76264. var updatable = options.updatable;
  76265. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76266. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  76267. var pi2 = Math.PI * 2;
  76268. var paths = new Array();
  76269. var invertUV = options.invertUV || false;
  76270. var i = 0;
  76271. var p = 0;
  76272. var step = pi2 / tessellation * arc;
  76273. var rotated;
  76274. var path = new Array();
  76275. for (i = 0; i <= tessellation - clip; i++) {
  76276. var path = [];
  76277. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  76278. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[0].y, 0));
  76279. 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));
  76280. }
  76281. for (p = 0; p < shape.length; p++) {
  76282. 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);
  76283. path.push(rotated);
  76284. }
  76285. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  76286. 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));
  76287. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[shape.length - 1].y, 0));
  76288. }
  76289. paths.push(path);
  76290. }
  76291. // lathe ribbon
  76292. 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);
  76293. return lathe;
  76294. };
  76295. return LatheBuilder;
  76296. }());
  76297. /***/ }),
  76298. /***/ "./Meshes/Builders/linesBuilder.ts":
  76299. /*!*****************************************!*\
  76300. !*** ./Meshes/Builders/linesBuilder.ts ***!
  76301. \*****************************************/
  76302. /*! exports provided: LinesBuilder */
  76303. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76304. "use strict";
  76305. __webpack_require__.r(__webpack_exports__);
  76306. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return LinesBuilder; });
  76307. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76308. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76309. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76310. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  76311. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  76312. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem = function (options) {
  76313. var indices = [];
  76314. var positions = [];
  76315. var lines = options.lines;
  76316. var colors = options.colors;
  76317. var vertexColors = [];
  76318. var idx = 0;
  76319. for (var l = 0; l < lines.length; l++) {
  76320. var points = lines[l];
  76321. for (var index = 0; index < points.length; index++) {
  76322. positions.push(points[index].x, points[index].y, points[index].z);
  76323. if (colors) {
  76324. var color = colors[l];
  76325. vertexColors.push(color[index].r, color[index].g, color[index].b, color[index].a);
  76326. }
  76327. if (index > 0) {
  76328. indices.push(idx - 1);
  76329. indices.push(idx);
  76330. }
  76331. idx++;
  76332. }
  76333. }
  76334. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76335. vertexData.indices = indices;
  76336. vertexData.positions = positions;
  76337. if (colors) {
  76338. vertexData.colors = vertexColors;
  76339. }
  76340. return vertexData;
  76341. };
  76342. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines = function (options) {
  76343. var dashSize = options.dashSize || 3;
  76344. var gapSize = options.gapSize || 1;
  76345. var dashNb = options.dashNb || 200;
  76346. var points = options.points;
  76347. var positions = new Array();
  76348. var indices = new Array();
  76349. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76350. var lg = 0;
  76351. var nb = 0;
  76352. var shft = 0;
  76353. var dashshft = 0;
  76354. var curshft = 0;
  76355. var idx = 0;
  76356. var i = 0;
  76357. for (i = 0; i < points.length - 1; i++) {
  76358. points[i + 1].subtractToRef(points[i], curvect);
  76359. lg += curvect.length();
  76360. }
  76361. shft = lg / dashNb;
  76362. dashshft = dashSize * shft / (dashSize + gapSize);
  76363. for (i = 0; i < points.length - 1; i++) {
  76364. points[i + 1].subtractToRef(points[i], curvect);
  76365. nb = Math.floor(curvect.length() / shft);
  76366. curvect.normalize();
  76367. for (var j = 0; j < nb; j++) {
  76368. curshft = shft * j;
  76369. positions.push(points[i].x + curshft * curvect.x, points[i].y + curshft * curvect.y, points[i].z + curshft * curvect.z);
  76370. positions.push(points[i].x + (curshft + dashshft) * curvect.x, points[i].y + (curshft + dashshft) * curvect.y, points[i].z + (curshft + dashshft) * curvect.z);
  76371. indices.push(idx, idx + 1);
  76372. idx += 2;
  76373. }
  76374. }
  76375. // Result
  76376. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76377. vertexData.positions = positions;
  76378. vertexData.indices = indices;
  76379. return vertexData;
  76380. };
  76381. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines = function (name, points, scene, updatable, instance) {
  76382. if (scene === void 0) { scene = null; }
  76383. if (updatable === void 0) { updatable = false; }
  76384. if (instance === void 0) { instance = null; }
  76385. var options = {
  76386. points: points,
  76387. updatable: updatable,
  76388. instance: instance
  76389. };
  76390. return LinesBuilder.CreateLines(name, options, scene);
  76391. };
  76392. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  76393. if (scene === void 0) { scene = null; }
  76394. var options = {
  76395. points: points,
  76396. dashSize: dashSize,
  76397. gapSize: gapSize,
  76398. dashNb: dashNb,
  76399. updatable: updatable,
  76400. instance: instance
  76401. };
  76402. return LinesBuilder.CreateDashedLines(name, options, scene);
  76403. };
  76404. /**
  76405. * Class containing static functions to help procedurally build meshes
  76406. */
  76407. var LinesBuilder = /** @class */ (function () {
  76408. function LinesBuilder() {
  76409. }
  76410. /**
  76411. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  76412. * * 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
  76413. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  76414. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  76415. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  76416. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  76417. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  76418. * * 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
  76419. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  76420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76421. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  76422. * @param name defines the name of the new line system
  76423. * @param options defines the options used to create the line system
  76424. * @param scene defines the hosting scene
  76425. * @returns a new line system mesh
  76426. */
  76427. LinesBuilder.CreateLineSystem = function (name, options, scene) {
  76428. var instance = options.instance;
  76429. var lines = options.lines;
  76430. var colors = options.colors;
  76431. if (instance) { // lines update
  76432. var positions = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  76433. var vertexColor;
  76434. var lineColors;
  76435. if (colors) {
  76436. vertexColor = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  76437. }
  76438. var i = 0;
  76439. var c = 0;
  76440. for (var l = 0; l < lines.length; l++) {
  76441. var points = lines[l];
  76442. for (var p = 0; p < points.length; p++) {
  76443. positions[i] = points[p].x;
  76444. positions[i + 1] = points[p].y;
  76445. positions[i + 2] = points[p].z;
  76446. if (colors && vertexColor) {
  76447. lineColors = colors[l];
  76448. vertexColor[c] = lineColors[p].r;
  76449. vertexColor[c + 1] = lineColors[p].g;
  76450. vertexColor[c + 2] = lineColors[p].b;
  76451. vertexColor[c + 3] = lineColors[p].a;
  76452. c += 4;
  76453. }
  76454. i += 3;
  76455. }
  76456. }
  76457. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, positions, false, false);
  76458. if (colors && vertexColor) {
  76459. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind, vertexColor, false, false);
  76460. }
  76461. return instance;
  76462. }
  76463. // line system creation
  76464. var useVertexColor = (colors) ? true : false;
  76465. var lineSystem = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene, null, undefined, undefined, useVertexColor, options.useVertexAlpha);
  76466. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem(options);
  76467. vertexData.applyToMesh(lineSystem, options.updatable);
  76468. return lineSystem;
  76469. };
  76470. /**
  76471. * Creates a line mesh
  76472. * 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
  76473. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  76474. * * The parameter `points` is an array successive Vector3
  76475. * * 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
  76476. * * The optional parameter `colors` is an array of successive Color4, one per line point
  76477. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  76478. * * When updating an instance, remember that only point positions can change, not the number of points
  76479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76480. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  76481. * @param name defines the name of the new line system
  76482. * @param options defines the options used to create the line system
  76483. * @param scene defines the hosting scene
  76484. * @returns a new line mesh
  76485. */
  76486. LinesBuilder.CreateLines = function (name, options, scene) {
  76487. if (scene === void 0) { scene = null; }
  76488. var colors = (options.colors) ? [options.colors] : null;
  76489. var lines = LinesBuilder.CreateLineSystem(name, { lines: [options.points], updatable: options.updatable, instance: options.instance, colors: colors, useVertexAlpha: options.useVertexAlpha }, scene);
  76490. return lines;
  76491. };
  76492. /**
  76493. * Creates a dashed line mesh
  76494. * * 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
  76495. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  76496. * * The parameter `points` is an array successive Vector3
  76497. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  76498. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  76499. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  76500. * * 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
  76501. * * When updating an instance, remember that only point positions can change, not the number of points
  76502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76503. * @param name defines the name of the mesh
  76504. * @param options defines the options used to create the mesh
  76505. * @param scene defines the hosting scene
  76506. * @returns the dashed line mesh
  76507. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  76508. */
  76509. LinesBuilder.CreateDashedLines = function (name, options, scene) {
  76510. if (scene === void 0) { scene = null; }
  76511. var points = options.points;
  76512. var instance = options.instance;
  76513. var gapSize = options.gapSize || 1;
  76514. var dashSize = options.dashSize || 3;
  76515. if (instance) { // dashed lines update
  76516. var positionFunction = function (positions) {
  76517. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76518. var nbSeg = positions.length / 6;
  76519. var lg = 0;
  76520. var nb = 0;
  76521. var shft = 0;
  76522. var dashshft = 0;
  76523. var curshft = 0;
  76524. var p = 0;
  76525. var i = 0;
  76526. var j = 0;
  76527. for (i = 0; i < points.length - 1; i++) {
  76528. points[i + 1].subtractToRef(points[i], curvect);
  76529. lg += curvect.length();
  76530. }
  76531. shft = lg / nbSeg;
  76532. var dashSize = instance._creationDataStorage.dashSize;
  76533. var gapSize = instance._creationDataStorage.gapSize;
  76534. dashshft = dashSize * shft / (dashSize + gapSize);
  76535. for (i = 0; i < points.length - 1; i++) {
  76536. points[i + 1].subtractToRef(points[i], curvect);
  76537. nb = Math.floor(curvect.length() / shft);
  76538. curvect.normalize();
  76539. j = 0;
  76540. while (j < nb && p < positions.length) {
  76541. curshft = shft * j;
  76542. positions[p] = points[i].x + curshft * curvect.x;
  76543. positions[p + 1] = points[i].y + curshft * curvect.y;
  76544. positions[p + 2] = points[i].z + curshft * curvect.z;
  76545. positions[p + 3] = points[i].x + (curshft + dashshft) * curvect.x;
  76546. positions[p + 4] = points[i].y + (curshft + dashshft) * curvect.y;
  76547. positions[p + 5] = points[i].z + (curshft + dashshft) * curvect.z;
  76548. p += 6;
  76549. j++;
  76550. }
  76551. }
  76552. while (p < positions.length) {
  76553. positions[p] = points[i].x;
  76554. positions[p + 1] = points[i].y;
  76555. positions[p + 2] = points[i].z;
  76556. p += 3;
  76557. }
  76558. };
  76559. instance.updateMeshPositions(positionFunction, false);
  76560. return instance;
  76561. }
  76562. // dashed lines creation
  76563. var dashedLines = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene);
  76564. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines(options);
  76565. vertexData.applyToMesh(dashedLines, options.updatable);
  76566. dashedLines._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  76567. dashedLines._creationDataStorage.dashSize = dashSize;
  76568. dashedLines._creationDataStorage.gapSize = gapSize;
  76569. return dashedLines;
  76570. };
  76571. return LinesBuilder;
  76572. }());
  76573. /***/ }),
  76574. /***/ "./Meshes/Builders/planeBuilder.ts":
  76575. /*!*****************************************!*\
  76576. !*** ./Meshes/Builders/planeBuilder.ts ***!
  76577. \*****************************************/
  76578. /*! exports provided: PlaneBuilder */
  76579. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76580. "use strict";
  76581. __webpack_require__.r(__webpack_exports__);
  76582. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return PlaneBuilder; });
  76583. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76584. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76585. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane = function (options) {
  76586. var indices = [];
  76587. var positions = [];
  76588. var normals = [];
  76589. var uvs = [];
  76590. var width = options.width || options.size || 1;
  76591. var height = options.height || options.size || 1;
  76592. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  76593. // Vertices
  76594. var halfWidth = width / 2.0;
  76595. var halfHeight = height / 2.0;
  76596. positions.push(-halfWidth, -halfHeight, 0);
  76597. normals.push(0, 0, -1.0);
  76598. uvs.push(0.0, 0.0);
  76599. positions.push(halfWidth, -halfHeight, 0);
  76600. normals.push(0, 0, -1.0);
  76601. uvs.push(1.0, 0.0);
  76602. positions.push(halfWidth, halfHeight, 0);
  76603. normals.push(0, 0, -1.0);
  76604. uvs.push(1.0, 1.0);
  76605. positions.push(-halfWidth, halfHeight, 0);
  76606. normals.push(0, 0, -1.0);
  76607. uvs.push(0.0, 1.0);
  76608. // Indices
  76609. indices.push(0);
  76610. indices.push(1);
  76611. indices.push(2);
  76612. indices.push(0);
  76613. indices.push(2);
  76614. indices.push(3);
  76615. // Sides
  76616. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  76617. // Result
  76618. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  76619. vertexData.indices = indices;
  76620. vertexData.positions = positions;
  76621. vertexData.normals = normals;
  76622. vertexData.uvs = uvs;
  76623. return vertexData;
  76624. };
  76625. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  76626. var options = {
  76627. size: size,
  76628. width: size,
  76629. height: size,
  76630. sideOrientation: sideOrientation,
  76631. updatable: updatable
  76632. };
  76633. return PlaneBuilder.CreatePlane(name, options, scene);
  76634. };
  76635. /**
  76636. * Class containing static functions to help procedurally build meshes
  76637. */
  76638. var PlaneBuilder = /** @class */ (function () {
  76639. function PlaneBuilder() {
  76640. }
  76641. /**
  76642. * Creates a plane mesh
  76643. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  76644. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  76645. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  76646. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76647. * * 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
  76648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76649. * @param name defines the name of the mesh
  76650. * @param options defines the options used to create the mesh
  76651. * @param scene defines the hosting scene
  76652. * @returns the plane mesh
  76653. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  76654. */
  76655. PlaneBuilder.CreatePlane = function (name, options, scene) {
  76656. var plane = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  76657. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76658. plane._originalBuilderSideOrientation = options.sideOrientation;
  76659. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane(options);
  76660. vertexData.applyToMesh(plane, options.updatable);
  76661. if (options.sourcePlane) {
  76662. plane.translate(options.sourcePlane.normal, -options.sourcePlane.d);
  76663. plane.setDirection(options.sourcePlane.normal.scale(-1));
  76664. }
  76665. return plane;
  76666. };
  76667. return PlaneBuilder;
  76668. }());
  76669. /***/ }),
  76670. /***/ "./Meshes/Builders/polygonBuilder.ts":
  76671. /*!*******************************************!*\
  76672. !*** ./Meshes/Builders/polygonBuilder.ts ***!
  76673. \*******************************************/
  76674. /*! exports provided: PolygonBuilder */
  76675. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76676. "use strict";
  76677. __webpack_require__.r(__webpack_exports__);
  76678. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return PolygonBuilder; });
  76679. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76680. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76681. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76682. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../polygonMesh */ "./Meshes/polygonMesh.ts");
  76683. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  76684. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  76685. var faceUV = fUV || new Array(3);
  76686. var faceColors = fColors;
  76687. var colors = [];
  76688. // default face colors and UV if undefined
  76689. for (var f = 0; f < 3; f++) {
  76690. if (faceUV[f] === undefined) {
  76691. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  76692. }
  76693. if (faceColors && faceColors[f] === undefined) {
  76694. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  76695. }
  76696. }
  76697. var positions = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  76698. var normals = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  76699. var uvs = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  76700. var indices = polygon.getIndices();
  76701. // set face colours and textures
  76702. var idx = 0;
  76703. var face = 0;
  76704. for (var index = 0; index < normals.length; index += 3) {
  76705. //Edge Face no. 1
  76706. if (Math.abs(normals[index + 1]) < 0.001) {
  76707. face = 1;
  76708. }
  76709. //Top Face no. 0
  76710. if (Math.abs(normals[index + 1] - 1) < 0.001) {
  76711. face = 0;
  76712. }
  76713. //Bottom Face no. 2
  76714. if (Math.abs(normals[index + 1] + 1) < 0.001) {
  76715. face = 2;
  76716. }
  76717. idx = index / 3;
  76718. uvs[2 * idx] = (1 - uvs[2 * idx]) * faceUV[face].x + uvs[2 * idx] * faceUV[face].z;
  76719. uvs[2 * idx + 1] = (1 - uvs[2 * idx + 1]) * faceUV[face].y + uvs[2 * idx + 1] * faceUV[face].w;
  76720. if (faceColors) {
  76721. colors.push(faceColors[face].r, faceColors[face].g, faceColors[face].b, faceColors[face].a);
  76722. }
  76723. }
  76724. // sides
  76725. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs);
  76726. // Result
  76727. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76728. vertexData.indices = indices;
  76729. vertexData.positions = positions;
  76730. vertexData.normals = normals;
  76731. vertexData.uvs = uvs;
  76732. if (faceColors) {
  76733. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  76734. vertexData.colors = totalColors;
  76735. }
  76736. return vertexData;
  76737. };
  76738. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  76739. if (earcutInjection === void 0) { earcutInjection = earcut; }
  76740. var options = {
  76741. shape: shape,
  76742. holes: holes,
  76743. updatable: updatable,
  76744. sideOrientation: sideOrientation
  76745. };
  76746. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  76747. };
  76748. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  76749. if (earcutInjection === void 0) { earcutInjection = earcut; }
  76750. var options = {
  76751. shape: shape,
  76752. holes: holes,
  76753. depth: depth,
  76754. updatable: updatable,
  76755. sideOrientation: sideOrientation
  76756. };
  76757. return PolygonBuilder.ExtrudePolygon(name, options, scene, earcutInjection);
  76758. };
  76759. /**
  76760. * Class containing static functions to help procedurally build meshes
  76761. */
  76762. var PolygonBuilder = /** @class */ (function () {
  76763. function PolygonBuilder() {
  76764. }
  76765. /**
  76766. * Creates a polygon mesh
  76767. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  76768. * * 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
  76769. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  76770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76771. * * 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)
  76772. * * Remember you can only change the shape positions, not their number when updating a polygon
  76773. * @param name defines the name of the mesh
  76774. * @param options defines the options used to create the mesh
  76775. * @param scene defines the hosting scene
  76776. * @param earcutInjection can be used to inject your own earcut reference
  76777. * @returns the polygon mesh
  76778. */
  76779. PolygonBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  76780. if (earcutInjection === void 0) { earcutInjection = earcut; }
  76781. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76782. var shape = options.shape;
  76783. var holes = options.holes || [];
  76784. var depth = options.depth || 0;
  76785. var contours = [];
  76786. var hole = [];
  76787. for (var i = 0; i < shape.length; i++) {
  76788. contours[i] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](shape[i].x, shape[i].z);
  76789. }
  76790. var epsilon = 0.00000001;
  76791. if (contours[0].equalsWithEpsilon(contours[contours.length - 1], epsilon)) {
  76792. contours.pop();
  76793. }
  76794. var polygonTriangulation = new _polygonMesh__WEBPACK_IMPORTED_MODULE_3__["PolygonMeshBuilder"](name, contours, scene, earcutInjection);
  76795. for (var hNb = 0; hNb < holes.length; hNb++) {
  76796. hole = [];
  76797. for (var hPoint = 0; hPoint < holes[hNb].length; hPoint++) {
  76798. hole.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](holes[hNb][hPoint].x, holes[hNb][hPoint].z));
  76799. }
  76800. polygonTriangulation.addHole(hole);
  76801. }
  76802. var polygon = polygonTriangulation.build(options.updatable, depth);
  76803. polygon._originalBuilderSideOrientation = options.sideOrientation;
  76804. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon(polygon, options.sideOrientation, options.faceUV, options.faceColors, options.frontUVs, options.backUVs);
  76805. vertexData.applyToMesh(polygon, options.updatable);
  76806. return polygon;
  76807. };
  76808. /**
  76809. * Creates an extruded polygon mesh, with depth in the Y direction.
  76810. * * 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)
  76811. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  76812. * @param name defines the name of the mesh
  76813. * @param options defines the options used to create the mesh
  76814. * @param scene defines the hosting scene
  76815. * @param earcutInjection can be used to inject your own earcut reference
  76816. * @returns the polygon mesh
  76817. */
  76818. PolygonBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  76819. if (earcutInjection === void 0) { earcutInjection = earcut; }
  76820. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  76821. };
  76822. return PolygonBuilder;
  76823. }());
  76824. /***/ }),
  76825. /***/ "./Meshes/Builders/polyhedronBuilder.ts":
  76826. /*!**********************************************!*\
  76827. !*** ./Meshes/Builders/polyhedronBuilder.ts ***!
  76828. \**********************************************/
  76829. /*! exports provided: PolyhedronBuilder */
  76830. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76831. "use strict";
  76832. __webpack_require__.r(__webpack_exports__);
  76833. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return PolyhedronBuilder; });
  76834. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76835. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76836. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76837. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron = function (options) {
  76838. // provided polyhedron types :
  76839. // 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  76840. // 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)
  76841. var polyhedra = [];
  76842. 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]] };
  76843. 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]] };
  76844. polyhedra[2] = {
  76845. 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]],
  76846. 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]]
  76847. };
  76848. polyhedra[3] = {
  76849. 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]],
  76850. 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]]
  76851. };
  76852. polyhedra[4] = {
  76853. 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]],
  76854. 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]]
  76855. };
  76856. 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]] };
  76857. 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]] };
  76858. 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]] };
  76859. 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]] };
  76860. 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]] };
  76861. 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]] };
  76862. 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]] };
  76863. 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]] };
  76864. 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]] };
  76865. polyhedra[14] = {
  76866. 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]],
  76867. 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]]
  76868. };
  76869. var type = options.type && (options.type < 0 || options.type >= polyhedra.length) ? 0 : options.type || 0;
  76870. var size = options.size;
  76871. var sizeX = options.sizeX || size || 1;
  76872. var sizeY = options.sizeY || size || 1;
  76873. var sizeZ = options.sizeZ || size || 1;
  76874. var data = options.custom || polyhedra[type];
  76875. var nbfaces = data.face.length;
  76876. var faceUV = options.faceUV || new Array(nbfaces);
  76877. var faceColors = options.faceColors;
  76878. var flat = (options.flat === undefined) ? true : options.flat;
  76879. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  76880. var positions = new Array();
  76881. var indices = new Array();
  76882. var normals = new Array();
  76883. var uvs = new Array();
  76884. var colors = new Array();
  76885. var index = 0;
  76886. var faceIdx = 0; // face cursor in the array "indexes"
  76887. var indexes = new Array();
  76888. var i = 0;
  76889. var f = 0;
  76890. var u, v, ang, x, y, tmp;
  76891. // default face colors and UV if undefined
  76892. if (flat) {
  76893. for (f = 0; f < nbfaces; f++) {
  76894. if (faceColors && faceColors[f] === undefined) {
  76895. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  76896. }
  76897. if (faceUV && faceUV[f] === undefined) {
  76898. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  76899. }
  76900. }
  76901. }
  76902. if (!flat) {
  76903. for (i = 0; i < data.vertex.length; i++) {
  76904. positions.push(data.vertex[i][0] * sizeX, data.vertex[i][1] * sizeY, data.vertex[i][2] * sizeZ);
  76905. uvs.push(0, 0);
  76906. }
  76907. for (f = 0; f < nbfaces; f++) {
  76908. for (i = 0; i < data.face[f].length - 2; i++) {
  76909. indices.push(data.face[f][0], data.face[f][i + 2], data.face[f][i + 1]);
  76910. }
  76911. }
  76912. }
  76913. else {
  76914. for (f = 0; f < nbfaces; f++) {
  76915. var fl = data.face[f].length; // number of vertices of the current face
  76916. ang = 2 * Math.PI / fl;
  76917. x = 0.5 * Math.tan(ang / 2);
  76918. y = 0.5;
  76919. // positions, uvs, colors
  76920. for (i = 0; i < fl; i++) {
  76921. // positions
  76922. 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);
  76923. indexes.push(index);
  76924. index++;
  76925. // uvs
  76926. u = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * (0.5 + x);
  76927. v = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * (y - 0.5);
  76928. uvs.push(u, v);
  76929. tmp = x * Math.cos(ang) - y * Math.sin(ang);
  76930. y = x * Math.sin(ang) + y * Math.cos(ang);
  76931. x = tmp;
  76932. // colors
  76933. if (faceColors) {
  76934. colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
  76935. }
  76936. }
  76937. // indices from indexes
  76938. for (i = 0; i < fl - 2; i++) {
  76939. indices.push(indexes[0 + faceIdx], indexes[i + 2 + faceIdx], indexes[i + 1 + faceIdx]);
  76940. }
  76941. faceIdx += fl;
  76942. }
  76943. }
  76944. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  76945. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  76946. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76947. vertexData.positions = positions;
  76948. vertexData.indices = indices;
  76949. vertexData.normals = normals;
  76950. vertexData.uvs = uvs;
  76951. if (faceColors && flat) {
  76952. vertexData.colors = colors;
  76953. }
  76954. return vertexData;
  76955. };
  76956. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolyhedron = function (name, options, scene) {
  76957. return PolyhedronBuilder.CreatePolyhedron(name, options, scene);
  76958. };
  76959. /**
  76960. * Class containing static functions to help procedurally build meshes
  76961. */
  76962. var PolyhedronBuilder = /** @class */ (function () {
  76963. function PolyhedronBuilder() {
  76964. }
  76965. /**
  76966. * Creates a polyhedron mesh
  76967. * * 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
  76968. * * The parameter `size` (positive float, default 1) sets the polygon size
  76969. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  76970. * * 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`
  76971. * * 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
  76972. * * 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)`)
  76973. * * 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
  76974. * * 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
  76975. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76976. * * 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
  76977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76978. * @param name defines the name of the mesh
  76979. * @param options defines the options used to create the mesh
  76980. * @param scene defines the hosting scene
  76981. * @returns the polyhedron mesh
  76982. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  76983. */
  76984. PolyhedronBuilder.CreatePolyhedron = function (name, options, scene) {
  76985. var polyhedron = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  76986. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76987. polyhedron._originalBuilderSideOrientation = options.sideOrientation;
  76988. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron(options);
  76989. vertexData.applyToMesh(polyhedron, options.updatable);
  76990. return polyhedron;
  76991. };
  76992. return PolyhedronBuilder;
  76993. }());
  76994. /***/ }),
  76995. /***/ "./Meshes/Builders/ribbonBuilder.ts":
  76996. /*!******************************************!*\
  76997. !*** ./Meshes/Builders/ribbonBuilder.ts ***!
  76998. \******************************************/
  76999. /*! exports provided: RibbonBuilder */
  77000. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77001. "use strict";
  77002. __webpack_require__.r(__webpack_exports__);
  77003. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return RibbonBuilder; });
  77004. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77005. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77006. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  77007. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77008. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  77009. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon = function (options) {
  77010. var pathArray = options.pathArray;
  77011. var closeArray = options.closeArray || false;
  77012. var closePath = options.closePath || false;
  77013. var invertUV = options.invertUV || false;
  77014. var defaultOffset = Math.floor(pathArray[0].length / 2);
  77015. var offset = options.offset || defaultOffset;
  77016. offset = offset > defaultOffset ? defaultOffset : Math.floor(offset); // offset max allowed : defaultOffset
  77017. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].DEFAULTSIDE;
  77018. var customUV = options.uvs;
  77019. var customColors = options.colors;
  77020. var positions = [];
  77021. var indices = [];
  77022. var normals = [];
  77023. var uvs = [];
  77024. var us = []; // us[path_id] = [uDist1, uDist2, uDist3 ... ] distances between points on path path_id
  77025. var vs = []; // vs[i] = [vDist1, vDist2, vDist3, ... ] distances between points i of consecutives paths from pathArray
  77026. var uTotalDistance = []; // uTotalDistance[p] : total distance of path p
  77027. var vTotalDistance = []; // vTotalDistance[i] : total distance between points i of first and last path from pathArray
  77028. var minlg; // minimal length among all paths from pathArray
  77029. var lg = []; // array of path lengths : nb of vertex per path
  77030. var idx = []; // array of path indexes : index of each path (first vertex) in the total vertex number
  77031. var p; // path iterator
  77032. var i; // point iterator
  77033. var j; // point iterator
  77034. // if single path in pathArray
  77035. if (pathArray.length < 2) {
  77036. var ar1 = [];
  77037. var ar2 = [];
  77038. for (i = 0; i < pathArray[0].length - offset; i++) {
  77039. ar1.push(pathArray[0][i]);
  77040. ar2.push(pathArray[0][i + offset]);
  77041. }
  77042. pathArray = [ar1, ar2];
  77043. }
  77044. // positions and horizontal distances (u)
  77045. var idc = 0;
  77046. var closePathCorr = (closePath) ? 1 : 0; // the final index will be +1 if closePath
  77047. var path;
  77048. var l;
  77049. minlg = pathArray[0].length;
  77050. var vectlg;
  77051. var dist;
  77052. for (p = 0; p < pathArray.length; p++) {
  77053. uTotalDistance[p] = 0;
  77054. us[p] = [0];
  77055. path = pathArray[p];
  77056. l = path.length;
  77057. minlg = (minlg < l) ? minlg : l;
  77058. j = 0;
  77059. while (j < l) {
  77060. positions.push(path[j].x, path[j].y, path[j].z);
  77061. if (j > 0) {
  77062. vectlg = path[j].subtract(path[j - 1]).length();
  77063. dist = vectlg + uTotalDistance[p];
  77064. us[p].push(dist);
  77065. uTotalDistance[p] = dist;
  77066. }
  77067. j++;
  77068. }
  77069. if (closePath) { // an extra hidden vertex is added in the "positions" array
  77070. j--;
  77071. positions.push(path[0].x, path[0].y, path[0].z);
  77072. vectlg = path[j].subtract(path[0]).length();
  77073. dist = vectlg + uTotalDistance[p];
  77074. us[p].push(dist);
  77075. uTotalDistance[p] = dist;
  77076. }
  77077. lg[p] = l + closePathCorr;
  77078. idx[p] = idc;
  77079. idc += (l + closePathCorr);
  77080. }
  77081. // vertical distances (v)
  77082. var path1;
  77083. var path2;
  77084. var vertex1 = null;
  77085. var vertex2 = null;
  77086. for (i = 0; i < minlg + closePathCorr; i++) {
  77087. vTotalDistance[i] = 0;
  77088. vs[i] = [0];
  77089. for (p = 0; p < pathArray.length - 1; p++) {
  77090. path1 = pathArray[p];
  77091. path2 = pathArray[p + 1];
  77092. if (i === minlg) { // closePath
  77093. vertex1 = path1[0];
  77094. vertex2 = path2[0];
  77095. }
  77096. else {
  77097. vertex1 = path1[i];
  77098. vertex2 = path2[i];
  77099. }
  77100. vectlg = vertex2.subtract(vertex1).length();
  77101. dist = vectlg + vTotalDistance[i];
  77102. vs[i].push(dist);
  77103. vTotalDistance[i] = dist;
  77104. }
  77105. if (closeArray && vertex2 && vertex1) {
  77106. path1 = pathArray[p];
  77107. path2 = pathArray[0];
  77108. if (i === minlg) { // closePath
  77109. vertex2 = path2[0];
  77110. }
  77111. vectlg = vertex2.subtract(vertex1).length();
  77112. dist = vectlg + vTotalDistance[i];
  77113. vTotalDistance[i] = dist;
  77114. }
  77115. }
  77116. // uvs
  77117. var u;
  77118. var v;
  77119. if (customUV) {
  77120. for (p = 0; p < customUV.length; p++) {
  77121. uvs.push(customUV[p].x, customUV[p].y);
  77122. }
  77123. }
  77124. else {
  77125. for (p = 0; p < pathArray.length; p++) {
  77126. for (i = 0; i < minlg + closePathCorr; i++) {
  77127. u = (uTotalDistance[p] != 0.0) ? us[p][i] / uTotalDistance[p] : 0.0;
  77128. v = (vTotalDistance[i] != 0.0) ? vs[i][p] / vTotalDistance[i] : 0.0;
  77129. if (invertUV) {
  77130. uvs.push(v, u);
  77131. }
  77132. else {
  77133. uvs.push(u, v);
  77134. }
  77135. }
  77136. }
  77137. }
  77138. // indices
  77139. p = 0; // path index
  77140. var pi = 0; // positions array index
  77141. var l1 = lg[p] - 1; // path1 length
  77142. var l2 = lg[p + 1] - 1; // path2 length
  77143. var min = (l1 < l2) ? l1 : l2; // current path stop index
  77144. var shft = idx[1] - idx[0]; // shift
  77145. var path1nb = closeArray ? lg.length : lg.length - 1; // number of path1 to iterate on
  77146. while (pi <= min && p < path1nb) { // stay under min and don't go over next to last path
  77147. // 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
  77148. indices.push(pi, pi + shft, pi + 1);
  77149. indices.push(pi + shft + 1, pi + 1, pi + shft);
  77150. pi += 1;
  77151. if (pi === min) { // if end of one of two consecutive paths reached, go to next existing path
  77152. p++;
  77153. if (p === lg.length - 1) { // last path of pathArray reached <=> closeArray == true
  77154. shft = idx[0] - idx[p];
  77155. l1 = lg[p] - 1;
  77156. l2 = lg[0] - 1;
  77157. }
  77158. else {
  77159. shft = idx[p + 1] - idx[p];
  77160. l1 = lg[p] - 1;
  77161. l2 = lg[p + 1] - 1;
  77162. }
  77163. pi = idx[p];
  77164. min = (l1 < l2) ? l1 + pi : l2 + pi;
  77165. }
  77166. }
  77167. // normals
  77168. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals);
  77169. if (closePath) { // update both the first and last vertex normals to their average value
  77170. var indexFirst = 0;
  77171. var indexLast = 0;
  77172. for (p = 0; p < pathArray.length; p++) {
  77173. indexFirst = idx[p] * 3;
  77174. if (p + 1 < pathArray.length) {
  77175. indexLast = (idx[p + 1] - 1) * 3;
  77176. }
  77177. else {
  77178. indexLast = normals.length - 3;
  77179. }
  77180. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  77181. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  77182. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  77183. normals[indexLast] = normals[indexFirst];
  77184. normals[indexLast + 1] = normals[indexFirst + 1];
  77185. normals[indexLast + 2] = normals[indexFirst + 2];
  77186. }
  77187. }
  77188. // sides
  77189. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77190. // Colors
  77191. var colors = null;
  77192. if (customColors) {
  77193. colors = new Float32Array(customColors.length * 4);
  77194. for (var c = 0; c < customColors.length; c++) {
  77195. colors[c * 4] = customColors[c].r;
  77196. colors[c * 4 + 1] = customColors[c].g;
  77197. colors[c * 4 + 2] = customColors[c].b;
  77198. colors[c * 4 + 3] = customColors[c].a;
  77199. }
  77200. }
  77201. // Result
  77202. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  77203. var positions32 = new Float32Array(positions);
  77204. var normals32 = new Float32Array(normals);
  77205. var uvs32 = new Float32Array(uvs);
  77206. vertexData.indices = indices;
  77207. vertexData.positions = positions32;
  77208. vertexData.normals = normals32;
  77209. vertexData.uvs = uvs32;
  77210. if (colors) {
  77211. vertexData.set(colors, _buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  77212. }
  77213. if (closePath) {
  77214. vertexData._idx = idx;
  77215. }
  77216. return vertexData;
  77217. };
  77218. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  77219. if (closeArray === void 0) { closeArray = false; }
  77220. if (updatable === void 0) { updatable = false; }
  77221. return RibbonBuilder.CreateRibbon(name, {
  77222. pathArray: pathArray,
  77223. closeArray: closeArray,
  77224. closePath: closePath,
  77225. offset: offset,
  77226. updatable: updatable,
  77227. sideOrientation: sideOrientation,
  77228. instance: instance
  77229. }, scene);
  77230. };
  77231. /**
  77232. * Class containing static functions to help procedurally build meshes
  77233. */
  77234. var RibbonBuilder = /** @class */ (function () {
  77235. function RibbonBuilder() {
  77236. }
  77237. /**
  77238. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  77239. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  77240. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  77241. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  77242. * * 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
  77243. * * 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
  77244. * * 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
  77245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77246. * * 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
  77247. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  77248. * * 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
  77249. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  77250. * * 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
  77251. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  77252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77253. * @param name defines the name of the mesh
  77254. * @param options defines the options used to create the mesh
  77255. * @param scene defines the hosting scene
  77256. * @returns the ribbon mesh
  77257. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  77258. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  77259. */
  77260. RibbonBuilder.CreateRibbon = function (name, options, scene) {
  77261. if (scene === void 0) { scene = null; }
  77262. var pathArray = options.pathArray;
  77263. var closeArray = options.closeArray;
  77264. var closePath = options.closePath;
  77265. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77266. var instance = options.instance;
  77267. var updatable = options.updatable;
  77268. if (instance) { // existing ribbon instance update
  77269. // positionFunction : ribbon case
  77270. // only pathArray and sideOrientation parameters are taken into account for positions update
  77271. var minimum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0].setAll(Number.MAX_VALUE);
  77272. var maximum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1].setAll(-Number.MAX_VALUE);
  77273. var positionFunction = function (positions) {
  77274. var minlg = pathArray[0].length;
  77275. var mesh = instance;
  77276. var i = 0;
  77277. var ns = (mesh._originalBuilderSideOrientation === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DOUBLESIDE) ? 2 : 1;
  77278. for (var si = 1; si <= ns; ++si) {
  77279. for (var p = 0; p < pathArray.length; ++p) {
  77280. var path = pathArray[p];
  77281. var l = path.length;
  77282. minlg = (minlg < l) ? minlg : l;
  77283. for (var j = 0; j < minlg; ++j) {
  77284. var pathPoint = path[j];
  77285. positions[i] = pathPoint.x;
  77286. positions[i + 1] = pathPoint.y;
  77287. positions[i + 2] = pathPoint.z;
  77288. minimum_1.minimizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  77289. maximum_1.maximizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  77290. i += 3;
  77291. }
  77292. if (mesh._creationDataStorage && mesh._creationDataStorage.closePath) {
  77293. var pathPoint = path[0];
  77294. positions[i] = pathPoint.x;
  77295. positions[i + 1] = pathPoint.y;
  77296. positions[i + 2] = pathPoint.z;
  77297. i += 3;
  77298. }
  77299. }
  77300. }
  77301. };
  77302. var positions = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  77303. positionFunction(positions);
  77304. if (instance._boundingInfo) {
  77305. instance._boundingInfo.reConstruct(minimum_1, maximum_1, instance._worldMatrix);
  77306. }
  77307. else {
  77308. instance._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](minimum_1, maximum_1, instance._worldMatrix);
  77309. }
  77310. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positions, false, false);
  77311. if (options.colors) {
  77312. var colors = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  77313. for (var c = 0, colorIndex = 0; c < options.colors.length; c++, colorIndex += 4) {
  77314. var color = options.colors[c];
  77315. colors[colorIndex] = color.r;
  77316. colors[colorIndex + 1] = color.g;
  77317. colors[colorIndex + 2] = color.b;
  77318. colors[colorIndex + 3] = color.a;
  77319. }
  77320. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colors, false, false);
  77321. }
  77322. if (options.uvs) {
  77323. var uvs = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  77324. for (var i = 0; i < options.uvs.length; i++) {
  77325. uvs[i * 2] = options.uvs[i].x;
  77326. uvs[i * 2 + 1] = options.uvs[i].y;
  77327. }
  77328. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvs, false, false);
  77329. }
  77330. if (!instance.areNormalsFrozen || instance.isFacetDataEnabled) {
  77331. var indices = instance.getIndices();
  77332. var normals = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  77333. var params = instance.isFacetDataEnabled ? instance.getFacetDataParameters() : null;
  77334. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals, params);
  77335. if (instance._creationDataStorage && instance._creationDataStorage.closePath) {
  77336. var indexFirst = 0;
  77337. var indexLast = 0;
  77338. for (var p = 0; p < pathArray.length; p++) {
  77339. indexFirst = instance._creationDataStorage.idx[p] * 3;
  77340. if (p + 1 < pathArray.length) {
  77341. indexLast = (instance._creationDataStorage.idx[p + 1] - 1) * 3;
  77342. }
  77343. else {
  77344. indexLast = normals.length - 3;
  77345. }
  77346. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  77347. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  77348. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  77349. normals[indexLast] = normals[indexFirst];
  77350. normals[indexLast + 1] = normals[indexFirst + 1];
  77351. normals[indexLast + 2] = normals[indexFirst + 2];
  77352. }
  77353. }
  77354. if (!(instance.areNormalsFrozen)) {
  77355. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normals, false, false);
  77356. }
  77357. }
  77358. return instance;
  77359. }
  77360. else { // new ribbon creation
  77361. var ribbon = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77362. ribbon._originalBuilderSideOrientation = sideOrientation;
  77363. ribbon._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  77364. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon(options);
  77365. if (closePath) {
  77366. ribbon._creationDataStorage.idx = vertexData._idx;
  77367. }
  77368. ribbon._creationDataStorage.closePath = closePath;
  77369. ribbon._creationDataStorage.closeArray = closeArray;
  77370. vertexData.applyToMesh(ribbon, updatable);
  77371. return ribbon;
  77372. }
  77373. };
  77374. return RibbonBuilder;
  77375. }());
  77376. /***/ }),
  77377. /***/ "./Meshes/Builders/shapeBuilder.ts":
  77378. /*!*****************************************!*\
  77379. !*** ./Meshes/Builders/shapeBuilder.ts ***!
  77380. \*****************************************/
  77381. /*! exports provided: ShapeBuilder */
  77382. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77383. "use strict";
  77384. __webpack_require__.r(__webpack_exports__);
  77385. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return ShapeBuilder; });
  77386. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77387. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77388. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  77389. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  77390. if (scene === void 0) { scene = null; }
  77391. var options = {
  77392. shape: shape,
  77393. path: path,
  77394. scale: scale,
  77395. rotation: rotation,
  77396. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  77397. sideOrientation: sideOrientation,
  77398. instance: instance,
  77399. updatable: updatable
  77400. };
  77401. return ShapeBuilder.ExtrudeShape(name, options, scene);
  77402. };
  77403. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  77404. var options = {
  77405. shape: shape,
  77406. path: path,
  77407. scaleFunction: scaleFunction,
  77408. rotationFunction: rotationFunction,
  77409. ribbonCloseArray: ribbonCloseArray,
  77410. ribbonClosePath: ribbonClosePath,
  77411. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  77412. sideOrientation: sideOrientation,
  77413. instance: instance,
  77414. updatable: updatable
  77415. };
  77416. return ShapeBuilder.ExtrudeShapeCustom(name, options, scene);
  77417. };
  77418. /**
  77419. * Class containing static functions to help procedurally build meshes
  77420. */
  77421. var ShapeBuilder = /** @class */ (function () {
  77422. function ShapeBuilder() {
  77423. }
  77424. /**
  77425. * 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.
  77426. * * 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.
  77427. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  77428. * * 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.
  77429. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  77430. * * 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
  77431. * * 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
  77432. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  77433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77434. * * 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
  77435. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  77436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77437. * @param name defines the name of the mesh
  77438. * @param options defines the options used to create the mesh
  77439. * @param scene defines the hosting scene
  77440. * @returns the extruded shape mesh
  77441. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  77442. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77443. */
  77444. ShapeBuilder.ExtrudeShape = function (name, options, scene) {
  77445. if (scene === void 0) { scene = null; }
  77446. var path = options.path;
  77447. var shape = options.shape;
  77448. var scale = options.scale || 1;
  77449. var rotation = options.rotation || 0;
  77450. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  77451. var updatable = options.updatable;
  77452. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77453. var instance = options.instance || null;
  77454. var invertUV = options.invertUV || false;
  77455. 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);
  77456. };
  77457. /**
  77458. * Creates an custom extruded shape mesh.
  77459. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  77460. * * 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.
  77461. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  77462. * * 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
  77463. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  77464. * * 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
  77465. * * It must returns a float value that will be the scale value applied to the shape on each path point
  77466. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  77467. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  77468. * * 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
  77469. * * 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
  77470. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  77471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77472. * * 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
  77473. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  77474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77475. * @param name defines the name of the mesh
  77476. * @param options defines the options used to create the mesh
  77477. * @param scene defines the hosting scene
  77478. * @returns the custom extruded shape mesh
  77479. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  77480. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  77481. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77482. */
  77483. ShapeBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  77484. var path = options.path;
  77485. var shape = options.shape;
  77486. var scaleFunction = options.scaleFunction || (function () { return 1; });
  77487. var rotationFunction = options.rotationFunction || (function () { return 0; });
  77488. var ribbonCloseArray = options.ribbonCloseArray || false;
  77489. var ribbonClosePath = options.ribbonClosePath || false;
  77490. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  77491. var updatable = options.updatable;
  77492. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77493. var instance = options.instance;
  77494. var invertUV = options.invertUV || false;
  77495. 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);
  77496. };
  77497. ShapeBuilder._ExtrudeShapeGeneric = function (name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs) {
  77498. // extrusion geometry
  77499. var extrusionPathArray = function (shape, curve, path3D, shapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom) {
  77500. var tangents = path3D.getTangents();
  77501. var normals = path3D.getNormals();
  77502. var binormals = path3D.getBinormals();
  77503. var distances = path3D.getDistances();
  77504. var angle = 0;
  77505. var returnScale = function () { return scale !== null ? scale : 1; };
  77506. var returnRotation = function () { return rotation !== null ? rotation : 0; };
  77507. var rotate = custom && rotateFunction ? rotateFunction : returnRotation;
  77508. var scl = custom && scaleFunction ? scaleFunction : returnScale;
  77509. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  77510. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  77511. for (var i = 0; i < curve.length; i++) {
  77512. var shapePath = new Array();
  77513. var angleStep = rotate(i, distances[i]);
  77514. var scaleRatio = scl(i, distances[i]);
  77515. for (var p = 0; p < shape.length; p++) {
  77516. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], angle, rotationMatrix);
  77517. var planed = ((tangents[i].scale(shape[p].z)).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y)));
  77518. var rotated = shapePath[p] ? shapePath[p] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77519. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(planed, rotationMatrix, rotated);
  77520. rotated.scaleInPlace(scaleRatio).addInPlace(curve[i]);
  77521. shapePath[p] = rotated;
  77522. }
  77523. shapePaths[index] = shapePath;
  77524. angle += angleStep;
  77525. index++;
  77526. }
  77527. // cap
  77528. var capPath = function (shapePath) {
  77529. var pointCap = Array();
  77530. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77531. var i;
  77532. for (i = 0; i < shapePath.length; i++) {
  77533. barycenter.addInPlace(shapePath[i]);
  77534. }
  77535. barycenter.scaleInPlace(1.0 / shapePath.length);
  77536. for (i = 0; i < shapePath.length; i++) {
  77537. pointCap.push(barycenter);
  77538. }
  77539. return pointCap;
  77540. };
  77541. switch (cap) {
  77542. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  77543. break;
  77544. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  77545. shapePaths[0] = capPath(shapePaths[2]);
  77546. shapePaths[1] = shapePaths[2];
  77547. break;
  77548. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  77549. shapePaths[index] = shapePaths[index - 1];
  77550. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  77551. break;
  77552. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  77553. shapePaths[0] = capPath(shapePaths[2]);
  77554. shapePaths[1] = shapePaths[2];
  77555. shapePaths[index] = shapePaths[index - 1];
  77556. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  77557. break;
  77558. default:
  77559. break;
  77560. }
  77561. return shapePaths;
  77562. };
  77563. var path3D;
  77564. var pathArray;
  77565. if (instance) { // instance update
  77566. var storage = instance._creationDataStorage;
  77567. path3D = storage.path3D.update(curve);
  77568. pathArray = extrusionPathArray(shape, curve, storage.path3D, storage.pathArray, scale, rotation, scaleFunction, rotateFunction, storage.cap, custom);
  77569. instance = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon("", pathArray, false, false, 0, scene || undefined, false, 0, instance);
  77570. return instance;
  77571. }
  77572. // extruded shape creation
  77573. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](curve);
  77574. var newShapePaths = new Array();
  77575. cap = (cap < 0 || cap > 3) ? 0 : cap;
  77576. pathArray = extrusionPathArray(shape, curve, path3D, newShapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom);
  77577. 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);
  77578. extrudedGeneric._creationDataStorage.pathArray = pathArray;
  77579. extrudedGeneric._creationDataStorage.path3D = path3D;
  77580. extrudedGeneric._creationDataStorage.cap = cap;
  77581. return extrudedGeneric;
  77582. };
  77583. return ShapeBuilder;
  77584. }());
  77585. /***/ }),
  77586. /***/ "./Meshes/Builders/sphereBuilder.ts":
  77587. /*!******************************************!*\
  77588. !*** ./Meshes/Builders/sphereBuilder.ts ***!
  77589. \******************************************/
  77590. /*! exports provided: SphereBuilder */
  77591. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77592. "use strict";
  77593. __webpack_require__.r(__webpack_exports__);
  77594. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return SphereBuilder; });
  77595. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77596. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77597. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77598. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere = function (options) {
  77599. var segments = options.segments || 32;
  77600. var diameterX = options.diameterX || options.diameter || 1;
  77601. var diameterY = options.diameterY || options.diameter || 1;
  77602. var diameterZ = options.diameterZ || options.diameter || 1;
  77603. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  77604. var slice = options.slice && (options.slice <= 0) ? 1.0 : options.slice || 1.0;
  77605. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  77606. var radius = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](diameterX / 2, diameterY / 2, diameterZ / 2);
  77607. var totalZRotationSteps = 2 + segments;
  77608. var totalYRotationSteps = 2 * totalZRotationSteps;
  77609. var indices = [];
  77610. var positions = [];
  77611. var normals = [];
  77612. var uvs = [];
  77613. for (var zRotationStep = 0; zRotationStep <= totalZRotationSteps; zRotationStep++) {
  77614. var normalizedZ = zRotationStep / totalZRotationSteps;
  77615. var angleZ = normalizedZ * Math.PI * slice;
  77616. for (var yRotationStep = 0; yRotationStep <= totalYRotationSteps; yRotationStep++) {
  77617. var normalizedY = yRotationStep / totalYRotationSteps;
  77618. var angleY = normalizedY * Math.PI * 2 * arc;
  77619. var rotationZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationZ(-angleZ);
  77620. var rotationY = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(angleY);
  77621. var afterRotZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), rotationZ);
  77622. var complete = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(afterRotZ, rotationY);
  77623. var vertex = complete.multiply(radius);
  77624. var normal = complete.divide(radius).normalize();
  77625. positions.push(vertex.x, vertex.y, vertex.z);
  77626. normals.push(normal.x, normal.y, normal.z);
  77627. uvs.push(normalizedY, normalizedZ);
  77628. }
  77629. if (zRotationStep > 0) {
  77630. var verticesCount = positions.length / 3;
  77631. for (var firstIndex = verticesCount - 2 * (totalYRotationSteps + 1); (firstIndex + totalYRotationSteps + 2) < verticesCount; firstIndex++) {
  77632. indices.push((firstIndex));
  77633. indices.push((firstIndex + 1));
  77634. indices.push(firstIndex + totalYRotationSteps + 1);
  77635. indices.push((firstIndex + totalYRotationSteps + 1));
  77636. indices.push((firstIndex + 1));
  77637. indices.push((firstIndex + totalYRotationSteps + 2));
  77638. }
  77639. }
  77640. }
  77641. // Sides
  77642. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77643. // Result
  77644. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77645. vertexData.indices = indices;
  77646. vertexData.positions = positions;
  77647. vertexData.normals = normals;
  77648. vertexData.uvs = uvs;
  77649. return vertexData;
  77650. };
  77651. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  77652. var options = {
  77653. segments: segments,
  77654. diameterX: diameter,
  77655. diameterY: diameter,
  77656. diameterZ: diameter,
  77657. sideOrientation: sideOrientation,
  77658. updatable: updatable
  77659. };
  77660. return SphereBuilder.CreateSphere(name, options, scene);
  77661. };
  77662. /**
  77663. * Class containing static functions to help procedurally build meshes
  77664. */
  77665. var SphereBuilder = /** @class */ (function () {
  77666. function SphereBuilder() {
  77667. }
  77668. /**
  77669. * Creates a sphere mesh
  77670. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  77671. * * 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`)
  77672. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  77673. * * 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
  77674. * * 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)
  77675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77676. * * 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
  77677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77678. * @param name defines the name of the mesh
  77679. * @param options defines the options used to create the mesh
  77680. * @param scene defines the hosting scene
  77681. * @returns the sphere mesh
  77682. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  77683. */
  77684. SphereBuilder.CreateSphere = function (name, options, scene) {
  77685. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77686. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77687. sphere._originalBuilderSideOrientation = options.sideOrientation;
  77688. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere(options);
  77689. vertexData.applyToMesh(sphere, options.updatable);
  77690. return sphere;
  77691. };
  77692. return SphereBuilder;
  77693. }());
  77694. /***/ }),
  77695. /***/ "./Meshes/Builders/torusBuilder.ts":
  77696. /*!*****************************************!*\
  77697. !*** ./Meshes/Builders/torusBuilder.ts ***!
  77698. \*****************************************/
  77699. /*! exports provided: TorusBuilder */
  77700. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77701. "use strict";
  77702. __webpack_require__.r(__webpack_exports__);
  77703. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return TorusBuilder; });
  77704. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77705. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77706. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77707. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus = function (options) {
  77708. var indices = [];
  77709. var positions = [];
  77710. var normals = [];
  77711. var uvs = [];
  77712. var diameter = options.diameter || 1;
  77713. var thickness = options.thickness || 0.5;
  77714. var tessellation = options.tessellation || 16;
  77715. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  77716. var stride = tessellation + 1;
  77717. for (var i = 0; i <= tessellation; i++) {
  77718. var u = i / tessellation;
  77719. var outerAngle = i * Math.PI * 2.0 / tessellation - Math.PI / 2.0;
  77720. 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));
  77721. for (var j = 0; j <= tessellation; j++) {
  77722. var v = 1 - j / tessellation;
  77723. var innerAngle = j * Math.PI * 2.0 / tessellation + Math.PI;
  77724. var dx = Math.cos(innerAngle);
  77725. var dy = Math.sin(innerAngle);
  77726. // Create a vertex.
  77727. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](dx, dy, 0);
  77728. var position = normal.scale(thickness / 2);
  77729. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](u, v);
  77730. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(position, transform);
  77731. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, transform);
  77732. positions.push(position.x, position.y, position.z);
  77733. normals.push(normal.x, normal.y, normal.z);
  77734. uvs.push(textureCoordinate.x, textureCoordinate.y);
  77735. // And create indices for two triangles.
  77736. var nextI = (i + 1) % stride;
  77737. var nextJ = (j + 1) % stride;
  77738. indices.push(i * stride + j);
  77739. indices.push(i * stride + nextJ);
  77740. indices.push(nextI * stride + j);
  77741. indices.push(i * stride + nextJ);
  77742. indices.push(nextI * stride + nextJ);
  77743. indices.push(nextI * stride + j);
  77744. }
  77745. }
  77746. // Sides
  77747. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77748. // Result
  77749. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77750. vertexData.indices = indices;
  77751. vertexData.positions = positions;
  77752. vertexData.normals = normals;
  77753. vertexData.uvs = uvs;
  77754. return vertexData;
  77755. };
  77756. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  77757. var options = {
  77758. diameter: diameter,
  77759. thickness: thickness,
  77760. tessellation: tessellation,
  77761. sideOrientation: sideOrientation,
  77762. updatable: updatable
  77763. };
  77764. return TorusBuilder.CreateTorus(name, options, scene);
  77765. };
  77766. /**
  77767. * Class containing static functions to help procedurally build meshes
  77768. */
  77769. var TorusBuilder = /** @class */ (function () {
  77770. function TorusBuilder() {
  77771. }
  77772. /**
  77773. * Creates a torus mesh
  77774. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  77775. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  77776. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  77777. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77778. * * 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
  77779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77780. * @param name defines the name of the mesh
  77781. * @param options defines the options used to create the mesh
  77782. * @param scene defines the hosting scene
  77783. * @returns the torus mesh
  77784. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  77785. */
  77786. TorusBuilder.CreateTorus = function (name, options, scene) {
  77787. var torus = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77788. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77789. torus._originalBuilderSideOrientation = options.sideOrientation;
  77790. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus(options);
  77791. vertexData.applyToMesh(torus, options.updatable);
  77792. return torus;
  77793. };
  77794. return TorusBuilder;
  77795. }());
  77796. /***/ }),
  77797. /***/ "./Meshes/Builders/torusKnotBuilder.ts":
  77798. /*!*********************************************!*\
  77799. !*** ./Meshes/Builders/torusKnotBuilder.ts ***!
  77800. \*********************************************/
  77801. /*! exports provided: TorusKnotBuilder */
  77802. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77803. "use strict";
  77804. __webpack_require__.r(__webpack_exports__);
  77805. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return TorusKnotBuilder; });
  77806. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77807. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77808. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77809. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot = function (options) {
  77810. var indices = new Array();
  77811. var positions = new Array();
  77812. var normals = new Array();
  77813. var uvs = new Array();
  77814. var radius = options.radius || 2;
  77815. var tube = options.tube || 0.5;
  77816. var radialSegments = options.radialSegments || 32;
  77817. var tubularSegments = options.tubularSegments || 32;
  77818. var p = options.p || 2;
  77819. var q = options.q || 3;
  77820. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  77821. // Helper
  77822. var getPos = function (angle) {
  77823. var cu = Math.cos(angle);
  77824. var su = Math.sin(angle);
  77825. var quOverP = q / p * angle;
  77826. var cs = Math.cos(quOverP);
  77827. var tx = radius * (2 + cs) * 0.5 * cu;
  77828. var ty = radius * (2 + cs) * su * 0.5;
  77829. var tz = radius * Math.sin(quOverP) * 0.5;
  77830. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](tx, ty, tz);
  77831. };
  77832. // Vertices
  77833. var i;
  77834. var j;
  77835. for (i = 0; i <= radialSegments; i++) {
  77836. var modI = i % radialSegments;
  77837. var u = modI / radialSegments * 2 * p * Math.PI;
  77838. var p1 = getPos(u);
  77839. var p2 = getPos(u + 0.01);
  77840. var tang = p2.subtract(p1);
  77841. var n = p2.add(p1);
  77842. var bitan = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(tang, n);
  77843. n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(bitan, tang);
  77844. bitan.normalize();
  77845. n.normalize();
  77846. for (j = 0; j < tubularSegments; j++) {
  77847. var modJ = j % tubularSegments;
  77848. var v = modJ / tubularSegments * 2 * Math.PI;
  77849. var cx = -tube * Math.cos(v);
  77850. var cy = tube * Math.sin(v);
  77851. positions.push(p1.x + cx * n.x + cy * bitan.x);
  77852. positions.push(p1.y + cx * n.y + cy * bitan.y);
  77853. positions.push(p1.z + cx * n.z + cy * bitan.z);
  77854. uvs.push(i / radialSegments);
  77855. uvs.push(j / tubularSegments);
  77856. }
  77857. }
  77858. for (i = 0; i < radialSegments; i++) {
  77859. for (j = 0; j < tubularSegments; j++) {
  77860. var jNext = (j + 1) % tubularSegments;
  77861. var a = i * tubularSegments + j;
  77862. var b = (i + 1) * tubularSegments + j;
  77863. var c = (i + 1) * tubularSegments + jNext;
  77864. var d = i * tubularSegments + jNext;
  77865. indices.push(d);
  77866. indices.push(b);
  77867. indices.push(a);
  77868. indices.push(d);
  77869. indices.push(c);
  77870. indices.push(b);
  77871. }
  77872. }
  77873. // Normals
  77874. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  77875. // Sides
  77876. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77877. // Result
  77878. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77879. vertexData.indices = indices;
  77880. vertexData.positions = positions;
  77881. vertexData.normals = normals;
  77882. vertexData.uvs = uvs;
  77883. return vertexData;
  77884. };
  77885. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  77886. var options = {
  77887. radius: radius,
  77888. tube: tube,
  77889. radialSegments: radialSegments,
  77890. tubularSegments: tubularSegments,
  77891. p: p,
  77892. q: q,
  77893. sideOrientation: sideOrientation,
  77894. updatable: updatable
  77895. };
  77896. return TorusKnotBuilder.CreateTorusKnot(name, options, scene);
  77897. };
  77898. /**
  77899. * Class containing static functions to help procedurally build meshes
  77900. */
  77901. var TorusKnotBuilder = /** @class */ (function () {
  77902. function TorusKnotBuilder() {
  77903. }
  77904. /**
  77905. * Creates a torus knot mesh
  77906. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  77907. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  77908. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  77909. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  77910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77911. * * 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
  77912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77913. * @param name defines the name of the mesh
  77914. * @param options defines the options used to create the mesh
  77915. * @param scene defines the hosting scene
  77916. * @returns the torus knot mesh
  77917. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  77918. */
  77919. TorusKnotBuilder.CreateTorusKnot = function (name, options, scene) {
  77920. var torusKnot = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77921. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77922. torusKnot._originalBuilderSideOrientation = options.sideOrientation;
  77923. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot(options);
  77924. vertexData.applyToMesh(torusKnot, options.updatable);
  77925. return torusKnot;
  77926. };
  77927. return TorusKnotBuilder;
  77928. }());
  77929. /***/ }),
  77930. /***/ "./Meshes/Builders/tubeBuilder.ts":
  77931. /*!****************************************!*\
  77932. !*** ./Meshes/Builders/tubeBuilder.ts ***!
  77933. \****************************************/
  77934. /*! exports provided: TubeBuilder */
  77935. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77936. "use strict";
  77937. __webpack_require__.r(__webpack_exports__);
  77938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return TubeBuilder; });
  77939. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77940. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77941. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  77942. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  77943. var options = {
  77944. path: path,
  77945. radius: radius,
  77946. tessellation: tessellation,
  77947. radiusFunction: radiusFunction,
  77948. arc: 1,
  77949. cap: cap,
  77950. updatable: updatable,
  77951. sideOrientation: sideOrientation,
  77952. instance: instance
  77953. };
  77954. return TubeBuilder.CreateTube(name, options, scene);
  77955. };
  77956. /**
  77957. * Class containing static functions to help procedurally build meshes
  77958. */
  77959. var TubeBuilder = /** @class */ (function () {
  77960. function TubeBuilder() {
  77961. }
  77962. /**
  77963. * Creates a tube mesh.
  77964. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  77965. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  77966. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  77967. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  77968. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  77969. * * 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)
  77970. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  77971. * * 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
  77972. * * 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
  77973. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77974. * * 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
  77975. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  77976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77977. * @param name defines the name of the mesh
  77978. * @param options defines the options used to create the mesh
  77979. * @param scene defines the hosting scene
  77980. * @returns the tube mesh
  77981. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  77982. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  77983. */
  77984. TubeBuilder.CreateTube = function (name, options, scene) {
  77985. var path = options.path;
  77986. var instance = options.instance;
  77987. var radius = 1.0;
  77988. if (options.radius !== undefined) {
  77989. radius = options.radius;
  77990. }
  77991. else if (instance) {
  77992. radius = instance._creationDataStorage.radius;
  77993. }
  77994. var tessellation = options.tessellation || 64 | 0;
  77995. var radiusFunction = options.radiusFunction || null;
  77996. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  77997. var invertUV = options.invertUV || false;
  77998. var updatable = options.updatable;
  77999. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78000. options.arc = options.arc && (options.arc <= 0.0 || options.arc > 1.0) ? 1.0 : options.arc || 1.0;
  78001. // tube geometry
  78002. var tubePathArray = function (path, path3D, circlePaths, radius, tessellation, radiusFunction, cap, arc) {
  78003. var tangents = path3D.getTangents();
  78004. var normals = path3D.getNormals();
  78005. var distances = path3D.getDistances();
  78006. var pi2 = Math.PI * 2;
  78007. var step = pi2 / tessellation * arc;
  78008. var returnRadius = function () { return radius; };
  78009. var radiusFunctionFinal = radiusFunction || returnRadius;
  78010. var circlePath;
  78011. var rad;
  78012. var normal;
  78013. var rotated;
  78014. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  78015. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  78016. for (var i = 0; i < path.length; i++) {
  78017. rad = radiusFunctionFinal(i, distances[i]); // current radius
  78018. circlePath = Array(); // current circle array
  78019. normal = normals[i]; // current normal
  78020. for (var t = 0; t < tessellation; t++) {
  78021. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], step * t, rotationMatrix);
  78022. rotated = circlePath[t] ? circlePath[t] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78023. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(normal, rotationMatrix, rotated);
  78024. rotated.scaleInPlace(rad).addInPlace(path[i]);
  78025. circlePath[t] = rotated;
  78026. }
  78027. circlePaths[index] = circlePath;
  78028. index++;
  78029. }
  78030. // cap
  78031. var capPath = function (nbPoints, pathIndex) {
  78032. var pointCap = Array();
  78033. for (var i = 0; i < nbPoints; i++) {
  78034. pointCap.push(path[pathIndex]);
  78035. }
  78036. return pointCap;
  78037. };
  78038. switch (cap) {
  78039. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  78040. break;
  78041. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  78042. circlePaths[0] = capPath(tessellation, 0);
  78043. circlePaths[1] = circlePaths[2].slice(0);
  78044. break;
  78045. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  78046. circlePaths[index] = circlePaths[index - 1].slice(0);
  78047. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  78048. break;
  78049. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  78050. circlePaths[0] = capPath(tessellation, 0);
  78051. circlePaths[1] = circlePaths[2].slice(0);
  78052. circlePaths[index] = circlePaths[index - 1].slice(0);
  78053. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  78054. break;
  78055. default:
  78056. break;
  78057. }
  78058. return circlePaths;
  78059. };
  78060. var path3D;
  78061. var pathArray;
  78062. if (instance) { // tube update
  78063. var storage = instance._creationDataStorage;
  78064. var arc = options.arc || storage.arc;
  78065. path3D = storage.path3D.update(path);
  78066. pathArray = tubePathArray(path, path3D, storage.pathArray, radius, storage.tessellation, radiusFunction, storage.cap, arc);
  78067. instance = _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"].CreateRibbon("", { pathArray: pathArray, instance: instance });
  78068. // Update mode, no need to recreate the storage.
  78069. storage.path3D = path3D;
  78070. storage.pathArray = pathArray;
  78071. storage.arc = arc;
  78072. storage.radius = radius;
  78073. return instance;
  78074. }
  78075. // tube creation
  78076. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](path);
  78077. var newPathArray = new Array();
  78078. cap = (cap < 0 || cap > 3) ? 0 : cap;
  78079. pathArray = tubePathArray(path, path3D, newPathArray, radius, tessellation, radiusFunction, cap, options.arc);
  78080. 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);
  78081. tube._creationDataStorage.pathArray = pathArray;
  78082. tube._creationDataStorage.path3D = path3D;
  78083. tube._creationDataStorage.tessellation = tessellation;
  78084. tube._creationDataStorage.cap = cap;
  78085. tube._creationDataStorage.arc = options.arc;
  78086. tube._creationDataStorage.radius = radius;
  78087. return tube;
  78088. };
  78089. return TubeBuilder;
  78090. }());
  78091. /***/ }),
  78092. /***/ "./Meshes/Compression/dracoCompression.ts":
  78093. /*!************************************************!*\
  78094. !*** ./Meshes/Compression/dracoCompression.ts ***!
  78095. \************************************************/
  78096. /*! exports provided: DracoCompression */
  78097. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78098. "use strict";
  78099. __webpack_require__.r(__webpack_exports__);
  78100. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return DracoCompression; });
  78101. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  78102. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78103. /**
  78104. * Draco compression (https://google.github.io/draco/)
  78105. *
  78106. * This class wraps the Draco module.
  78107. *
  78108. * **Encoder**
  78109. *
  78110. * The encoder is not currently implemented.
  78111. *
  78112. * **Decoder**
  78113. *
  78114. * 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.
  78115. *
  78116. * To update the configuration, use the following code:
  78117. * ```javascript
  78118. * DracoCompression.Configuration = {
  78119. * decoder: {
  78120. * wasmUrl: "<url to the WebAssembly library>",
  78121. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  78122. * fallbackUrl: "<url to the fallback JavaScript library>",
  78123. * }
  78124. * };
  78125. * ```
  78126. *
  78127. * 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.
  78128. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  78129. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  78130. *
  78131. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  78132. * ```javascript
  78133. * var dracoCompression = new DracoCompression();
  78134. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  78135. * [VertexBuffer.PositionKind]: 0
  78136. * });
  78137. * ```
  78138. *
  78139. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  78140. */
  78141. var DracoCompression = /** @class */ (function () {
  78142. /**
  78143. * Constructor
  78144. */
  78145. function DracoCompression() {
  78146. }
  78147. Object.defineProperty(DracoCompression, "DecoderAvailable", {
  78148. /**
  78149. * Returns true if the decoder is available.
  78150. */
  78151. get: function () {
  78152. if (typeof DracoDecoderModule !== "undefined") {
  78153. return true;
  78154. }
  78155. var decoder = DracoCompression.Configuration.decoder;
  78156. if (decoder) {
  78157. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  78158. return true;
  78159. }
  78160. if (decoder.fallbackUrl) {
  78161. return true;
  78162. }
  78163. }
  78164. return false;
  78165. },
  78166. enumerable: true,
  78167. configurable: true
  78168. });
  78169. /**
  78170. * Stop all async operations and release resources.
  78171. */
  78172. DracoCompression.prototype.dispose = function () {
  78173. };
  78174. /**
  78175. * Decode Draco compressed mesh data to vertex data.
  78176. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  78177. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  78178. * @returns A promise that resolves with the decoded vertex data
  78179. */
  78180. DracoCompression.prototype.decodeMeshAsync = function (data, attributes) {
  78181. var dataView = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
  78182. return DracoCompression._GetDecoderModule().then(function (wrappedModule) {
  78183. var module = wrappedModule.module;
  78184. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  78185. var buffer = new module.DecoderBuffer();
  78186. buffer.Init(dataView, dataView.byteLength);
  78187. var decoder = new module.Decoder();
  78188. var geometry;
  78189. var status;
  78190. try {
  78191. var type = decoder.GetEncodedGeometryType(buffer);
  78192. switch (type) {
  78193. case module.TRIANGULAR_MESH:
  78194. geometry = new module.Mesh();
  78195. status = decoder.DecodeBufferToMesh(buffer, geometry);
  78196. break;
  78197. case module.POINT_CLOUD:
  78198. geometry = new module.PointCloud();
  78199. status = decoder.DecodeBufferToPointCloud(buffer, geometry);
  78200. break;
  78201. default:
  78202. throw new Error("Invalid geometry type " + type);
  78203. }
  78204. if (!status.ok() || !geometry.ptr) {
  78205. throw new Error(status.error_msg());
  78206. }
  78207. var numPoints = geometry.num_points();
  78208. if (type === module.TRIANGULAR_MESH) {
  78209. var numFaces = geometry.num_faces();
  78210. var faceIndices = new module.DracoInt32Array();
  78211. try {
  78212. var indices = new Uint32Array(numFaces * 3);
  78213. for (var i = 0; i < numFaces; i++) {
  78214. decoder.GetFaceFromMesh(geometry, i, faceIndices);
  78215. var offset = i * 3;
  78216. indices[offset + 0] = faceIndices.GetValue(0);
  78217. indices[offset + 1] = faceIndices.GetValue(1);
  78218. indices[offset + 2] = faceIndices.GetValue(2);
  78219. }
  78220. vertexData.indices = indices;
  78221. }
  78222. finally {
  78223. module.destroy(faceIndices);
  78224. }
  78225. }
  78226. for (var kind in attributes) {
  78227. var uniqueId = attributes[kind];
  78228. var attribute = decoder.GetAttributeByUniqueId(geometry, uniqueId);
  78229. var dracoData = new module.DracoFloat32Array();
  78230. try {
  78231. decoder.GetAttributeFloatForAllPoints(geometry, attribute, dracoData);
  78232. var babylonData = new Float32Array(numPoints * attribute.num_components());
  78233. for (var i = 0; i < babylonData.length; i++) {
  78234. babylonData[i] = dracoData.GetValue(i);
  78235. }
  78236. vertexData.set(babylonData, kind);
  78237. }
  78238. finally {
  78239. module.destroy(dracoData);
  78240. }
  78241. }
  78242. }
  78243. finally {
  78244. if (geometry) {
  78245. module.destroy(geometry);
  78246. }
  78247. module.destroy(decoder);
  78248. module.destroy(buffer);
  78249. }
  78250. return vertexData;
  78251. });
  78252. };
  78253. DracoCompression._GetDecoderModule = function () {
  78254. if (!DracoCompression._DecoderModulePromise) {
  78255. var promise = null;
  78256. var config_1 = {};
  78257. if (typeof DracoDecoderModule !== "undefined") {
  78258. promise = Promise.resolve();
  78259. }
  78260. else {
  78261. var decoder = DracoCompression.Configuration.decoder;
  78262. if (decoder) {
  78263. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  78264. promise = Promise.all([
  78265. DracoCompression._LoadScriptAsync(decoder.wasmUrl),
  78266. DracoCompression._LoadFileAsync(decoder.wasmBinaryUrl).then(function (data) {
  78267. config_1.wasmBinary = data;
  78268. })
  78269. ]);
  78270. }
  78271. else if (decoder.fallbackUrl) {
  78272. promise = DracoCompression._LoadScriptAsync(decoder.fallbackUrl);
  78273. }
  78274. }
  78275. }
  78276. if (!promise) {
  78277. throw new Error("Draco decoder module is not available");
  78278. }
  78279. DracoCompression._DecoderModulePromise = promise.then(function () {
  78280. return new Promise(function (resolve) {
  78281. config_1.onModuleLoaded = function (decoderModule) {
  78282. // decoderModule is Promise-like. Wrap before resolving to avoid loop.
  78283. resolve({ module: decoderModule });
  78284. };
  78285. DracoDecoderModule(config_1);
  78286. });
  78287. });
  78288. }
  78289. return DracoCompression._DecoderModulePromise;
  78290. };
  78291. DracoCompression._LoadScriptAsync = function (url) {
  78292. return new Promise(function (resolve, reject) {
  78293. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadScript(url, function () {
  78294. resolve();
  78295. }, function (message) {
  78296. reject(new Error(message));
  78297. });
  78298. });
  78299. };
  78300. DracoCompression._LoadFileAsync = function (url) {
  78301. return new Promise(function (resolve, reject) {
  78302. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(url, function (data) {
  78303. resolve(data);
  78304. }, undefined, undefined, true, function (request, exception) {
  78305. reject(exception);
  78306. });
  78307. });
  78308. };
  78309. /**
  78310. * The configuration. Defaults to the following urls:
  78311. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  78312. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  78313. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  78314. */
  78315. DracoCompression.Configuration = {
  78316. decoder: {
  78317. wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",
  78318. wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm",
  78319. fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  78320. }
  78321. };
  78322. return DracoCompression;
  78323. }());
  78324. /***/ }),
  78325. /***/ "./Meshes/Compression/index.ts":
  78326. /*!*************************************!*\
  78327. !*** ./Meshes/Compression/index.ts ***!
  78328. \*************************************/
  78329. /*! exports provided: DracoCompression */
  78330. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78331. "use strict";
  78332. __webpack_require__.r(__webpack_exports__);
  78333. /* harmony import */ var _dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dracoCompression */ "./Meshes/Compression/dracoCompression.ts");
  78334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _dracoCompression__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  78335. /***/ }),
  78336. /***/ "./Meshes/abstractMesh.ts":
  78337. /*!********************************!*\
  78338. !*** ./Meshes/abstractMesh.ts ***!
  78339. \********************************/
  78340. /*! exports provided: AbstractMesh */
  78341. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78342. "use strict";
  78343. __webpack_require__.r(__webpack_exports__);
  78344. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return AbstractMesh; });
  78345. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  78346. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  78347. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  78348. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  78349. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  78350. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  78351. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78352. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  78353. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  78354. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  78355. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  78356. /** @hidden */
  78357. var _FacetDataStorage = /** @class */ (function () {
  78358. function _FacetDataStorage() {
  78359. this.facetNb = 0; // facet number
  78360. this.partitioningSubdivisions = 10; // number of subdivisions per axis in the partioning space
  78361. this.partitioningBBoxRatio = 1.01; // the partioning array space is by default 1% bigger than the bounding box
  78362. this.facetDataEnabled = false; // is the facet data feature enabled on this mesh ?
  78363. this.facetParameters = {}; // keep a reference to the object parameters to avoid memory re-allocation
  78364. this.bbSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(); // bbox size approximated for facet data
  78365. this.subDiv = {
  78366. max: 1,
  78367. X: 1,
  78368. Y: 1,
  78369. Z: 1
  78370. };
  78371. this.facetDepthSort = false; // is the facet depth sort to be computed
  78372. this.facetDepthSortEnabled = false; // is the facet depth sort initialized
  78373. }
  78374. return _FacetDataStorage;
  78375. }());
  78376. /**
  78377. * Class used to store all common mesh properties
  78378. */
  78379. var AbstractMesh = /** @class */ (function (_super) {
  78380. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractMesh, _super);
  78381. // Constructor
  78382. /**
  78383. * Creates a new AbstractMesh
  78384. * @param name defines the name of the mesh
  78385. * @param scene defines the hosting scene
  78386. */
  78387. function AbstractMesh(name, scene) {
  78388. if (scene === void 0) { scene = null; }
  78389. var _this = _super.call(this, name, scene, false) || this;
  78390. _this._facetData = new _FacetDataStorage();
  78391. /**
  78392. * The culling strategy to use to check whether the mesh must be rendered or not.
  78393. * This value can be changed at any time and will be used on the next render mesh selection.
  78394. * The possible values are :
  78395. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  78396. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  78397. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  78398. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  78399. * Please read each static variable documentation to get details about the culling process.
  78400. * */
  78401. _this.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_STANDARD;
  78402. // Events
  78403. /**
  78404. * An event triggered when this mesh collides with another one
  78405. */
  78406. _this.onCollideObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  78407. /**
  78408. * An event triggered when the collision's position changes
  78409. */
  78410. _this.onCollisionPositionChangeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  78411. /**
  78412. * An event triggered when material is changed
  78413. */
  78414. _this.onMaterialChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  78415. // Properties
  78416. /**
  78417. * Gets or sets the orientation for POV movement & rotation
  78418. */
  78419. _this.definedFacingForward = true;
  78420. _this._visibility = 1.0;
  78421. /** Gets or sets the alpha index used to sort transparent meshes
  78422. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  78423. */
  78424. _this.alphaIndex = Number.MAX_VALUE;
  78425. /**
  78426. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  78427. */
  78428. _this.isVisible = true;
  78429. /**
  78430. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78431. */
  78432. _this.isPickable = true;
  78433. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  78434. _this.showSubMeshesBoundingBox = false;
  78435. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  78436. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  78437. */
  78438. _this.isBlocker = false;
  78439. /**
  78440. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  78441. */
  78442. _this.enablePointerMoveEvents = false;
  78443. /**
  78444. * Specifies the rendering group id for this mesh (0 by default)
  78445. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78446. */
  78447. _this.renderingGroupId = 0;
  78448. _this._receiveShadows = false;
  78449. /** Defines color to use when rendering outline */
  78450. _this.outlineColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  78451. /** Define width to use when rendering outline */
  78452. _this.outlineWidth = 0.02;
  78453. /** Defines color to use when rendering overlay */
  78454. _this.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  78455. /** Defines alpha to use when rendering overlay */
  78456. _this.overlayAlpha = 0.5;
  78457. _this._hasVertexAlpha = false;
  78458. _this._useVertexColors = true;
  78459. _this._computeBonesUsingShaders = true;
  78460. _this._numBoneInfluencers = 4;
  78461. _this._applyFog = true;
  78462. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  78463. _this.useOctreeForRenderingSelection = true;
  78464. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  78465. _this.useOctreeForPicking = true;
  78466. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  78467. _this.useOctreeForCollisions = true;
  78468. _this._layerMask = 0x0FFFFFFF;
  78469. /**
  78470. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  78471. */
  78472. _this.alwaysSelectAsActiveMesh = false;
  78473. /**
  78474. * Gets or sets the current action manager
  78475. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78476. */
  78477. _this.actionManager = null;
  78478. // Collisions
  78479. _this._checkCollisions = false;
  78480. _this._collisionMask = -1;
  78481. _this._collisionGroup = -1;
  78482. /**
  78483. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  78484. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  78485. */
  78486. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 1, 0.5);
  78487. /**
  78488. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  78489. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  78490. */
  78491. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  78492. _this._oldPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  78493. _this._diffPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  78494. // Edges
  78495. /**
  78496. * Defines edge width used when edgesRenderer is enabled
  78497. * @see https://www.babylonjs-playground.com/#10OJSG#13
  78498. */
  78499. _this.edgesWidth = 1;
  78500. /**
  78501. * Defines edge color used when edgesRenderer is enabled
  78502. * @see https://www.babylonjs-playground.com/#10OJSG#13
  78503. */
  78504. _this.edgesColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](1, 0, 0, 1);
  78505. /** @hidden */
  78506. _this._renderId = 0;
  78507. /** @hidden */
  78508. _this._intersectionsInProgress = new Array();
  78509. /** @hidden */
  78510. _this._unIndexed = false;
  78511. /** @hidden */
  78512. _this._lightSources = new Array();
  78513. /**
  78514. * An event triggered when the mesh is rebuilt.
  78515. */
  78516. _this.onRebuildObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  78517. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  78518. if (collidedMesh === void 0) { collidedMesh = null; }
  78519. newPosition.subtractToRef(_this._oldPositionForCollisions, _this._diffPositionForCollisions);
  78520. if (_this._diffPositionForCollisions.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].CollisionsEpsilon) {
  78521. _this.position.addInPlace(_this._diffPositionForCollisions);
  78522. }
  78523. if (collidedMesh) {
  78524. _this.onCollideObservable.notifyObservers(collidedMesh);
  78525. }
  78526. _this.onCollisionPositionChangeObservable.notifyObservers(_this.position);
  78527. };
  78528. _this.getScene().addMesh(_this);
  78529. _this._resyncLightSources();
  78530. return _this;
  78531. }
  78532. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_NONE", {
  78533. /**
  78534. * No billboard
  78535. */
  78536. get: function () {
  78537. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE;
  78538. },
  78539. enumerable: true,
  78540. configurable: true
  78541. });
  78542. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_X", {
  78543. /** Billboard on X axis */
  78544. get: function () {
  78545. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_X;
  78546. },
  78547. enumerable: true,
  78548. configurable: true
  78549. });
  78550. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Y", {
  78551. /** Billboard on Y axis */
  78552. get: function () {
  78553. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Y;
  78554. },
  78555. enumerable: true,
  78556. configurable: true
  78557. });
  78558. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Z", {
  78559. /** Billboard on Z axis */
  78560. get: function () {
  78561. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Z;
  78562. },
  78563. enumerable: true,
  78564. configurable: true
  78565. });
  78566. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_ALL", {
  78567. /** Billboard on all axes */
  78568. get: function () {
  78569. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_ALL;
  78570. },
  78571. enumerable: true,
  78572. configurable: true
  78573. });
  78574. Object.defineProperty(AbstractMesh.prototype, "facetNb", {
  78575. /**
  78576. * Gets the number of facets in the mesh
  78577. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  78578. */
  78579. get: function () {
  78580. return this._facetData.facetNb;
  78581. },
  78582. enumerable: true,
  78583. configurable: true
  78584. });
  78585. Object.defineProperty(AbstractMesh.prototype, "partitioningSubdivisions", {
  78586. /**
  78587. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  78588. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  78589. */
  78590. get: function () {
  78591. return this._facetData.partitioningSubdivisions;
  78592. },
  78593. set: function (nb) {
  78594. this._facetData.partitioningSubdivisions = nb;
  78595. },
  78596. enumerable: true,
  78597. configurable: true
  78598. });
  78599. Object.defineProperty(AbstractMesh.prototype, "partitioningBBoxRatio", {
  78600. /**
  78601. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  78602. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  78603. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  78604. */
  78605. get: function () {
  78606. return this._facetData.partitioningBBoxRatio;
  78607. },
  78608. set: function (ratio) {
  78609. this._facetData.partitioningBBoxRatio = ratio;
  78610. },
  78611. enumerable: true,
  78612. configurable: true
  78613. });
  78614. Object.defineProperty(AbstractMesh.prototype, "mustDepthSortFacets", {
  78615. /**
  78616. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  78617. * Works only for updatable meshes.
  78618. * Doesn't work with multi-materials
  78619. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  78620. */
  78621. get: function () {
  78622. return this._facetData.facetDepthSort;
  78623. },
  78624. set: function (sort) {
  78625. this._facetData.facetDepthSort = sort;
  78626. },
  78627. enumerable: true,
  78628. configurable: true
  78629. });
  78630. Object.defineProperty(AbstractMesh.prototype, "facetDepthSortFrom", {
  78631. /**
  78632. * The location (Vector3) where the facet depth sort must be computed from.
  78633. * By default, the active camera position.
  78634. * Used only when facet depth sort is enabled
  78635. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  78636. */
  78637. get: function () {
  78638. return this._facetData.facetDepthSortFrom;
  78639. },
  78640. set: function (location) {
  78641. this._facetData.facetDepthSortFrom = location;
  78642. },
  78643. enumerable: true,
  78644. configurable: true
  78645. });
  78646. Object.defineProperty(AbstractMesh.prototype, "isFacetDataEnabled", {
  78647. /**
  78648. * gets a boolean indicating if facetData is enabled
  78649. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  78650. */
  78651. get: function () {
  78652. return this._facetData.facetDataEnabled;
  78653. },
  78654. enumerable: true,
  78655. configurable: true
  78656. });
  78657. /** @hidden */
  78658. AbstractMesh.prototype._updateNonUniformScalingState = function (value) {
  78659. if (!_super.prototype._updateNonUniformScalingState.call(this, value)) {
  78660. return false;
  78661. }
  78662. this._markSubMeshesAsMiscDirty();
  78663. return true;
  78664. };
  78665. Object.defineProperty(AbstractMesh.prototype, "onCollide", {
  78666. /** Set a function to call when this mesh collides with another one */
  78667. set: function (callback) {
  78668. if (this._onCollideObserver) {
  78669. this.onCollideObservable.remove(this._onCollideObserver);
  78670. }
  78671. this._onCollideObserver = this.onCollideObservable.add(callback);
  78672. },
  78673. enumerable: true,
  78674. configurable: true
  78675. });
  78676. Object.defineProperty(AbstractMesh.prototype, "onCollisionPositionChange", {
  78677. /** Set a function to call when the collision's position changes */
  78678. set: function (callback) {
  78679. if (this._onCollisionPositionChangeObserver) {
  78680. this.onCollisionPositionChangeObservable.remove(this._onCollisionPositionChangeObserver);
  78681. }
  78682. this._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(callback);
  78683. },
  78684. enumerable: true,
  78685. configurable: true
  78686. });
  78687. Object.defineProperty(AbstractMesh.prototype, "visibility", {
  78688. /**
  78689. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  78690. */
  78691. get: function () {
  78692. return this._visibility;
  78693. },
  78694. /**
  78695. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  78696. */
  78697. set: function (value) {
  78698. if (this._visibility === value) {
  78699. return;
  78700. }
  78701. this._visibility = value;
  78702. this._markSubMeshesAsMiscDirty();
  78703. },
  78704. enumerable: true,
  78705. configurable: true
  78706. });
  78707. Object.defineProperty(AbstractMesh.prototype, "material", {
  78708. /** Gets or sets current material */
  78709. get: function () {
  78710. return this._material;
  78711. },
  78712. set: function (value) {
  78713. if (this._material === value) {
  78714. return;
  78715. }
  78716. // remove from material mesh map id needed
  78717. if (this._material && this._material.meshMap) {
  78718. this._material.meshMap[this.uniqueId] = undefined;
  78719. }
  78720. this._material = value;
  78721. if (value && value.meshMap) {
  78722. value.meshMap[this.uniqueId] = this;
  78723. }
  78724. if (this.onMaterialChangedObservable.hasObservers) {
  78725. this.onMaterialChangedObservable.notifyObservers(this);
  78726. }
  78727. if (!this.subMeshes) {
  78728. return;
  78729. }
  78730. this._unBindEffect();
  78731. },
  78732. enumerable: true,
  78733. configurable: true
  78734. });
  78735. Object.defineProperty(AbstractMesh.prototype, "receiveShadows", {
  78736. /**
  78737. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  78738. * @see http://doc.babylonjs.com/babylon101/shadows
  78739. */
  78740. get: function () {
  78741. return this._receiveShadows;
  78742. },
  78743. set: function (value) {
  78744. if (this._receiveShadows === value) {
  78745. return;
  78746. }
  78747. this._receiveShadows = value;
  78748. this._markSubMeshesAsLightDirty();
  78749. },
  78750. enumerable: true,
  78751. configurable: true
  78752. });
  78753. Object.defineProperty(AbstractMesh.prototype, "hasVertexAlpha", {
  78754. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  78755. get: function () {
  78756. return this._hasVertexAlpha;
  78757. },
  78758. set: function (value) {
  78759. if (this._hasVertexAlpha === value) {
  78760. return;
  78761. }
  78762. this._hasVertexAlpha = value;
  78763. this._markSubMeshesAsAttributesDirty();
  78764. this._markSubMeshesAsMiscDirty();
  78765. },
  78766. enumerable: true,
  78767. configurable: true
  78768. });
  78769. Object.defineProperty(AbstractMesh.prototype, "useVertexColors", {
  78770. /** 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) */
  78771. get: function () {
  78772. return this._useVertexColors;
  78773. },
  78774. set: function (value) {
  78775. if (this._useVertexColors === value) {
  78776. return;
  78777. }
  78778. this._useVertexColors = value;
  78779. this._markSubMeshesAsAttributesDirty();
  78780. },
  78781. enumerable: true,
  78782. configurable: true
  78783. });
  78784. Object.defineProperty(AbstractMesh.prototype, "computeBonesUsingShaders", {
  78785. /**
  78786. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  78787. */
  78788. get: function () {
  78789. return this._computeBonesUsingShaders;
  78790. },
  78791. set: function (value) {
  78792. if (this._computeBonesUsingShaders === value) {
  78793. return;
  78794. }
  78795. this._computeBonesUsingShaders = value;
  78796. this._markSubMeshesAsAttributesDirty();
  78797. },
  78798. enumerable: true,
  78799. configurable: true
  78800. });
  78801. Object.defineProperty(AbstractMesh.prototype, "numBoneInfluencers", {
  78802. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  78803. get: function () {
  78804. return this._numBoneInfluencers;
  78805. },
  78806. set: function (value) {
  78807. if (this._numBoneInfluencers === value) {
  78808. return;
  78809. }
  78810. this._numBoneInfluencers = value;
  78811. this._markSubMeshesAsAttributesDirty();
  78812. },
  78813. enumerable: true,
  78814. configurable: true
  78815. });
  78816. Object.defineProperty(AbstractMesh.prototype, "applyFog", {
  78817. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  78818. get: function () {
  78819. return this._applyFog;
  78820. },
  78821. set: function (value) {
  78822. if (this._applyFog === value) {
  78823. return;
  78824. }
  78825. this._applyFog = value;
  78826. this._markSubMeshesAsMiscDirty();
  78827. },
  78828. enumerable: true,
  78829. configurable: true
  78830. });
  78831. Object.defineProperty(AbstractMesh.prototype, "layerMask", {
  78832. /**
  78833. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  78834. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  78835. */
  78836. get: function () {
  78837. return this._layerMask;
  78838. },
  78839. set: function (value) {
  78840. if (value === this._layerMask) {
  78841. return;
  78842. }
  78843. this._layerMask = value;
  78844. this._resyncLightSources();
  78845. },
  78846. enumerable: true,
  78847. configurable: true
  78848. });
  78849. Object.defineProperty(AbstractMesh.prototype, "collisionMask", {
  78850. /**
  78851. * Gets or sets a collision mask used to mask collisions (default is -1).
  78852. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  78853. */
  78854. get: function () {
  78855. return this._collisionMask;
  78856. },
  78857. set: function (mask) {
  78858. this._collisionMask = !isNaN(mask) ? mask : -1;
  78859. },
  78860. enumerable: true,
  78861. configurable: true
  78862. });
  78863. Object.defineProperty(AbstractMesh.prototype, "collisionGroup", {
  78864. /**
  78865. * Gets or sets the current collision group mask (-1 by default).
  78866. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  78867. */
  78868. get: function () {
  78869. return this._collisionGroup;
  78870. },
  78871. set: function (mask) {
  78872. this._collisionGroup = !isNaN(mask) ? mask : -1;
  78873. },
  78874. enumerable: true,
  78875. configurable: true
  78876. });
  78877. Object.defineProperty(AbstractMesh.prototype, "_positions", {
  78878. /** @hidden */
  78879. get: function () {
  78880. return null;
  78881. },
  78882. enumerable: true,
  78883. configurable: true
  78884. });
  78885. Object.defineProperty(AbstractMesh.prototype, "skeleton", {
  78886. get: function () {
  78887. return this._skeleton;
  78888. },
  78889. /**
  78890. * Gets or sets a skeleton to apply skining transformations
  78891. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78892. */
  78893. set: function (value) {
  78894. if (this._skeleton && this._skeleton.needInitialSkinMatrix) {
  78895. this._skeleton._unregisterMeshWithPoseMatrix(this);
  78896. }
  78897. if (value && value.needInitialSkinMatrix) {
  78898. value._registerMeshWithPoseMatrix(this);
  78899. }
  78900. this._skeleton = value;
  78901. if (!this._skeleton) {
  78902. this._bonesTransformMatrices = null;
  78903. }
  78904. this._markSubMeshesAsAttributesDirty();
  78905. },
  78906. enumerable: true,
  78907. configurable: true
  78908. });
  78909. /**
  78910. * Returns the string "AbstractMesh"
  78911. * @returns "AbstractMesh"
  78912. */
  78913. AbstractMesh.prototype.getClassName = function () {
  78914. return "AbstractMesh";
  78915. };
  78916. /**
  78917. * Gets a string representation of the current mesh
  78918. * @param fullDetails defines a boolean indicating if full details must be included
  78919. * @returns a string representation of the current mesh
  78920. */
  78921. AbstractMesh.prototype.toString = function (fullDetails) {
  78922. var ret = "Name: " + this.name + ", isInstance: " + (this.getClassName() !== "InstancedMesh" ? "YES" : "NO");
  78923. ret += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
  78924. if (this._skeleton) {
  78925. ret += ", skeleton: " + this._skeleton.name;
  78926. }
  78927. if (fullDetails) {
  78928. ret += ", billboard mode: " + (["NONE", "X", "Y", null, "Z", null, null, "ALL"])[this.billboardMode];
  78929. ret += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingFreezeWorldMatrix ? "YES" : "NO");
  78930. }
  78931. return ret;
  78932. };
  78933. /** @hidden */
  78934. AbstractMesh.prototype._rebuild = function () {
  78935. this.onRebuildObservable.notifyObservers(this);
  78936. if (this._occlusionQuery) {
  78937. this._occlusionQuery = null;
  78938. }
  78939. if (!this.subMeshes) {
  78940. return;
  78941. }
  78942. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  78943. var subMesh = _a[_i];
  78944. subMesh._rebuild();
  78945. }
  78946. };
  78947. /** @hidden */
  78948. AbstractMesh.prototype._resyncLightSources = function () {
  78949. this._lightSources.length = 0;
  78950. for (var _i = 0, _a = this.getScene().lights; _i < _a.length; _i++) {
  78951. var light = _a[_i];
  78952. if (!light.isEnabled()) {
  78953. continue;
  78954. }
  78955. if (light.canAffectMesh(this)) {
  78956. this._lightSources.push(light);
  78957. }
  78958. }
  78959. this._markSubMeshesAsLightDirty();
  78960. };
  78961. /** @hidden */
  78962. AbstractMesh.prototype._resyncLighSource = function (light) {
  78963. var isIn = light.isEnabled() && light.canAffectMesh(this);
  78964. var index = this._lightSources.indexOf(light);
  78965. if (index === -1) {
  78966. if (!isIn) {
  78967. return;
  78968. }
  78969. this._lightSources.push(light);
  78970. }
  78971. else {
  78972. if (isIn) {
  78973. return;
  78974. }
  78975. this._lightSources.splice(index, 1);
  78976. }
  78977. this._markSubMeshesAsLightDirty();
  78978. };
  78979. /** @hidden */
  78980. AbstractMesh.prototype._unBindEffect = function () {
  78981. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  78982. var subMesh = _a[_i];
  78983. subMesh.setEffect(null);
  78984. }
  78985. };
  78986. /** @hidden */
  78987. AbstractMesh.prototype._removeLightSource = function (light) {
  78988. var index = this._lightSources.indexOf(light);
  78989. if (index === -1) {
  78990. return;
  78991. }
  78992. this._lightSources.splice(index, 1);
  78993. this._markSubMeshesAsLightDirty();
  78994. };
  78995. AbstractMesh.prototype._markSubMeshesAsDirty = function (func) {
  78996. if (!this.subMeshes) {
  78997. return;
  78998. }
  78999. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  79000. var subMesh = _a[_i];
  79001. if (subMesh._materialDefines) {
  79002. func(subMesh._materialDefines);
  79003. }
  79004. }
  79005. };
  79006. /** @hidden */
  79007. AbstractMesh.prototype._markSubMeshesAsLightDirty = function () {
  79008. this._markSubMeshesAsDirty(function (defines) { return defines.markAsLightDirty(); });
  79009. };
  79010. /** @hidden */
  79011. AbstractMesh.prototype._markSubMeshesAsAttributesDirty = function () {
  79012. this._markSubMeshesAsDirty(function (defines) { return defines.markAsAttributesDirty(); });
  79013. };
  79014. /** @hidden */
  79015. AbstractMesh.prototype._markSubMeshesAsMiscDirty = function () {
  79016. if (!this.subMeshes) {
  79017. return;
  79018. }
  79019. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  79020. var subMesh = _a[_i];
  79021. var material = subMesh.getMaterial();
  79022. if (material) {
  79023. material.markAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MATERIAL_MiscDirtyFlag);
  79024. }
  79025. }
  79026. };
  79027. Object.defineProperty(AbstractMesh.prototype, "scaling", {
  79028. /**
  79029. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  79030. */
  79031. get: function () {
  79032. return this._scaling;
  79033. },
  79034. set: function (newScaling) {
  79035. this._scaling = newScaling;
  79036. if (this.physicsImpostor) {
  79037. this.physicsImpostor.forceUpdate();
  79038. }
  79039. },
  79040. enumerable: true,
  79041. configurable: true
  79042. });
  79043. Object.defineProperty(AbstractMesh.prototype, "isBlocked", {
  79044. // Methods
  79045. /**
  79046. * Returns true if the mesh is blocked. Implemented by child classes
  79047. */
  79048. get: function () {
  79049. return false;
  79050. },
  79051. enumerable: true,
  79052. configurable: true
  79053. });
  79054. /**
  79055. * Returns the mesh itself by default. Implemented by child classes
  79056. * @param camera defines the camera to use to pick the right LOD level
  79057. * @returns the currentAbstractMesh
  79058. */
  79059. AbstractMesh.prototype.getLOD = function (camera) {
  79060. return this;
  79061. };
  79062. /**
  79063. * Returns 0 by default. Implemented by child classes
  79064. * @returns an integer
  79065. */
  79066. AbstractMesh.prototype.getTotalVertices = function () {
  79067. return 0;
  79068. };
  79069. /**
  79070. * Returns a positive integer : the total number of indices in this mesh geometry.
  79071. * @returns the numner of indices or zero if the mesh has no geometry.
  79072. */
  79073. AbstractMesh.prototype.getTotalIndices = function () {
  79074. return 0;
  79075. };
  79076. /**
  79077. * Returns null by default. Implemented by child classes
  79078. * @returns null
  79079. */
  79080. AbstractMesh.prototype.getIndices = function () {
  79081. return null;
  79082. };
  79083. /**
  79084. * Returns the array of the requested vertex data kind. Implemented by child classes
  79085. * @param kind defines the vertex data kind to use
  79086. * @returns null
  79087. */
  79088. AbstractMesh.prototype.getVerticesData = function (kind) {
  79089. return null;
  79090. };
  79091. /**
  79092. * Sets the vertex data of the mesh geometry for the requested `kind`.
  79093. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  79094. * Note that a new underlying VertexBuffer object is created each call.
  79095. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  79096. * @param kind defines vertex data kind:
  79097. * * VertexBuffer.PositionKind
  79098. * * VertexBuffer.UVKind
  79099. * * VertexBuffer.UV2Kind
  79100. * * VertexBuffer.UV3Kind
  79101. * * VertexBuffer.UV4Kind
  79102. * * VertexBuffer.UV5Kind
  79103. * * VertexBuffer.UV6Kind
  79104. * * VertexBuffer.ColorKind
  79105. * * VertexBuffer.MatricesIndicesKind
  79106. * * VertexBuffer.MatricesIndicesExtraKind
  79107. * * VertexBuffer.MatricesWeightsKind
  79108. * * VertexBuffer.MatricesWeightsExtraKind
  79109. * @param data defines the data source
  79110. * @param updatable defines if the data must be flagged as updatable (or static)
  79111. * @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
  79112. * @returns the current mesh
  79113. */
  79114. AbstractMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  79115. return this;
  79116. };
  79117. /**
  79118. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  79119. * If the mesh has no geometry, it is simply returned as it is.
  79120. * @param kind defines vertex data kind:
  79121. * * VertexBuffer.PositionKind
  79122. * * VertexBuffer.UVKind
  79123. * * VertexBuffer.UV2Kind
  79124. * * VertexBuffer.UV3Kind
  79125. * * VertexBuffer.UV4Kind
  79126. * * VertexBuffer.UV5Kind
  79127. * * VertexBuffer.UV6Kind
  79128. * * VertexBuffer.ColorKind
  79129. * * VertexBuffer.MatricesIndicesKind
  79130. * * VertexBuffer.MatricesIndicesExtraKind
  79131. * * VertexBuffer.MatricesWeightsKind
  79132. * * VertexBuffer.MatricesWeightsExtraKind
  79133. * @param data defines the data source
  79134. * @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
  79135. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  79136. * @returns the current mesh
  79137. */
  79138. AbstractMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  79139. return this;
  79140. };
  79141. /**
  79142. * Sets the mesh indices,
  79143. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  79144. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  79145. * @param totalVertices Defines the total number of vertices
  79146. * @returns the current mesh
  79147. */
  79148. AbstractMesh.prototype.setIndices = function (indices, totalVertices) {
  79149. return this;
  79150. };
  79151. /**
  79152. * Gets a boolean indicating if specific vertex data is present
  79153. * @param kind defines the vertex data kind to use
  79154. * @returns true is data kind is present
  79155. */
  79156. AbstractMesh.prototype.isVerticesDataPresent = function (kind) {
  79157. return false;
  79158. };
  79159. /**
  79160. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  79161. * @returns a BoundingInfo
  79162. */
  79163. AbstractMesh.prototype.getBoundingInfo = function () {
  79164. if (this._masterMesh) {
  79165. return this._masterMesh.getBoundingInfo();
  79166. }
  79167. if (!this._boundingInfo) {
  79168. // this._boundingInfo is being created here
  79169. this._updateBoundingInfo();
  79170. }
  79171. // cannot be null.
  79172. return this._boundingInfo;
  79173. };
  79174. /**
  79175. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  79176. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  79177. * @returns the current mesh
  79178. */
  79179. AbstractMesh.prototype.normalizeToUnitCube = function (includeDescendants) {
  79180. if (includeDescendants === void 0) { includeDescendants = true; }
  79181. var boundingVectors = this.getHierarchyBoundingVectors(includeDescendants);
  79182. var sizeVec = boundingVectors.max.subtract(boundingVectors.min);
  79183. var maxDimension = Math.max(sizeVec.x, sizeVec.y, sizeVec.z);
  79184. if (maxDimension === 0) {
  79185. return this;
  79186. }
  79187. var scale = 1 / maxDimension;
  79188. this.scaling.scaleInPlace(scale);
  79189. return this;
  79190. };
  79191. /**
  79192. * Overwrite the current bounding info
  79193. * @param boundingInfo defines the new bounding info
  79194. * @returns the current mesh
  79195. */
  79196. AbstractMesh.prototype.setBoundingInfo = function (boundingInfo) {
  79197. this._boundingInfo = boundingInfo;
  79198. return this;
  79199. };
  79200. Object.defineProperty(AbstractMesh.prototype, "useBones", {
  79201. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  79202. get: function () {
  79203. 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));
  79204. },
  79205. enumerable: true,
  79206. configurable: true
  79207. });
  79208. /** @hidden */
  79209. AbstractMesh.prototype._preActivate = function () {
  79210. };
  79211. /** @hidden */
  79212. AbstractMesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  79213. };
  79214. /** @hidden */
  79215. AbstractMesh.prototype._activate = function (renderId) {
  79216. this._renderId = renderId;
  79217. };
  79218. /**
  79219. * Gets the current world matrix
  79220. * @returns a Matrix
  79221. */
  79222. AbstractMesh.prototype.getWorldMatrix = function () {
  79223. if (this._masterMesh) {
  79224. return this._masterMesh.getWorldMatrix();
  79225. }
  79226. return _super.prototype.getWorldMatrix.call(this);
  79227. };
  79228. /** @hidden */
  79229. AbstractMesh.prototype._getWorldMatrixDeterminant = function () {
  79230. if (this._masterMesh) {
  79231. return this._masterMesh._getWorldMatrixDeterminant();
  79232. }
  79233. return _super.prototype._getWorldMatrixDeterminant.call(this);
  79234. };
  79235. // ================================== Point of View Movement =================================
  79236. /**
  79237. * Perform relative position change from the point of view of behind the front of the mesh.
  79238. * This is performed taking into account the meshes current rotation, so you do not have to care.
  79239. * Supports definition of mesh facing forward or backward
  79240. * @param amountRight defines the distance on the right axis
  79241. * @param amountUp defines the distance on the up axis
  79242. * @param amountForward defines the distance on the forward axis
  79243. * @returns the current mesh
  79244. */
  79245. AbstractMesh.prototype.movePOV = function (amountRight, amountUp, amountForward) {
  79246. this.position.addInPlace(this.calcMovePOV(amountRight, amountUp, amountForward));
  79247. return this;
  79248. };
  79249. /**
  79250. * Calculate relative position change from the point of view of behind the front of the mesh.
  79251. * This is performed taking into account the meshes current rotation, so you do not have to care.
  79252. * Supports definition of mesh facing forward or backward
  79253. * @param amountRight defines the distance on the right axis
  79254. * @param amountUp defines the distance on the up axis
  79255. * @param amountForward defines the distance on the forward axis
  79256. * @returns the new displacement vector
  79257. */
  79258. AbstractMesh.prototype.calcMovePOV = function (amountRight, amountUp, amountForward) {
  79259. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  79260. var rotQuaternion = (this.rotationQuaternion) ? this.rotationQuaternion : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  79261. rotQuaternion.toRotationMatrix(rotMatrix);
  79262. var translationDelta = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79263. var defForwardMult = this.definedFacingForward ? -1 : 1;
  79264. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(amountRight * defForwardMult, amountUp, amountForward * defForwardMult, rotMatrix, translationDelta);
  79265. return translationDelta;
  79266. };
  79267. // ================================== Point of View Rotation =================================
  79268. /**
  79269. * Perform relative rotation change from the point of view of behind the front of the mesh.
  79270. * Supports definition of mesh facing forward or backward
  79271. * @param flipBack defines the flip
  79272. * @param twirlClockwise defines the twirl
  79273. * @param tiltRight defines the tilt
  79274. * @returns the current mesh
  79275. */
  79276. AbstractMesh.prototype.rotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  79277. this.rotation.addInPlace(this.calcRotatePOV(flipBack, twirlClockwise, tiltRight));
  79278. return this;
  79279. };
  79280. /**
  79281. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  79282. * Supports definition of mesh facing forward or backward.
  79283. * @param flipBack defines the flip
  79284. * @param twirlClockwise defines the twirl
  79285. * @param tiltRight defines the tilt
  79286. * @returns the new rotation vector
  79287. */
  79288. AbstractMesh.prototype.calcRotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  79289. var defForwardMult = this.definedFacingForward ? 1 : -1;
  79290. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](flipBack * defForwardMult, twirlClockwise, tiltRight * defForwardMult);
  79291. };
  79292. /**
  79293. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  79294. * @param includeDescendants Include bounding info from descendants as well (true by default)
  79295. * @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
  79296. * @returns the new bounding vectors
  79297. */
  79298. AbstractMesh.prototype.getHierarchyBoundingVectors = function (includeDescendants, predicate) {
  79299. if (includeDescendants === void 0) { includeDescendants = true; }
  79300. if (predicate === void 0) { predicate = null; }
  79301. // Ensures that all world matrix will be recomputed.
  79302. this.getScene().incrementRenderId();
  79303. this.computeWorldMatrix(true);
  79304. var min;
  79305. var max;
  79306. var boundingInfo = this.getBoundingInfo();
  79307. if (!this.subMeshes) {
  79308. min = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  79309. max = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  79310. }
  79311. else {
  79312. min = boundingInfo.boundingBox.minimumWorld;
  79313. max = boundingInfo.boundingBox.maximumWorld;
  79314. }
  79315. if (includeDescendants) {
  79316. var descendants = this.getDescendants(false);
  79317. for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
  79318. var descendant = descendants_1[_i];
  79319. var childMesh = descendant;
  79320. childMesh.computeWorldMatrix(true);
  79321. // Filters meshes based on custom predicate function.
  79322. if (predicate && !predicate(childMesh)) {
  79323. continue;
  79324. }
  79325. //make sure we have the needed params to get mix and max
  79326. if (!childMesh.getBoundingInfo || childMesh.getTotalVertices() === 0) {
  79327. continue;
  79328. }
  79329. var childBoundingInfo = childMesh.getBoundingInfo();
  79330. var boundingBox = childBoundingInfo.boundingBox;
  79331. var minBox = boundingBox.minimumWorld;
  79332. var maxBox = boundingBox.maximumWorld;
  79333. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  79334. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  79335. }
  79336. }
  79337. return {
  79338. min: min,
  79339. max: max
  79340. };
  79341. };
  79342. /**
  79343. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79344. * This means the mesh underlying bounding box and sphere are recomputed.
  79345. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79346. * @returns the current mesh
  79347. */
  79348. AbstractMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  79349. if (applySkeleton === void 0) { applySkeleton = false; }
  79350. if (this._boundingInfo && this._boundingInfo.isLocked) {
  79351. return this;
  79352. }
  79353. this._refreshBoundingInfo(this._getPositionData(applySkeleton), null);
  79354. return this;
  79355. };
  79356. /** @hidden */
  79357. AbstractMesh.prototype._refreshBoundingInfo = function (data, bias) {
  79358. if (data) {
  79359. var extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMax(data, 0, this.getTotalVertices(), bias);
  79360. if (this._boundingInfo) {
  79361. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  79362. }
  79363. else {
  79364. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](extend.minimum, extend.maximum);
  79365. }
  79366. }
  79367. if (this.subMeshes) {
  79368. for (var index = 0; index < this.subMeshes.length; index++) {
  79369. this.subMeshes[index].refreshBoundingInfo();
  79370. }
  79371. }
  79372. this._updateBoundingInfo();
  79373. };
  79374. /** @hidden */
  79375. AbstractMesh.prototype._getPositionData = function (applySkeleton) {
  79376. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  79377. if (data && applySkeleton && this.skeleton) {
  79378. data = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Slice(data);
  79379. var matricesIndicesData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesKind);
  79380. var matricesWeightsData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsKind);
  79381. if (matricesWeightsData && matricesIndicesData) {
  79382. var needExtras = this.numBoneInfluencers > 4;
  79383. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  79384. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  79385. var skeletonMatrices = this.skeleton.getTransformMatrices(this);
  79386. var tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  79387. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  79388. var tempMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  79389. var matWeightIdx = 0;
  79390. for (var index = 0; index < data.length; index += 3, matWeightIdx += 4) {
  79391. finalMatrix.reset();
  79392. var inf;
  79393. var weight;
  79394. for (inf = 0; inf < 4; inf++) {
  79395. weight = matricesWeightsData[matWeightIdx + inf];
  79396. if (weight > 0) {
  79397. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  79398. finalMatrix.addToSelf(tempMatrix);
  79399. }
  79400. }
  79401. if (needExtras) {
  79402. for (inf = 0; inf < 4; inf++) {
  79403. weight = matricesWeightsExtraData[matWeightIdx + inf];
  79404. if (weight > 0) {
  79405. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  79406. finalMatrix.addToSelf(tempMatrix);
  79407. }
  79408. }
  79409. }
  79410. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(data[index], data[index + 1], data[index + 2], finalMatrix, tempVector);
  79411. tempVector.toArray(data, index);
  79412. }
  79413. }
  79414. }
  79415. return data;
  79416. };
  79417. /** @hidden */
  79418. AbstractMesh.prototype._updateBoundingInfo = function () {
  79419. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  79420. if (this._boundingInfo) {
  79421. this._boundingInfo.update(effectiveMesh.worldMatrixFromCache);
  79422. }
  79423. else {
  79424. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](this.absolutePosition, this.absolutePosition, effectiveMesh.worldMatrixFromCache);
  79425. }
  79426. this._updateSubMeshesBoundingInfo(effectiveMesh.worldMatrixFromCache);
  79427. return this;
  79428. };
  79429. /** @hidden */
  79430. AbstractMesh.prototype._updateSubMeshesBoundingInfo = function (matrix) {
  79431. if (!this.subMeshes) {
  79432. return this;
  79433. }
  79434. var count = this.subMeshes.length;
  79435. for (var subIndex = 0; subIndex < count; subIndex++) {
  79436. var subMesh = this.subMeshes[subIndex];
  79437. if (count > 1 || !subMesh.IsGlobal) {
  79438. subMesh.updateBoundingInfo(matrix);
  79439. }
  79440. }
  79441. return this;
  79442. };
  79443. /** @hidden */
  79444. AbstractMesh.prototype._afterComputeWorldMatrix = function () {
  79445. // Bounding info
  79446. this._updateBoundingInfo();
  79447. };
  79448. /**
  79449. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  79450. * A mesh is in the frustum if its bounding box intersects the frustum
  79451. * @param frustumPlanes defines the frustum to test
  79452. * @returns true if the mesh is in the frustum planes
  79453. */
  79454. AbstractMesh.prototype.isInFrustum = function (frustumPlanes) {
  79455. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  79456. };
  79457. /**
  79458. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  79459. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  79460. * @param frustumPlanes defines the frustum to test
  79461. * @returns true if the mesh is completely in the frustum planes
  79462. */
  79463. AbstractMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  79464. return this._boundingInfo !== null && this._boundingInfo.isCompletelyInFrustum(frustumPlanes);
  79465. };
  79466. /**
  79467. * True if the mesh intersects another mesh or a SolidParticle object
  79468. * @param mesh defines a target mesh or SolidParticle to test
  79469. * @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)
  79470. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  79471. * @returns true if there is an intersection
  79472. */
  79473. AbstractMesh.prototype.intersectsMesh = function (mesh, precise, includeDescendants) {
  79474. if (precise === void 0) { precise = false; }
  79475. if (!this._boundingInfo || !mesh._boundingInfo) {
  79476. return false;
  79477. }
  79478. if (this._boundingInfo.intersects(mesh._boundingInfo, precise)) {
  79479. return true;
  79480. }
  79481. if (includeDescendants) {
  79482. for (var _i = 0, _a = this.getChildMeshes(); _i < _a.length; _i++) {
  79483. var child = _a[_i];
  79484. if (child.intersectsMesh(mesh, precise, true)) {
  79485. return true;
  79486. }
  79487. }
  79488. }
  79489. return false;
  79490. };
  79491. /**
  79492. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  79493. * @param point defines the point to test
  79494. * @returns true if there is an intersection
  79495. */
  79496. AbstractMesh.prototype.intersectsPoint = function (point) {
  79497. if (!this._boundingInfo) {
  79498. return false;
  79499. }
  79500. return this._boundingInfo.intersectsPoint(point);
  79501. };
  79502. Object.defineProperty(AbstractMesh.prototype, "checkCollisions", {
  79503. // Collisions
  79504. /**
  79505. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  79506. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79507. */
  79508. get: function () {
  79509. return this._checkCollisions;
  79510. },
  79511. set: function (collisionEnabled) {
  79512. this._checkCollisions = collisionEnabled;
  79513. },
  79514. enumerable: true,
  79515. configurable: true
  79516. });
  79517. Object.defineProperty(AbstractMesh.prototype, "collider", {
  79518. /**
  79519. * Gets Collider object used to compute collisions (not physics)
  79520. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79521. */
  79522. get: function () {
  79523. return this._collider;
  79524. },
  79525. enumerable: true,
  79526. configurable: true
  79527. });
  79528. /**
  79529. * Move the mesh using collision engine
  79530. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79531. * @param displacement defines the requested displacement vector
  79532. * @returns the current mesh
  79533. */
  79534. AbstractMesh.prototype.moveWithCollisions = function (displacement) {
  79535. var globalPosition = this.getAbsolutePosition();
  79536. globalPosition.addToRef(this.ellipsoidOffset, this._oldPositionForCollisions);
  79537. var coordinator = this.getScene().collisionCoordinator;
  79538. if (!this._collider) {
  79539. this._collider = coordinator.createCollider();
  79540. }
  79541. this._collider._radius = this.ellipsoid;
  79542. coordinator.getNewPosition(this._oldPositionForCollisions, displacement, this._collider, 3, this, this._onCollisionPositionChange, this.uniqueId);
  79543. return this;
  79544. };
  79545. // Collisions
  79546. /** @hidden */
  79547. AbstractMesh.prototype._collideForSubMesh = function (subMesh, transformMatrix, collider) {
  79548. this._generatePointsArray();
  79549. if (!this._positions) {
  79550. return this;
  79551. }
  79552. // Transformation
  79553. if (!subMesh._lastColliderWorldVertices || !subMesh._lastColliderTransformMatrix.equals(transformMatrix)) {
  79554. subMesh._lastColliderTransformMatrix = transformMatrix.clone();
  79555. subMesh._lastColliderWorldVertices = [];
  79556. subMesh._trianglePlanes = [];
  79557. var start = subMesh.verticesStart;
  79558. var end = (subMesh.verticesStart + subMesh.verticesCount);
  79559. for (var i = start; i < end; i++) {
  79560. subMesh._lastColliderWorldVertices.push(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this._positions[i], transformMatrix));
  79561. }
  79562. }
  79563. // Collide
  79564. collider._collide(subMesh._trianglePlanes, subMesh._lastColliderWorldVertices, this.getIndices(), subMesh.indexStart, subMesh.indexStart + subMesh.indexCount, subMesh.verticesStart, !!subMesh.getMaterial());
  79565. if (collider.collisionFound) {
  79566. collider.collidedMesh = this;
  79567. }
  79568. return this;
  79569. };
  79570. /** @hidden */
  79571. AbstractMesh.prototype._processCollisionsForSubMeshes = function (collider, transformMatrix) {
  79572. var subMeshes = this._scene.getCollidingSubMeshCandidates(this, collider);
  79573. var len = subMeshes.length;
  79574. for (var index = 0; index < len; index++) {
  79575. var subMesh = subMeshes.data[index];
  79576. // Bounding test
  79577. if (len > 1 && !subMesh._checkCollision(collider)) {
  79578. continue;
  79579. }
  79580. this._collideForSubMesh(subMesh, transformMatrix, collider);
  79581. }
  79582. return this;
  79583. };
  79584. /** @hidden */
  79585. AbstractMesh.prototype._checkCollision = function (collider) {
  79586. // Bounding box test
  79587. if (!this._boundingInfo || !this._boundingInfo._checkCollision(collider)) {
  79588. return this;
  79589. }
  79590. // Transformation matrix
  79591. var collisionsScalingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  79592. var collisionsTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  79593. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, collisionsScalingMatrix);
  79594. this.worldMatrixFromCache.multiplyToRef(collisionsScalingMatrix, collisionsTransformMatrix);
  79595. this._processCollisionsForSubMeshes(collider, collisionsTransformMatrix);
  79596. return this;
  79597. };
  79598. // Picking
  79599. /** @hidden */
  79600. AbstractMesh.prototype._generatePointsArray = function () {
  79601. return false;
  79602. };
  79603. /**
  79604. * Checks if the passed Ray intersects with the mesh
  79605. * @param ray defines the ray to use
  79606. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  79607. * @returns the picking info
  79608. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  79609. */
  79610. AbstractMesh.prototype.intersects = function (ray, fastCheck) {
  79611. var pickingInfo = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]();
  79612. var intersectionThreshold = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? this.intersectionThreshold : 0;
  79613. var boundingInfo = this._boundingInfo;
  79614. if (!this.subMeshes || !boundingInfo || !ray.intersectsSphere(boundingInfo.boundingSphere, intersectionThreshold) || !ray.intersectsBox(boundingInfo.boundingBox, intersectionThreshold)) {
  79615. return pickingInfo;
  79616. }
  79617. if (!this._generatePointsArray()) {
  79618. return pickingInfo;
  79619. }
  79620. var intersectInfo = null;
  79621. var subMeshes = this._scene.getIntersectingSubMeshCandidates(this, ray);
  79622. var len = subMeshes.length;
  79623. for (var index = 0; index < len; index++) {
  79624. var subMesh = subMeshes.data[index];
  79625. // Bounding test
  79626. if (len > 1 && !subMesh.canIntersects(ray)) {
  79627. continue;
  79628. }
  79629. var currentIntersectInfo = subMesh.intersects(ray, this._positions, this.getIndices(), fastCheck);
  79630. if (currentIntersectInfo) {
  79631. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  79632. intersectInfo = currentIntersectInfo;
  79633. intersectInfo.subMeshId = index;
  79634. if (fastCheck) {
  79635. break;
  79636. }
  79637. }
  79638. }
  79639. }
  79640. if (intersectInfo) {
  79641. // Get picked point
  79642. var world = this.getWorldMatrix();
  79643. var worldOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  79644. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  79645. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(ray.origin, world, worldOrigin);
  79646. ray.direction.scaleToRef(intersectInfo.distance, direction);
  79647. var worldDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(direction, world);
  79648. var pickedPoint = worldDirection.addInPlace(worldOrigin);
  79649. // Return result
  79650. pickingInfo.hit = true;
  79651. pickingInfo.distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(worldOrigin, pickedPoint);
  79652. pickingInfo.pickedPoint = pickedPoint;
  79653. pickingInfo.pickedMesh = this;
  79654. pickingInfo.bu = intersectInfo.bu || 0;
  79655. pickingInfo.bv = intersectInfo.bv || 0;
  79656. pickingInfo.faceId = intersectInfo.faceId;
  79657. pickingInfo.subMeshId = intersectInfo.subMeshId;
  79658. return pickingInfo;
  79659. }
  79660. return pickingInfo;
  79661. };
  79662. /**
  79663. * Clones the current mesh
  79664. * @param name defines the mesh name
  79665. * @param newParent defines the new mesh parent
  79666. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  79667. * @returns the new mesh
  79668. */
  79669. AbstractMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  79670. return null;
  79671. };
  79672. /**
  79673. * Disposes all the submeshes of the current meshnp
  79674. * @returns the current mesh
  79675. */
  79676. AbstractMesh.prototype.releaseSubMeshes = function () {
  79677. if (this.subMeshes) {
  79678. while (this.subMeshes.length) {
  79679. this.subMeshes[0].dispose();
  79680. }
  79681. }
  79682. else {
  79683. this.subMeshes = new Array();
  79684. }
  79685. return this;
  79686. };
  79687. /**
  79688. * Releases resources associated with this abstract mesh.
  79689. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79690. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79691. */
  79692. AbstractMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  79693. var _this = this;
  79694. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  79695. var index;
  79696. // Smart Array Retainers.
  79697. this.getScene().freeActiveMeshes();
  79698. this.getScene().freeRenderingGroups();
  79699. // Action manager
  79700. if (this.actionManager !== undefined && this.actionManager !== null) {
  79701. this.actionManager.dispose();
  79702. this.actionManager = null;
  79703. }
  79704. // Skeleton
  79705. this._skeleton = null;
  79706. // Intersections in progress
  79707. for (index = 0; index < this._intersectionsInProgress.length; index++) {
  79708. var other = this._intersectionsInProgress[index];
  79709. var pos = other._intersectionsInProgress.indexOf(this);
  79710. other._intersectionsInProgress.splice(pos, 1);
  79711. }
  79712. this._intersectionsInProgress = [];
  79713. // Lights
  79714. var lights = this.getScene().lights;
  79715. lights.forEach(function (light) {
  79716. var meshIndex = light.includedOnlyMeshes.indexOf(_this);
  79717. if (meshIndex !== -1) {
  79718. light.includedOnlyMeshes.splice(meshIndex, 1);
  79719. }
  79720. meshIndex = light.excludedMeshes.indexOf(_this);
  79721. if (meshIndex !== -1) {
  79722. light.excludedMeshes.splice(meshIndex, 1);
  79723. }
  79724. // Shadow generators
  79725. var generator = light.getShadowGenerator();
  79726. if (generator) {
  79727. var shadowMap = generator.getShadowMap();
  79728. if (shadowMap && shadowMap.renderList) {
  79729. meshIndex = shadowMap.renderList.indexOf(_this);
  79730. if (meshIndex !== -1) {
  79731. shadowMap.renderList.splice(meshIndex, 1);
  79732. }
  79733. }
  79734. }
  79735. });
  79736. // SubMeshes
  79737. if (this.getClassName() !== "InstancedMesh" || this.getClassName() !== "InstancedLinesMesh") {
  79738. this.releaseSubMeshes();
  79739. }
  79740. // Query
  79741. var engine = this.getScene().getEngine();
  79742. if (this._occlusionQuery) {
  79743. this.isOcclusionQueryInProgress = false;
  79744. engine.deleteQuery(this._occlusionQuery);
  79745. this._occlusionQuery = null;
  79746. }
  79747. // Engine
  79748. engine.wipeCaches();
  79749. // Remove from scene
  79750. this.getScene().removeMesh(this);
  79751. if (disposeMaterialAndTextures) {
  79752. if (this.material) {
  79753. this.material.dispose(false, true);
  79754. }
  79755. }
  79756. if (!doNotRecurse) {
  79757. // Particles
  79758. for (index = 0; index < this.getScene().particleSystems.length; index++) {
  79759. if (this.getScene().particleSystems[index].emitter === this) {
  79760. this.getScene().particleSystems[index].dispose();
  79761. index--;
  79762. }
  79763. }
  79764. }
  79765. // facet data
  79766. if (this._facetData.facetDataEnabled) {
  79767. this.disableFacetData();
  79768. }
  79769. this.onAfterWorldMatrixUpdateObservable.clear();
  79770. this.onCollideObservable.clear();
  79771. this.onCollisionPositionChangeObservable.clear();
  79772. this.onRebuildObservable.clear();
  79773. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  79774. };
  79775. /**
  79776. * Adds the passed mesh as a child to the current mesh
  79777. * @param mesh defines the child mesh
  79778. * @returns the current mesh
  79779. */
  79780. AbstractMesh.prototype.addChild = function (mesh) {
  79781. mesh.setParent(this);
  79782. return this;
  79783. };
  79784. /**
  79785. * Removes the passed mesh from the current mesh children list
  79786. * @param mesh defines the child mesh
  79787. * @returns the current mesh
  79788. */
  79789. AbstractMesh.prototype.removeChild = function (mesh) {
  79790. mesh.setParent(null);
  79791. return this;
  79792. };
  79793. // Facet data
  79794. /** @hidden */
  79795. AbstractMesh.prototype._initFacetData = function () {
  79796. var data = this._facetData;
  79797. if (!data.facetNormals) {
  79798. data.facetNormals = new Array();
  79799. }
  79800. if (!data.facetPositions) {
  79801. data.facetPositions = new Array();
  79802. }
  79803. if (!data.facetPartitioning) {
  79804. data.facetPartitioning = new Array();
  79805. }
  79806. data.facetNb = (this.getIndices().length / 3) | 0;
  79807. data.partitioningSubdivisions = (data.partitioningSubdivisions) ? data.partitioningSubdivisions : 10; // default nb of partitioning subdivisions = 10
  79808. data.partitioningBBoxRatio = (data.partitioningBBoxRatio) ? data.partitioningBBoxRatio : 1.01; // default ratio 1.01 = the partitioning is 1% bigger than the bounding box
  79809. for (var f = 0; f < data.facetNb; f++) {
  79810. data.facetNormals[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79811. data.facetPositions[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79812. }
  79813. data.facetDataEnabled = true;
  79814. return this;
  79815. };
  79816. /**
  79817. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  79818. * This method can be called within the render loop.
  79819. * 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
  79820. * @returns the current mesh
  79821. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79822. */
  79823. AbstractMesh.prototype.updateFacetData = function () {
  79824. var data = this._facetData;
  79825. if (!data.facetDataEnabled) {
  79826. this._initFacetData();
  79827. }
  79828. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  79829. var indices = this.getIndices();
  79830. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  79831. var bInfo = this.getBoundingInfo();
  79832. if (data.facetDepthSort && !data.facetDepthSortEnabled) {
  79833. // init arrays, matrix and sort function on first call
  79834. data.facetDepthSortEnabled = true;
  79835. if (indices instanceof Uint16Array) {
  79836. data.depthSortedIndices = new Uint16Array(indices);
  79837. }
  79838. else if (indices instanceof Uint32Array) {
  79839. data.depthSortedIndices = new Uint32Array(indices);
  79840. }
  79841. else {
  79842. var needs32bits = false;
  79843. for (var i = 0; i < indices.length; i++) {
  79844. if (indices[i] > 65535) {
  79845. needs32bits = true;
  79846. break;
  79847. }
  79848. }
  79849. if (needs32bits) {
  79850. data.depthSortedIndices = new Uint32Array(indices);
  79851. }
  79852. else {
  79853. data.depthSortedIndices = new Uint16Array(indices);
  79854. }
  79855. }
  79856. data.facetDepthSortFunction = function (f1, f2) {
  79857. return (f2.sqDistance - f1.sqDistance);
  79858. };
  79859. if (!data.facetDepthSortFrom) {
  79860. var camera = this.getScene().activeCamera;
  79861. data.facetDepthSortFrom = (camera) ? camera.position : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79862. }
  79863. data.depthSortedFacets = [];
  79864. for (var f = 0; f < data.facetNb; f++) {
  79865. var depthSortedFacet = { ind: f * 3, sqDistance: 0.0 };
  79866. data.depthSortedFacets.push(depthSortedFacet);
  79867. }
  79868. data.invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  79869. data.facetDepthSortOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79870. }
  79871. 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"];
  79872. 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"];
  79873. 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"];
  79874. var bbSizeMax = (data.bbSize.x > data.bbSize.y) ? data.bbSize.x : data.bbSize.y;
  79875. bbSizeMax = (bbSizeMax > data.bbSize.z) ? bbSizeMax : data.bbSize.z;
  79876. data.subDiv.max = data.partitioningSubdivisions;
  79877. data.subDiv.X = Math.floor(data.subDiv.max * data.bbSize.x / bbSizeMax); // adjust the number of subdivisions per axis
  79878. data.subDiv.Y = Math.floor(data.subDiv.max * data.bbSize.y / bbSizeMax); // according to each bbox size per axis
  79879. data.subDiv.Z = Math.floor(data.subDiv.max * data.bbSize.z / bbSizeMax);
  79880. data.subDiv.X = data.subDiv.X < 1 ? 1 : data.subDiv.X; // at least one subdivision
  79881. data.subDiv.Y = data.subDiv.Y < 1 ? 1 : data.subDiv.Y;
  79882. data.subDiv.Z = data.subDiv.Z < 1 ? 1 : data.subDiv.Z;
  79883. // set the parameters for ComputeNormals()
  79884. data.facetParameters.facetNormals = this.getFacetLocalNormals();
  79885. data.facetParameters.facetPositions = this.getFacetLocalPositions();
  79886. data.facetParameters.facetPartitioning = this.getFacetLocalPartitioning();
  79887. data.facetParameters.bInfo = bInfo;
  79888. data.facetParameters.bbSize = data.bbSize;
  79889. data.facetParameters.subDiv = data.subDiv;
  79890. data.facetParameters.ratio = this.partitioningBBoxRatio;
  79891. data.facetParameters.depthSort = data.facetDepthSort;
  79892. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  79893. this.computeWorldMatrix(true);
  79894. this._worldMatrix.invertToRef(data.invertedMatrix);
  79895. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(data.facetDepthSortFrom, data.invertedMatrix, data.facetDepthSortOrigin);
  79896. data.facetParameters.distanceTo = data.facetDepthSortOrigin;
  79897. }
  79898. data.facetParameters.depthSortedFacets = data.depthSortedFacets;
  79899. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, data.facetParameters);
  79900. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  79901. data.depthSortedFacets.sort(data.facetDepthSortFunction);
  79902. var l = (data.depthSortedIndices.length / 3) | 0;
  79903. for (var f = 0; f < l; f++) {
  79904. var sind = data.depthSortedFacets[f].ind;
  79905. data.depthSortedIndices[f * 3] = indices[sind];
  79906. data.depthSortedIndices[f * 3 + 1] = indices[sind + 1];
  79907. data.depthSortedIndices[f * 3 + 2] = indices[sind + 2];
  79908. }
  79909. this.updateIndices(data.depthSortedIndices);
  79910. }
  79911. return this;
  79912. };
  79913. /**
  79914. * Returns the facetLocalNormals array.
  79915. * The normals are expressed in the mesh local spac
  79916. * @returns an array of Vector3
  79917. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79918. */
  79919. AbstractMesh.prototype.getFacetLocalNormals = function () {
  79920. if (!this._facetData.facetNormals) {
  79921. this.updateFacetData();
  79922. }
  79923. return this._facetData.facetNormals;
  79924. };
  79925. /**
  79926. * Returns the facetLocalPositions array.
  79927. * The facet positions are expressed in the mesh local space
  79928. * @returns an array of Vector3
  79929. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79930. */
  79931. AbstractMesh.prototype.getFacetLocalPositions = function () {
  79932. if (!this._facetData.facetPositions) {
  79933. this.updateFacetData();
  79934. }
  79935. return this._facetData.facetPositions;
  79936. };
  79937. /**
  79938. * Returns the facetLocalPartioning array
  79939. * @returns an array of array of numbers
  79940. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79941. */
  79942. AbstractMesh.prototype.getFacetLocalPartitioning = function () {
  79943. if (!this._facetData.facetPartitioning) {
  79944. this.updateFacetData();
  79945. }
  79946. return this._facetData.facetPartitioning;
  79947. };
  79948. /**
  79949. * Returns the i-th facet position in the world system.
  79950. * This method allocates a new Vector3 per call
  79951. * @param i defines the facet index
  79952. * @returns a new Vector3
  79953. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79954. */
  79955. AbstractMesh.prototype.getFacetPosition = function (i) {
  79956. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79957. this.getFacetPositionToRef(i, pos);
  79958. return pos;
  79959. };
  79960. /**
  79961. * Sets the reference Vector3 with the i-th facet position in the world system
  79962. * @param i defines the facet index
  79963. * @param ref defines the target vector
  79964. * @returns the current mesh
  79965. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79966. */
  79967. AbstractMesh.prototype.getFacetPositionToRef = function (i, ref) {
  79968. var localPos = (this.getFacetLocalPositions())[i];
  79969. var world = this.getWorldMatrix();
  79970. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(localPos, world, ref);
  79971. return this;
  79972. };
  79973. /**
  79974. * Returns the i-th facet normal in the world system.
  79975. * This method allocates a new Vector3 per call
  79976. * @param i defines the facet index
  79977. * @returns a new Vector3
  79978. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79979. */
  79980. AbstractMesh.prototype.getFacetNormal = function (i) {
  79981. var norm = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79982. this.getFacetNormalToRef(i, norm);
  79983. return norm;
  79984. };
  79985. /**
  79986. * Sets the reference Vector3 with the i-th facet normal in the world system
  79987. * @param i defines the facet index
  79988. * @param ref defines the target vector
  79989. * @returns the current mesh
  79990. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79991. */
  79992. AbstractMesh.prototype.getFacetNormalToRef = function (i, ref) {
  79993. var localNorm = (this.getFacetLocalNormals())[i];
  79994. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localNorm, this.getWorldMatrix(), ref);
  79995. return this;
  79996. };
  79997. /**
  79998. * 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)
  79999. * @param x defines x coordinate
  80000. * @param y defines y coordinate
  80001. * @param z defines z coordinate
  80002. * @returns the array of facet indexes
  80003. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80004. */
  80005. AbstractMesh.prototype.getFacetsAtLocalCoordinates = function (x, y, z) {
  80006. var bInfo = this.getBoundingInfo();
  80007. var data = this._facetData;
  80008. var ox = Math.floor((x - bInfo.minimum.x * data.partitioningBBoxRatio) * data.subDiv.X * data.partitioningBBoxRatio / data.bbSize.x);
  80009. var oy = Math.floor((y - bInfo.minimum.y * data.partitioningBBoxRatio) * data.subDiv.Y * data.partitioningBBoxRatio / data.bbSize.y);
  80010. var oz = Math.floor((z - bInfo.minimum.z * data.partitioningBBoxRatio) * data.subDiv.Z * data.partitioningBBoxRatio / data.bbSize.z);
  80011. if (ox < 0 || ox > data.subDiv.max || oy < 0 || oy > data.subDiv.max || oz < 0 || oz > data.subDiv.max) {
  80012. return null;
  80013. }
  80014. return data.facetPartitioning[ox + data.subDiv.max * oy + data.subDiv.max * data.subDiv.max * oz];
  80015. };
  80016. /**
  80017. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  80018. * @param projected sets as the (x,y,z) world projection on the facet
  80019. * @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
  80020. * @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
  80021. * @param x defines x coordinate
  80022. * @param y defines y coordinate
  80023. * @param z defines z coordinate
  80024. * @returns the face index if found (or null instead)
  80025. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80026. */
  80027. AbstractMesh.prototype.getClosestFacetAtCoordinates = function (x, y, z, projected, checkFace, facing) {
  80028. if (checkFace === void 0) { checkFace = false; }
  80029. if (facing === void 0) { facing = true; }
  80030. var world = this.getWorldMatrix();
  80031. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5];
  80032. world.invertToRef(invMat);
  80033. var invVect = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[8];
  80034. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, invMat, invVect); // transform (x,y,z) to coordinates in the mesh local space
  80035. var closest = this.getClosestFacetAtLocalCoordinates(invVect.x, invVect.y, invVect.z, projected, checkFace, facing);
  80036. if (projected) {
  80037. // tranform the local computed projected vector to world coordinates
  80038. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(projected.x, projected.y, projected.z, world, projected);
  80039. }
  80040. return closest;
  80041. };
  80042. /**
  80043. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  80044. * @param projected sets as the (x,y,z) local projection on the facet
  80045. * @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
  80046. * @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
  80047. * @param x defines x coordinate
  80048. * @param y defines y coordinate
  80049. * @param z defines z coordinate
  80050. * @returns the face index if found (or null instead)
  80051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80052. */
  80053. AbstractMesh.prototype.getClosestFacetAtLocalCoordinates = function (x, y, z, projected, checkFace, facing) {
  80054. if (checkFace === void 0) { checkFace = false; }
  80055. if (facing === void 0) { facing = true; }
  80056. var closest = null;
  80057. var tmpx = 0.0;
  80058. var tmpy = 0.0;
  80059. var tmpz = 0.0;
  80060. var d = 0.0; // tmp dot facet normal * facet position
  80061. var t0 = 0.0;
  80062. var projx = 0.0;
  80063. var projy = 0.0;
  80064. var projz = 0.0;
  80065. // Get all the facets in the same partitioning block than (x, y, z)
  80066. var facetPositions = this.getFacetLocalPositions();
  80067. var facetNormals = this.getFacetLocalNormals();
  80068. var facetsInBlock = this.getFacetsAtLocalCoordinates(x, y, z);
  80069. if (!facetsInBlock) {
  80070. return null;
  80071. }
  80072. // Get the closest facet to (x, y, z)
  80073. var shortest = Number.MAX_VALUE; // init distance vars
  80074. var tmpDistance = shortest;
  80075. var fib; // current facet in the block
  80076. var norm; // current facet normal
  80077. var p0; // current facet barycenter position
  80078. // loop on all the facets in the current partitioning block
  80079. for (var idx = 0; idx < facetsInBlock.length; idx++) {
  80080. fib = facetsInBlock[idx];
  80081. norm = facetNormals[fib];
  80082. p0 = facetPositions[fib];
  80083. d = (x - p0.x) * norm.x + (y - p0.y) * norm.y + (z - p0.z) * norm.z;
  80084. if (!checkFace || (checkFace && facing && d >= 0.0) || (checkFace && !facing && d <= 0.0)) {
  80085. // compute (x,y,z) projection on the facet = (projx, projy, projz)
  80086. d = norm.x * p0.x + norm.y * p0.y + norm.z * p0.z;
  80087. t0 = -(norm.x * x + norm.y * y + norm.z * z - d) / (norm.x * norm.x + norm.y * norm.y + norm.z * norm.z);
  80088. projx = x + norm.x * t0;
  80089. projy = y + norm.y * t0;
  80090. projz = z + norm.z * t0;
  80091. tmpx = projx - x;
  80092. tmpy = projy - y;
  80093. tmpz = projz - z;
  80094. tmpDistance = tmpx * tmpx + tmpy * tmpy + tmpz * tmpz; // compute length between (x, y, z) and its projection on the facet
  80095. if (tmpDistance < shortest) { // just keep the closest facet to (x, y, z)
  80096. shortest = tmpDistance;
  80097. closest = fib;
  80098. if (projected) {
  80099. projected.x = projx;
  80100. projected.y = projy;
  80101. projected.z = projz;
  80102. }
  80103. }
  80104. }
  80105. }
  80106. return closest;
  80107. };
  80108. /**
  80109. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  80110. * @returns the parameters
  80111. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80112. */
  80113. AbstractMesh.prototype.getFacetDataParameters = function () {
  80114. return this._facetData.facetParameters;
  80115. };
  80116. /**
  80117. * Disables the feature FacetData and frees the related memory
  80118. * @returns the current mesh
  80119. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80120. */
  80121. AbstractMesh.prototype.disableFacetData = function () {
  80122. if (this._facetData.facetDataEnabled) {
  80123. this._facetData.facetDataEnabled = false;
  80124. this._facetData.facetPositions = new Array();
  80125. this._facetData.facetNormals = new Array();
  80126. this._facetData.facetPartitioning = new Array();
  80127. this._facetData.facetParameters = null;
  80128. this._facetData.depthSortedIndices = new Uint32Array(0);
  80129. }
  80130. return this;
  80131. };
  80132. /**
  80133. * Updates the AbstractMesh indices array
  80134. * @param indices defines the data source
  80135. * @returns the current mesh
  80136. */
  80137. AbstractMesh.prototype.updateIndices = function (indices) {
  80138. return this;
  80139. };
  80140. /**
  80141. * Creates new normals data for the mesh
  80142. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  80143. * @returns the current mesh
  80144. */
  80145. AbstractMesh.prototype.createNormals = function (updatable) {
  80146. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  80147. var indices = this.getIndices();
  80148. var normals;
  80149. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  80150. normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  80151. }
  80152. else {
  80153. normals = [];
  80154. }
  80155. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, { useRightHandedSystem: this.getScene().useRightHandedSystem });
  80156. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind, normals, updatable);
  80157. return this;
  80158. };
  80159. /**
  80160. * Align the mesh with a normal
  80161. * @param normal defines the normal to use
  80162. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  80163. * @returns the current mesh
  80164. */
  80165. AbstractMesh.prototype.alignWithNormal = function (normal, upDirection) {
  80166. if (!upDirection) {
  80167. upDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y;
  80168. }
  80169. var axisX = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  80170. var axisZ = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  80171. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(upDirection, normal, axisZ);
  80172. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(normal, axisZ, axisX);
  80173. if (this.rotationQuaternion) {
  80174. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationQuaternionFromAxisToRef(axisX, normal, axisZ, this.rotationQuaternion);
  80175. }
  80176. else {
  80177. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].RotationFromAxisToRef(axisX, normal, axisZ, this.rotation);
  80178. }
  80179. return this;
  80180. };
  80181. /** @hidden */
  80182. AbstractMesh.prototype._checkOcclusionQuery = function () {
  80183. return false;
  80184. };
  80185. /** No occlusion */
  80186. AbstractMesh.OCCLUSION_TYPE_NONE = 0;
  80187. /** Occlusion set to optimisitic */
  80188. AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC = 1;
  80189. /** Occlusion set to strict */
  80190. AbstractMesh.OCCLUSION_TYPE_STRICT = 2;
  80191. /** Use an accurante occlusion algorithm */
  80192. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0;
  80193. /** Use a conservative occlusion algorithm */
  80194. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1;
  80195. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80196. * Test order :
  80197. * Is the bounding sphere outside the frustum ?
  80198. * If not, are the bounding box vertices outside the frustum ?
  80199. * It not, then the cullable object is in the frustum.
  80200. */
  80201. AbstractMesh.CULLINGSTRATEGY_STANDARD = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD;
  80202. /** Culling strategy : Bounding Sphere Only.
  80203. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80204. * It's also less accurate than the standard because some not visible objects can still be selected.
  80205. * Test : is the bounding sphere outside the frustum ?
  80206. * If not, then the cullable object is in the frustum.
  80207. */
  80208. AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  80209. /** Culling strategy : Optimistic Inclusion.
  80210. * This in an inclusion test first, then the standard exclusion test.
  80211. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80212. * 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.
  80213. * Anyway, it's as accurate as the standard strategy.
  80214. * Test :
  80215. * Is the cullable object bounding sphere center in the frustum ?
  80216. * If not, apply the default culling strategy.
  80217. */
  80218. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION;
  80219. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80220. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80221. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80222. * 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.
  80223. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80224. * Test :
  80225. * Is the cullable object bounding sphere center in the frustum ?
  80226. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80227. */
  80228. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;
  80229. return AbstractMesh;
  80230. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"]));
  80231. /***/ }),
  80232. /***/ "./Meshes/buffer.ts":
  80233. /*!**************************!*\
  80234. !*** ./Meshes/buffer.ts ***!
  80235. \**************************/
  80236. /*! exports provided: Buffer, VertexBuffer */
  80237. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80238. "use strict";
  80239. __webpack_require__.r(__webpack_exports__);
  80240. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return Buffer; });
  80241. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return VertexBuffer; });
  80242. /**
  80243. * Class used to store data that will be store in GPU memory
  80244. */
  80245. var Buffer = /** @class */ (function () {
  80246. /**
  80247. * Constructor
  80248. * @param engine the engine
  80249. * @param data the data to use for this buffer
  80250. * @param updatable whether the data is updatable
  80251. * @param stride the stride (optional)
  80252. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80253. * @param instanced whether the buffer is instanced (optional)
  80254. * @param useBytes set to true if the stride in in bytes (optional)
  80255. */
  80256. function Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes) {
  80257. if (stride === void 0) { stride = 0; }
  80258. if (postponeInternalCreation === void 0) { postponeInternalCreation = false; }
  80259. if (instanced === void 0) { instanced = false; }
  80260. if (useBytes === void 0) { useBytes = false; }
  80261. if (engine.getScene) { // old versions of VertexBuffer accepted 'mesh' instead of 'engine'
  80262. this._engine = engine.getScene().getEngine();
  80263. }
  80264. else {
  80265. this._engine = engine;
  80266. }
  80267. this._updatable = updatable;
  80268. this._instanced = instanced;
  80269. this._data = data;
  80270. this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;
  80271. if (!postponeInternalCreation) { // by default
  80272. this.create();
  80273. }
  80274. }
  80275. /**
  80276. * Create a new VertexBuffer based on the current buffer
  80277. * @param kind defines the vertex buffer kind (position, normal, etc.)
  80278. * @param offset defines offset in the buffer (0 by default)
  80279. * @param size defines the size in floats of attributes (position is 3 for instance)
  80280. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  80281. * @param instanced defines if the vertex buffer contains indexed data
  80282. * @param useBytes defines if the offset and stride are in bytes
  80283. * @returns the new vertex buffer
  80284. */
  80285. Buffer.prototype.createVertexBuffer = function (kind, offset, size, stride, instanced, useBytes) {
  80286. if (useBytes === void 0) { useBytes = false; }
  80287. var byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;
  80288. var byteStride = stride ? (useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT) : this.byteStride;
  80289. // a lot of these parameters are ignored as they are overriden by the buffer
  80290. return new VertexBuffer(this._engine, this, kind, this._updatable, true, byteStride, instanced === undefined ? this._instanced : instanced, byteOffset, size, undefined, undefined, true);
  80291. };
  80292. // Properties
  80293. /**
  80294. * Gets a boolean indicating if the Buffer is updatable?
  80295. * @returns true if the buffer is updatable
  80296. */
  80297. Buffer.prototype.isUpdatable = function () {
  80298. return this._updatable;
  80299. };
  80300. /**
  80301. * Gets current buffer's data
  80302. * @returns a DataArray or null
  80303. */
  80304. Buffer.prototype.getData = function () {
  80305. return this._data;
  80306. };
  80307. /**
  80308. * Gets underlying native buffer
  80309. * @returns underlying native buffer
  80310. */
  80311. Buffer.prototype.getBuffer = function () {
  80312. return this._buffer;
  80313. };
  80314. /**
  80315. * Gets the stride in float32 units (i.e. byte stride / 4).
  80316. * May not be an integer if the byte stride is not divisible by 4.
  80317. * DEPRECATED. Use byteStride instead.
  80318. * @returns the stride in float32 units
  80319. */
  80320. Buffer.prototype.getStrideSize = function () {
  80321. return this.byteStride / Float32Array.BYTES_PER_ELEMENT;
  80322. };
  80323. // Methods
  80324. /**
  80325. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80326. * @param data defines the data to store
  80327. */
  80328. Buffer.prototype.create = function (data) {
  80329. if (data === void 0) { data = null; }
  80330. if (!data && this._buffer) {
  80331. return; // nothing to do
  80332. }
  80333. data = data || this._data;
  80334. if (!data) {
  80335. return;
  80336. }
  80337. if (!this._buffer) { // create buffer
  80338. if (this._updatable) {
  80339. this._buffer = this._engine.createDynamicVertexBuffer(data);
  80340. this._data = data;
  80341. }
  80342. else {
  80343. this._buffer = this._engine.createVertexBuffer(data);
  80344. }
  80345. }
  80346. else if (this._updatable) { // update buffer
  80347. this._engine.updateDynamicVertexBuffer(this._buffer, data);
  80348. this._data = data;
  80349. }
  80350. };
  80351. /** @hidden */
  80352. Buffer.prototype._rebuild = function () {
  80353. this._buffer = null;
  80354. this.create(this._data);
  80355. };
  80356. /**
  80357. * Update current buffer data
  80358. * @param data defines the data to store
  80359. */
  80360. Buffer.prototype.update = function (data) {
  80361. this.create(data);
  80362. };
  80363. /**
  80364. * Updates the data directly.
  80365. * @param data the new data
  80366. * @param offset the new offset
  80367. * @param vertexCount the vertex count (optional)
  80368. * @param useBytes set to true if the offset is in bytes
  80369. */
  80370. Buffer.prototype.updateDirectly = function (data, offset, vertexCount, useBytes) {
  80371. if (useBytes === void 0) { useBytes = false; }
  80372. if (!this._buffer) {
  80373. return;
  80374. }
  80375. if (this._updatable) { // update buffer
  80376. this._engine.updateDynamicVertexBuffer(this._buffer, data, useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT, (vertexCount ? vertexCount * this.byteStride : undefined));
  80377. this._data = null;
  80378. }
  80379. };
  80380. /**
  80381. * Release all resources
  80382. */
  80383. Buffer.prototype.dispose = function () {
  80384. if (!this._buffer) {
  80385. return;
  80386. }
  80387. if (this._engine._releaseBuffer(this._buffer)) {
  80388. this._buffer = null;
  80389. }
  80390. };
  80391. return Buffer;
  80392. }());
  80393. /**
  80394. * Specialized buffer used to store vertex data
  80395. */
  80396. var VertexBuffer = /** @class */ (function () {
  80397. /**
  80398. * Constructor
  80399. * @param engine the engine
  80400. * @param data the data to use for this vertex buffer
  80401. * @param kind the vertex buffer kind
  80402. * @param updatable whether the data is updatable
  80403. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80404. * @param stride the stride (optional)
  80405. * @param instanced whether the buffer is instanced (optional)
  80406. * @param offset the offset of the data (optional)
  80407. * @param size the number of components (optional)
  80408. * @param type the type of the component (optional)
  80409. * @param normalized whether the data contains normalized data (optional)
  80410. * @param useBytes set to true if stride and offset are in bytes (optional)
  80411. */
  80412. function VertexBuffer(engine, data, kind, updatable, postponeInternalCreation, stride, instanced, offset, size, type, normalized, useBytes) {
  80413. if (normalized === void 0) { normalized = false; }
  80414. if (useBytes === void 0) { useBytes = false; }
  80415. if (data instanceof Buffer) {
  80416. this._buffer = data;
  80417. this._ownsBuffer = false;
  80418. }
  80419. else {
  80420. this._buffer = new Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes);
  80421. this._ownsBuffer = true;
  80422. }
  80423. this._kind = kind;
  80424. if (type == undefined) {
  80425. var data_1 = this.getData();
  80426. this.type = VertexBuffer.FLOAT;
  80427. if (data_1 instanceof Int8Array) {
  80428. this.type = VertexBuffer.BYTE;
  80429. }
  80430. else if (data_1 instanceof Uint8Array) {
  80431. this.type = VertexBuffer.UNSIGNED_BYTE;
  80432. }
  80433. else if (data_1 instanceof Int16Array) {
  80434. this.type = VertexBuffer.SHORT;
  80435. }
  80436. else if (data_1 instanceof Uint16Array) {
  80437. this.type = VertexBuffer.UNSIGNED_SHORT;
  80438. }
  80439. else if (data_1 instanceof Int32Array) {
  80440. this.type = VertexBuffer.INT;
  80441. }
  80442. else if (data_1 instanceof Uint32Array) {
  80443. this.type = VertexBuffer.UNSIGNED_INT;
  80444. }
  80445. }
  80446. else {
  80447. this.type = type;
  80448. }
  80449. var typeByteLength = VertexBuffer.GetTypeByteLength(this.type);
  80450. if (useBytes) {
  80451. this._size = size || (stride ? (stride / typeByteLength) : VertexBuffer.DeduceStride(kind));
  80452. this.byteStride = stride || this._buffer.byteStride || (this._size * typeByteLength);
  80453. this.byteOffset = offset || 0;
  80454. }
  80455. else {
  80456. this._size = size || stride || VertexBuffer.DeduceStride(kind);
  80457. this.byteStride = stride ? (stride * typeByteLength) : (this._buffer.byteStride || (this._size * typeByteLength));
  80458. this.byteOffset = (offset || 0) * typeByteLength;
  80459. }
  80460. this.normalized = normalized;
  80461. this._instanced = instanced !== undefined ? instanced : false;
  80462. this._instanceDivisor = instanced ? 1 : 0;
  80463. }
  80464. Object.defineProperty(VertexBuffer.prototype, "instanceDivisor", {
  80465. /**
  80466. * Gets or sets the instance divisor when in instanced mode
  80467. */
  80468. get: function () {
  80469. return this._instanceDivisor;
  80470. },
  80471. set: function (value) {
  80472. this._instanceDivisor = value;
  80473. if (value == 0) {
  80474. this._instanced = false;
  80475. }
  80476. else {
  80477. this._instanced = true;
  80478. }
  80479. },
  80480. enumerable: true,
  80481. configurable: true
  80482. });
  80483. /** @hidden */
  80484. VertexBuffer.prototype._rebuild = function () {
  80485. if (!this._buffer) {
  80486. return;
  80487. }
  80488. this._buffer._rebuild();
  80489. };
  80490. /**
  80491. * Returns the kind of the VertexBuffer (string)
  80492. * @returns a string
  80493. */
  80494. VertexBuffer.prototype.getKind = function () {
  80495. return this._kind;
  80496. };
  80497. // Properties
  80498. /**
  80499. * Gets a boolean indicating if the VertexBuffer is updatable?
  80500. * @returns true if the buffer is updatable
  80501. */
  80502. VertexBuffer.prototype.isUpdatable = function () {
  80503. return this._buffer.isUpdatable();
  80504. };
  80505. /**
  80506. * Gets current buffer's data
  80507. * @returns a DataArray or null
  80508. */
  80509. VertexBuffer.prototype.getData = function () {
  80510. return this._buffer.getData();
  80511. };
  80512. /**
  80513. * Gets underlying native buffer
  80514. * @returns underlying native buffer
  80515. */
  80516. VertexBuffer.prototype.getBuffer = function () {
  80517. return this._buffer.getBuffer();
  80518. };
  80519. /**
  80520. * Gets the stride in float32 units (i.e. byte stride / 4).
  80521. * May not be an integer if the byte stride is not divisible by 4.
  80522. * DEPRECATED. Use byteStride instead.
  80523. * @returns the stride in float32 units
  80524. */
  80525. VertexBuffer.prototype.getStrideSize = function () {
  80526. return this.byteStride / VertexBuffer.GetTypeByteLength(this.type);
  80527. };
  80528. /**
  80529. * Returns the offset as a multiple of the type byte length.
  80530. * DEPRECATED. Use byteOffset instead.
  80531. * @returns the offset in bytes
  80532. */
  80533. VertexBuffer.prototype.getOffset = function () {
  80534. return this.byteOffset / VertexBuffer.GetTypeByteLength(this.type);
  80535. };
  80536. /**
  80537. * Returns the number of components per vertex attribute (integer)
  80538. * @returns the size in float
  80539. */
  80540. VertexBuffer.prototype.getSize = function () {
  80541. return this._size;
  80542. };
  80543. /**
  80544. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  80545. * @returns true if this buffer is instanced
  80546. */
  80547. VertexBuffer.prototype.getIsInstanced = function () {
  80548. return this._instanced;
  80549. };
  80550. /**
  80551. * Returns the instancing divisor, zero for non-instanced (integer).
  80552. * @returns a number
  80553. */
  80554. VertexBuffer.prototype.getInstanceDivisor = function () {
  80555. return this._instanceDivisor;
  80556. };
  80557. // Methods
  80558. /**
  80559. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80560. * @param data defines the data to store
  80561. */
  80562. VertexBuffer.prototype.create = function (data) {
  80563. this._buffer.create(data);
  80564. };
  80565. /**
  80566. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  80567. * This function will create a new buffer if the current one is not updatable
  80568. * @param data defines the data to store
  80569. */
  80570. VertexBuffer.prototype.update = function (data) {
  80571. this._buffer.update(data);
  80572. };
  80573. /**
  80574. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  80575. * Returns the directly updated WebGLBuffer.
  80576. * @param data the new data
  80577. * @param offset the new offset
  80578. * @param useBytes set to true if the offset is in bytes
  80579. */
  80580. VertexBuffer.prototype.updateDirectly = function (data, offset, useBytes) {
  80581. if (useBytes === void 0) { useBytes = false; }
  80582. this._buffer.updateDirectly(data, offset, undefined, useBytes);
  80583. };
  80584. /**
  80585. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  80586. */
  80587. VertexBuffer.prototype.dispose = function () {
  80588. if (this._ownsBuffer) {
  80589. this._buffer.dispose();
  80590. }
  80591. };
  80592. /**
  80593. * Enumerates each value of this vertex buffer as numbers.
  80594. * @param count the number of values to enumerate
  80595. * @param callback the callback function called for each value
  80596. */
  80597. VertexBuffer.prototype.forEach = function (count, callback) {
  80598. VertexBuffer.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, callback);
  80599. };
  80600. /**
  80601. * Deduces the stride given a kind.
  80602. * @param kind The kind string to deduce
  80603. * @returns The deduced stride
  80604. */
  80605. VertexBuffer.DeduceStride = function (kind) {
  80606. switch (kind) {
  80607. case VertexBuffer.UVKind:
  80608. case VertexBuffer.UV2Kind:
  80609. case VertexBuffer.UV3Kind:
  80610. case VertexBuffer.UV4Kind:
  80611. case VertexBuffer.UV5Kind:
  80612. case VertexBuffer.UV6Kind:
  80613. return 2;
  80614. case VertexBuffer.NormalKind:
  80615. case VertexBuffer.PositionKind:
  80616. return 3;
  80617. case VertexBuffer.ColorKind:
  80618. case VertexBuffer.MatricesIndicesKind:
  80619. case VertexBuffer.MatricesIndicesExtraKind:
  80620. case VertexBuffer.MatricesWeightsKind:
  80621. case VertexBuffer.MatricesWeightsExtraKind:
  80622. case VertexBuffer.TangentKind:
  80623. return 4;
  80624. default:
  80625. throw new Error("Invalid kind '" + kind + "'");
  80626. }
  80627. };
  80628. /**
  80629. * Gets the byte length of the given type.
  80630. * @param type the type
  80631. * @returns the number of bytes
  80632. */
  80633. VertexBuffer.GetTypeByteLength = function (type) {
  80634. switch (type) {
  80635. case VertexBuffer.BYTE:
  80636. case VertexBuffer.UNSIGNED_BYTE:
  80637. return 1;
  80638. case VertexBuffer.SHORT:
  80639. case VertexBuffer.UNSIGNED_SHORT:
  80640. return 2;
  80641. case VertexBuffer.INT:
  80642. case VertexBuffer.FLOAT:
  80643. return 4;
  80644. default:
  80645. throw new Error("Invalid type '" + type + "'");
  80646. }
  80647. };
  80648. /**
  80649. * Enumerates each value of the given parameters as numbers.
  80650. * @param data the data to enumerate
  80651. * @param byteOffset the byte offset of the data
  80652. * @param byteStride the byte stride of the data
  80653. * @param componentCount the number of components per element
  80654. * @param componentType the type of the component
  80655. * @param count the total number of components
  80656. * @param normalized whether the data is normalized
  80657. * @param callback the callback function called for each value
  80658. */
  80659. VertexBuffer.ForEach = function (data, byteOffset, byteStride, componentCount, componentType, count, normalized, callback) {
  80660. if (data instanceof Array) {
  80661. var offset = byteOffset / 4;
  80662. var stride = byteStride / 4;
  80663. for (var index = 0; index < count; index += componentCount) {
  80664. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  80665. callback(data[offset + componentIndex], index + componentIndex);
  80666. }
  80667. offset += stride;
  80668. }
  80669. }
  80670. else {
  80671. var dataView = data instanceof ArrayBuffer ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);
  80672. var componentByteLength = VertexBuffer.GetTypeByteLength(componentType);
  80673. for (var index = 0; index < count; index += componentCount) {
  80674. var componentByteOffset = byteOffset;
  80675. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  80676. var value = VertexBuffer._GetFloatValue(dataView, componentType, componentByteOffset, normalized);
  80677. callback(value, index + componentIndex);
  80678. componentByteOffset += componentByteLength;
  80679. }
  80680. byteOffset += byteStride;
  80681. }
  80682. }
  80683. };
  80684. VertexBuffer._GetFloatValue = function (dataView, type, byteOffset, normalized) {
  80685. switch (type) {
  80686. case VertexBuffer.BYTE: {
  80687. var value = dataView.getInt8(byteOffset);
  80688. if (normalized) {
  80689. value = Math.max(value / 127, -1);
  80690. }
  80691. return value;
  80692. }
  80693. case VertexBuffer.UNSIGNED_BYTE: {
  80694. var value = dataView.getUint8(byteOffset);
  80695. if (normalized) {
  80696. value = value / 255;
  80697. }
  80698. return value;
  80699. }
  80700. case VertexBuffer.SHORT: {
  80701. var value = dataView.getInt16(byteOffset, true);
  80702. if (normalized) {
  80703. value = Math.max(value / 16383, -1);
  80704. }
  80705. return value;
  80706. }
  80707. case VertexBuffer.UNSIGNED_SHORT: {
  80708. var value = dataView.getUint16(byteOffset, true);
  80709. if (normalized) {
  80710. value = value / 65535;
  80711. }
  80712. return value;
  80713. }
  80714. case VertexBuffer.FLOAT: {
  80715. return dataView.getFloat32(byteOffset, true);
  80716. }
  80717. default: {
  80718. throw new Error("Invalid component type " + type);
  80719. }
  80720. }
  80721. };
  80722. /**
  80723. * The byte type.
  80724. */
  80725. VertexBuffer.BYTE = 5120;
  80726. /**
  80727. * The unsigned byte type.
  80728. */
  80729. VertexBuffer.UNSIGNED_BYTE = 5121;
  80730. /**
  80731. * The short type.
  80732. */
  80733. VertexBuffer.SHORT = 5122;
  80734. /**
  80735. * The unsigned short type.
  80736. */
  80737. VertexBuffer.UNSIGNED_SHORT = 5123;
  80738. /**
  80739. * The integer type.
  80740. */
  80741. VertexBuffer.INT = 5124;
  80742. /**
  80743. * The unsigned integer type.
  80744. */
  80745. VertexBuffer.UNSIGNED_INT = 5125;
  80746. /**
  80747. * The float type.
  80748. */
  80749. VertexBuffer.FLOAT = 5126;
  80750. // Enums
  80751. /**
  80752. * Positions
  80753. */
  80754. VertexBuffer.PositionKind = "position";
  80755. /**
  80756. * Normals
  80757. */
  80758. VertexBuffer.NormalKind = "normal";
  80759. /**
  80760. * Tangents
  80761. */
  80762. VertexBuffer.TangentKind = "tangent";
  80763. /**
  80764. * Texture coordinates
  80765. */
  80766. VertexBuffer.UVKind = "uv";
  80767. /**
  80768. * Texture coordinates 2
  80769. */
  80770. VertexBuffer.UV2Kind = "uv2";
  80771. /**
  80772. * Texture coordinates 3
  80773. */
  80774. VertexBuffer.UV3Kind = "uv3";
  80775. /**
  80776. * Texture coordinates 4
  80777. */
  80778. VertexBuffer.UV4Kind = "uv4";
  80779. /**
  80780. * Texture coordinates 5
  80781. */
  80782. VertexBuffer.UV5Kind = "uv5";
  80783. /**
  80784. * Texture coordinates 6
  80785. */
  80786. VertexBuffer.UV6Kind = "uv6";
  80787. /**
  80788. * Colors
  80789. */
  80790. VertexBuffer.ColorKind = "color";
  80791. /**
  80792. * Matrix indices (for bones)
  80793. */
  80794. VertexBuffer.MatricesIndicesKind = "matricesIndices";
  80795. /**
  80796. * Matrix weights (for bones)
  80797. */
  80798. VertexBuffer.MatricesWeightsKind = "matricesWeights";
  80799. /**
  80800. * Additional matrix indices (for bones)
  80801. */
  80802. VertexBuffer.MatricesIndicesExtraKind = "matricesIndicesExtra";
  80803. /**
  80804. * Additional matrix weights (for bones)
  80805. */
  80806. VertexBuffer.MatricesWeightsExtraKind = "matricesWeightsExtra";
  80807. return VertexBuffer;
  80808. }());
  80809. /***/ }),
  80810. /***/ "./Meshes/csg.ts":
  80811. /*!***********************!*\
  80812. !*** ./Meshes/csg.ts ***!
  80813. \***********************/
  80814. /*! exports provided: CSG */
  80815. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80816. "use strict";
  80817. __webpack_require__.r(__webpack_exports__);
  80818. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return CSG; });
  80819. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  80820. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  80821. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  80822. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  80823. /**
  80824. * Unique ID when we import meshes from Babylon to CSG
  80825. */
  80826. var currentCSGMeshId = 0;
  80827. /**
  80828. * Represents a vertex of a polygon. Use your own vertex class instead of this
  80829. * one to provide additional features like texture coordinates and vertex
  80830. * colors. Custom vertex classes need to provide a `pos` property and `clone()`,
  80831. * `flip()`, and `interpolate()` methods that behave analogous to the ones
  80832. * defined by `BABYLON.CSG.Vertex`. This class provides `normal` so convenience
  80833. * functions like `BABYLON.CSG.sphere()` can return a smooth vertex normal, but `normal`
  80834. * is not used anywhere else.
  80835. * Same goes for uv, it allows to keep the original vertex uv coordinates of the 2 meshes
  80836. */
  80837. var Vertex = /** @class */ (function () {
  80838. /**
  80839. * Initializes the vertex
  80840. * @param pos The position of the vertex
  80841. * @param normal The normal of the vertex
  80842. * @param uv The texture coordinate of the vertex
  80843. */
  80844. function Vertex(
  80845. /**
  80846. * The position of the vertex
  80847. */
  80848. pos,
  80849. /**
  80850. * The normal of the vertex
  80851. */
  80852. normal,
  80853. /**
  80854. * The texture coordinate of the vertex
  80855. */
  80856. uv) {
  80857. this.pos = pos;
  80858. this.normal = normal;
  80859. this.uv = uv;
  80860. }
  80861. /**
  80862. * Make a clone, or deep copy, of the vertex
  80863. * @returns A new Vertex
  80864. */
  80865. Vertex.prototype.clone = function () {
  80866. return new Vertex(this.pos.clone(), this.normal.clone(), this.uv.clone());
  80867. };
  80868. /**
  80869. * Invert all orientation-specific data (e.g. vertex normal). Called when the
  80870. * orientation of a polygon is flipped.
  80871. */
  80872. Vertex.prototype.flip = function () {
  80873. this.normal = this.normal.scale(-1);
  80874. };
  80875. /**
  80876. * Create a new vertex between this vertex and `other` by linearly
  80877. * interpolating all properties using a parameter of `t`. Subclasses should
  80878. * override this to interpolate additional properties.
  80879. * @param other the vertex to interpolate against
  80880. * @param t The factor used to linearly interpolate between the vertices
  80881. */
  80882. Vertex.prototype.interpolate = function (other, t) {
  80883. 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));
  80884. };
  80885. return Vertex;
  80886. }());
  80887. /**
  80888. * Represents a plane in 3D space.
  80889. */
  80890. var Plane = /** @class */ (function () {
  80891. /**
  80892. * Initializes the plane
  80893. * @param normal The normal for the plane
  80894. * @param w
  80895. */
  80896. function Plane(normal, w) {
  80897. this.normal = normal;
  80898. this.w = w;
  80899. }
  80900. /**
  80901. * Construct a plane from three points
  80902. * @param a Point a
  80903. * @param b Point b
  80904. * @param c Point c
  80905. */
  80906. Plane.FromPoints = function (a, b, c) {
  80907. var v0 = c.subtract(a);
  80908. var v1 = b.subtract(a);
  80909. if (v0.lengthSquared() === 0 || v1.lengthSquared() === 0) {
  80910. return null;
  80911. }
  80912. var n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v0, v1));
  80913. return new Plane(n, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(n, a));
  80914. };
  80915. /**
  80916. * Clone, or make a deep copy of the plane
  80917. * @returns a new Plane
  80918. */
  80919. Plane.prototype.clone = function () {
  80920. return new Plane(this.normal.clone(), this.w);
  80921. };
  80922. /**
  80923. * Flip the face of the plane
  80924. */
  80925. Plane.prototype.flip = function () {
  80926. this.normal.scaleInPlace(-1);
  80927. this.w = -this.w;
  80928. };
  80929. /**
  80930. * Split `polygon` by this plane if needed, then put the polygon or polygon
  80931. * fragments in the appropriate lists. Coplanar polygons go into either
  80932. `* coplanarFront` or `coplanarBack` depending on their orientation with
  80933. * respect to this plane. Polygons in front or in back of this plane go into
  80934. * either `front` or `back`
  80935. * @param polygon The polygon to be split
  80936. * @param coplanarFront Will contain polygons coplanar with the plane that are oriented to the front of the plane
  80937. * @param coplanarBack Will contain polygons coplanar with the plane that are oriented to the back of the plane
  80938. * @param front Will contain the polygons in front of the plane
  80939. * @param back Will contain the polygons begind the plane
  80940. */
  80941. Plane.prototype.splitPolygon = function (polygon, coplanarFront, coplanarBack, front, back) {
  80942. var COPLANAR = 0;
  80943. var FRONT = 1;
  80944. var BACK = 2;
  80945. var SPANNING = 3;
  80946. // Classify each point as well as the entire polygon into one of the above
  80947. // four classes.
  80948. var polygonType = 0;
  80949. var types = [];
  80950. var i;
  80951. var t;
  80952. for (i = 0; i < polygon.vertices.length; i++) {
  80953. t = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.vertices[i].pos) - this.w;
  80954. var type = (t < -Plane.EPSILON) ? BACK : (t > Plane.EPSILON) ? FRONT : COPLANAR;
  80955. polygonType |= type;
  80956. types.push(type);
  80957. }
  80958. // Put the polygon in the correct list, splitting it when necessary
  80959. switch (polygonType) {
  80960. case COPLANAR:
  80961. (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.plane.normal) > 0 ? coplanarFront : coplanarBack).push(polygon);
  80962. break;
  80963. case FRONT:
  80964. front.push(polygon);
  80965. break;
  80966. case BACK:
  80967. back.push(polygon);
  80968. break;
  80969. case SPANNING:
  80970. var f = [], b = [];
  80971. for (i = 0; i < polygon.vertices.length; i++) {
  80972. var j = (i + 1) % polygon.vertices.length;
  80973. var ti = types[i], tj = types[j];
  80974. var vi = polygon.vertices[i], vj = polygon.vertices[j];
  80975. if (ti !== BACK) {
  80976. f.push(vi);
  80977. }
  80978. if (ti !== FRONT) {
  80979. b.push(ti !== BACK ? vi.clone() : vi);
  80980. }
  80981. if ((ti | tj) === SPANNING) {
  80982. 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));
  80983. var v = vi.interpolate(vj, t);
  80984. f.push(v);
  80985. b.push(v.clone());
  80986. }
  80987. }
  80988. var poly;
  80989. if (f.length >= 3) {
  80990. poly = new Polygon(f, polygon.shared);
  80991. if (poly.plane) {
  80992. front.push(poly);
  80993. }
  80994. }
  80995. if (b.length >= 3) {
  80996. poly = new Polygon(b, polygon.shared);
  80997. if (poly.plane) {
  80998. back.push(poly);
  80999. }
  81000. }
  81001. break;
  81002. }
  81003. };
  81004. /**
  81005. * `CSG.Plane.EPSILON` is the tolerance used by `splitPolygon()` to decide if a
  81006. * point is on the plane
  81007. */
  81008. Plane.EPSILON = 1e-5;
  81009. return Plane;
  81010. }());
  81011. /**
  81012. * Represents a convex polygon. The vertices used to initialize a polygon must
  81013. * be coplanar and form a convex loop.
  81014. *
  81015. * Each convex polygon has a `shared` property, which is shared between all
  81016. * polygons that are clones of each other or were split from the same polygon.
  81017. * This can be used to define per-polygon properties (such as surface color)
  81018. */
  81019. var Polygon = /** @class */ (function () {
  81020. /**
  81021. * Initializes the polygon
  81022. * @param vertices The vertices of the polygon
  81023. * @param shared The properties shared across all polygons
  81024. */
  81025. function Polygon(vertices, shared) {
  81026. this.vertices = vertices;
  81027. this.shared = shared;
  81028. this.plane = Plane.FromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);
  81029. }
  81030. /**
  81031. * Clones, or makes a deep copy, or the polygon
  81032. */
  81033. Polygon.prototype.clone = function () {
  81034. var vertices = this.vertices.map(function (v) { return v.clone(); });
  81035. return new Polygon(vertices, this.shared);
  81036. };
  81037. /**
  81038. * Flips the faces of the polygon
  81039. */
  81040. Polygon.prototype.flip = function () {
  81041. this.vertices.reverse().map(function (v) { v.flip(); });
  81042. this.plane.flip();
  81043. };
  81044. return Polygon;
  81045. }());
  81046. /**
  81047. * Holds a node in a BSP tree. A BSP tree is built from a collection of polygons
  81048. * by picking a polygon to split along. That polygon (and all other coplanar
  81049. * polygons) are added directly to that node and the other polygons are added to
  81050. * the front and/or back subtrees. This is not a leafy BSP tree since there is
  81051. * no distinction between internal and leaf nodes
  81052. */
  81053. var Node = /** @class */ (function () {
  81054. /**
  81055. * Initializes the node
  81056. * @param polygons A collection of polygons held in the node
  81057. */
  81058. function Node(polygons) {
  81059. this.plane = null;
  81060. this.front = null;
  81061. this.back = null;
  81062. this.polygons = new Array();
  81063. if (polygons) {
  81064. this.build(polygons);
  81065. }
  81066. }
  81067. /**
  81068. * Clones, or makes a deep copy, of the node
  81069. * @returns The cloned node
  81070. */
  81071. Node.prototype.clone = function () {
  81072. var node = new Node();
  81073. node.plane = this.plane && this.plane.clone();
  81074. node.front = this.front && this.front.clone();
  81075. node.back = this.back && this.back.clone();
  81076. node.polygons = this.polygons.map(function (p) { return p.clone(); });
  81077. return node;
  81078. };
  81079. /**
  81080. * Convert solid space to empty space and empty space to solid space
  81081. */
  81082. Node.prototype.invert = function () {
  81083. for (var i = 0; i < this.polygons.length; i++) {
  81084. this.polygons[i].flip();
  81085. }
  81086. if (this.plane) {
  81087. this.plane.flip();
  81088. }
  81089. if (this.front) {
  81090. this.front.invert();
  81091. }
  81092. if (this.back) {
  81093. this.back.invert();
  81094. }
  81095. var temp = this.front;
  81096. this.front = this.back;
  81097. this.back = temp;
  81098. };
  81099. /**
  81100. * Recursively remove all polygons in `polygons` that are inside this BSP
  81101. * tree.
  81102. * @param polygons Polygons to remove from the BSP
  81103. * @returns Polygons clipped from the BSP
  81104. */
  81105. Node.prototype.clipPolygons = function (polygons) {
  81106. if (!this.plane) {
  81107. return polygons.slice();
  81108. }
  81109. var front = new Array(), back = new Array();
  81110. for (var i = 0; i < polygons.length; i++) {
  81111. this.plane.splitPolygon(polygons[i], front, back, front, back);
  81112. }
  81113. if (this.front) {
  81114. front = this.front.clipPolygons(front);
  81115. }
  81116. if (this.back) {
  81117. back = this.back.clipPolygons(back);
  81118. }
  81119. else {
  81120. back = [];
  81121. }
  81122. return front.concat(back);
  81123. };
  81124. /**
  81125. * Remove all polygons in this BSP tree that are inside the other BSP tree
  81126. * `bsp`.
  81127. * @param bsp BSP containing polygons to remove from this BSP
  81128. */
  81129. Node.prototype.clipTo = function (bsp) {
  81130. this.polygons = bsp.clipPolygons(this.polygons);
  81131. if (this.front) {
  81132. this.front.clipTo(bsp);
  81133. }
  81134. if (this.back) {
  81135. this.back.clipTo(bsp);
  81136. }
  81137. };
  81138. /**
  81139. * Return a list of all polygons in this BSP tree
  81140. * @returns List of all polygons in this BSP tree
  81141. */
  81142. Node.prototype.allPolygons = function () {
  81143. var polygons = this.polygons.slice();
  81144. if (this.front) {
  81145. polygons = polygons.concat(this.front.allPolygons());
  81146. }
  81147. if (this.back) {
  81148. polygons = polygons.concat(this.back.allPolygons());
  81149. }
  81150. return polygons;
  81151. };
  81152. /**
  81153. * Build a BSP tree out of `polygons`. When called on an existing tree, the
  81154. * new polygons are filtered down to the bottom of the tree and become new
  81155. * nodes there. Each set of polygons is partitioned using the first polygon
  81156. * (no heuristic is used to pick a good split)
  81157. * @param polygons Polygons used to construct the BSP tree
  81158. */
  81159. Node.prototype.build = function (polygons) {
  81160. if (!polygons.length) {
  81161. return;
  81162. }
  81163. if (!this.plane) {
  81164. this.plane = polygons[0].plane.clone();
  81165. }
  81166. var front = new Array(), back = new Array();
  81167. for (var i = 0; i < polygons.length; i++) {
  81168. this.plane.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
  81169. }
  81170. if (front.length) {
  81171. if (!this.front) {
  81172. this.front = new Node();
  81173. }
  81174. this.front.build(front);
  81175. }
  81176. if (back.length) {
  81177. if (!this.back) {
  81178. this.back = new Node();
  81179. }
  81180. this.back.build(back);
  81181. }
  81182. };
  81183. return Node;
  81184. }());
  81185. /**
  81186. * Class for building Constructive Solid Geometry
  81187. */
  81188. var CSG = /** @class */ (function () {
  81189. function CSG() {
  81190. this.polygons = new Array();
  81191. }
  81192. /**
  81193. * Convert the Mesh to CSG
  81194. * @param mesh The Mesh to convert to CSG
  81195. * @returns A new CSG from the Mesh
  81196. */
  81197. CSG.FromMesh = function (mesh) {
  81198. var vertex, normal, uv, position, polygon, polygons = new Array(), vertices;
  81199. var matrix, meshPosition, meshRotation, meshRotationQuaternion = null, meshScaling;
  81200. if (mesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]) {
  81201. mesh.computeWorldMatrix(true);
  81202. matrix = mesh.getWorldMatrix();
  81203. meshPosition = mesh.position.clone();
  81204. meshRotation = mesh.rotation.clone();
  81205. if (mesh.rotationQuaternion) {
  81206. meshRotationQuaternion = mesh.rotationQuaternion.clone();
  81207. }
  81208. meshScaling = mesh.scaling.clone();
  81209. }
  81210. else {
  81211. throw 'BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh';
  81212. }
  81213. 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);
  81214. var subMeshes = mesh.subMeshes;
  81215. for (var sm = 0, sml = subMeshes.length; sm < sml; sm++) {
  81216. for (var i = subMeshes[sm].indexStart, il = subMeshes[sm].indexCount + subMeshes[sm].indexStart; i < il; i += 3) {
  81217. vertices = [];
  81218. for (var j = 0; j < 3; j++) {
  81219. 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]);
  81220. uv = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uvs[indices[i + j] * 2], uvs[indices[i + j] * 2 + 1]);
  81221. 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]);
  81222. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(sourcePosition, matrix);
  81223. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(sourceNormal, matrix);
  81224. vertex = new Vertex(position, normal, uv);
  81225. vertices.push(vertex);
  81226. }
  81227. polygon = new Polygon(vertices, { subMeshId: sm, meshId: currentCSGMeshId, materialIndex: subMeshes[sm].materialIndex });
  81228. // To handle the case of degenerated triangle
  81229. // polygon.plane == null <=> the polygon does not represent 1 single plane <=> the triangle is degenerated
  81230. if (polygon.plane) {
  81231. polygons.push(polygon);
  81232. }
  81233. }
  81234. }
  81235. var csg = CSG.FromPolygons(polygons);
  81236. csg.matrix = matrix;
  81237. csg.position = meshPosition;
  81238. csg.rotation = meshRotation;
  81239. csg.scaling = meshScaling;
  81240. csg.rotationQuaternion = meshRotationQuaternion;
  81241. currentCSGMeshId++;
  81242. return csg;
  81243. };
  81244. /**
  81245. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  81246. * @param polygons Polygons used to construct a CSG solid
  81247. */
  81248. CSG.FromPolygons = function (polygons) {
  81249. var csg = new CSG();
  81250. csg.polygons = polygons;
  81251. return csg;
  81252. };
  81253. /**
  81254. * Clones, or makes a deep copy, of the CSG
  81255. * @returns A new CSG
  81256. */
  81257. CSG.prototype.clone = function () {
  81258. var csg = new CSG();
  81259. csg.polygons = this.polygons.map(function (p) { return p.clone(); });
  81260. csg.copyTransformAttributes(this);
  81261. return csg;
  81262. };
  81263. /**
  81264. * Unions this CSG with another CSG
  81265. * @param csg The CSG to union against this CSG
  81266. * @returns The unioned CSG
  81267. */
  81268. CSG.prototype.union = function (csg) {
  81269. var a = new Node(this.clone().polygons);
  81270. var b = new Node(csg.clone().polygons);
  81271. a.clipTo(b);
  81272. b.clipTo(a);
  81273. b.invert();
  81274. b.clipTo(a);
  81275. b.invert();
  81276. a.build(b.allPolygons());
  81277. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  81278. };
  81279. /**
  81280. * Unions this CSG with another CSG in place
  81281. * @param csg The CSG to union against this CSG
  81282. */
  81283. CSG.prototype.unionInPlace = function (csg) {
  81284. var a = new Node(this.polygons);
  81285. var b = new Node(csg.polygons);
  81286. a.clipTo(b);
  81287. b.clipTo(a);
  81288. b.invert();
  81289. b.clipTo(a);
  81290. b.invert();
  81291. a.build(b.allPolygons());
  81292. this.polygons = a.allPolygons();
  81293. };
  81294. /**
  81295. * Subtracts this CSG with another CSG
  81296. * @param csg The CSG to subtract against this CSG
  81297. * @returns A new CSG
  81298. */
  81299. CSG.prototype.subtract = function (csg) {
  81300. var a = new Node(this.clone().polygons);
  81301. var b = new Node(csg.clone().polygons);
  81302. a.invert();
  81303. a.clipTo(b);
  81304. b.clipTo(a);
  81305. b.invert();
  81306. b.clipTo(a);
  81307. b.invert();
  81308. a.build(b.allPolygons());
  81309. a.invert();
  81310. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  81311. };
  81312. /**
  81313. * Subtracts this CSG with another CSG in place
  81314. * @param csg The CSG to subtact against this CSG
  81315. */
  81316. CSG.prototype.subtractInPlace = function (csg) {
  81317. var a = new Node(this.polygons);
  81318. var b = new Node(csg.polygons);
  81319. a.invert();
  81320. a.clipTo(b);
  81321. b.clipTo(a);
  81322. b.invert();
  81323. b.clipTo(a);
  81324. b.invert();
  81325. a.build(b.allPolygons());
  81326. a.invert();
  81327. this.polygons = a.allPolygons();
  81328. };
  81329. /**
  81330. * Intersect this CSG with another CSG
  81331. * @param csg The CSG to intersect against this CSG
  81332. * @returns A new CSG
  81333. */
  81334. CSG.prototype.intersect = function (csg) {
  81335. var a = new Node(this.clone().polygons);
  81336. var b = new Node(csg.clone().polygons);
  81337. a.invert();
  81338. b.clipTo(a);
  81339. b.invert();
  81340. a.clipTo(b);
  81341. b.clipTo(a);
  81342. a.build(b.allPolygons());
  81343. a.invert();
  81344. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  81345. };
  81346. /**
  81347. * Intersects this CSG with another CSG in place
  81348. * @param csg The CSG to intersect against this CSG
  81349. */
  81350. CSG.prototype.intersectInPlace = function (csg) {
  81351. var a = new Node(this.polygons);
  81352. var b = new Node(csg.polygons);
  81353. a.invert();
  81354. b.clipTo(a);
  81355. b.invert();
  81356. a.clipTo(b);
  81357. b.clipTo(a);
  81358. a.build(b.allPolygons());
  81359. a.invert();
  81360. this.polygons = a.allPolygons();
  81361. };
  81362. /**
  81363. * Return a new CSG solid with solid and empty space switched. This solid is
  81364. * not modified.
  81365. * @returns A new CSG solid with solid and empty space switched
  81366. */
  81367. CSG.prototype.inverse = function () {
  81368. var csg = this.clone();
  81369. csg.inverseInPlace();
  81370. return csg;
  81371. };
  81372. /**
  81373. * Inverses the CSG in place
  81374. */
  81375. CSG.prototype.inverseInPlace = function () {
  81376. this.polygons.map(function (p) { p.flip(); });
  81377. };
  81378. /**
  81379. * This is used to keep meshes transformations so they can be restored
  81380. * when we build back a Babylon Mesh
  81381. * NB : All CSG operations are performed in world coordinates
  81382. * @param csg The CSG to copy the transform attributes from
  81383. * @returns This CSG
  81384. */
  81385. CSG.prototype.copyTransformAttributes = function (csg) {
  81386. this.matrix = csg.matrix;
  81387. this.position = csg.position;
  81388. this.rotation = csg.rotation;
  81389. this.scaling = csg.scaling;
  81390. this.rotationQuaternion = csg.rotationQuaternion;
  81391. return this;
  81392. };
  81393. /**
  81394. * Build Raw mesh from CSG
  81395. * Coordinates here are in world space
  81396. * @param name The name of the mesh geometry
  81397. * @param scene The Scene
  81398. * @param keepSubMeshes Specifies if the submeshes should be kept
  81399. * @returns A new Mesh
  81400. */
  81401. CSG.prototype.buildMeshGeometry = function (name, scene, keepSubMeshes) {
  81402. var matrix = this.matrix.clone();
  81403. matrix.invert();
  81404. 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;
  81405. if (keepSubMeshes) {
  81406. // Sort Polygons, since subMeshes are indices range
  81407. polygons.sort(function (a, b) {
  81408. if (a.shared.meshId === b.shared.meshId) {
  81409. return a.shared.subMeshId - b.shared.subMeshId;
  81410. }
  81411. else {
  81412. return a.shared.meshId - b.shared.meshId;
  81413. }
  81414. });
  81415. }
  81416. for (var i = 0, il = polygons.length; i < il; i++) {
  81417. polygon = polygons[i];
  81418. // Building SubMeshes
  81419. if (!subMesh_dict[polygon.shared.meshId]) {
  81420. subMesh_dict[polygon.shared.meshId] = {};
  81421. }
  81422. if (!subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId]) {
  81423. subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId] = {
  81424. indexStart: +Infinity,
  81425. indexEnd: -Infinity,
  81426. materialIndex: polygon.shared.materialIndex
  81427. };
  81428. }
  81429. subMesh_obj = subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId];
  81430. for (var j = 2, jl = polygon.vertices.length; j < jl; j++) {
  81431. polygonIndices[0] = 0;
  81432. polygonIndices[1] = j - 1;
  81433. polygonIndices[2] = j;
  81434. for (var k = 0; k < 3; k++) {
  81435. vertex.copyFrom(polygon.vertices[polygonIndices[k]].pos);
  81436. normal.copyFrom(polygon.vertices[polygonIndices[k]].normal);
  81437. uv.copyFrom(polygon.vertices[polygonIndices[k]].uv);
  81438. var localVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(vertex, matrix);
  81439. var localNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, matrix);
  81440. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z];
  81441. // Check if 2 points can be merged
  81442. if (!(typeof vertex_idx !== 'undefined' &&
  81443. normals[vertex_idx * 3] === localNormal.x &&
  81444. normals[vertex_idx * 3 + 1] === localNormal.y &&
  81445. normals[vertex_idx * 3 + 2] === localNormal.z &&
  81446. uvs[vertex_idx * 2] === uv.x &&
  81447. uvs[vertex_idx * 2 + 1] === uv.y)) {
  81448. vertices.push(localVertex.x, localVertex.y, localVertex.z);
  81449. uvs.push(uv.x, uv.y);
  81450. normals.push(normal.x, normal.y, normal.z);
  81451. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z] = (vertices.length / 3) - 1;
  81452. }
  81453. indices.push(vertex_idx);
  81454. subMesh_obj.indexStart = Math.min(currentIndex, subMesh_obj.indexStart);
  81455. subMesh_obj.indexEnd = Math.max(currentIndex, subMesh_obj.indexEnd);
  81456. currentIndex++;
  81457. }
  81458. }
  81459. }
  81460. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, vertices);
  81461. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals);
  81462. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs);
  81463. mesh.setIndices(indices, null);
  81464. if (keepSubMeshes) {
  81465. // We offset the materialIndex by the previous number of materials in the CSG mixed meshes
  81466. var materialIndexOffset = 0, materialMaxIndex;
  81467. mesh.subMeshes = new Array();
  81468. for (var m in subMesh_dict) {
  81469. materialMaxIndex = -1;
  81470. for (var sm in subMesh_dict[m]) {
  81471. subMesh_obj = subMesh_dict[m][sm];
  81472. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].CreateFromIndices(subMesh_obj.materialIndex + materialIndexOffset, subMesh_obj.indexStart, subMesh_obj.indexEnd - subMesh_obj.indexStart + 1, mesh);
  81473. materialMaxIndex = Math.max(subMesh_obj.materialIndex, materialMaxIndex);
  81474. }
  81475. materialIndexOffset += ++materialMaxIndex;
  81476. }
  81477. }
  81478. return mesh;
  81479. };
  81480. /**
  81481. * Build Mesh from CSG taking material and transforms into account
  81482. * @param name The name of the Mesh
  81483. * @param material The material of the Mesh
  81484. * @param scene The Scene
  81485. * @param keepSubMeshes Specifies if submeshes should be kept
  81486. * @returns The new Mesh
  81487. */
  81488. CSG.prototype.toMesh = function (name, material, scene, keepSubMeshes) {
  81489. var mesh = this.buildMeshGeometry(name, scene, keepSubMeshes);
  81490. mesh.material = material;
  81491. mesh.position.copyFrom(this.position);
  81492. mesh.rotation.copyFrom(this.rotation);
  81493. if (this.rotationQuaternion) {
  81494. mesh.rotationQuaternion = this.rotationQuaternion.clone();
  81495. }
  81496. mesh.scaling.copyFrom(this.scaling);
  81497. mesh.computeWorldMatrix(true);
  81498. return mesh;
  81499. };
  81500. return CSG;
  81501. }());
  81502. /***/ }),
  81503. /***/ "./Meshes/geometry.ts":
  81504. /*!****************************!*\
  81505. !*** ./Meshes/geometry.ts ***!
  81506. \****************************/
  81507. /*! exports provided: Geometry */
  81508. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81509. "use strict";
  81510. __webpack_require__.r(__webpack_exports__);
  81511. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return Geometry; });
  81512. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  81513. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  81514. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  81515. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  81516. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  81517. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  81518. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  81519. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  81520. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  81521. /**
  81522. * Class used to store geometry data (vertex buffers + index buffer)
  81523. */
  81524. var Geometry = /** @class */ (function () {
  81525. /**
  81526. * Creates a new geometry
  81527. * @param id defines the unique ID
  81528. * @param scene defines the hosting scene
  81529. * @param vertexData defines the VertexData used to get geometry data
  81530. * @param updatable defines if geometry must be updatable (false by default)
  81531. * @param mesh defines the mesh that will be associated with the geometry
  81532. */
  81533. function Geometry(id, scene, vertexData, updatable, mesh) {
  81534. if (updatable === void 0) { updatable = false; }
  81535. if (mesh === void 0) { mesh = null; }
  81536. /**
  81537. * Gets the delay loading state of the geometry (none by default which means not delayed)
  81538. */
  81539. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  81540. this._totalVertices = 0;
  81541. this._isDisposed = false;
  81542. this._indexBufferIsUpdatable = false;
  81543. this.id = id;
  81544. this.uniqueId = scene.getUniqueId();
  81545. this._engine = scene.getEngine();
  81546. this._meshes = [];
  81547. this._scene = scene;
  81548. //Init vertex buffer cache
  81549. this._vertexBuffers = {};
  81550. this._indices = [];
  81551. this._updatable = updatable;
  81552. // vertexData
  81553. if (vertexData) {
  81554. this.setAllVerticesData(vertexData, updatable);
  81555. }
  81556. else {
  81557. this._totalVertices = 0;
  81558. this._indices = [];
  81559. }
  81560. if (this._engine.getCaps().vertexArrayObject) {
  81561. this._vertexArrayObjects = {};
  81562. }
  81563. // applyToMesh
  81564. if (mesh) {
  81565. this.applyToMesh(mesh);
  81566. mesh.computeWorldMatrix(true);
  81567. }
  81568. }
  81569. Object.defineProperty(Geometry.prototype, "boundingBias", {
  81570. /**
  81571. * 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
  81572. */
  81573. get: function () {
  81574. return this._boundingBias;
  81575. },
  81576. /**
  81577. * 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
  81578. */
  81579. set: function (value) {
  81580. if (this._boundingBias) {
  81581. this._boundingBias.copyFrom(value);
  81582. }
  81583. else {
  81584. this._boundingBias = value.clone();
  81585. }
  81586. this._updateBoundingInfo(true, null);
  81587. },
  81588. enumerable: true,
  81589. configurable: true
  81590. });
  81591. /**
  81592. * Static function used to attach a new empty geometry to a mesh
  81593. * @param mesh defines the mesh to attach the geometry to
  81594. * @returns the new Geometry
  81595. */
  81596. Geometry.CreateGeometryForMesh = function (mesh) {
  81597. var geometry = new Geometry(Geometry.RandomId(), mesh.getScene());
  81598. geometry.applyToMesh(mesh);
  81599. return geometry;
  81600. };
  81601. Object.defineProperty(Geometry.prototype, "extend", {
  81602. /**
  81603. * Gets the current extend of the geometry
  81604. */
  81605. get: function () {
  81606. return this._extend;
  81607. },
  81608. enumerable: true,
  81609. configurable: true
  81610. });
  81611. /**
  81612. * Gets the hosting scene
  81613. * @returns the hosting Scene
  81614. */
  81615. Geometry.prototype.getScene = function () {
  81616. return this._scene;
  81617. };
  81618. /**
  81619. * Gets the hosting engine
  81620. * @returns the hosting Engine
  81621. */
  81622. Geometry.prototype.getEngine = function () {
  81623. return this._engine;
  81624. };
  81625. /**
  81626. * Defines if the geometry is ready to use
  81627. * @returns true if the geometry is ready to be used
  81628. */
  81629. Geometry.prototype.isReady = function () {
  81630. return this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED || this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  81631. };
  81632. Object.defineProperty(Geometry.prototype, "doNotSerialize", {
  81633. /**
  81634. * Gets a value indicating that the geometry should not be serialized
  81635. */
  81636. get: function () {
  81637. for (var index = 0; index < this._meshes.length; index++) {
  81638. if (!this._meshes[index].doNotSerialize) {
  81639. return false;
  81640. }
  81641. }
  81642. return true;
  81643. },
  81644. enumerable: true,
  81645. configurable: true
  81646. });
  81647. /** @hidden */
  81648. Geometry.prototype._rebuild = function () {
  81649. if (this._vertexArrayObjects) {
  81650. this._vertexArrayObjects = {};
  81651. }
  81652. // Index buffer
  81653. if (this._meshes.length !== 0 && this._indices) {
  81654. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  81655. }
  81656. // Vertex buffers
  81657. for (var key in this._vertexBuffers) {
  81658. var vertexBuffer = this._vertexBuffers[key];
  81659. vertexBuffer._rebuild();
  81660. }
  81661. };
  81662. /**
  81663. * Affects all geometry data in one call
  81664. * @param vertexData defines the geometry data
  81665. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  81666. */
  81667. Geometry.prototype.setAllVerticesData = function (vertexData, updatable) {
  81668. vertexData.applyToGeometry(this, updatable);
  81669. this.notifyUpdate();
  81670. };
  81671. /**
  81672. * Set specific vertex data
  81673. * @param kind defines the data kind (Position, normal, etc...)
  81674. * @param data defines the vertex data to use
  81675. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  81676. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  81677. */
  81678. Geometry.prototype.setVerticesData = function (kind, data, updatable, stride) {
  81679. if (updatable === void 0) { updatable = false; }
  81680. var buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"](this._engine, data, kind, updatable, this._meshes.length === 0, stride);
  81681. this.setVerticesBuffer(buffer);
  81682. };
  81683. /**
  81684. * Removes a specific vertex data
  81685. * @param kind defines the data kind (Position, normal, etc...)
  81686. */
  81687. Geometry.prototype.removeVerticesData = function (kind) {
  81688. if (this._vertexBuffers[kind]) {
  81689. this._vertexBuffers[kind].dispose();
  81690. delete this._vertexBuffers[kind];
  81691. }
  81692. };
  81693. /**
  81694. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  81695. * @param buffer defines the vertex buffer to use
  81696. * @param totalVertices defines the total number of vertices for position kind (could be null)
  81697. */
  81698. Geometry.prototype.setVerticesBuffer = function (buffer, totalVertices) {
  81699. if (totalVertices === void 0) { totalVertices = null; }
  81700. var kind = buffer.getKind();
  81701. if (this._vertexBuffers[kind]) {
  81702. this._vertexBuffers[kind].dispose();
  81703. }
  81704. this._vertexBuffers[kind] = buffer;
  81705. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  81706. var data = buffer.getData();
  81707. if (totalVertices != null) {
  81708. this._totalVertices = totalVertices;
  81709. }
  81710. else {
  81711. if (data != null) {
  81712. this._totalVertices = data.length / (buffer.byteStride / 4);
  81713. }
  81714. }
  81715. this._updateExtend(data);
  81716. this._resetPointsArrayCache();
  81717. var meshes = this._meshes;
  81718. var numOfMeshes = meshes.length;
  81719. for (var index = 0; index < numOfMeshes; index++) {
  81720. var mesh = meshes[index];
  81721. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  81722. mesh._createGlobalSubMesh(false);
  81723. mesh.computeWorldMatrix(true);
  81724. }
  81725. }
  81726. this.notifyUpdate(kind);
  81727. if (this._vertexArrayObjects) {
  81728. this._disposeVertexArrayObjects();
  81729. this._vertexArrayObjects = {}; // Will trigger a rebuild of the VAO if supported
  81730. }
  81731. };
  81732. /**
  81733. * Update a specific vertex buffer
  81734. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  81735. * It will do nothing if the buffer is not updatable
  81736. * @param kind defines the data kind (Position, normal, etc...)
  81737. * @param data defines the data to use
  81738. * @param offset defines the offset in the target buffer where to store the data
  81739. * @param useBytes set to true if the offset is in bytes
  81740. */
  81741. Geometry.prototype.updateVerticesDataDirectly = function (kind, data, offset, useBytes) {
  81742. if (useBytes === void 0) { useBytes = false; }
  81743. var vertexBuffer = this.getVertexBuffer(kind);
  81744. if (!vertexBuffer) {
  81745. return;
  81746. }
  81747. vertexBuffer.updateDirectly(data, offset, useBytes);
  81748. this.notifyUpdate(kind);
  81749. };
  81750. /**
  81751. * Update a specific vertex buffer
  81752. * This function will create a new buffer if the current one is not updatable
  81753. * @param kind defines the data kind (Position, normal, etc...)
  81754. * @param data defines the data to use
  81755. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  81756. */
  81757. Geometry.prototype.updateVerticesData = function (kind, data, updateExtends) {
  81758. if (updateExtends === void 0) { updateExtends = false; }
  81759. var vertexBuffer = this.getVertexBuffer(kind);
  81760. if (!vertexBuffer) {
  81761. return;
  81762. }
  81763. vertexBuffer.update(data);
  81764. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  81765. this._updateBoundingInfo(updateExtends, data);
  81766. }
  81767. this.notifyUpdate(kind);
  81768. };
  81769. Geometry.prototype._updateBoundingInfo = function (updateExtends, data) {
  81770. if (updateExtends) {
  81771. this._updateExtend(data);
  81772. }
  81773. this._resetPointsArrayCache();
  81774. if (updateExtends) {
  81775. var meshes = this._meshes;
  81776. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  81777. var mesh = meshes_1[_i];
  81778. if (mesh._boundingInfo) {
  81779. mesh._boundingInfo.reConstruct(this._extend.minimum, this._extend.maximum);
  81780. }
  81781. else {
  81782. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  81783. }
  81784. var subMeshes = mesh.subMeshes;
  81785. for (var _a = 0, subMeshes_1 = subMeshes; _a < subMeshes_1.length; _a++) {
  81786. var subMesh = subMeshes_1[_a];
  81787. subMesh.refreshBoundingInfo();
  81788. }
  81789. }
  81790. }
  81791. };
  81792. /** @hidden */
  81793. Geometry.prototype._bind = function (effect, indexToBind) {
  81794. if (!effect) {
  81795. return;
  81796. }
  81797. if (indexToBind === undefined) {
  81798. indexToBind = this._indexBuffer;
  81799. }
  81800. var vbs = this.getVertexBuffers();
  81801. if (!vbs) {
  81802. return;
  81803. }
  81804. if (indexToBind != this._indexBuffer || !this._vertexArrayObjects) {
  81805. this._engine.bindBuffers(vbs, indexToBind, effect);
  81806. return;
  81807. }
  81808. // Using VAO
  81809. if (!this._vertexArrayObjects[effect.key]) {
  81810. this._vertexArrayObjects[effect.key] = this._engine.recordVertexArrayObject(vbs, indexToBind, effect);
  81811. }
  81812. this._engine.bindVertexArrayObject(this._vertexArrayObjects[effect.key], indexToBind);
  81813. };
  81814. /**
  81815. * Gets total number of vertices
  81816. * @returns the total number of vertices
  81817. */
  81818. Geometry.prototype.getTotalVertices = function () {
  81819. if (!this.isReady()) {
  81820. return 0;
  81821. }
  81822. return this._totalVertices;
  81823. };
  81824. /**
  81825. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  81826. * @param kind defines the data kind (Position, normal, etc...)
  81827. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81828. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81829. * @returns a float array containing vertex data
  81830. */
  81831. Geometry.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  81832. var vertexBuffer = this.getVertexBuffer(kind);
  81833. if (!vertexBuffer) {
  81834. return null;
  81835. }
  81836. var data = vertexBuffer.getData();
  81837. if (!data) {
  81838. return null;
  81839. }
  81840. var tightlyPackedByteStride = vertexBuffer.getSize() * _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].GetTypeByteLength(vertexBuffer.type);
  81841. var count = this._totalVertices * vertexBuffer.getSize();
  81842. if (vertexBuffer.type !== _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].FLOAT || vertexBuffer.byteStride !== tightlyPackedByteStride) {
  81843. var copy_1 = [];
  81844. vertexBuffer.forEach(count, function (value) { return copy_1.push(value); });
  81845. return copy_1;
  81846. }
  81847. if (!((data instanceof Array) || (data instanceof Float32Array)) || vertexBuffer.byteOffset !== 0 || data.length !== count) {
  81848. if (data instanceof Array) {
  81849. var offset = vertexBuffer.byteOffset / 4;
  81850. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data, offset, offset + count);
  81851. }
  81852. else if (data instanceof ArrayBuffer) {
  81853. return new Float32Array(data, vertexBuffer.byteOffset, count);
  81854. }
  81855. else {
  81856. var offset = data.byteOffset + vertexBuffer.byteOffset;
  81857. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  81858. var result = new Float32Array(count);
  81859. var source = new Float32Array(data.buffer, offset, count);
  81860. result.set(source);
  81861. return result;
  81862. }
  81863. return new Float32Array(data.buffer, offset, count);
  81864. }
  81865. }
  81866. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  81867. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data);
  81868. }
  81869. return data;
  81870. };
  81871. /**
  81872. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  81873. * @param kind defines the data kind (Position, normal, etc...)
  81874. * @returns true if the vertex buffer with the specified kind is updatable
  81875. */
  81876. Geometry.prototype.isVertexBufferUpdatable = function (kind) {
  81877. var vb = this._vertexBuffers[kind];
  81878. if (!vb) {
  81879. return false;
  81880. }
  81881. return vb.isUpdatable();
  81882. };
  81883. /**
  81884. * Gets a specific vertex buffer
  81885. * @param kind defines the data kind (Position, normal, etc...)
  81886. * @returns a VertexBuffer
  81887. */
  81888. Geometry.prototype.getVertexBuffer = function (kind) {
  81889. if (!this.isReady()) {
  81890. return null;
  81891. }
  81892. return this._vertexBuffers[kind];
  81893. };
  81894. /**
  81895. * Returns all vertex buffers
  81896. * @return an object holding all vertex buffers indexed by kind
  81897. */
  81898. Geometry.prototype.getVertexBuffers = function () {
  81899. if (!this.isReady()) {
  81900. return null;
  81901. }
  81902. return this._vertexBuffers;
  81903. };
  81904. /**
  81905. * Gets a boolean indicating if specific vertex buffer is present
  81906. * @param kind defines the data kind (Position, normal, etc...)
  81907. * @returns true if data is present
  81908. */
  81909. Geometry.prototype.isVerticesDataPresent = function (kind) {
  81910. if (!this._vertexBuffers) {
  81911. if (this._delayInfo) {
  81912. return this._delayInfo.indexOf(kind) !== -1;
  81913. }
  81914. return false;
  81915. }
  81916. return this._vertexBuffers[kind] !== undefined;
  81917. };
  81918. /**
  81919. * Gets a list of all attached data kinds (Position, normal, etc...)
  81920. * @returns a list of string containing all kinds
  81921. */
  81922. Geometry.prototype.getVerticesDataKinds = function () {
  81923. var result = [];
  81924. var kind;
  81925. if (!this._vertexBuffers && this._delayInfo) {
  81926. for (kind in this._delayInfo) {
  81927. result.push(kind);
  81928. }
  81929. }
  81930. else {
  81931. for (kind in this._vertexBuffers) {
  81932. result.push(kind);
  81933. }
  81934. }
  81935. return result;
  81936. };
  81937. /**
  81938. * Update index buffer
  81939. * @param indices defines the indices to store in the index buffer
  81940. * @param offset defines the offset in the target buffer where to store the data
  81941. */
  81942. Geometry.prototype.updateIndices = function (indices, offset) {
  81943. if (!this._indexBuffer) {
  81944. return;
  81945. }
  81946. if (!this._indexBufferIsUpdatable) {
  81947. this.setIndices(indices, null, true);
  81948. }
  81949. else {
  81950. var needToUpdateSubMeshes = indices.length !== this._indices.length;
  81951. this._indices = indices;
  81952. this._engine.updateDynamicIndexBuffer(this._indexBuffer, indices, offset);
  81953. if (needToUpdateSubMeshes) {
  81954. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  81955. var mesh = _a[_i];
  81956. mesh._createGlobalSubMesh(true);
  81957. }
  81958. }
  81959. }
  81960. };
  81961. /**
  81962. * Creates a new index buffer
  81963. * @param indices defines the indices to store in the index buffer
  81964. * @param totalVertices defines the total number of vertices (could be null)
  81965. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  81966. */
  81967. Geometry.prototype.setIndices = function (indices, totalVertices, updatable) {
  81968. if (totalVertices === void 0) { totalVertices = null; }
  81969. if (updatable === void 0) { updatable = false; }
  81970. if (this._indexBuffer) {
  81971. this._engine._releaseBuffer(this._indexBuffer);
  81972. }
  81973. this._disposeVertexArrayObjects();
  81974. this._indices = indices;
  81975. this._indexBufferIsUpdatable = updatable;
  81976. if (this._meshes.length !== 0 && this._indices) {
  81977. this._indexBuffer = this._engine.createIndexBuffer(this._indices, updatable);
  81978. }
  81979. if (totalVertices != undefined) { // including null and undefined
  81980. this._totalVertices = totalVertices;
  81981. }
  81982. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  81983. var mesh = _a[_i];
  81984. mesh._createGlobalSubMesh(true);
  81985. }
  81986. this.notifyUpdate();
  81987. };
  81988. /**
  81989. * Return the total number of indices
  81990. * @returns the total number of indices
  81991. */
  81992. Geometry.prototype.getTotalIndices = function () {
  81993. if (!this.isReady()) {
  81994. return 0;
  81995. }
  81996. return this._indices.length;
  81997. };
  81998. /**
  81999. * Gets the index buffer array
  82000. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82001. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82002. * @returns the index buffer array
  82003. */
  82004. Geometry.prototype.getIndices = function (copyWhenShared, forceCopy) {
  82005. if (!this.isReady()) {
  82006. return null;
  82007. }
  82008. var orig = this._indices;
  82009. if (!forceCopy && (!copyWhenShared || this._meshes.length === 1)) {
  82010. return orig;
  82011. }
  82012. else {
  82013. var len = orig.length;
  82014. var copy = [];
  82015. for (var i = 0; i < len; i++) {
  82016. copy.push(orig[i]);
  82017. }
  82018. return copy;
  82019. }
  82020. };
  82021. /**
  82022. * Gets the index buffer
  82023. * @return the index buffer
  82024. */
  82025. Geometry.prototype.getIndexBuffer = function () {
  82026. if (!this.isReady()) {
  82027. return null;
  82028. }
  82029. return this._indexBuffer;
  82030. };
  82031. /** @hidden */
  82032. Geometry.prototype._releaseVertexArrayObject = function (effect) {
  82033. if (effect === void 0) { effect = null; }
  82034. if (!effect || !this._vertexArrayObjects) {
  82035. return;
  82036. }
  82037. if (this._vertexArrayObjects[effect.key]) {
  82038. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[effect.key]);
  82039. delete this._vertexArrayObjects[effect.key];
  82040. }
  82041. };
  82042. /**
  82043. * Release the associated resources for a specific mesh
  82044. * @param mesh defines the source mesh
  82045. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  82046. */
  82047. Geometry.prototype.releaseForMesh = function (mesh, shouldDispose) {
  82048. var meshes = this._meshes;
  82049. var index = meshes.indexOf(mesh);
  82050. if (index === -1) {
  82051. return;
  82052. }
  82053. meshes.splice(index, 1);
  82054. mesh._geometry = null;
  82055. if (meshes.length === 0 && shouldDispose) {
  82056. this.dispose();
  82057. }
  82058. };
  82059. /**
  82060. * Apply current geometry to a given mesh
  82061. * @param mesh defines the mesh to apply geometry to
  82062. */
  82063. Geometry.prototype.applyToMesh = function (mesh) {
  82064. if (mesh._geometry === this) {
  82065. return;
  82066. }
  82067. var previousGeometry = mesh._geometry;
  82068. if (previousGeometry) {
  82069. previousGeometry.releaseForMesh(mesh);
  82070. }
  82071. var meshes = this._meshes;
  82072. // must be done before setting vertexBuffers because of mesh._createGlobalSubMesh()
  82073. mesh._geometry = this;
  82074. this._scene.pushGeometry(this);
  82075. meshes.push(mesh);
  82076. if (this.isReady()) {
  82077. this._applyToMesh(mesh);
  82078. }
  82079. else {
  82080. mesh._boundingInfo = this._boundingInfo;
  82081. }
  82082. };
  82083. Geometry.prototype._updateExtend = function (data) {
  82084. if (data === void 0) { data = null; }
  82085. if (!data) {
  82086. data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  82087. }
  82088. this._extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].ExtractMinAndMax(data, 0, this._totalVertices, this.boundingBias, 3);
  82089. };
  82090. Geometry.prototype._applyToMesh = function (mesh) {
  82091. var numOfMeshes = this._meshes.length;
  82092. // vertexBuffers
  82093. for (var kind in this._vertexBuffers) {
  82094. if (numOfMeshes === 1) {
  82095. this._vertexBuffers[kind].create();
  82096. }
  82097. var buffer = this._vertexBuffers[kind].getBuffer();
  82098. if (buffer) {
  82099. buffer.references = numOfMeshes;
  82100. }
  82101. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  82102. if (!this._extend) {
  82103. this._updateExtend();
  82104. }
  82105. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  82106. mesh._createGlobalSubMesh(false);
  82107. //bounding info was just created again, world matrix should be applied again.
  82108. mesh._updateBoundingInfo();
  82109. }
  82110. }
  82111. // indexBuffer
  82112. if (numOfMeshes === 1 && this._indices && this._indices.length > 0) {
  82113. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  82114. }
  82115. if (this._indexBuffer) {
  82116. this._indexBuffer.references = numOfMeshes;
  82117. }
  82118. // morphTargets
  82119. mesh._syncGeometryWithMorphTargetManager();
  82120. // instances
  82121. mesh.synchronizeInstances();
  82122. };
  82123. Geometry.prototype.notifyUpdate = function (kind) {
  82124. if (this.onGeometryUpdated) {
  82125. this.onGeometryUpdated(this, kind);
  82126. }
  82127. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  82128. var mesh = _a[_i];
  82129. mesh._markSubMeshesAsAttributesDirty();
  82130. }
  82131. };
  82132. /**
  82133. * Load the geometry if it was flagged as delay loaded
  82134. * @param scene defines the hosting scene
  82135. * @param onLoaded defines a callback called when the geometry is loaded
  82136. */
  82137. Geometry.prototype.load = function (scene, onLoaded) {
  82138. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING) {
  82139. return;
  82140. }
  82141. if (this.isReady()) {
  82142. if (onLoaded) {
  82143. onLoaded();
  82144. }
  82145. return;
  82146. }
  82147. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING;
  82148. this._queueLoad(scene, onLoaded);
  82149. };
  82150. Geometry.prototype._queueLoad = function (scene, onLoaded) {
  82151. var _this = this;
  82152. if (!this.delayLoadingFile) {
  82153. return;
  82154. }
  82155. scene._addPendingData(this);
  82156. scene._loadFile(this.delayLoadingFile, function (data) {
  82157. if (!_this._delayLoadingFunction) {
  82158. return;
  82159. }
  82160. _this._delayLoadingFunction(JSON.parse(data), _this);
  82161. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  82162. _this._delayInfo = [];
  82163. scene._removePendingData(_this);
  82164. var meshes = _this._meshes;
  82165. var numOfMeshes = meshes.length;
  82166. for (var index = 0; index < numOfMeshes; index++) {
  82167. _this._applyToMesh(meshes[index]);
  82168. }
  82169. if (onLoaded) {
  82170. onLoaded();
  82171. }
  82172. }, undefined, true);
  82173. };
  82174. /**
  82175. * Invert the geometry to move from a right handed system to a left handed one.
  82176. */
  82177. Geometry.prototype.toLeftHanded = function () {
  82178. // Flip faces
  82179. var tIndices = this.getIndices(false);
  82180. if (tIndices != null && tIndices.length > 0) {
  82181. for (var i = 0; i < tIndices.length; i += 3) {
  82182. var tTemp = tIndices[i + 0];
  82183. tIndices[i + 0] = tIndices[i + 2];
  82184. tIndices[i + 2] = tTemp;
  82185. }
  82186. this.setIndices(tIndices);
  82187. }
  82188. // Negate position.z
  82189. var tPositions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, false);
  82190. if (tPositions != null && tPositions.length > 0) {
  82191. for (var i = 0; i < tPositions.length; i += 3) {
  82192. tPositions[i + 2] = -tPositions[i + 2];
  82193. }
  82194. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, tPositions, false);
  82195. }
  82196. // Negate normal.z
  82197. var tNormals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, false);
  82198. if (tNormals != null && tNormals.length > 0) {
  82199. for (var i = 0; i < tNormals.length; i += 3) {
  82200. tNormals[i + 2] = -tNormals[i + 2];
  82201. }
  82202. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, tNormals, false);
  82203. }
  82204. };
  82205. // Cache
  82206. /** @hidden */
  82207. Geometry.prototype._resetPointsArrayCache = function () {
  82208. this._positions = null;
  82209. };
  82210. /** @hidden */
  82211. Geometry.prototype._generatePointsArray = function () {
  82212. if (this._positions) {
  82213. return true;
  82214. }
  82215. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  82216. if (!data || data.length === 0) {
  82217. return false;
  82218. }
  82219. this._positions = [];
  82220. for (var index = 0; index < data.length; index += 3) {
  82221. this._positions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(data, index));
  82222. }
  82223. return true;
  82224. };
  82225. /**
  82226. * Gets a value indicating if the geometry is disposed
  82227. * @returns true if the geometry was disposed
  82228. */
  82229. Geometry.prototype.isDisposed = function () {
  82230. return this._isDisposed;
  82231. };
  82232. Geometry.prototype._disposeVertexArrayObjects = function () {
  82233. if (this._vertexArrayObjects) {
  82234. for (var kind in this._vertexArrayObjects) {
  82235. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[kind]);
  82236. }
  82237. this._vertexArrayObjects = {};
  82238. }
  82239. };
  82240. /**
  82241. * Free all associated resources
  82242. */
  82243. Geometry.prototype.dispose = function () {
  82244. var meshes = this._meshes;
  82245. var numOfMeshes = meshes.length;
  82246. var index;
  82247. for (index = 0; index < numOfMeshes; index++) {
  82248. this.releaseForMesh(meshes[index]);
  82249. }
  82250. this._meshes = [];
  82251. this._disposeVertexArrayObjects();
  82252. for (var kind in this._vertexBuffers) {
  82253. this._vertexBuffers[kind].dispose();
  82254. }
  82255. this._vertexBuffers = {};
  82256. this._totalVertices = 0;
  82257. if (this._indexBuffer) {
  82258. this._engine._releaseBuffer(this._indexBuffer);
  82259. }
  82260. this._indexBuffer = null;
  82261. this._indices = [];
  82262. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  82263. this.delayLoadingFile = null;
  82264. this._delayLoadingFunction = null;
  82265. this._delayInfo = [];
  82266. this._boundingInfo = null;
  82267. this._scene.removeGeometry(this);
  82268. this._isDisposed = true;
  82269. };
  82270. /**
  82271. * Clone the current geometry into a new geometry
  82272. * @param id defines the unique ID of the new geometry
  82273. * @returns a new geometry object
  82274. */
  82275. Geometry.prototype.copy = function (id) {
  82276. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  82277. vertexData.indices = [];
  82278. var indices = this.getIndices();
  82279. if (indices) {
  82280. for (var index = 0; index < indices.length; index++) {
  82281. vertexData.indices.push(indices[index]);
  82282. }
  82283. }
  82284. var updatable = false;
  82285. var stopChecking = false;
  82286. var kind;
  82287. for (kind in this._vertexBuffers) {
  82288. // using slice() to make a copy of the array and not just reference it
  82289. var data = this.getVerticesData(kind);
  82290. if (data) {
  82291. if (data instanceof Float32Array) {
  82292. vertexData.set(new Float32Array(data), kind);
  82293. }
  82294. else {
  82295. vertexData.set(data.slice(0), kind);
  82296. }
  82297. if (!stopChecking) {
  82298. var vb = this.getVertexBuffer(kind);
  82299. if (vb) {
  82300. updatable = vb.isUpdatable();
  82301. stopChecking = !updatable;
  82302. }
  82303. }
  82304. }
  82305. }
  82306. var geometry = new Geometry(id, this._scene, vertexData, updatable);
  82307. geometry.delayLoadState = this.delayLoadState;
  82308. geometry.delayLoadingFile = this.delayLoadingFile;
  82309. geometry._delayLoadingFunction = this._delayLoadingFunction;
  82310. for (kind in this._delayInfo) {
  82311. geometry._delayInfo = geometry._delayInfo || [];
  82312. geometry._delayInfo.push(kind);
  82313. }
  82314. // Bounding info
  82315. geometry._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  82316. return geometry;
  82317. };
  82318. /**
  82319. * Serialize the current geometry info (and not the vertices data) into a JSON object
  82320. * @return a JSON representation of the current geometry data (without the vertices data)
  82321. */
  82322. Geometry.prototype.serialize = function () {
  82323. var serializationObject = {};
  82324. serializationObject.id = this.id;
  82325. serializationObject.updatable = this._updatable;
  82326. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].HasTags(this)) {
  82327. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].GetTags(this);
  82328. }
  82329. return serializationObject;
  82330. };
  82331. Geometry.prototype.toNumberArray = function (origin) {
  82332. if (Array.isArray(origin)) {
  82333. return origin;
  82334. }
  82335. else {
  82336. return Array.prototype.slice.call(origin);
  82337. }
  82338. };
  82339. /**
  82340. * Serialize all vertices data into a JSON oject
  82341. * @returns a JSON representation of the current geometry data
  82342. */
  82343. Geometry.prototype.serializeVerticeData = function () {
  82344. var serializationObject = this.serialize();
  82345. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  82346. serializationObject.positions = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  82347. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  82348. serializationObject.positions._updatable = true;
  82349. }
  82350. }
  82351. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  82352. serializationObject.normals = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind));
  82353. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  82354. serializationObject.normals._updatable = true;
  82355. }
  82356. }
  82357. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  82358. serializationObject.tangets = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind));
  82359. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  82360. serializationObject.tangets._updatable = true;
  82361. }
  82362. }
  82363. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  82364. serializationObject.uvs = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind));
  82365. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  82366. serializationObject.uvs._updatable = true;
  82367. }
  82368. }
  82369. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  82370. serializationObject.uv2s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind));
  82371. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  82372. serializationObject.uv2s._updatable = true;
  82373. }
  82374. }
  82375. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  82376. serializationObject.uv3s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind));
  82377. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  82378. serializationObject.uv3s._updatable = true;
  82379. }
  82380. }
  82381. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  82382. serializationObject.uv4s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind));
  82383. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  82384. serializationObject.uv4s._updatable = true;
  82385. }
  82386. }
  82387. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  82388. serializationObject.uv5s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind));
  82389. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  82390. serializationObject.uv5s._updatable = true;
  82391. }
  82392. }
  82393. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  82394. serializationObject.uv6s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind));
  82395. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  82396. serializationObject.uv6s._updatable = true;
  82397. }
  82398. }
  82399. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  82400. serializationObject.colors = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind));
  82401. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  82402. serializationObject.colors._updatable = true;
  82403. }
  82404. }
  82405. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  82406. serializationObject.matricesIndices = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind));
  82407. serializationObject.matricesIndices._isExpanded = true;
  82408. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  82409. serializationObject.matricesIndices._updatable = true;
  82410. }
  82411. }
  82412. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  82413. serializationObject.matricesWeights = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind));
  82414. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  82415. serializationObject.matricesWeights._updatable = true;
  82416. }
  82417. }
  82418. serializationObject.indices = this.toNumberArray(this.getIndices());
  82419. return serializationObject;
  82420. };
  82421. // Statics
  82422. /**
  82423. * Extracts a clone of a mesh geometry
  82424. * @param mesh defines the source mesh
  82425. * @param id defines the unique ID of the new geometry object
  82426. * @returns the new geometry object
  82427. */
  82428. Geometry.ExtractFromMesh = function (mesh, id) {
  82429. var geometry = mesh._geometry;
  82430. if (!geometry) {
  82431. return null;
  82432. }
  82433. return geometry.copy(id);
  82434. };
  82435. /**
  82436. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  82437. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  82438. * Be aware Math.random() could cause collisions, but:
  82439. * "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"
  82440. * @returns a string containing a new GUID
  82441. */
  82442. Geometry.RandomId = function () {
  82443. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].RandomId();
  82444. };
  82445. /** @hidden */
  82446. Geometry._ImportGeometry = function (parsedGeometry, mesh) {
  82447. var scene = mesh.getScene();
  82448. // Geometry
  82449. var geometryId = parsedGeometry.geometryId;
  82450. if (geometryId) {
  82451. var geometry = scene.getGeometryByID(geometryId);
  82452. if (geometry) {
  82453. geometry.applyToMesh(mesh);
  82454. }
  82455. }
  82456. else if (parsedGeometry instanceof ArrayBuffer) {
  82457. var binaryInfo = mesh._binaryInfo;
  82458. if (binaryInfo.positionsAttrDesc && binaryInfo.positionsAttrDesc.count > 0) {
  82459. var positionsData = new Float32Array(parsedGeometry, binaryInfo.positionsAttrDesc.offset, binaryInfo.positionsAttrDesc.count);
  82460. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positionsData, false);
  82461. }
  82462. if (binaryInfo.normalsAttrDesc && binaryInfo.normalsAttrDesc.count > 0) {
  82463. var normalsData = new Float32Array(parsedGeometry, binaryInfo.normalsAttrDesc.offset, binaryInfo.normalsAttrDesc.count);
  82464. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normalsData, false);
  82465. }
  82466. if (binaryInfo.tangetsAttrDesc && binaryInfo.tangetsAttrDesc.count > 0) {
  82467. var tangentsData = new Float32Array(parsedGeometry, binaryInfo.tangetsAttrDesc.offset, binaryInfo.tangetsAttrDesc.count);
  82468. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, tangentsData, false);
  82469. }
  82470. if (binaryInfo.uvsAttrDesc && binaryInfo.uvsAttrDesc.count > 0) {
  82471. var uvsData = new Float32Array(parsedGeometry, binaryInfo.uvsAttrDesc.offset, binaryInfo.uvsAttrDesc.count);
  82472. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvsData, false);
  82473. }
  82474. if (binaryInfo.uvs2AttrDesc && binaryInfo.uvs2AttrDesc.count > 0) {
  82475. var uvs2Data = new Float32Array(parsedGeometry, binaryInfo.uvs2AttrDesc.offset, binaryInfo.uvs2AttrDesc.count);
  82476. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, uvs2Data, false);
  82477. }
  82478. if (binaryInfo.uvs3AttrDesc && binaryInfo.uvs3AttrDesc.count > 0) {
  82479. var uvs3Data = new Float32Array(parsedGeometry, binaryInfo.uvs3AttrDesc.offset, binaryInfo.uvs3AttrDesc.count);
  82480. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, uvs3Data, false);
  82481. }
  82482. if (binaryInfo.uvs4AttrDesc && binaryInfo.uvs4AttrDesc.count > 0) {
  82483. var uvs4Data = new Float32Array(parsedGeometry, binaryInfo.uvs4AttrDesc.offset, binaryInfo.uvs4AttrDesc.count);
  82484. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, uvs4Data, false);
  82485. }
  82486. if (binaryInfo.uvs5AttrDesc && binaryInfo.uvs5AttrDesc.count > 0) {
  82487. var uvs5Data = new Float32Array(parsedGeometry, binaryInfo.uvs5AttrDesc.offset, binaryInfo.uvs5AttrDesc.count);
  82488. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, uvs5Data, false);
  82489. }
  82490. if (binaryInfo.uvs6AttrDesc && binaryInfo.uvs6AttrDesc.count > 0) {
  82491. var uvs6Data = new Float32Array(parsedGeometry, binaryInfo.uvs6AttrDesc.offset, binaryInfo.uvs6AttrDesc.count);
  82492. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, uvs6Data, false);
  82493. }
  82494. if (binaryInfo.colorsAttrDesc && binaryInfo.colorsAttrDesc.count > 0) {
  82495. var colorsData = new Float32Array(parsedGeometry, binaryInfo.colorsAttrDesc.offset, binaryInfo.colorsAttrDesc.count);
  82496. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colorsData, false, binaryInfo.colorsAttrDesc.stride);
  82497. }
  82498. if (binaryInfo.matricesIndicesAttrDesc && binaryInfo.matricesIndicesAttrDesc.count > 0) {
  82499. var matricesIndicesData = new Int32Array(parsedGeometry, binaryInfo.matricesIndicesAttrDesc.offset, binaryInfo.matricesIndicesAttrDesc.count);
  82500. var floatIndices = [];
  82501. for (var i = 0; i < matricesIndicesData.length; i++) {
  82502. var index = matricesIndicesData[i];
  82503. floatIndices.push(index & 0x000000FF);
  82504. floatIndices.push((index & 0x0000FF00) >> 8);
  82505. floatIndices.push((index & 0x00FF0000) >> 16);
  82506. floatIndices.push(index >> 24);
  82507. }
  82508. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, false);
  82509. }
  82510. if (binaryInfo.matricesWeightsAttrDesc && binaryInfo.matricesWeightsAttrDesc.count > 0) {
  82511. var matricesWeightsData = new Float32Array(parsedGeometry, binaryInfo.matricesWeightsAttrDesc.offset, binaryInfo.matricesWeightsAttrDesc.count);
  82512. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, matricesWeightsData, false);
  82513. }
  82514. if (binaryInfo.indicesAttrDesc && binaryInfo.indicesAttrDesc.count > 0) {
  82515. var indicesData = new Int32Array(parsedGeometry, binaryInfo.indicesAttrDesc.offset, binaryInfo.indicesAttrDesc.count);
  82516. mesh.setIndices(indicesData, null);
  82517. }
  82518. if (binaryInfo.subMeshesAttrDesc && binaryInfo.subMeshesAttrDesc.count > 0) {
  82519. var subMeshesData = new Int32Array(parsedGeometry, binaryInfo.subMeshesAttrDesc.offset, binaryInfo.subMeshesAttrDesc.count * 5);
  82520. mesh.subMeshes = [];
  82521. for (var i = 0; i < binaryInfo.subMeshesAttrDesc.count; i++) {
  82522. var materialIndex = subMeshesData[(i * 5) + 0];
  82523. var verticesStart = subMeshesData[(i * 5) + 1];
  82524. var verticesCount = subMeshesData[(i * 5) + 2];
  82525. var indexStart = subMeshesData[(i * 5) + 3];
  82526. var indexCount = subMeshesData[(i * 5) + 4];
  82527. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh);
  82528. }
  82529. }
  82530. }
  82531. else if (parsedGeometry.positions && parsedGeometry.normals && parsedGeometry.indices) {
  82532. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, parsedGeometry.positions, parsedGeometry.positions._updatable);
  82533. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, parsedGeometry.normals, parsedGeometry.normals._updatable);
  82534. if (parsedGeometry.tangents) {
  82535. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, parsedGeometry.tangents, parsedGeometry.tangents._updatable);
  82536. }
  82537. if (parsedGeometry.uvs) {
  82538. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, parsedGeometry.uvs, parsedGeometry.uvs._updatable);
  82539. }
  82540. if (parsedGeometry.uvs2) {
  82541. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, parsedGeometry.uvs2, parsedGeometry.uvs2._updatable);
  82542. }
  82543. if (parsedGeometry.uvs3) {
  82544. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, parsedGeometry.uvs3, parsedGeometry.uvs3._updatable);
  82545. }
  82546. if (parsedGeometry.uvs4) {
  82547. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, parsedGeometry.uvs4, parsedGeometry.uvs4._updatable);
  82548. }
  82549. if (parsedGeometry.uvs5) {
  82550. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, parsedGeometry.uvs5, parsedGeometry.uvs5._updatable);
  82551. }
  82552. if (parsedGeometry.uvs6) {
  82553. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, parsedGeometry.uvs6, parsedGeometry.uvs6._updatable);
  82554. }
  82555. if (parsedGeometry.colors) {
  82556. 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);
  82557. }
  82558. if (parsedGeometry.matricesIndices) {
  82559. if (!parsedGeometry.matricesIndices._isExpanded) {
  82560. var floatIndices = [];
  82561. for (var i = 0; i < parsedGeometry.matricesIndices.length; i++) {
  82562. var matricesIndex = parsedGeometry.matricesIndices[i];
  82563. floatIndices.push(matricesIndex & 0x000000FF);
  82564. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  82565. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  82566. floatIndices.push(matricesIndex >> 24);
  82567. }
  82568. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, parsedGeometry.matricesIndices._updatable);
  82569. }
  82570. else {
  82571. delete parsedGeometry.matricesIndices._isExpanded;
  82572. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, parsedGeometry.matricesIndices, parsedGeometry.matricesIndices._updatable);
  82573. }
  82574. }
  82575. if (parsedGeometry.matricesIndicesExtra) {
  82576. if (!parsedGeometry.matricesIndicesExtra._isExpanded) {
  82577. var floatIndices = [];
  82578. for (var i = 0; i < parsedGeometry.matricesIndicesExtra.length; i++) {
  82579. var matricesIndex = parsedGeometry.matricesIndicesExtra[i];
  82580. floatIndices.push(matricesIndex & 0x000000FF);
  82581. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  82582. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  82583. floatIndices.push(matricesIndex >> 24);
  82584. }
  82585. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, floatIndices, parsedGeometry.matricesIndicesExtra._updatable);
  82586. }
  82587. else {
  82588. delete parsedGeometry.matricesIndices._isExpanded;
  82589. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, parsedGeometry.matricesIndicesExtra, parsedGeometry.matricesIndicesExtra._updatable);
  82590. }
  82591. }
  82592. if (parsedGeometry.matricesWeights) {
  82593. Geometry._CleanMatricesWeights(parsedGeometry, mesh);
  82594. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, parsedGeometry.matricesWeights, parsedGeometry.matricesWeights._updatable);
  82595. }
  82596. if (parsedGeometry.matricesWeightsExtra) {
  82597. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind, parsedGeometry.matricesWeightsExtra, parsedGeometry.matricesWeights._updatable);
  82598. }
  82599. mesh.setIndices(parsedGeometry.indices, null);
  82600. }
  82601. // SubMeshes
  82602. if (parsedGeometry.subMeshes) {
  82603. mesh.subMeshes = [];
  82604. for (var subIndex = 0; subIndex < parsedGeometry.subMeshes.length; subIndex++) {
  82605. var parsedSubMesh = parsedGeometry.subMeshes[subIndex];
  82606. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(parsedSubMesh.materialIndex, parsedSubMesh.verticesStart, parsedSubMesh.verticesCount, parsedSubMesh.indexStart, parsedSubMesh.indexCount, mesh);
  82607. }
  82608. }
  82609. // Flat shading
  82610. if (mesh._shouldGenerateFlatShading) {
  82611. mesh.convertToFlatShadedMesh();
  82612. delete mesh._shouldGenerateFlatShading;
  82613. }
  82614. // Update
  82615. mesh.computeWorldMatrix(true);
  82616. scene.onMeshImportedObservable.notifyObservers(mesh);
  82617. };
  82618. Geometry._CleanMatricesWeights = function (parsedGeometry, mesh) {
  82619. var epsilon = 1e-3;
  82620. if (!_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__["SceneLoaderFlags"].CleanBoneMatrixWeights) {
  82621. return;
  82622. }
  82623. var noInfluenceBoneIndex = 0.0;
  82624. if (parsedGeometry.skeletonId > -1) {
  82625. var skeleton = mesh.getScene().getLastSkeletonByID(parsedGeometry.skeletonId);
  82626. if (!skeleton) {
  82627. return;
  82628. }
  82629. noInfluenceBoneIndex = skeleton.bones.length;
  82630. }
  82631. else {
  82632. return;
  82633. }
  82634. var matricesIndices = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  82635. var matricesIndicesExtra = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  82636. var matricesWeights = parsedGeometry.matricesWeights;
  82637. var matricesWeightsExtra = parsedGeometry.matricesWeightsExtra;
  82638. var influencers = parsedGeometry.numBoneInfluencer;
  82639. var size = matricesWeights.length;
  82640. for (var i = 0; i < size; i += 4) {
  82641. var weight = 0.0;
  82642. var firstZeroWeight = -1;
  82643. for (var j = 0; j < 4; j++) {
  82644. var w = matricesWeights[i + j];
  82645. weight += w;
  82646. if (w < epsilon && firstZeroWeight < 0) {
  82647. firstZeroWeight = j;
  82648. }
  82649. }
  82650. if (matricesWeightsExtra) {
  82651. for (var j = 0; j < 4; j++) {
  82652. var w = matricesWeightsExtra[i + j];
  82653. weight += w;
  82654. if (w < epsilon && firstZeroWeight < 0) {
  82655. firstZeroWeight = j + 4;
  82656. }
  82657. }
  82658. }
  82659. if (firstZeroWeight < 0 || firstZeroWeight > (influencers - 1)) {
  82660. firstZeroWeight = influencers - 1;
  82661. }
  82662. if (weight > epsilon) {
  82663. var mweight = 1.0 / weight;
  82664. for (var j = 0; j < 4; j++) {
  82665. matricesWeights[i + j] *= mweight;
  82666. }
  82667. if (matricesWeightsExtra) {
  82668. for (var j = 0; j < 4; j++) {
  82669. matricesWeightsExtra[i + j] *= mweight;
  82670. }
  82671. }
  82672. }
  82673. else {
  82674. if (firstZeroWeight >= 4) {
  82675. matricesWeightsExtra[i + firstZeroWeight - 4] = 1.0 - weight;
  82676. matricesIndicesExtra[i + firstZeroWeight - 4] = noInfluenceBoneIndex;
  82677. }
  82678. else {
  82679. matricesWeights[i + firstZeroWeight] = 1.0 - weight;
  82680. matricesIndices[i + firstZeroWeight] = noInfluenceBoneIndex;
  82681. }
  82682. }
  82683. }
  82684. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, matricesIndices);
  82685. if (parsedGeometry.matricesWeightsExtra) {
  82686. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, matricesIndicesExtra);
  82687. }
  82688. };
  82689. /**
  82690. * Create a new geometry from persisted data (Using .babylon file format)
  82691. * @param parsedVertexData defines the persisted data
  82692. * @param scene defines the hosting scene
  82693. * @param rootUrl defines the root url to use to load assets (like delayed data)
  82694. * @returns the new geometry object
  82695. */
  82696. Geometry.Parse = function (parsedVertexData, scene, rootUrl) {
  82697. if (scene.getGeometryByID(parsedVertexData.id)) {
  82698. return null; // null since geometry could be something else than a box...
  82699. }
  82700. var geometry = new Geometry(parsedVertexData.id, scene, undefined, parsedVertexData.updatable);
  82701. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"]) {
  82702. _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].AddTagsTo(geometry, parsedVertexData.tags);
  82703. }
  82704. if (parsedVertexData.delayLoadingFile) {
  82705. geometry.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  82706. geometry.delayLoadingFile = rootUrl + parsedVertexData.delayLoadingFile;
  82707. 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));
  82708. geometry._delayInfo = [];
  82709. if (parsedVertexData.hasUVs) {
  82710. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  82711. }
  82712. if (parsedVertexData.hasUVs2) {
  82713. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  82714. }
  82715. if (parsedVertexData.hasUVs3) {
  82716. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind);
  82717. }
  82718. if (parsedVertexData.hasUVs4) {
  82719. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind);
  82720. }
  82721. if (parsedVertexData.hasUVs5) {
  82722. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind);
  82723. }
  82724. if (parsedVertexData.hasUVs6) {
  82725. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind);
  82726. }
  82727. if (parsedVertexData.hasColors) {
  82728. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  82729. }
  82730. if (parsedVertexData.hasMatricesIndices) {
  82731. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  82732. }
  82733. if (parsedVertexData.hasMatricesWeights) {
  82734. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  82735. }
  82736. geometry._delayLoadingFunction = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData;
  82737. }
  82738. else {
  82739. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData(parsedVertexData, geometry);
  82740. }
  82741. scene.pushGeometry(geometry, true);
  82742. return geometry;
  82743. };
  82744. return Geometry;
  82745. }());
  82746. /***/ }),
  82747. /***/ "./Meshes/groundMesh.ts":
  82748. /*!******************************!*\
  82749. !*** ./Meshes/groundMesh.ts ***!
  82750. \******************************/
  82751. /*! exports provided: GroundMesh */
  82752. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82753. "use strict";
  82754. __webpack_require__.r(__webpack_exports__);
  82755. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return GroundMesh; });
  82756. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  82757. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  82758. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  82759. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  82760. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._GroundMeshParser = function (parsedMesh, scene) {
  82761. return GroundMesh.Parse(parsedMesh, scene);
  82762. };
  82763. /**
  82764. * Mesh representing the gorund
  82765. */
  82766. var GroundMesh = /** @class */ (function (_super) {
  82767. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GroundMesh, _super);
  82768. function GroundMesh(name, scene) {
  82769. var _this = _super.call(this, name, scene) || this;
  82770. /** If octree should be generated */
  82771. _this.generateOctree = false;
  82772. return _this;
  82773. }
  82774. /**
  82775. * "GroundMesh"
  82776. * @returns "GroundMesh"
  82777. */
  82778. GroundMesh.prototype.getClassName = function () {
  82779. return "GroundMesh";
  82780. };
  82781. Object.defineProperty(GroundMesh.prototype, "subdivisions", {
  82782. /**
  82783. * The minimum of x and y subdivisions
  82784. */
  82785. get: function () {
  82786. return Math.min(this._subdivisionsX, this._subdivisionsY);
  82787. },
  82788. enumerable: true,
  82789. configurable: true
  82790. });
  82791. Object.defineProperty(GroundMesh.prototype, "subdivisionsX", {
  82792. /**
  82793. * X subdivisions
  82794. */
  82795. get: function () {
  82796. return this._subdivisionsX;
  82797. },
  82798. enumerable: true,
  82799. configurable: true
  82800. });
  82801. Object.defineProperty(GroundMesh.prototype, "subdivisionsY", {
  82802. /**
  82803. * Y subdivisions
  82804. */
  82805. get: function () {
  82806. return this._subdivisionsY;
  82807. },
  82808. enumerable: true,
  82809. configurable: true
  82810. });
  82811. /**
  82812. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  82813. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  82814. * @param chunksCount the number of subdivisions for x and y
  82815. * @param octreeBlocksSize (Default: 32)
  82816. */
  82817. GroundMesh.prototype.optimize = function (chunksCount, octreeBlocksSize) {
  82818. if (octreeBlocksSize === void 0) { octreeBlocksSize = 32; }
  82819. this._subdivisionsX = chunksCount;
  82820. this._subdivisionsY = chunksCount;
  82821. this.subdivide(chunksCount);
  82822. // Call the octree system optimization if it is defined.
  82823. var thisAsAny = this;
  82824. if (thisAsAny.createOrUpdateSubmeshesOctree) {
  82825. thisAsAny.createOrUpdateSubmeshesOctree(octreeBlocksSize);
  82826. }
  82827. };
  82828. /**
  82829. * Returns a height (y) value in the Worl system :
  82830. * the ground altitude at the coordinates (x, z) expressed in the World system.
  82831. * @param x x coordinate
  82832. * @param z z coordinate
  82833. * @returns the ground y position if (x, z) are outside the ground surface.
  82834. */
  82835. GroundMesh.prototype.getHeightAtCoordinates = function (x, z) {
  82836. var world = this.getWorldMatrix();
  82837. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  82838. world.invertToRef(invMat);
  82839. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  82840. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, invMat, tmpVect); // transform x,z in the mesh local space
  82841. x = tmpVect.x;
  82842. z = tmpVect.z;
  82843. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  82844. return this.position.y;
  82845. }
  82846. if (!this._heightQuads || this._heightQuads.length == 0) {
  82847. this._initHeightQuads();
  82848. this._computeHeightQuads();
  82849. }
  82850. var facet = this._getFacetAt(x, z);
  82851. var y = -(facet.x * x + facet.z * z + facet.w) / facet.y;
  82852. // return y in the World system
  82853. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0.0, y, 0.0, world, tmpVect);
  82854. return tmpVect.y;
  82855. };
  82856. /**
  82857. * Returns a normalized vector (Vector3) orthogonal to the ground
  82858. * at the ground coordinates (x, z) expressed in the World system.
  82859. * @param x x coordinate
  82860. * @param z z coordinate
  82861. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  82862. */
  82863. GroundMesh.prototype.getNormalAtCoordinates = function (x, z) {
  82864. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.0, 1.0, 0.0);
  82865. this.getNormalAtCoordinatesToRef(x, z, normal);
  82866. return normal;
  82867. };
  82868. /**
  82869. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  82870. * at the ground coordinates (x, z) expressed in the World system.
  82871. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  82872. * @param x x coordinate
  82873. * @param z z coordinate
  82874. * @param ref vector to store the result
  82875. * @returns the GroundMesh.
  82876. */
  82877. GroundMesh.prototype.getNormalAtCoordinatesToRef = function (x, z, ref) {
  82878. var world = this.getWorldMatrix();
  82879. var tmpMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  82880. world.invertToRef(tmpMat);
  82881. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  82882. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, tmpMat, tmpVect); // transform x,z in the mesh local space
  82883. x = tmpVect.x;
  82884. z = tmpVect.z;
  82885. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  82886. return this;
  82887. }
  82888. if (!this._heightQuads || this._heightQuads.length == 0) {
  82889. this._initHeightQuads();
  82890. this._computeHeightQuads();
  82891. }
  82892. var facet = this._getFacetAt(x, z);
  82893. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(facet.x, facet.y, facet.z, world, ref);
  82894. return this;
  82895. };
  82896. /**
  82897. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  82898. * if the ground has been updated.
  82899. * This can be used in the render loop.
  82900. * @returns the GroundMesh.
  82901. */
  82902. GroundMesh.prototype.updateCoordinateHeights = function () {
  82903. if (!this._heightQuads || this._heightQuads.length == 0) {
  82904. this._initHeightQuads();
  82905. }
  82906. this._computeHeightQuads();
  82907. return this;
  82908. };
  82909. // Returns the element "facet" from the heightQuads array relative to (x, z) local coordinates
  82910. GroundMesh.prototype._getFacetAt = function (x, z) {
  82911. // retrieve col and row from x, z coordinates in the ground local system
  82912. var col = Math.floor((x + this._maxX) * this._subdivisionsX / this._width);
  82913. var row = Math.floor(-(z + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY);
  82914. var quad = this._heightQuads[row * this._subdivisionsX + col];
  82915. var facet;
  82916. if (z < quad.slope.x * x + quad.slope.y) {
  82917. facet = quad.facet1;
  82918. }
  82919. else {
  82920. facet = quad.facet2;
  82921. }
  82922. return facet;
  82923. };
  82924. // Creates and populates the heightMap array with "facet" elements :
  82925. // a quad is two triangular facets separated by a slope, so a "facet" element is 1 slope + 2 facets
  82926. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  82927. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  82928. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  82929. // Returns the GroundMesh.
  82930. GroundMesh.prototype._initHeightQuads = function () {
  82931. var subdivisionsX = this._subdivisionsX;
  82932. var subdivisionsY = this._subdivisionsY;
  82933. this._heightQuads = new Array();
  82934. for (var row = 0; row < subdivisionsY; row++) {
  82935. for (var col = 0; col < subdivisionsX; col++) {
  82936. 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) };
  82937. this._heightQuads[row * subdivisionsX + col] = quad;
  82938. }
  82939. }
  82940. return this;
  82941. };
  82942. // Compute each quad element values and update the the heightMap array :
  82943. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  82944. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  82945. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  82946. // Returns the GroundMesh.
  82947. GroundMesh.prototype._computeHeightQuads = function () {
  82948. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  82949. if (!positions) {
  82950. return this;
  82951. }
  82952. var v1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  82953. var v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  82954. var v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  82955. var v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  82956. var v1v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  82957. var v1v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  82958. var v1v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  82959. var norm1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[7];
  82960. var norm2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  82961. var i = 0;
  82962. var j = 0;
  82963. var k = 0;
  82964. var cd = 0; // 2D slope coefficient : z = cd * x + h
  82965. var h = 0;
  82966. var d1 = 0; // facet plane equation : ax + by + cz + d = 0
  82967. var d2 = 0;
  82968. var subdivisionsX = this._subdivisionsX;
  82969. var subdivisionsY = this._subdivisionsY;
  82970. for (var row = 0; row < subdivisionsY; row++) {
  82971. for (var col = 0; col < subdivisionsX; col++) {
  82972. i = col * 3;
  82973. j = row * (subdivisionsX + 1) * 3;
  82974. k = (row + 1) * (subdivisionsX + 1) * 3;
  82975. v1.x = positions[j + i];
  82976. v1.y = positions[j + i + 1];
  82977. v1.z = positions[j + i + 2];
  82978. v2.x = positions[j + i + 3];
  82979. v2.y = positions[j + i + 4];
  82980. v2.z = positions[j + i + 5];
  82981. v3.x = positions[k + i];
  82982. v3.y = positions[k + i + 1];
  82983. v3.z = positions[k + i + 2];
  82984. v4.x = positions[k + i + 3];
  82985. v4.y = positions[k + i + 4];
  82986. v4.z = positions[k + i + 5];
  82987. // 2D slope V1V4
  82988. cd = (v4.z - v1.z) / (v4.x - v1.x);
  82989. h = v1.z - cd * v1.x; // v1 belongs to the slope
  82990. // facet equations :
  82991. // we compute each facet normal vector
  82992. // the equation of the facet plane is : norm.x * x + norm.y * y + norm.z * z + d = 0
  82993. // we compute the value d by applying the equation to v1 which belongs to the plane
  82994. // then we store the facet equation in a Vector4
  82995. v2.subtractToRef(v1, v1v2);
  82996. v3.subtractToRef(v1, v1v3);
  82997. v4.subtractToRef(v1, v1v4);
  82998. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v4, v1v3, norm1); // caution : CrossToRef uses the Tmp class
  82999. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v2, v1v4, norm2);
  83000. norm1.normalize();
  83001. norm2.normalize();
  83002. d1 = -(norm1.x * v1.x + norm1.y * v1.y + norm1.z * v1.z);
  83003. d2 = -(norm2.x * v2.x + norm2.y * v2.y + norm2.z * v2.z);
  83004. var quad = this._heightQuads[row * subdivisionsX + col];
  83005. quad.slope.copyFromFloats(cd, h);
  83006. quad.facet1.copyFromFloats(norm1.x, norm1.y, norm1.z, d1);
  83007. quad.facet2.copyFromFloats(norm2.x, norm2.y, norm2.z, d2);
  83008. }
  83009. }
  83010. return this;
  83011. };
  83012. /**
  83013. * Serializes this ground mesh
  83014. * @param serializationObject object to write serialization to
  83015. */
  83016. GroundMesh.prototype.serialize = function (serializationObject) {
  83017. _super.prototype.serialize.call(this, serializationObject);
  83018. serializationObject.subdivisionsX = this._subdivisionsX;
  83019. serializationObject.subdivisionsY = this._subdivisionsY;
  83020. serializationObject.minX = this._minX;
  83021. serializationObject.maxX = this._maxX;
  83022. serializationObject.minZ = this._minZ;
  83023. serializationObject.maxZ = this._maxZ;
  83024. serializationObject.width = this._width;
  83025. serializationObject.height = this._height;
  83026. };
  83027. /**
  83028. * Parses a serialized ground mesh
  83029. * @param parsedMesh the serialized mesh
  83030. * @param scene the scene to create the ground mesh in
  83031. * @returns the created ground mesh
  83032. */
  83033. GroundMesh.Parse = function (parsedMesh, scene) {
  83034. var result = new GroundMesh(parsedMesh.name, scene);
  83035. result._subdivisionsX = parsedMesh.subdivisionsX || 1;
  83036. result._subdivisionsY = parsedMesh.subdivisionsY || 1;
  83037. result._minX = parsedMesh.minX;
  83038. result._maxX = parsedMesh.maxX;
  83039. result._minZ = parsedMesh.minZ;
  83040. result._maxZ = parsedMesh.maxZ;
  83041. result._width = parsedMesh.width;
  83042. result._height = parsedMesh.height;
  83043. return result;
  83044. };
  83045. return GroundMesh;
  83046. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  83047. /***/ }),
  83048. /***/ "./Meshes/index.ts":
  83049. /*!*************************!*\
  83050. !*** ./Meshes/index.ts ***!
  83051. \*************************/
  83052. /*! 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 */
  83053. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83054. "use strict";
  83055. __webpack_require__.r(__webpack_exports__);
  83056. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  83057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  83058. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  83059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["Buffer"]; });
  83060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"]; });
  83061. /* harmony import */ var _Compression_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Compression/index */ "./Meshes/Compression/index.ts");
  83062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Compression_index__WEBPACK_IMPORTED_MODULE_2__["DracoCompression"]; });
  83063. /* harmony import */ var _csg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./csg */ "./Meshes/csg.ts");
  83064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _csg__WEBPACK_IMPORTED_MODULE_3__["CSG"]; });
  83065. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  83066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"]; });
  83067. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./groundMesh */ "./Meshes/groundMesh.ts");
  83068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _groundMesh__WEBPACK_IMPORTED_MODULE_5__["GroundMesh"]; });
  83069. /* harmony import */ var _instancedMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./instancedMesh */ "./Meshes/instancedMesh.ts");
  83070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _instancedMesh__WEBPACK_IMPORTED_MODULE_6__["InstancedMesh"]; });
  83071. /* harmony import */ var _linesMesh__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./linesMesh */ "./Meshes/linesMesh.ts");
  83072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_7__["LinesMesh"]; });
  83073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_7__["InstancedLinesMesh"]; });
  83074. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  83075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["MeshLODLevel"]; });
  83076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["_CreationDataStorage"]; });
  83077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["_InstancesBatch"]; });
  83078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["Mesh"]; });
  83079. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  83080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__["VertexData"]; });
  83081. /* harmony import */ var _meshBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./meshBuilder */ "./Meshes/meshBuilder.ts");
  83082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _meshBuilder__WEBPACK_IMPORTED_MODULE_10__["MeshBuilder"]; });
  83083. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  83084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_11__["SimplificationSettings"]; });
  83085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_11__["SimplificationQueue"]; });
  83086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_11__["SimplificationType"]; });
  83087. /* harmony import */ var _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./meshSimplificationSceneComponent */ "./Meshes/meshSimplificationSceneComponent.ts");
  83088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_12__["SimplicationQueueSceneComponent"]; });
  83089. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./polygonMesh */ "./Meshes/polygonMesh.ts");
  83090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_13__["Polygon"]; });
  83091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_13__["PolygonMeshBuilder"]; });
  83092. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  83093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_14__["BaseSubMesh"]; });
  83094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_14__["SubMesh"]; });
  83095. /* harmony import */ var _transformNode__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./transformNode */ "./Meshes/transformNode.ts");
  83096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _transformNode__WEBPACK_IMPORTED_MODULE_15__["TransformNode"]; });
  83097. /* harmony import */ var _Builders_index__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Builders/index */ "./Meshes/Builders/index.ts");
  83098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["BoxBuilder"]; });
  83099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["SphereBuilder"]; });
  83100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["CylinderBuilder"]; });
  83101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["LinesBuilder"]; });
  83102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["PlaneBuilder"]; });
  83103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["DiscBuilder"]; });
  83104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["RibbonBuilder"]; });
  83105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["TorusBuilder"]; });
  83106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["TorusKnotBuilder"]; });
  83107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["PolygonBuilder"]; });
  83108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["ShapeBuilder"]; });
  83109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["LatheBuilder"]; });
  83110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["GroundBuilder"]; });
  83111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["TubeBuilder"]; });
  83112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["PolyhedronBuilder"]; });
  83113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["IcoSphereBuilder"]; });
  83114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"]; });
  83115. /***/ }),
  83116. /***/ "./Meshes/instancedMesh.ts":
  83117. /*!*********************************!*\
  83118. !*** ./Meshes/instancedMesh.ts ***!
  83119. \*********************************/
  83120. /*! exports provided: InstancedMesh */
  83121. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83122. "use strict";
  83123. __webpack_require__.r(__webpack_exports__);
  83124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return InstancedMesh; });
  83125. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  83126. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  83127. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  83128. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  83129. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  83130. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._instancedMeshFactory = function (name, mesh) {
  83131. return new InstancedMesh(name, mesh);
  83132. };
  83133. /**
  83134. * Creates an instance based on a source mesh.
  83135. */
  83136. var InstancedMesh = /** @class */ (function (_super) {
  83137. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedMesh, _super);
  83138. function InstancedMesh(name, source) {
  83139. var _this = _super.call(this, name, source.getScene()) || this;
  83140. /** @hidden */
  83141. _this._indexInSourceMeshInstanceArray = -1;
  83142. source.addInstance(_this);
  83143. _this._sourceMesh = source;
  83144. _this.position.copyFrom(source.position);
  83145. _this.rotation.copyFrom(source.rotation);
  83146. _this.scaling.copyFrom(source.scaling);
  83147. if (source.rotationQuaternion) {
  83148. _this.rotationQuaternion = source.rotationQuaternion.clone();
  83149. }
  83150. _this.infiniteDistance = source.infiniteDistance;
  83151. _this.setPivotMatrix(source.getPivotMatrix());
  83152. _this.refreshBoundingInfo();
  83153. _this._syncSubMeshes();
  83154. return _this;
  83155. }
  83156. /**
  83157. * Returns the string "InstancedMesh".
  83158. */
  83159. InstancedMesh.prototype.getClassName = function () {
  83160. return "InstancedMesh";
  83161. };
  83162. Object.defineProperty(InstancedMesh.prototype, "receiveShadows", {
  83163. // Methods
  83164. /**
  83165. * If the source mesh receives shadows
  83166. */
  83167. get: function () {
  83168. return this._sourceMesh.receiveShadows;
  83169. },
  83170. enumerable: true,
  83171. configurable: true
  83172. });
  83173. Object.defineProperty(InstancedMesh.prototype, "material", {
  83174. /**
  83175. * The material of the source mesh
  83176. */
  83177. get: function () {
  83178. return this._sourceMesh.material;
  83179. },
  83180. enumerable: true,
  83181. configurable: true
  83182. });
  83183. Object.defineProperty(InstancedMesh.prototype, "visibility", {
  83184. /**
  83185. * Visibility of the source mesh
  83186. */
  83187. get: function () {
  83188. return this._sourceMesh.visibility;
  83189. },
  83190. enumerable: true,
  83191. configurable: true
  83192. });
  83193. Object.defineProperty(InstancedMesh.prototype, "skeleton", {
  83194. /**
  83195. * Skeleton of the source mesh
  83196. */
  83197. get: function () {
  83198. return this._sourceMesh.skeleton;
  83199. },
  83200. enumerable: true,
  83201. configurable: true
  83202. });
  83203. Object.defineProperty(InstancedMesh.prototype, "renderingGroupId", {
  83204. /**
  83205. * Rendering ground id of the source mesh
  83206. */
  83207. get: function () {
  83208. return this._sourceMesh.renderingGroupId;
  83209. },
  83210. set: function (value) {
  83211. if (!this._sourceMesh || value === this._sourceMesh.renderingGroupId) {
  83212. return;
  83213. }
  83214. //no-op with warning
  83215. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene");
  83216. },
  83217. enumerable: true,
  83218. configurable: true
  83219. });
  83220. /**
  83221. * Returns the total number of vertices (integer).
  83222. */
  83223. InstancedMesh.prototype.getTotalVertices = function () {
  83224. return this._sourceMesh.getTotalVertices();
  83225. };
  83226. /**
  83227. * Returns a positive integer : the total number of indices in this mesh geometry.
  83228. * @returns the numner of indices or zero if the mesh has no geometry.
  83229. */
  83230. InstancedMesh.prototype.getTotalIndices = function () {
  83231. return this._sourceMesh.getTotalIndices();
  83232. };
  83233. Object.defineProperty(InstancedMesh.prototype, "sourceMesh", {
  83234. /**
  83235. * The source mesh of the instance
  83236. */
  83237. get: function () {
  83238. return this._sourceMesh;
  83239. },
  83240. enumerable: true,
  83241. configurable: true
  83242. });
  83243. /**
  83244. * Is this node ready to be used/rendered
  83245. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  83246. * @return {boolean} is it ready
  83247. */
  83248. InstancedMesh.prototype.isReady = function (completeCheck) {
  83249. if (completeCheck === void 0) { completeCheck = false; }
  83250. return this._sourceMesh.isReady(completeCheck, true);
  83251. };
  83252. /**
  83253. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  83254. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  83255. * @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.
  83256. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  83257. */
  83258. InstancedMesh.prototype.getVerticesData = function (kind, copyWhenShared) {
  83259. return this._sourceMesh.getVerticesData(kind, copyWhenShared);
  83260. };
  83261. /**
  83262. * Sets the vertex data of the mesh geometry for the requested `kind`.
  83263. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  83264. * The `data` are either a numeric array either a Float32Array.
  83265. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  83266. * 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).
  83267. * Note that a new underlying VertexBuffer object is created each call.
  83268. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  83269. *
  83270. * Possible `kind` values :
  83271. * - VertexBuffer.PositionKind
  83272. * - VertexBuffer.UVKind
  83273. * - VertexBuffer.UV2Kind
  83274. * - VertexBuffer.UV3Kind
  83275. * - VertexBuffer.UV4Kind
  83276. * - VertexBuffer.UV5Kind
  83277. * - VertexBuffer.UV6Kind
  83278. * - VertexBuffer.ColorKind
  83279. * - VertexBuffer.MatricesIndicesKind
  83280. * - VertexBuffer.MatricesIndicesExtraKind
  83281. * - VertexBuffer.MatricesWeightsKind
  83282. * - VertexBuffer.MatricesWeightsExtraKind
  83283. *
  83284. * Returns the Mesh.
  83285. */
  83286. InstancedMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  83287. if (this.sourceMesh) {
  83288. this.sourceMesh.setVerticesData(kind, data, updatable, stride);
  83289. }
  83290. return this.sourceMesh;
  83291. };
  83292. /**
  83293. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  83294. * If the mesh has no geometry, it is simply returned as it is.
  83295. * The `data` are either a numeric array either a Float32Array.
  83296. * No new underlying VertexBuffer object is created.
  83297. * 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.
  83298. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  83299. *
  83300. * Possible `kind` values :
  83301. * - VertexBuffer.PositionKind
  83302. * - VertexBuffer.UVKind
  83303. * - VertexBuffer.UV2Kind
  83304. * - VertexBuffer.UV3Kind
  83305. * - VertexBuffer.UV4Kind
  83306. * - VertexBuffer.UV5Kind
  83307. * - VertexBuffer.UV6Kind
  83308. * - VertexBuffer.ColorKind
  83309. * - VertexBuffer.MatricesIndicesKind
  83310. * - VertexBuffer.MatricesIndicesExtraKind
  83311. * - VertexBuffer.MatricesWeightsKind
  83312. * - VertexBuffer.MatricesWeightsExtraKind
  83313. *
  83314. * Returns the Mesh.
  83315. */
  83316. InstancedMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  83317. if (this.sourceMesh) {
  83318. this.sourceMesh.updateVerticesData(kind, data, updateExtends, makeItUnique);
  83319. }
  83320. return this.sourceMesh;
  83321. };
  83322. /**
  83323. * Sets the mesh indices.
  83324. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  83325. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83326. * This method creates a new index buffer each call.
  83327. * Returns the Mesh.
  83328. */
  83329. InstancedMesh.prototype.setIndices = function (indices, totalVertices) {
  83330. if (totalVertices === void 0) { totalVertices = null; }
  83331. if (this.sourceMesh) {
  83332. this.sourceMesh.setIndices(indices, totalVertices);
  83333. }
  83334. return this.sourceMesh;
  83335. };
  83336. /**
  83337. * Boolean : True if the mesh owns the requested kind of data.
  83338. */
  83339. InstancedMesh.prototype.isVerticesDataPresent = function (kind) {
  83340. return this._sourceMesh.isVerticesDataPresent(kind);
  83341. };
  83342. /**
  83343. * Returns an array of indices (IndicesArray).
  83344. */
  83345. InstancedMesh.prototype.getIndices = function () {
  83346. return this._sourceMesh.getIndices();
  83347. };
  83348. Object.defineProperty(InstancedMesh.prototype, "_positions", {
  83349. get: function () {
  83350. return this._sourceMesh._positions;
  83351. },
  83352. enumerable: true,
  83353. configurable: true
  83354. });
  83355. /**
  83356. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83357. * This means the mesh underlying bounding box and sphere are recomputed.
  83358. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83359. * @returns the current mesh
  83360. */
  83361. InstancedMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  83362. if (applySkeleton === void 0) { applySkeleton = false; }
  83363. if (this._boundingInfo && this._boundingInfo.isLocked) {
  83364. return this;
  83365. }
  83366. var bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;
  83367. this._refreshBoundingInfo(this._sourceMesh._getPositionData(applySkeleton), bias);
  83368. return this;
  83369. };
  83370. /** @hidden */
  83371. InstancedMesh.prototype._preActivate = function () {
  83372. if (this._currentLOD) {
  83373. this._currentLOD._preActivate();
  83374. }
  83375. return this;
  83376. };
  83377. /** @hidden */
  83378. InstancedMesh.prototype._activate = function (renderId) {
  83379. if (this._currentLOD) {
  83380. this._currentLOD._registerInstanceForRenderId(this, renderId);
  83381. }
  83382. return this;
  83383. };
  83384. /**
  83385. * Returns the current associated LOD AbstractMesh.
  83386. */
  83387. InstancedMesh.prototype.getLOD = function (camera) {
  83388. if (!camera) {
  83389. return this;
  83390. }
  83391. var boundingInfo = this.getBoundingInfo();
  83392. this._currentLOD = this.sourceMesh.getLOD(camera, boundingInfo.boundingSphere);
  83393. if (this._currentLOD === this.sourceMesh) {
  83394. return this;
  83395. }
  83396. return this._currentLOD;
  83397. };
  83398. /** @hidden */
  83399. InstancedMesh.prototype._syncSubMeshes = function () {
  83400. this.releaseSubMeshes();
  83401. if (this._sourceMesh.subMeshes) {
  83402. for (var index = 0; index < this._sourceMesh.subMeshes.length; index++) {
  83403. this._sourceMesh.subMeshes[index].clone(this, this._sourceMesh);
  83404. }
  83405. }
  83406. return this;
  83407. };
  83408. /** @hidden */
  83409. InstancedMesh.prototype._generatePointsArray = function () {
  83410. return this._sourceMesh._generatePointsArray();
  83411. };
  83412. /**
  83413. * Creates a new InstancedMesh from the current mesh.
  83414. * - name (string) : the cloned mesh name
  83415. * - newParent (optional Node) : the optional Node to parent the clone to.
  83416. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  83417. *
  83418. * Returns the clone.
  83419. */
  83420. InstancedMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  83421. var result = this._sourceMesh.createInstance(name);
  83422. // Deep copy
  83423. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__["DeepCopier"].DeepCopy(this, result, ["name", "subMeshes", "uniqueId"], []);
  83424. // Bounding info
  83425. this.refreshBoundingInfo();
  83426. // Parent
  83427. if (newParent) {
  83428. result.parent = newParent;
  83429. }
  83430. if (!doNotCloneChildren) {
  83431. // Children
  83432. for (var index = 0; index < this.getScene().meshes.length; index++) {
  83433. var mesh = this.getScene().meshes[index];
  83434. if (mesh.parent === this) {
  83435. mesh.clone(mesh.name, result);
  83436. }
  83437. }
  83438. }
  83439. result.computeWorldMatrix(true);
  83440. return result;
  83441. };
  83442. /**
  83443. * Disposes the InstancedMesh.
  83444. * Returns nothing.
  83445. */
  83446. InstancedMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  83447. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  83448. // Remove from mesh
  83449. this._sourceMesh.removeInstance(this);
  83450. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  83451. };
  83452. return InstancedMesh;
  83453. }(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]));
  83454. /***/ }),
  83455. /***/ "./Meshes/linesMesh.ts":
  83456. /*!*****************************!*\
  83457. !*** ./Meshes/linesMesh.ts ***!
  83458. \*****************************/
  83459. /*! exports provided: LinesMesh, InstancedLinesMesh */
  83460. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83461. "use strict";
  83462. __webpack_require__.r(__webpack_exports__);
  83463. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return LinesMesh; });
  83464. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return InstancedLinesMesh; });
  83465. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  83466. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  83467. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  83468. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  83469. /* harmony import */ var _Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/instancedMesh */ "./Meshes/instancedMesh.ts");
  83470. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  83471. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  83472. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  83473. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  83474. /**
  83475. * Line mesh
  83476. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  83477. */
  83478. var LinesMesh = /** @class */ (function (_super) {
  83479. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LinesMesh, _super);
  83480. /**
  83481. * Creates a new LinesMesh
  83482. * @param name defines the name
  83483. * @param scene defines the hosting scene
  83484. * @param parent defines the parent mesh if any
  83485. * @param source defines the optional source LinesMesh used to clone data from
  83486. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  83487. * When false, achieved by calling a clone(), also passing False.
  83488. * This will make creation of children, recursive.
  83489. * @param useVertexColor defines if this LinesMesh supports vertex color
  83490. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  83491. */
  83492. function LinesMesh(name, scene, parent, source, doNotCloneChildren,
  83493. /**
  83494. * If vertex color should be applied to the mesh
  83495. */
  83496. useVertexColor,
  83497. /**
  83498. * If vertex alpha should be applied to the mesh
  83499. */
  83500. useVertexAlpha) {
  83501. if (scene === void 0) { scene = null; }
  83502. if (parent === void 0) { parent = null; }
  83503. var _this = _super.call(this, name, scene, parent, source, doNotCloneChildren) || this;
  83504. _this.useVertexColor = useVertexColor;
  83505. _this.useVertexAlpha = useVertexAlpha;
  83506. /**
  83507. * Color of the line (Default: White)
  83508. */
  83509. _this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
  83510. /**
  83511. * Alpha of the line (Default: 1)
  83512. */
  83513. _this.alpha = 1;
  83514. if (source) {
  83515. _this.color = source.color.clone();
  83516. _this.alpha = source.alpha;
  83517. _this.useVertexColor = source.useVertexColor;
  83518. _this.useVertexAlpha = source.useVertexAlpha;
  83519. }
  83520. _this.intersectionThreshold = 0.1;
  83521. var defines = [];
  83522. var options = {
  83523. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, "world0", "world1", "world2", "world3"],
  83524. uniforms: ["world", "viewProjection"],
  83525. needAlphaBlending: true,
  83526. defines: defines
  83527. };
  83528. if (useVertexAlpha === false) {
  83529. options.needAlphaBlending = false;
  83530. }
  83531. if (!useVertexColor) {
  83532. options.uniforms.push("color");
  83533. }
  83534. else {
  83535. options.defines.push("#define VERTEXCOLOR");
  83536. options.attributes.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  83537. }
  83538. _this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("colorShader", _this.getScene(), "color", options);
  83539. return _this;
  83540. }
  83541. /**
  83542. * Returns the string "LineMesh"
  83543. */
  83544. LinesMesh.prototype.getClassName = function () {
  83545. return "LinesMesh";
  83546. };
  83547. Object.defineProperty(LinesMesh.prototype, "material", {
  83548. /**
  83549. * @hidden
  83550. */
  83551. get: function () {
  83552. return this._colorShader;
  83553. },
  83554. /**
  83555. * @hidden
  83556. */
  83557. set: function (value) {
  83558. // Do nothing
  83559. },
  83560. enumerable: true,
  83561. configurable: true
  83562. });
  83563. Object.defineProperty(LinesMesh.prototype, "checkCollisions", {
  83564. /**
  83565. * @hidden
  83566. */
  83567. get: function () {
  83568. return false;
  83569. },
  83570. enumerable: true,
  83571. configurable: true
  83572. });
  83573. /** @hidden */
  83574. LinesMesh.prototype._bind = function (subMesh, effect, fillMode) {
  83575. if (!this._geometry) {
  83576. return this;
  83577. }
  83578. // VBOs
  83579. this._geometry._bind(this._colorShader.getEffect());
  83580. // Color
  83581. if (!this.useVertexColor) {
  83582. this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
  83583. }
  83584. return this;
  83585. };
  83586. /** @hidden */
  83587. LinesMesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  83588. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  83589. return this;
  83590. }
  83591. var engine = this.getScene().getEngine();
  83592. // Draw order
  83593. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].LineListDrawMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  83594. return this;
  83595. };
  83596. /**
  83597. * Disposes of the line mesh
  83598. * @param doNotRecurse If children should be disposed
  83599. */
  83600. LinesMesh.prototype.dispose = function (doNotRecurse) {
  83601. this._colorShader.dispose(false, false, true);
  83602. _super.prototype.dispose.call(this, doNotRecurse);
  83603. };
  83604. /**
  83605. * Returns a new LineMesh object cloned from the current one.
  83606. */
  83607. LinesMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  83608. return new LinesMesh(name, this.getScene(), newParent, this, doNotCloneChildren);
  83609. };
  83610. /**
  83611. * Creates a new InstancedLinesMesh object from the mesh model.
  83612. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83613. * @param name defines the name of the new instance
  83614. * @returns a new InstancedLinesMesh
  83615. */
  83616. LinesMesh.prototype.createInstance = function (name) {
  83617. return new InstancedLinesMesh(name, this);
  83618. };
  83619. return LinesMesh;
  83620. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  83621. /**
  83622. * Creates an instance based on a source LinesMesh
  83623. */
  83624. var InstancedLinesMesh = /** @class */ (function (_super) {
  83625. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedLinesMesh, _super);
  83626. function InstancedLinesMesh(name, source) {
  83627. var _this = _super.call(this, name, source) || this;
  83628. _this.intersectionThreshold = source.intersectionThreshold;
  83629. return _this;
  83630. }
  83631. /**
  83632. * Returns the string "InstancedLinesMesh".
  83633. */
  83634. InstancedLinesMesh.prototype.getClassName = function () {
  83635. return "InstancedLinesMesh";
  83636. };
  83637. return InstancedLinesMesh;
  83638. }(_Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__["InstancedMesh"]));
  83639. /***/ }),
  83640. /***/ "./Meshes/mesh.ts":
  83641. /*!************************!*\
  83642. !*** ./Meshes/mesh.ts ***!
  83643. \************************/
  83644. /*! exports provided: MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh */
  83645. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83646. "use strict";
  83647. __webpack_require__.r(__webpack_exports__);
  83648. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return MeshLODLevel; });
  83649. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _CreationDataStorage; });
  83650. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _InstancesBatch; });
  83651. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return Mesh; });
  83652. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  83653. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  83654. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  83655. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  83656. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  83657. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  83658. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  83659. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  83660. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  83661. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  83662. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  83663. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  83664. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  83665. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  83666. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  83667. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  83668. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  83669. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  83670. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  83671. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  83672. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  83673. /**
  83674. * Class used to represent a specific level of detail of a mesh
  83675. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  83676. */
  83677. var MeshLODLevel = /** @class */ (function () {
  83678. /**
  83679. * Creates a new LOD level
  83680. * @param distance defines the distance where this level should star being displayed
  83681. * @param mesh defines the mesh to use to render this level
  83682. */
  83683. function MeshLODLevel(
  83684. /** Defines the distance where this level should star being displayed */
  83685. distance,
  83686. /** Defines the mesh to use to render this level */
  83687. mesh) {
  83688. this.distance = distance;
  83689. this.mesh = mesh;
  83690. }
  83691. return MeshLODLevel;
  83692. }());
  83693. /**
  83694. * @hidden
  83695. **/
  83696. var _CreationDataStorage = /** @class */ (function () {
  83697. function _CreationDataStorage() {
  83698. }
  83699. return _CreationDataStorage;
  83700. }());
  83701. /**
  83702. * @hidden
  83703. **/
  83704. var _InstanceDataStorage = /** @class */ (function () {
  83705. function _InstanceDataStorage() {
  83706. this.visibleInstances = {};
  83707. this.renderIdForInstances = new Array();
  83708. this.batchCache = new _InstancesBatch();
  83709. this.instancesBufferSize = 32 * 16 * 4; // let's start with a maximum of 32 instances
  83710. }
  83711. return _InstanceDataStorage;
  83712. }());
  83713. /**
  83714. * @hidden
  83715. **/
  83716. var _InstancesBatch = /** @class */ (function () {
  83717. function _InstancesBatch() {
  83718. this.mustReturn = false;
  83719. this.visibleInstances = new Array();
  83720. this.renderSelf = new Array();
  83721. }
  83722. return _InstancesBatch;
  83723. }());
  83724. /**
  83725. * Class used to represent renderable models
  83726. */
  83727. var Mesh = /** @class */ (function (_super) {
  83728. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Mesh, _super);
  83729. /**
  83730. * @constructor
  83731. * @param name The value used by scene.getMeshByName() to do a lookup.
  83732. * @param scene The scene to add this mesh to.
  83733. * @param parent The parent of this mesh, if it has one
  83734. * @param source An optional Mesh from which geometry is shared, cloned.
  83735. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  83736. * When false, achieved by calling a clone(), also passing False.
  83737. * This will make creation of children, recursive.
  83738. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  83739. */
  83740. function Mesh(name, scene, parent, source, doNotCloneChildren, clonePhysicsImpostor) {
  83741. if (scene === void 0) { scene = null; }
  83742. if (parent === void 0) { parent = null; }
  83743. if (source === void 0) { source = null; }
  83744. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  83745. var _this = _super.call(this, name, scene) || this;
  83746. // Members
  83747. /**
  83748. * Gets the delay loading state of the mesh (when delay loading is turned on)
  83749. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  83750. */
  83751. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NONE;
  83752. /**
  83753. * Gets the list of instances created from this mesh
  83754. * it is not supposed to be modified manually.
  83755. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  83756. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83757. */
  83758. _this.instances = new Array();
  83759. _this._LODLevels = new Array();
  83760. /** @hidden */
  83761. _this._instanceDataStorage = new _InstanceDataStorage();
  83762. // Use by builder only to know what orientation were the mesh build in.
  83763. /** @hidden */
  83764. _this._originalBuilderSideOrientation = Mesh.DEFAULTSIDE;
  83765. /**
  83766. * Use this property to change the original side orientation defined at construction time
  83767. */
  83768. _this.overrideMaterialSideOrientation = null;
  83769. _this._areNormalsFrozen = false; // Will be used by ribbons mainly
  83770. // Will be used to save a source mesh reference, If any
  83771. _this._source = null;
  83772. /** @hidden */
  83773. _this._isMesh = true;
  83774. scene = _this.getScene();
  83775. if (source) {
  83776. // Geometry
  83777. if (source._geometry) {
  83778. source._geometry.applyToMesh(_this);
  83779. }
  83780. // Deep copy
  83781. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(source, _this, ["name", "material", "skeleton", "instances", "parent", "uniqueId",
  83782. "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen",
  83783. "onBeforeDrawObservable", "onBeforeRenderObservable", "onAfterRenderObservable", "onBeforeDraw",
  83784. "onAfterWorldMatrixUpdateObservable", "onCollideObservable", "onCollisionPositionChangeObservable", "onRebuildObservable",
  83785. "onDisposeObservable"
  83786. ], ["_poseMatrix"]);
  83787. // Source mesh
  83788. _this._source = source;
  83789. if (scene.useClonedMeshhMap) {
  83790. if (!source.meshMap) {
  83791. source.meshMap = {};
  83792. }
  83793. source.meshMap[_this.uniqueId] = _this;
  83794. }
  83795. // Construction Params
  83796. // Clone parameters allowing mesh to be updated in case of parametric shapes.
  83797. _this._originalBuilderSideOrientation = source._originalBuilderSideOrientation;
  83798. _this._creationDataStorage = source._creationDataStorage;
  83799. // Animation ranges
  83800. if (_this._source._ranges) {
  83801. var ranges = _this._source._ranges;
  83802. for (var name in ranges) {
  83803. if (!ranges.hasOwnProperty(name)) {
  83804. continue;
  83805. }
  83806. if (!ranges[name]) {
  83807. continue;
  83808. }
  83809. _this.createAnimationRange(name, ranges[name].from, ranges[name].to);
  83810. }
  83811. }
  83812. // Metadata
  83813. if (source.metadata && source.metadata.clone) {
  83814. _this.metadata = source.metadata.clone();
  83815. }
  83816. else {
  83817. _this.metadata = source.metadata;
  83818. }
  83819. // Tags
  83820. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(source)) {
  83821. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(_this, _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(source, true));
  83822. }
  83823. // Parent
  83824. _this.parent = source.parent;
  83825. // Pivot
  83826. _this.setPivotMatrix(source.getPivotMatrix());
  83827. _this.id = name + "." + source.id;
  83828. // Material
  83829. _this.material = source.material;
  83830. var index;
  83831. if (!doNotCloneChildren) {
  83832. // Children
  83833. var directDescendants = source.getDescendants(true);
  83834. for (var index_1 = 0; index_1 < directDescendants.length; index_1++) {
  83835. var child = directDescendants[index_1];
  83836. if (child.clone) {
  83837. child.clone(name + "." + child.name, _this);
  83838. }
  83839. }
  83840. }
  83841. // Physics clone
  83842. var physicsEngine = _this.getScene().getPhysicsEngine();
  83843. if (clonePhysicsImpostor && physicsEngine) {
  83844. var impostor = physicsEngine.getImpostorForPhysicsObject(source);
  83845. if (impostor) {
  83846. _this.physicsImpostor = impostor.clone(_this);
  83847. }
  83848. }
  83849. // Particles
  83850. for (index = 0; index < scene.particleSystems.length; index++) {
  83851. var system = scene.particleSystems[index];
  83852. if (system.emitter === source) {
  83853. system.clone(system.name, _this);
  83854. }
  83855. }
  83856. _this.refreshBoundingInfo();
  83857. _this.computeWorldMatrix(true);
  83858. }
  83859. // Parent
  83860. if (parent !== null) {
  83861. _this.parent = parent;
  83862. }
  83863. return _this;
  83864. }
  83865. /**
  83866. * Gets the default side orientation.
  83867. * @param orientation the orientation to value to attempt to get
  83868. * @returns the default orientation
  83869. * @hidden
  83870. */
  83871. Mesh._GetDefaultSideOrientation = function (orientation) {
  83872. if (orientation == Mesh.DOUBLESIDE) {
  83873. return Mesh.DOUBLESIDE;
  83874. }
  83875. if (orientation === undefined || orientation === null) {
  83876. return Mesh.FRONTSIDE;
  83877. }
  83878. return orientation;
  83879. };
  83880. Object.defineProperty(Mesh.prototype, "onBeforeRenderObservable", {
  83881. /**
  83882. * An event triggered before rendering the mesh
  83883. */
  83884. get: function () {
  83885. if (!this._onBeforeRenderObservable) {
  83886. this._onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  83887. }
  83888. return this._onBeforeRenderObservable;
  83889. },
  83890. enumerable: true,
  83891. configurable: true
  83892. });
  83893. Object.defineProperty(Mesh.prototype, "onBeforeBindObservable", {
  83894. /**
  83895. * An event triggered before binding the mesh
  83896. */
  83897. get: function () {
  83898. if (!this._onBeforeBindObservable) {
  83899. this._onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  83900. }
  83901. return this._onBeforeBindObservable;
  83902. },
  83903. enumerable: true,
  83904. configurable: true
  83905. });
  83906. Object.defineProperty(Mesh.prototype, "onAfterRenderObservable", {
  83907. /**
  83908. * An event triggered after rendering the mesh
  83909. */
  83910. get: function () {
  83911. if (!this._onAfterRenderObservable) {
  83912. this._onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  83913. }
  83914. return this._onAfterRenderObservable;
  83915. },
  83916. enumerable: true,
  83917. configurable: true
  83918. });
  83919. Object.defineProperty(Mesh.prototype, "onBeforeDrawObservable", {
  83920. /**
  83921. * An event triggered before drawing the mesh
  83922. */
  83923. get: function () {
  83924. if (!this._onBeforeDrawObservable) {
  83925. this._onBeforeDrawObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  83926. }
  83927. return this._onBeforeDrawObservable;
  83928. },
  83929. enumerable: true,
  83930. configurable: true
  83931. });
  83932. Object.defineProperty(Mesh.prototype, "onBeforeDraw", {
  83933. /**
  83934. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  83935. */
  83936. set: function (callback) {
  83937. if (this._onBeforeDrawObserver) {
  83938. this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver);
  83939. }
  83940. this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(callback);
  83941. },
  83942. enumerable: true,
  83943. configurable: true
  83944. });
  83945. Object.defineProperty(Mesh.prototype, "morphTargetManager", {
  83946. /**
  83947. * Gets or sets the morph target manager
  83948. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  83949. */
  83950. get: function () {
  83951. return this._morphTargetManager;
  83952. },
  83953. set: function (value) {
  83954. if (this._morphTargetManager === value) {
  83955. return;
  83956. }
  83957. this._morphTargetManager = value;
  83958. this._syncGeometryWithMorphTargetManager();
  83959. },
  83960. enumerable: true,
  83961. configurable: true
  83962. });
  83963. Object.defineProperty(Mesh.prototype, "source", {
  83964. /**
  83965. * Gets the source mesh (the one used to clone this one from)
  83966. */
  83967. get: function () {
  83968. return this._source;
  83969. },
  83970. enumerable: true,
  83971. configurable: true
  83972. });
  83973. Object.defineProperty(Mesh.prototype, "isUnIndexed", {
  83974. /**
  83975. * Gets or sets a boolean indicating that this mesh does not use index buffer
  83976. */
  83977. get: function () {
  83978. return this._unIndexed;
  83979. },
  83980. set: function (value) {
  83981. if (this._unIndexed !== value) {
  83982. this._unIndexed = value;
  83983. this._markSubMeshesAsAttributesDirty();
  83984. }
  83985. },
  83986. enumerable: true,
  83987. configurable: true
  83988. });
  83989. // Methods
  83990. /**
  83991. * Gets the class name
  83992. * @returns the string "Mesh".
  83993. */
  83994. Mesh.prototype.getClassName = function () {
  83995. return "Mesh";
  83996. };
  83997. /**
  83998. * Returns a description of this mesh
  83999. * @param fullDetails define if full details about this mesh must be used
  84000. * @returns a descriptive string representing this mesh
  84001. */
  84002. Mesh.prototype.toString = function (fullDetails) {
  84003. var ret = _super.prototype.toString.call(this, fullDetails);
  84004. ret += ", n vertices: " + this.getTotalVertices();
  84005. ret += ", parent: " + (this._waitingParentId ? this._waitingParentId : (this.parent ? this.parent.name : "NONE"));
  84006. if (this.animations) {
  84007. for (var i = 0; i < this.animations.length; i++) {
  84008. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  84009. }
  84010. }
  84011. if (fullDetails) {
  84012. if (this._geometry) {
  84013. var ib = this.getIndices();
  84014. var vb = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  84015. if (vb && ib) {
  84016. ret += ", flat shading: " + (vb.length / 3 === ib.length ? "YES" : "NO");
  84017. }
  84018. }
  84019. else {
  84020. ret += ", flat shading: UNKNOWN";
  84021. }
  84022. }
  84023. return ret;
  84024. };
  84025. /** @hidden */
  84026. Mesh.prototype._unBindEffect = function () {
  84027. _super.prototype._unBindEffect.call(this);
  84028. for (var _i = 0, _a = this.instances; _i < _a.length; _i++) {
  84029. var instance = _a[_i];
  84030. instance._unBindEffect();
  84031. }
  84032. };
  84033. Object.defineProperty(Mesh.prototype, "hasLODLevels", {
  84034. /**
  84035. * Gets a boolean indicating if this mesh has LOD
  84036. */
  84037. get: function () {
  84038. return this._LODLevels.length > 0;
  84039. },
  84040. enumerable: true,
  84041. configurable: true
  84042. });
  84043. /**
  84044. * Gets the list of MeshLODLevel associated with the current mesh
  84045. * @returns an array of MeshLODLevel
  84046. */
  84047. Mesh.prototype.getLODLevels = function () {
  84048. return this._LODLevels;
  84049. };
  84050. Mesh.prototype._sortLODLevels = function () {
  84051. this._LODLevels.sort(function (a, b) {
  84052. if (a.distance < b.distance) {
  84053. return 1;
  84054. }
  84055. if (a.distance > b.distance) {
  84056. return -1;
  84057. }
  84058. return 0;
  84059. });
  84060. };
  84061. /**
  84062. * Add a mesh as LOD level triggered at the given distance.
  84063. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  84064. * @param distance The distance from the center of the object to show this level
  84065. * @param mesh The mesh to be added as LOD level (can be null)
  84066. * @return This mesh (for chaining)
  84067. */
  84068. Mesh.prototype.addLODLevel = function (distance, mesh) {
  84069. if (mesh && mesh._masterMesh) {
  84070. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("You cannot use a mesh as LOD level twice");
  84071. return this;
  84072. }
  84073. var level = new MeshLODLevel(distance, mesh);
  84074. this._LODLevels.push(level);
  84075. if (mesh) {
  84076. mesh._masterMesh = this;
  84077. }
  84078. this._sortLODLevels();
  84079. return this;
  84080. };
  84081. /**
  84082. * Returns the LOD level mesh at the passed distance or null if not found.
  84083. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  84084. * @param distance The distance from the center of the object to show this level
  84085. * @returns a Mesh or `null`
  84086. */
  84087. Mesh.prototype.getLODLevelAtDistance = function (distance) {
  84088. for (var index = 0; index < this._LODLevels.length; index++) {
  84089. var level = this._LODLevels[index];
  84090. if (level.distance === distance) {
  84091. return level.mesh;
  84092. }
  84093. }
  84094. return null;
  84095. };
  84096. /**
  84097. * Remove a mesh from the LOD array
  84098. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  84099. * @param mesh defines the mesh to be removed
  84100. * @return This mesh (for chaining)
  84101. */
  84102. Mesh.prototype.removeLODLevel = function (mesh) {
  84103. for (var index = 0; index < this._LODLevels.length; index++) {
  84104. if (this._LODLevels[index].mesh === mesh) {
  84105. this._LODLevels.splice(index, 1);
  84106. if (mesh) {
  84107. mesh._masterMesh = null;
  84108. }
  84109. }
  84110. }
  84111. this._sortLODLevels();
  84112. return this;
  84113. };
  84114. /**
  84115. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  84116. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  84117. * @param camera defines the camera to use to compute distance
  84118. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  84119. * @return This mesh (for chaining)
  84120. */
  84121. Mesh.prototype.getLOD = function (camera, boundingSphere) {
  84122. if (!this._LODLevels || this._LODLevels.length === 0) {
  84123. return this;
  84124. }
  84125. var bSphere;
  84126. if (boundingSphere) {
  84127. bSphere = boundingSphere;
  84128. }
  84129. else {
  84130. var boundingInfo = this.getBoundingInfo();
  84131. bSphere = boundingInfo.boundingSphere;
  84132. }
  84133. var distanceToCamera = bSphere.centerWorld.subtract(camera.globalPosition).length();
  84134. if (this._LODLevels[this._LODLevels.length - 1].distance > distanceToCamera) {
  84135. if (this.onLODLevelSelection) {
  84136. this.onLODLevelSelection(distanceToCamera, this, this._LODLevels[this._LODLevels.length - 1].mesh);
  84137. }
  84138. return this;
  84139. }
  84140. for (var index = 0; index < this._LODLevels.length; index++) {
  84141. var level = this._LODLevels[index];
  84142. if (level.distance < distanceToCamera) {
  84143. if (level.mesh) {
  84144. level.mesh._preActivate();
  84145. level.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);
  84146. }
  84147. if (this.onLODLevelSelection) {
  84148. this.onLODLevelSelection(distanceToCamera, this, level.mesh);
  84149. }
  84150. return level.mesh;
  84151. }
  84152. }
  84153. if (this.onLODLevelSelection) {
  84154. this.onLODLevelSelection(distanceToCamera, this, this);
  84155. }
  84156. return this;
  84157. };
  84158. Object.defineProperty(Mesh.prototype, "geometry", {
  84159. /**
  84160. * Gets the mesh internal Geometry object
  84161. */
  84162. get: function () {
  84163. return this._geometry;
  84164. },
  84165. enumerable: true,
  84166. configurable: true
  84167. });
  84168. /**
  84169. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  84170. * @returns the total number of vertices
  84171. */
  84172. Mesh.prototype.getTotalVertices = function () {
  84173. if (this._geometry === null || this._geometry === undefined) {
  84174. return 0;
  84175. }
  84176. return this._geometry.getTotalVertices();
  84177. };
  84178. /**
  84179. * Returns the content of an associated vertex buffer
  84180. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  84181. * - VertexBuffer.PositionKind
  84182. * - VertexBuffer.UVKind
  84183. * - VertexBuffer.UV2Kind
  84184. * - VertexBuffer.UV3Kind
  84185. * - VertexBuffer.UV4Kind
  84186. * - VertexBuffer.UV5Kind
  84187. * - VertexBuffer.UV6Kind
  84188. * - VertexBuffer.ColorKind
  84189. * - VertexBuffer.MatricesIndicesKind
  84190. * - VertexBuffer.MatricesIndicesExtraKind
  84191. * - VertexBuffer.MatricesWeightsKind
  84192. * - VertexBuffer.MatricesWeightsExtraKind
  84193. * @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
  84194. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  84195. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  84196. */
  84197. Mesh.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  84198. if (!this._geometry) {
  84199. return null;
  84200. }
  84201. return this._geometry.getVerticesData(kind, copyWhenShared, forceCopy);
  84202. };
  84203. /**
  84204. * Returns the mesh VertexBuffer object from the requested `kind`
  84205. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  84206. * - VertexBuffer.PositionKind
  84207. * - VertexBuffer.UVKind
  84208. * - VertexBuffer.UV2Kind
  84209. * - VertexBuffer.UV3Kind
  84210. * - VertexBuffer.UV4Kind
  84211. * - VertexBuffer.UV5Kind
  84212. * - VertexBuffer.UV6Kind
  84213. * - VertexBuffer.ColorKind
  84214. * - VertexBuffer.MatricesIndicesKind
  84215. * - VertexBuffer.MatricesIndicesExtraKind
  84216. * - VertexBuffer.MatricesWeightsKind
  84217. * - VertexBuffer.MatricesWeightsExtraKind
  84218. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  84219. */
  84220. Mesh.prototype.getVertexBuffer = function (kind) {
  84221. if (!this._geometry) {
  84222. return null;
  84223. }
  84224. return this._geometry.getVertexBuffer(kind);
  84225. };
  84226. /**
  84227. * Tests if a specific vertex buffer is associated with this mesh
  84228. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  84229. * - VertexBuffer.PositionKind
  84230. * - VertexBuffer.UVKind
  84231. * - VertexBuffer.UV2Kind
  84232. * - VertexBuffer.UV3Kind
  84233. * - VertexBuffer.UV4Kind
  84234. * - VertexBuffer.UV5Kind
  84235. * - VertexBuffer.UV6Kind
  84236. * - VertexBuffer.ColorKind
  84237. * - VertexBuffer.MatricesIndicesKind
  84238. * - VertexBuffer.MatricesIndicesExtraKind
  84239. * - VertexBuffer.MatricesWeightsKind
  84240. * - VertexBuffer.MatricesWeightsExtraKind
  84241. * @returns a boolean
  84242. */
  84243. Mesh.prototype.isVerticesDataPresent = function (kind) {
  84244. if (!this._geometry) {
  84245. if (this._delayInfo) {
  84246. return this._delayInfo.indexOf(kind) !== -1;
  84247. }
  84248. return false;
  84249. }
  84250. return this._geometry.isVerticesDataPresent(kind);
  84251. };
  84252. /**
  84253. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  84254. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  84255. * - VertexBuffer.PositionKind
  84256. * - VertexBuffer.UVKind
  84257. * - VertexBuffer.UV2Kind
  84258. * - VertexBuffer.UV3Kind
  84259. * - VertexBuffer.UV4Kind
  84260. * - VertexBuffer.UV5Kind
  84261. * - VertexBuffer.UV6Kind
  84262. * - VertexBuffer.ColorKind
  84263. * - VertexBuffer.MatricesIndicesKind
  84264. * - VertexBuffer.MatricesIndicesExtraKind
  84265. * - VertexBuffer.MatricesWeightsKind
  84266. * - VertexBuffer.MatricesWeightsExtraKind
  84267. * @returns a boolean
  84268. */
  84269. Mesh.prototype.isVertexBufferUpdatable = function (kind) {
  84270. if (!this._geometry) {
  84271. if (this._delayInfo) {
  84272. return this._delayInfo.indexOf(kind) !== -1;
  84273. }
  84274. return false;
  84275. }
  84276. return this._geometry.isVertexBufferUpdatable(kind);
  84277. };
  84278. /**
  84279. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  84280. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  84281. * - VertexBuffer.PositionKind
  84282. * - VertexBuffer.UVKind
  84283. * - VertexBuffer.UV2Kind
  84284. * - VertexBuffer.UV3Kind
  84285. * - VertexBuffer.UV4Kind
  84286. * - VertexBuffer.UV5Kind
  84287. * - VertexBuffer.UV6Kind
  84288. * - VertexBuffer.ColorKind
  84289. * - VertexBuffer.MatricesIndicesKind
  84290. * - VertexBuffer.MatricesIndicesExtraKind
  84291. * - VertexBuffer.MatricesWeightsKind
  84292. * - VertexBuffer.MatricesWeightsExtraKind
  84293. * @returns an array of strings
  84294. */
  84295. Mesh.prototype.getVerticesDataKinds = function () {
  84296. if (!this._geometry) {
  84297. var result = new Array();
  84298. if (this._delayInfo) {
  84299. this._delayInfo.forEach(function (kind) {
  84300. result.push(kind);
  84301. });
  84302. }
  84303. return result;
  84304. }
  84305. return this._geometry.getVerticesDataKinds();
  84306. };
  84307. /**
  84308. * Returns a positive integer : the total number of indices in this mesh geometry.
  84309. * @returns the numner of indices or zero if the mesh has no geometry.
  84310. */
  84311. Mesh.prototype.getTotalIndices = function () {
  84312. if (!this._geometry) {
  84313. return 0;
  84314. }
  84315. return this._geometry.getTotalIndices();
  84316. };
  84317. /**
  84318. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84319. * @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.
  84320. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84321. * @returns the indices array or an empty array if the mesh has no geometry
  84322. */
  84323. Mesh.prototype.getIndices = function (copyWhenShared, forceCopy) {
  84324. if (!this._geometry) {
  84325. return [];
  84326. }
  84327. return this._geometry.getIndices(copyWhenShared, forceCopy);
  84328. };
  84329. Object.defineProperty(Mesh.prototype, "isBlocked", {
  84330. get: function () {
  84331. return this._masterMesh !== null && this._masterMesh !== undefined;
  84332. },
  84333. enumerable: true,
  84334. configurable: true
  84335. });
  84336. /**
  84337. * Determine if the current mesh is ready to be rendered
  84338. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84339. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  84340. * @returns true if all associated assets are ready (material, textures, shaders)
  84341. */
  84342. Mesh.prototype.isReady = function (completeCheck, forceInstanceSupport) {
  84343. if (completeCheck === void 0) { completeCheck = false; }
  84344. if (forceInstanceSupport === void 0) { forceInstanceSupport = false; }
  84345. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  84346. return false;
  84347. }
  84348. if (!_super.prototype.isReady.call(this, completeCheck)) {
  84349. return false;
  84350. }
  84351. if (!this.subMeshes || this.subMeshes.length === 0) {
  84352. return true;
  84353. }
  84354. if (!completeCheck) {
  84355. return true;
  84356. }
  84357. var engine = this.getEngine();
  84358. var scene = this.getScene();
  84359. var hardwareInstancedRendering = forceInstanceSupport || engine.getCaps().instancedArrays && this.instances.length > 0;
  84360. this.computeWorldMatrix();
  84361. var mat = this.material || scene.defaultMaterial;
  84362. if (mat) {
  84363. if (mat._storeEffectOnSubMeshes) {
  84364. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  84365. var subMesh = _a[_i];
  84366. var effectiveMaterial = subMesh.getMaterial();
  84367. if (effectiveMaterial) {
  84368. if (effectiveMaterial._storeEffectOnSubMeshes) {
  84369. if (!effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  84370. return false;
  84371. }
  84372. }
  84373. else {
  84374. if (!effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  84375. return false;
  84376. }
  84377. }
  84378. }
  84379. }
  84380. }
  84381. else {
  84382. if (!mat.isReady(this, hardwareInstancedRendering)) {
  84383. return false;
  84384. }
  84385. }
  84386. }
  84387. // Shadows
  84388. for (var _b = 0, _c = this._lightSources; _b < _c.length; _b++) {
  84389. var light = _c[_b];
  84390. var generator = light.getShadowGenerator();
  84391. if (generator) {
  84392. for (var _d = 0, _e = this.subMeshes; _d < _e.length; _d++) {
  84393. var subMesh = _e[_d];
  84394. if (!generator.isReady(subMesh, hardwareInstancedRendering)) {
  84395. return false;
  84396. }
  84397. }
  84398. }
  84399. }
  84400. // LOD
  84401. for (var _f = 0, _g = this._LODLevels; _f < _g.length; _f++) {
  84402. var lod = _g[_f];
  84403. if (lod.mesh && !lod.mesh.isReady(hardwareInstancedRendering)) {
  84404. return false;
  84405. }
  84406. }
  84407. return true;
  84408. };
  84409. Object.defineProperty(Mesh.prototype, "areNormalsFrozen", {
  84410. /**
  84411. * 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.
  84412. */
  84413. get: function () {
  84414. return this._areNormalsFrozen;
  84415. },
  84416. enumerable: true,
  84417. configurable: true
  84418. });
  84419. /**
  84420. * 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.
  84421. * @returns the current mesh
  84422. */
  84423. Mesh.prototype.freezeNormals = function () {
  84424. this._areNormalsFrozen = true;
  84425. return this;
  84426. };
  84427. /**
  84428. * 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
  84429. * @returns the current mesh
  84430. */
  84431. Mesh.prototype.unfreezeNormals = function () {
  84432. this._areNormalsFrozen = false;
  84433. return this;
  84434. };
  84435. Object.defineProperty(Mesh.prototype, "overridenInstanceCount", {
  84436. /**
  84437. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  84438. */
  84439. set: function (count) {
  84440. this._instanceDataStorage.overridenInstanceCount = count;
  84441. },
  84442. enumerable: true,
  84443. configurable: true
  84444. });
  84445. // Methods
  84446. /** @hidden */
  84447. Mesh.prototype._preActivate = function () {
  84448. var sceneRenderId = this.getScene().getRenderId();
  84449. if (this._preActivateId === sceneRenderId) {
  84450. return this;
  84451. }
  84452. this._preActivateId = sceneRenderId;
  84453. this._instanceDataStorage.visibleInstances = null;
  84454. return this;
  84455. };
  84456. /** @hidden */
  84457. Mesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  84458. if (this._instanceDataStorage.visibleInstances) {
  84459. this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = renderId;
  84460. }
  84461. return this;
  84462. };
  84463. /** @hidden */
  84464. Mesh.prototype._registerInstanceForRenderId = function (instance, renderId) {
  84465. if (!this._instanceDataStorage.visibleInstances) {
  84466. this._instanceDataStorage.visibleInstances = {
  84467. defaultRenderId: renderId,
  84468. selfDefaultRenderId: this._renderId
  84469. };
  84470. }
  84471. if (!this._instanceDataStorage.visibleInstances[renderId]) {
  84472. this._instanceDataStorage.visibleInstances[renderId] = new Array();
  84473. }
  84474. this._instanceDataStorage.visibleInstances[renderId].push(instance);
  84475. return this;
  84476. };
  84477. /**
  84478. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84479. * This means the mesh underlying bounding box and sphere are recomputed.
  84480. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84481. * @returns the current mesh
  84482. */
  84483. Mesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  84484. if (applySkeleton === void 0) { applySkeleton = false; }
  84485. if (this._boundingInfo && this._boundingInfo.isLocked) {
  84486. return this;
  84487. }
  84488. var bias = this.geometry ? this.geometry.boundingBias : null;
  84489. this._refreshBoundingInfo(this._getPositionData(applySkeleton), bias);
  84490. return this;
  84491. };
  84492. /** @hidden */
  84493. Mesh.prototype._createGlobalSubMesh = function (force) {
  84494. var totalVertices = this.getTotalVertices();
  84495. if (!totalVertices || !this.getIndices()) {
  84496. return null;
  84497. }
  84498. // Check if we need to recreate the submeshes
  84499. if (this.subMeshes && this.subMeshes.length > 0) {
  84500. var ib = this.getIndices();
  84501. if (!ib) {
  84502. return null;
  84503. }
  84504. var totalIndices = ib.length;
  84505. var needToRecreate = false;
  84506. if (force) {
  84507. needToRecreate = true;
  84508. }
  84509. else {
  84510. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  84511. var submesh = _a[_i];
  84512. if (submesh.indexStart + submesh.indexCount >= totalIndices) {
  84513. needToRecreate = true;
  84514. break;
  84515. }
  84516. if (submesh.verticesStart + submesh.verticesCount >= totalVertices) {
  84517. needToRecreate = true;
  84518. break;
  84519. }
  84520. }
  84521. }
  84522. if (!needToRecreate) {
  84523. return this.subMeshes[0];
  84524. }
  84525. }
  84526. this.releaseSubMeshes();
  84527. return new _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"](0, 0, totalVertices, 0, this.getTotalIndices(), this);
  84528. };
  84529. /**
  84530. * This function will subdivide the mesh into multiple submeshes
  84531. * @param count defines the expected number of submeshes
  84532. */
  84533. Mesh.prototype.subdivide = function (count) {
  84534. if (count < 1) {
  84535. return;
  84536. }
  84537. var totalIndices = this.getTotalIndices();
  84538. var subdivisionSize = (totalIndices / count) | 0;
  84539. var offset = 0;
  84540. // Ensure that subdivisionSize is a multiple of 3
  84541. while (subdivisionSize % 3 !== 0) {
  84542. subdivisionSize++;
  84543. }
  84544. this.releaseSubMeshes();
  84545. for (var index = 0; index < count; index++) {
  84546. if (offset >= totalIndices) {
  84547. break;
  84548. }
  84549. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, Math.min(subdivisionSize, totalIndices - offset), this);
  84550. offset += subdivisionSize;
  84551. }
  84552. this.synchronizeInstances();
  84553. };
  84554. /**
  84555. * Copy a FloatArray into a specific associated vertex buffer
  84556. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  84557. * - VertexBuffer.PositionKind
  84558. * - VertexBuffer.UVKind
  84559. * - VertexBuffer.UV2Kind
  84560. * - VertexBuffer.UV3Kind
  84561. * - VertexBuffer.UV4Kind
  84562. * - VertexBuffer.UV5Kind
  84563. * - VertexBuffer.UV6Kind
  84564. * - VertexBuffer.ColorKind
  84565. * - VertexBuffer.MatricesIndicesKind
  84566. * - VertexBuffer.MatricesIndicesExtraKind
  84567. * - VertexBuffer.MatricesWeightsKind
  84568. * - VertexBuffer.MatricesWeightsExtraKind
  84569. * @param data defines the data source
  84570. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  84571. * @param stride defines the data stride size (can be null)
  84572. * @returns the current mesh
  84573. */
  84574. Mesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  84575. if (updatable === void 0) { updatable = false; }
  84576. if (!this._geometry) {
  84577. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  84578. vertexData.set(data, kind);
  84579. var scene = this.getScene();
  84580. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  84581. }
  84582. else {
  84583. this._geometry.setVerticesData(kind, data, updatable, stride);
  84584. }
  84585. return this;
  84586. };
  84587. /**
  84588. * Flags an associated vertex buffer as updatable
  84589. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  84590. * - VertexBuffer.PositionKind
  84591. * - VertexBuffer.UVKind
  84592. * - VertexBuffer.UV2Kind
  84593. * - VertexBuffer.UV3Kind
  84594. * - VertexBuffer.UV4Kind
  84595. * - VertexBuffer.UV5Kind
  84596. * - VertexBuffer.UV6Kind
  84597. * - VertexBuffer.ColorKind
  84598. * - VertexBuffer.MatricesIndicesKind
  84599. * - VertexBuffer.MatricesIndicesExtraKind
  84600. * - VertexBuffer.MatricesWeightsKind
  84601. * - VertexBuffer.MatricesWeightsExtraKind
  84602. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  84603. */
  84604. Mesh.prototype.markVerticesDataAsUpdatable = function (kind, updatable) {
  84605. if (updatable === void 0) { updatable = true; }
  84606. var vb = this.getVertexBuffer(kind);
  84607. if (!vb || vb.isUpdatable() === updatable) {
  84608. return;
  84609. }
  84610. this.setVerticesData(kind, this.getVerticesData(kind), updatable);
  84611. };
  84612. /**
  84613. * Sets the mesh global Vertex Buffer
  84614. * @param buffer defines the buffer to use
  84615. * @returns the current mesh
  84616. */
  84617. Mesh.prototype.setVerticesBuffer = function (buffer) {
  84618. if (!this._geometry) {
  84619. this._geometry = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].CreateGeometryForMesh(this);
  84620. }
  84621. this._geometry.setVerticesBuffer(buffer);
  84622. return this;
  84623. };
  84624. /**
  84625. * Update a specific associated vertex buffer
  84626. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  84627. * - VertexBuffer.PositionKind
  84628. * - VertexBuffer.UVKind
  84629. * - VertexBuffer.UV2Kind
  84630. * - VertexBuffer.UV3Kind
  84631. * - VertexBuffer.UV4Kind
  84632. * - VertexBuffer.UV5Kind
  84633. * - VertexBuffer.UV6Kind
  84634. * - VertexBuffer.ColorKind
  84635. * - VertexBuffer.MatricesIndicesKind
  84636. * - VertexBuffer.MatricesIndicesExtraKind
  84637. * - VertexBuffer.MatricesWeightsKind
  84638. * - VertexBuffer.MatricesWeightsExtraKind
  84639. * @param data defines the data source
  84640. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  84641. * @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)
  84642. * @returns the current mesh
  84643. */
  84644. Mesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  84645. if (!this._geometry) {
  84646. return this;
  84647. }
  84648. if (!makeItUnique) {
  84649. this._geometry.updateVerticesData(kind, data, updateExtends);
  84650. }
  84651. else {
  84652. this.makeGeometryUnique();
  84653. this.updateVerticesData(kind, data, updateExtends, false);
  84654. }
  84655. return this;
  84656. };
  84657. /**
  84658. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  84659. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  84660. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  84661. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  84662. * @returns the current mesh
  84663. */
  84664. Mesh.prototype.updateMeshPositions = function (positionFunction, computeNormals) {
  84665. if (computeNormals === void 0) { computeNormals = true; }
  84666. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  84667. if (!positions) {
  84668. return this;
  84669. }
  84670. positionFunction(positions);
  84671. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions, false, false);
  84672. if (computeNormals) {
  84673. var indices = this.getIndices();
  84674. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  84675. if (!normals) {
  84676. return this;
  84677. }
  84678. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, indices, normals);
  84679. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, false, false);
  84680. }
  84681. return this;
  84682. };
  84683. /**
  84684. * Creates a un-shared specific occurence of the geometry for the mesh.
  84685. * @returns the current mesh
  84686. */
  84687. Mesh.prototype.makeGeometryUnique = function () {
  84688. if (!this._geometry) {
  84689. return this;
  84690. }
  84691. var oldGeometry = this._geometry;
  84692. var geometry = this._geometry.copy(_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId());
  84693. oldGeometry.releaseForMesh(this, true);
  84694. geometry.applyToMesh(this);
  84695. return this;
  84696. };
  84697. /**
  84698. * Set the index buffer of this mesh
  84699. * @param indices defines the source data
  84700. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  84701. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  84702. * @returns the current mesh
  84703. */
  84704. Mesh.prototype.setIndices = function (indices, totalVertices, updatable) {
  84705. if (totalVertices === void 0) { totalVertices = null; }
  84706. if (updatable === void 0) { updatable = false; }
  84707. if (!this._geometry) {
  84708. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  84709. vertexData.indices = indices;
  84710. var scene = this.getScene();
  84711. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  84712. }
  84713. else {
  84714. this._geometry.setIndices(indices, totalVertices, updatable);
  84715. }
  84716. return this;
  84717. };
  84718. /**
  84719. * Update the current index buffer
  84720. * @param indices defines the source data
  84721. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  84722. * @returns the current mesh
  84723. */
  84724. Mesh.prototype.updateIndices = function (indices, offset) {
  84725. if (!this._geometry) {
  84726. return this;
  84727. }
  84728. this._geometry.updateIndices(indices, offset);
  84729. return this;
  84730. };
  84731. /**
  84732. * Invert the geometry to move from a right handed system to a left handed one.
  84733. * @returns the current mesh
  84734. */
  84735. Mesh.prototype.toLeftHanded = function () {
  84736. if (!this._geometry) {
  84737. return this;
  84738. }
  84739. this._geometry.toLeftHanded();
  84740. return this;
  84741. };
  84742. /** @hidden */
  84743. Mesh.prototype._bind = function (subMesh, effect, fillMode) {
  84744. if (!this._geometry) {
  84745. return this;
  84746. }
  84747. var engine = this.getScene().getEngine();
  84748. // Wireframe
  84749. var indexToBind;
  84750. if (this._unIndexed) {
  84751. indexToBind = null;
  84752. }
  84753. else {
  84754. switch (fillMode) {
  84755. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode:
  84756. indexToBind = null;
  84757. break;
  84758. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode:
  84759. indexToBind = subMesh._getLinesIndexBuffer(this.getIndices(), engine);
  84760. break;
  84761. default:
  84762. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].TriangleFillMode:
  84763. indexToBind = this._unIndexed ? null : this._geometry.getIndexBuffer();
  84764. break;
  84765. }
  84766. }
  84767. // VBOs
  84768. this._geometry._bind(effect, indexToBind);
  84769. return this;
  84770. };
  84771. /** @hidden */
  84772. Mesh.prototype._draw = function (subMesh, fillMode, instancesCount, alternate) {
  84773. if (alternate === void 0) { alternate = false; }
  84774. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  84775. return this;
  84776. }
  84777. if (this._onBeforeDrawObservable) {
  84778. this._onBeforeDrawObservable.notifyObservers(this);
  84779. }
  84780. var scene = this.getScene();
  84781. var engine = scene.getEngine();
  84782. if (this._unIndexed || fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode) {
  84783. // or triangles as points
  84784. engine.drawArraysType(fillMode, subMesh.verticesStart, subMesh.verticesCount, instancesCount);
  84785. }
  84786. else if (fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode) {
  84787. // Triangles as wireframe
  84788. engine.drawElementsType(fillMode, 0, subMesh._linesIndexCount, instancesCount);
  84789. }
  84790. else {
  84791. engine.drawElementsType(fillMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  84792. }
  84793. if (scene._isAlternateRenderingEnabled && !alternate) {
  84794. var effect = subMesh.effect || this._effectiveMaterial.getEffect();
  84795. if (!effect || !scene.activeCamera) {
  84796. return this;
  84797. }
  84798. scene._switchToAlternateCameraConfiguration(true);
  84799. this._effectiveMaterial.bindView(effect);
  84800. this._effectiveMaterial.bindViewProjection(effect);
  84801. engine.setViewport(scene.activeCamera._alternateCamera.viewport);
  84802. this._draw(subMesh, fillMode, instancesCount, true);
  84803. engine.setViewport(scene.activeCamera.viewport);
  84804. scene._switchToAlternateCameraConfiguration(false);
  84805. this._effectiveMaterial.bindView(effect);
  84806. this._effectiveMaterial.bindViewProjection(effect);
  84807. }
  84808. return this;
  84809. };
  84810. /**
  84811. * Registers for this mesh a javascript function called just before the rendering process
  84812. * @param func defines the function to call before rendering this mesh
  84813. * @returns the current mesh
  84814. */
  84815. Mesh.prototype.registerBeforeRender = function (func) {
  84816. this.onBeforeRenderObservable.add(func);
  84817. return this;
  84818. };
  84819. /**
  84820. * Disposes a previously registered javascript function called before the rendering
  84821. * @param func defines the function to remove
  84822. * @returns the current mesh
  84823. */
  84824. Mesh.prototype.unregisterBeforeRender = function (func) {
  84825. this.onBeforeRenderObservable.removeCallback(func);
  84826. return this;
  84827. };
  84828. /**
  84829. * Registers for this mesh a javascript function called just after the rendering is complete
  84830. * @param func defines the function to call after rendering this mesh
  84831. * @returns the current mesh
  84832. */
  84833. Mesh.prototype.registerAfterRender = function (func) {
  84834. this.onAfterRenderObservable.add(func);
  84835. return this;
  84836. };
  84837. /**
  84838. * Disposes a previously registered javascript function called after the rendering.
  84839. * @param func defines the function to remove
  84840. * @returns the current mesh
  84841. */
  84842. Mesh.prototype.unregisterAfterRender = function (func) {
  84843. this.onAfterRenderObservable.removeCallback(func);
  84844. return this;
  84845. };
  84846. /** @hidden */
  84847. Mesh.prototype._getInstancesRenderList = function (subMeshId) {
  84848. var scene = this.getScene();
  84849. var batchCache = this._instanceDataStorage.batchCache;
  84850. batchCache.mustReturn = false;
  84851. batchCache.renderSelf[subMeshId] = this.isEnabled() && this.isVisible;
  84852. batchCache.visibleInstances[subMeshId] = null;
  84853. if (this._instanceDataStorage.visibleInstances) {
  84854. var visibleInstances = this._instanceDataStorage.visibleInstances;
  84855. var currentRenderId = scene.getRenderId();
  84856. var defaultRenderId = (scene._isInIntermediateRendering() ? visibleInstances.intermediateDefaultRenderId : visibleInstances.defaultRenderId);
  84857. batchCache.visibleInstances[subMeshId] = visibleInstances[currentRenderId];
  84858. var selfRenderId = this._renderId;
  84859. if (!batchCache.visibleInstances[subMeshId] && defaultRenderId) {
  84860. batchCache.visibleInstances[subMeshId] = visibleInstances[defaultRenderId];
  84861. currentRenderId = Math.max(defaultRenderId, currentRenderId);
  84862. selfRenderId = Math.max(visibleInstances.selfDefaultRenderId, currentRenderId);
  84863. }
  84864. var visibleInstancesForSubMesh = batchCache.visibleInstances[subMeshId];
  84865. if (visibleInstancesForSubMesh && visibleInstancesForSubMesh.length) {
  84866. if (this._instanceDataStorage.renderIdForInstances[subMeshId] === currentRenderId) {
  84867. batchCache.mustReturn = true;
  84868. return batchCache;
  84869. }
  84870. if (currentRenderId !== selfRenderId) {
  84871. batchCache.renderSelf[subMeshId] = false;
  84872. }
  84873. }
  84874. this._instanceDataStorage.renderIdForInstances[subMeshId] = currentRenderId;
  84875. }
  84876. return batchCache;
  84877. };
  84878. /** @hidden */
  84879. Mesh.prototype._renderWithInstances = function (subMesh, fillMode, batch, effect, engine) {
  84880. var visibleInstances = batch.visibleInstances[subMesh._id];
  84881. if (!visibleInstances) {
  84882. return this;
  84883. }
  84884. var matricesCount = visibleInstances.length + 1;
  84885. var bufferSize = matricesCount * 16 * 4;
  84886. var instanceStorage = this._instanceDataStorage;
  84887. var currentInstancesBufferSize = instanceStorage.instancesBufferSize;
  84888. var instancesBuffer = instanceStorage.instancesBuffer;
  84889. while (instanceStorage.instancesBufferSize < bufferSize) {
  84890. instanceStorage.instancesBufferSize *= 2;
  84891. }
  84892. if (!instanceStorage.instancesData || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  84893. instanceStorage.instancesData = new Float32Array(instanceStorage.instancesBufferSize / 4);
  84894. }
  84895. var offset = 0;
  84896. var instancesCount = 0;
  84897. var world = this.getWorldMatrix();
  84898. if (batch.renderSelf[subMesh._id]) {
  84899. world.copyToArray(instanceStorage.instancesData, offset);
  84900. offset += 16;
  84901. instancesCount++;
  84902. }
  84903. if (visibleInstances) {
  84904. for (var instanceIndex = 0; instanceIndex < visibleInstances.length; instanceIndex++) {
  84905. var instance = visibleInstances[instanceIndex];
  84906. instance.getWorldMatrix().copyToArray(instanceStorage.instancesData, offset);
  84907. offset += 16;
  84908. instancesCount++;
  84909. }
  84910. }
  84911. if (!instancesBuffer || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  84912. if (instancesBuffer) {
  84913. instancesBuffer.dispose();
  84914. }
  84915. instancesBuffer = new _buffer__WEBPACK_IMPORTED_MODULE_7__["Buffer"](engine, instanceStorage.instancesData, true, 16, false, true);
  84916. instanceStorage.instancesBuffer = instancesBuffer;
  84917. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world0", 0, 4));
  84918. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world1", 4, 4));
  84919. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world2", 8, 4));
  84920. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world3", 12, 4));
  84921. }
  84922. else {
  84923. instancesBuffer.updateDirectly(instanceStorage.instancesData, 0, instancesCount);
  84924. }
  84925. this._bind(subMesh, effect, fillMode);
  84926. this._draw(subMesh, fillMode, instancesCount);
  84927. engine.unbindInstanceAttributes();
  84928. return this;
  84929. };
  84930. /** @hidden */
  84931. Mesh.prototype._processRendering = function (subMesh, effect, fillMode, batch, hardwareInstancedRendering, onBeforeDraw, effectiveMaterial) {
  84932. var scene = this.getScene();
  84933. var engine = scene.getEngine();
  84934. if (hardwareInstancedRendering) {
  84935. this._renderWithInstances(subMesh, fillMode, batch, effect, engine);
  84936. }
  84937. else {
  84938. if (batch.renderSelf[subMesh._id]) {
  84939. // Draw
  84940. if (onBeforeDraw) {
  84941. onBeforeDraw(false, this.getWorldMatrix(), effectiveMaterial);
  84942. }
  84943. this._draw(subMesh, fillMode, this._instanceDataStorage.overridenInstanceCount);
  84944. }
  84945. var visibleInstancesForSubMesh = batch.visibleInstances[subMesh._id];
  84946. if (visibleInstancesForSubMesh) {
  84947. for (var instanceIndex = 0; instanceIndex < visibleInstancesForSubMesh.length; instanceIndex++) {
  84948. var instance = visibleInstancesForSubMesh[instanceIndex];
  84949. // World
  84950. var world = instance.getWorldMatrix();
  84951. if (onBeforeDraw) {
  84952. onBeforeDraw(true, world, effectiveMaterial);
  84953. }
  84954. // Draw
  84955. this._draw(subMesh, fillMode);
  84956. }
  84957. }
  84958. }
  84959. return this;
  84960. };
  84961. /**
  84962. * 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
  84963. * @param subMesh defines the subMesh to render
  84964. * @param enableAlphaMode defines if alpha mode can be changed
  84965. * @returns the current mesh
  84966. */
  84967. Mesh.prototype.render = function (subMesh, enableAlphaMode) {
  84968. if (this._checkOcclusionQuery()) {
  84969. return this;
  84970. }
  84971. var scene = this.getScene();
  84972. // Managing instances
  84973. var batch = this._getInstancesRenderList(subMesh._id);
  84974. if (batch.mustReturn) {
  84975. return this;
  84976. }
  84977. // Checking geometry state
  84978. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  84979. return this;
  84980. }
  84981. if (this._onBeforeRenderObservable) {
  84982. this._onBeforeRenderObservable.notifyObservers(this);
  84983. }
  84984. var engine = scene.getEngine();
  84985. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  84986. // Material
  84987. var material = subMesh.getMaterial();
  84988. if (!material) {
  84989. return this;
  84990. }
  84991. this._effectiveMaterial = material;
  84992. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  84993. if (!this._effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  84994. return this;
  84995. }
  84996. }
  84997. else if (!this._effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  84998. return this;
  84999. }
  85000. // Alpha mode
  85001. if (enableAlphaMode) {
  85002. engine.setAlphaMode(this._effectiveMaterial.alphaMode);
  85003. }
  85004. for (var _i = 0, _a = scene._beforeRenderingMeshStage; _i < _a.length; _i++) {
  85005. var step = _a[_i];
  85006. step.action(this, subMesh, batch);
  85007. }
  85008. var effect;
  85009. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  85010. effect = subMesh.effect;
  85011. }
  85012. else {
  85013. effect = this._effectiveMaterial.getEffect();
  85014. }
  85015. if (!effect) {
  85016. return this;
  85017. }
  85018. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  85019. var sideOrientation = this.overrideMaterialSideOrientation;
  85020. if (sideOrientation == null) {
  85021. sideOrientation = this._effectiveMaterial.sideOrientation;
  85022. if (effectiveMesh._getWorldMatrixDeterminant() < 0) {
  85023. 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);
  85024. }
  85025. }
  85026. var reverse = this._effectiveMaterial._preBind(effect, sideOrientation);
  85027. if (this._effectiveMaterial.forceDepthWrite) {
  85028. engine.setDepthWrite(true);
  85029. }
  85030. // Bind
  85031. 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);
  85032. if (this._onBeforeBindObservable) {
  85033. this._onBeforeBindObservable.notifyObservers(this);
  85034. }
  85035. if (!hardwareInstancedRendering) { // Binding will be done later because we need to add more info to the VB
  85036. this._bind(subMesh, effect, fillMode);
  85037. }
  85038. var world = effectiveMesh.getWorldMatrix();
  85039. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  85040. this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
  85041. }
  85042. else {
  85043. this._effectiveMaterial.bind(world, this);
  85044. }
  85045. if (!this._effectiveMaterial.backFaceCulling && this._effectiveMaterial.separateCullingPass) {
  85046. engine.setState(true, this._effectiveMaterial.zOffset, false, !reverse);
  85047. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  85048. engine.setState(true, this._effectiveMaterial.zOffset, false, reverse);
  85049. }
  85050. // Draw
  85051. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  85052. // Unbind
  85053. this._effectiveMaterial.unbind();
  85054. for (var _b = 0, _c = scene._afterRenderingMeshStage; _b < _c.length; _b++) {
  85055. var step = _c[_b];
  85056. step.action(this, subMesh, batch);
  85057. }
  85058. if (this._onAfterRenderObservable) {
  85059. this._onAfterRenderObservable.notifyObservers(this);
  85060. }
  85061. return this;
  85062. };
  85063. Mesh.prototype._onBeforeDraw = function (isInstance, world, effectiveMaterial) {
  85064. if (isInstance && effectiveMaterial) {
  85065. effectiveMaterial.bindOnlyWorldMatrix(world);
  85066. }
  85067. };
  85068. /**
  85069. * Renormalize the mesh and patch it up if there are no weights
  85070. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  85071. * However in the case of zero weights then we set just a single influence to 1.
  85072. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  85073. */
  85074. Mesh.prototype.cleanMatrixWeights = function () {
  85075. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  85076. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind)) {
  85077. this.normalizeSkinWeightsAndExtra();
  85078. }
  85079. else {
  85080. this.normalizeSkinFourWeights();
  85081. }
  85082. }
  85083. };
  85084. // faster 4 weight version.
  85085. Mesh.prototype.normalizeSkinFourWeights = function () {
  85086. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  85087. var numWeights = matricesWeights.length;
  85088. for (var a = 0; a < numWeights; a += 4) {
  85089. // accumulate weights
  85090. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  85091. // check for invalid weight and just set it to 1.
  85092. if (t === 0) {
  85093. matricesWeights[a] = 1;
  85094. }
  85095. else {
  85096. // renormalize so everything adds to 1 use reciprical
  85097. var recip = 1 / t;
  85098. matricesWeights[a] *= recip;
  85099. matricesWeights[a + 1] *= recip;
  85100. matricesWeights[a + 2] *= recip;
  85101. matricesWeights[a + 3] *= recip;
  85102. }
  85103. }
  85104. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  85105. };
  85106. // handle special case of extra verts. (in theory gltf can handle 12 influences)
  85107. Mesh.prototype.normalizeSkinWeightsAndExtra = function () {
  85108. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  85109. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  85110. var numWeights = matricesWeights.length;
  85111. for (var a = 0; a < numWeights; a += 4) {
  85112. // accumulate weights
  85113. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  85114. t += matricesWeightsExtra[a] + matricesWeightsExtra[a + 1] + matricesWeightsExtra[a + 2] + matricesWeightsExtra[a + 3];
  85115. // check for invalid weight and just set it to 1.
  85116. if (t === 0) {
  85117. matricesWeights[a] = 1;
  85118. }
  85119. else {
  85120. // renormalize so everything adds to 1 use reciprical
  85121. var recip = 1 / t;
  85122. matricesWeights[a] *= recip;
  85123. matricesWeights[a + 1] *= recip;
  85124. matricesWeights[a + 2] *= recip;
  85125. matricesWeights[a + 3] *= recip;
  85126. // same goes for extras
  85127. matricesWeightsExtra[a] *= recip;
  85128. matricesWeightsExtra[a + 1] *= recip;
  85129. matricesWeightsExtra[a + 2] *= recip;
  85130. matricesWeightsExtra[a + 3] *= recip;
  85131. }
  85132. }
  85133. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  85134. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeightsExtra);
  85135. };
  85136. /**
  85137. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  85138. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  85139. * the user know there was an issue with importing the mesh
  85140. * @returns a validation object with skinned, valid and report string
  85141. */
  85142. Mesh.prototype.validateSkinning = function () {
  85143. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  85144. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  85145. if (matricesWeights === null || this.skeleton == null) {
  85146. return { skinned: false, valid: true, report: "not skinned" };
  85147. }
  85148. var numWeights = matricesWeights.length;
  85149. var numberNotSorted = 0;
  85150. var missingWeights = 0;
  85151. var maxUsedWeights = 0;
  85152. var numberNotNormalized = 0;
  85153. var numInfluences = matricesWeightsExtra === null ? 4 : 8;
  85154. var usedWeightCounts = new Array();
  85155. for (var a = 0; a <= numInfluences; a++) {
  85156. usedWeightCounts[a] = 0;
  85157. }
  85158. var toleranceEpsilon = 0.001;
  85159. for (var a = 0; a < numWeights; a += 4) {
  85160. var lastWeight = matricesWeights[a];
  85161. var t = lastWeight;
  85162. var usedWeights = t === 0 ? 0 : 1;
  85163. for (var b = 1; b < numInfluences; b++) {
  85164. var d = b < 4 ? matricesWeights[a + b] : matricesWeightsExtra[a + b - 4];
  85165. if (d > lastWeight) {
  85166. numberNotSorted++;
  85167. }
  85168. if (d !== 0) {
  85169. usedWeights++;
  85170. }
  85171. t += d;
  85172. lastWeight = d;
  85173. }
  85174. // count the buffer weights usage
  85175. usedWeightCounts[usedWeights]++;
  85176. // max influences
  85177. if (usedWeights > maxUsedWeights) {
  85178. maxUsedWeights = usedWeights;
  85179. }
  85180. // check for invalid weight and just set it to 1.
  85181. if (t === 0) {
  85182. missingWeights++;
  85183. }
  85184. else {
  85185. // renormalize so everything adds to 1 use reciprical
  85186. var recip = 1 / t;
  85187. var tolerance = 0;
  85188. for (b = 0; b < numInfluences; b++) {
  85189. if (b < 4) {
  85190. tolerance += Math.abs(matricesWeights[a + b] - (matricesWeights[a + b] * recip));
  85191. }
  85192. else {
  85193. tolerance += Math.abs(matricesWeightsExtra[a + b - 4] - (matricesWeightsExtra[a + b - 4] * recip));
  85194. }
  85195. }
  85196. // arbitary epsilon value for dicdating not normalized
  85197. if (tolerance > toleranceEpsilon) {
  85198. numberNotNormalized++;
  85199. }
  85200. }
  85201. }
  85202. // validate bone indices are in range of the skeleton
  85203. var numBones = this.skeleton.bones.length;
  85204. var matricesIndices = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  85205. var matricesIndicesExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind);
  85206. var numBadBoneIndices = 0;
  85207. for (var a = 0; a < numWeights; a++) {
  85208. for (var b = 0; b < numInfluences; b++) {
  85209. var index = b < 4 ? matricesIndices[b] : matricesIndicesExtra[b - 4];
  85210. if (index >= numBones || index < 0) {
  85211. numBadBoneIndices++;
  85212. }
  85213. }
  85214. }
  85215. // log mesh stats
  85216. var output = "Number of Weights = " + numWeights / 4 + "\nMaximum influences = " + maxUsedWeights +
  85217. "\nMissing Weights = " + missingWeights + "\nNot Sorted = " + numberNotSorted +
  85218. "\nNot Normalized = " + numberNotNormalized + "\nWeightCounts = [" + usedWeightCounts + "]" +
  85219. "\nNumber of bones = " + numBones + "\nBad Bone Indices = " + numBadBoneIndices;
  85220. return { skinned: true, valid: missingWeights === 0 && numberNotNormalized === 0 && numBadBoneIndices === 0, report: output };
  85221. };
  85222. /** @hidden */
  85223. Mesh.prototype._checkDelayState = function () {
  85224. var scene = this.getScene();
  85225. if (this._geometry) {
  85226. this._geometry.load(scene);
  85227. }
  85228. else if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  85229. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING;
  85230. this._queueLoad(scene);
  85231. }
  85232. return this;
  85233. };
  85234. Mesh.prototype._queueLoad = function (scene) {
  85235. var _this = this;
  85236. scene._addPendingData(this);
  85237. var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1);
  85238. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadFile(this.delayLoadingFile, function (data) {
  85239. if (data instanceof ArrayBuffer) {
  85240. _this._delayLoadingFunction(data, _this);
  85241. }
  85242. else {
  85243. _this._delayLoadingFunction(JSON.parse(data), _this);
  85244. }
  85245. _this.instances.forEach(function (instance) {
  85246. instance._syncSubMeshes();
  85247. });
  85248. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADED;
  85249. scene._removePendingData(_this);
  85250. }, function () { }, scene.offlineProvider, getBinaryData);
  85251. return this;
  85252. };
  85253. /**
  85254. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  85255. * A mesh is in the frustum if its bounding box intersects the frustum
  85256. * @param frustumPlanes defines the frustum to test
  85257. * @returns true if the mesh is in the frustum planes
  85258. */
  85259. Mesh.prototype.isInFrustum = function (frustumPlanes) {
  85260. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  85261. return false;
  85262. }
  85263. if (!_super.prototype.isInFrustum.call(this, frustumPlanes)) {
  85264. return false;
  85265. }
  85266. this._checkDelayState();
  85267. return true;
  85268. };
  85269. /**
  85270. * Sets the mesh material by the material or multiMaterial `id` property
  85271. * @param id is a string identifying the material or the multiMaterial
  85272. * @returns the current mesh
  85273. */
  85274. Mesh.prototype.setMaterialByID = function (id) {
  85275. var materials = this.getScene().materials;
  85276. var index;
  85277. for (index = materials.length - 1; index > -1; index--) {
  85278. if (materials[index].id === id) {
  85279. this.material = materials[index];
  85280. return this;
  85281. }
  85282. }
  85283. // Multi
  85284. var multiMaterials = this.getScene().multiMaterials;
  85285. for (index = multiMaterials.length - 1; index > -1; index--) {
  85286. if (multiMaterials[index].id === id) {
  85287. this.material = multiMaterials[index];
  85288. return this;
  85289. }
  85290. }
  85291. return this;
  85292. };
  85293. /**
  85294. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  85295. * @returns an array of IAnimatable
  85296. */
  85297. Mesh.prototype.getAnimatables = function () {
  85298. var results = new Array();
  85299. if (this.material) {
  85300. results.push(this.material);
  85301. }
  85302. if (this.skeleton) {
  85303. results.push(this.skeleton);
  85304. }
  85305. return results;
  85306. };
  85307. /**
  85308. * Modifies the mesh geometry according to the passed transformation matrix.
  85309. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  85310. * The mesh normals are modified using the same transformation.
  85311. * Note that, under the hood, this method sets a new VertexBuffer each call.
  85312. * @param transform defines the transform matrix to use
  85313. * @see http://doc.babylonjs.com/resources/baking_transformations
  85314. * @returns the current mesh
  85315. */
  85316. Mesh.prototype.bakeTransformIntoVertices = function (transform) {
  85317. // Position
  85318. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  85319. return this;
  85320. }
  85321. var submeshes = this.subMeshes.splice(0);
  85322. this._resetPointsArrayCache();
  85323. var data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  85324. var temp = new Array();
  85325. var index;
  85326. for (index = 0; index < data.length; index += 3) {
  85327. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).toArray(temp, index);
  85328. }
  85329. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind).isUpdatable());
  85330. // Normals
  85331. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  85332. data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  85333. temp = [];
  85334. for (index = 0; index < data.length; index += 3) {
  85335. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormal(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).normalize().toArray(temp, index);
  85336. }
  85337. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind).isUpdatable());
  85338. }
  85339. // flip faces?
  85340. if (transform.m[0] * transform.m[5] * transform.m[10] < 0) {
  85341. this.flipFaces();
  85342. }
  85343. // Restore submeshes
  85344. this.releaseSubMeshes();
  85345. this.subMeshes = submeshes;
  85346. return this;
  85347. };
  85348. /**
  85349. * Modifies the mesh geometry according to its own current World Matrix.
  85350. * The mesh World Matrix is then reset.
  85351. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  85352. * Note that, under the hood, this method sets a new VertexBuffer each call.
  85353. * @see http://doc.babylonjs.com/resources/baking_transformations
  85354. * @returns the current mesh
  85355. */
  85356. Mesh.prototype.bakeCurrentTransformIntoVertices = function () {
  85357. this.bakeTransformIntoVertices(this.computeWorldMatrix(true));
  85358. this.scaling.copyFromFloats(1, 1, 1);
  85359. this.position.copyFromFloats(0, 0, 0);
  85360. this.rotation.copyFromFloats(0, 0, 0);
  85361. //only if quaternion is already set
  85362. if (this.rotationQuaternion) {
  85363. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].Identity();
  85364. }
  85365. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  85366. return this;
  85367. };
  85368. Object.defineProperty(Mesh.prototype, "_positions", {
  85369. // Cache
  85370. /** @hidden */
  85371. get: function () {
  85372. if (this._geometry) {
  85373. return this._geometry._positions;
  85374. }
  85375. return null;
  85376. },
  85377. enumerable: true,
  85378. configurable: true
  85379. });
  85380. /** @hidden */
  85381. Mesh.prototype._resetPointsArrayCache = function () {
  85382. if (this._geometry) {
  85383. this._geometry._resetPointsArrayCache();
  85384. }
  85385. return this;
  85386. };
  85387. /** @hidden */
  85388. Mesh.prototype._generatePointsArray = function () {
  85389. if (this._geometry) {
  85390. return this._geometry._generatePointsArray();
  85391. }
  85392. return false;
  85393. };
  85394. /**
  85395. * Returns a new Mesh object generated from the current mesh properties.
  85396. * This method must not get confused with createInstance()
  85397. * @param name is a string, the name given to the new mesh
  85398. * @param newParent can be any Node object (default `null`)
  85399. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  85400. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  85401. * @returns a new mesh
  85402. */
  85403. Mesh.prototype.clone = function (name, newParent, doNotCloneChildren, clonePhysicsImpostor) {
  85404. if (name === void 0) { name = ""; }
  85405. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  85406. return new Mesh(name, this.getScene(), newParent, this, doNotCloneChildren, clonePhysicsImpostor);
  85407. };
  85408. /**
  85409. * Releases resources associated with this mesh.
  85410. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85411. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85412. */
  85413. Mesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  85414. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  85415. this.morphTargetManager = null;
  85416. if (this._geometry) {
  85417. this._geometry.releaseForMesh(this, true);
  85418. }
  85419. if (this._onBeforeDrawObservable) {
  85420. this._onBeforeDrawObservable.clear();
  85421. }
  85422. if (this._onBeforeBindObservable) {
  85423. this._onBeforeBindObservable.clear();
  85424. }
  85425. if (this._onBeforeRenderObservable) {
  85426. this._onBeforeRenderObservable.clear();
  85427. }
  85428. if (this._onAfterRenderObservable) {
  85429. this._onAfterRenderObservable.clear();
  85430. }
  85431. // Sources
  85432. if (this._scene.useClonedMeshhMap) {
  85433. if (this.meshMap) {
  85434. for (var uniqueId in this.meshMap) {
  85435. var mesh = this.meshMap[uniqueId];
  85436. if (mesh) {
  85437. mesh._source = null;
  85438. this.meshMap[uniqueId] = undefined;
  85439. }
  85440. }
  85441. }
  85442. if (this._source && this._source.meshMap) {
  85443. this._source.meshMap[this.uniqueId] = undefined;
  85444. }
  85445. }
  85446. else {
  85447. var meshes = this.getScene().meshes;
  85448. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  85449. var abstractMesh = meshes_1[_i];
  85450. var mesh = abstractMesh;
  85451. if (mesh._source && mesh._source === this) {
  85452. mesh._source = null;
  85453. }
  85454. }
  85455. }
  85456. this._source = null;
  85457. // Instances
  85458. if (this._instanceDataStorage.instancesBuffer) {
  85459. this._instanceDataStorage.instancesBuffer.dispose();
  85460. this._instanceDataStorage.instancesBuffer = null;
  85461. }
  85462. while (this.instances.length) {
  85463. this.instances[0].dispose();
  85464. }
  85465. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  85466. };
  85467. /**
  85468. * Modifies the mesh geometry according to a displacement map.
  85469. * 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.
  85470. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  85471. * @param url is a string, the URL from the image file is to be downloaded.
  85472. * @param minHeight is the lower limit of the displacement.
  85473. * @param maxHeight is the upper limit of the displacement.
  85474. * @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.
  85475. * @param uvOffset is an optional vector2 used to offset UV.
  85476. * @param uvScale is an optional vector2 used to scale UV.
  85477. * @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.
  85478. * @returns the Mesh.
  85479. */
  85480. Mesh.prototype.applyDisplacementMap = function (url, minHeight, maxHeight, onSuccess, uvOffset, uvScale, forceUpdate) {
  85481. var _this = this;
  85482. if (forceUpdate === void 0) { forceUpdate = false; }
  85483. var scene = this.getScene();
  85484. var onload = function (img) {
  85485. // Getting height map data
  85486. var canvas = document.createElement("canvas");
  85487. var context = canvas.getContext("2d");
  85488. var heightMapWidth = img.width;
  85489. var heightMapHeight = img.height;
  85490. canvas.width = heightMapWidth;
  85491. canvas.height = heightMapHeight;
  85492. context.drawImage(img, 0, 0);
  85493. // Create VertexData from map data
  85494. //Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  85495. var buffer = context.getImageData(0, 0, heightMapWidth, heightMapHeight).data;
  85496. _this.applyDisplacementMapFromBuffer(buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate);
  85497. //execute success callback, if set
  85498. if (onSuccess) {
  85499. onSuccess(_this);
  85500. }
  85501. };
  85502. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  85503. return this;
  85504. };
  85505. /**
  85506. * Modifies the mesh geometry according to a displacementMap buffer.
  85507. * 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.
  85508. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  85509. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  85510. * @param heightMapWidth is the width of the buffer image.
  85511. * @param heightMapHeight is the height of the buffer image.
  85512. * @param minHeight is the lower limit of the displacement.
  85513. * @param maxHeight is the upper limit of the displacement.
  85514. * @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.
  85515. * @param uvOffset is an optional vector2 used to offset UV.
  85516. * @param uvScale is an optional vector2 used to scale UV.
  85517. * @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.
  85518. * @returns the Mesh.
  85519. */
  85520. Mesh.prototype.applyDisplacementMapFromBuffer = function (buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate) {
  85521. if (forceUpdate === void 0) { forceUpdate = false; }
  85522. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)
  85523. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)
  85524. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind)) {
  85525. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing");
  85526. return this;
  85527. }
  85528. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, true, true);
  85529. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  85530. var uvs = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  85531. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  85532. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  85533. var uv = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  85534. uvOffset = uvOffset || _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  85535. uvScale = uvScale || new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](1, 1);
  85536. for (var index = 0; index < positions.length; index += 3) {
  85537. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(positions, index, position);
  85538. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(normals, index, normal);
  85539. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].FromArrayToRef(uvs, (index / 3) * 2, uv);
  85540. // Compute height
  85541. var u = ((Math.abs(uv.x * uvScale.x + uvOffset.x) * heightMapWidth) % heightMapWidth) | 0;
  85542. var v = ((Math.abs(uv.y * uvScale.y + uvOffset.y) * heightMapHeight) % heightMapHeight) | 0;
  85543. var pos = (u + v * heightMapWidth) * 4;
  85544. var r = buffer[pos] / 255.0;
  85545. var g = buffer[pos + 1] / 255.0;
  85546. var b = buffer[pos + 2] / 255.0;
  85547. var gradient = r * 0.3 + g * 0.59 + b * 0.11;
  85548. normal.normalize();
  85549. normal.scaleInPlace(minHeight + (maxHeight - minHeight) * gradient);
  85550. position = position.add(normal);
  85551. position.toArray(positions, index);
  85552. }
  85553. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, this.getIndices(), normals);
  85554. if (forceUpdate) {
  85555. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  85556. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  85557. }
  85558. else {
  85559. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  85560. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  85561. }
  85562. return this;
  85563. };
  85564. /**
  85565. * Modify the mesh to get a flat shading rendering.
  85566. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  85567. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  85568. * @returns current mesh
  85569. */
  85570. Mesh.prototype.convertToFlatShadedMesh = function () {
  85571. var kinds = this.getVerticesDataKinds();
  85572. var vbs = {};
  85573. var data = {};
  85574. var newdata = {};
  85575. var updatableNormals = false;
  85576. var kindIndex;
  85577. var kind;
  85578. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85579. kind = kinds[kindIndex];
  85580. var vertexBuffer = this.getVertexBuffer(kind);
  85581. if (kind === _buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) {
  85582. updatableNormals = vertexBuffer.isUpdatable();
  85583. kinds.splice(kindIndex, 1);
  85584. kindIndex--;
  85585. continue;
  85586. }
  85587. vbs[kind] = vertexBuffer;
  85588. data[kind] = vbs[kind].getData();
  85589. newdata[kind] = [];
  85590. }
  85591. // Save previous submeshes
  85592. var previousSubmeshes = this.subMeshes.slice(0);
  85593. var indices = this.getIndices();
  85594. var totalIndices = this.getTotalIndices();
  85595. // Generating unique vertices per face
  85596. var index;
  85597. for (index = 0; index < totalIndices; index++) {
  85598. var vertexIndex = indices[index];
  85599. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85600. kind = kinds[kindIndex];
  85601. var stride = vbs[kind].getStrideSize();
  85602. for (var offset = 0; offset < stride; offset++) {
  85603. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  85604. }
  85605. }
  85606. }
  85607. // Updating faces & normal
  85608. var normals = [];
  85609. var positions = newdata[_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  85610. for (index = 0; index < totalIndices; index += 3) {
  85611. indices[index] = index;
  85612. indices[index + 1] = index + 1;
  85613. indices[index + 2] = index + 2;
  85614. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, index * 3);
  85615. var p2 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 1) * 3);
  85616. var p3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 2) * 3);
  85617. var p1p2 = p1.subtract(p2);
  85618. var p3p2 = p3.subtract(p2);
  85619. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Cross(p1p2, p3p2));
  85620. // Store same normals for every vertex
  85621. for (var localIndex = 0; localIndex < 3; localIndex++) {
  85622. normals.push(normal.x);
  85623. normals.push(normal.y);
  85624. normals.push(normal.z);
  85625. }
  85626. }
  85627. this.setIndices(indices);
  85628. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, updatableNormals);
  85629. // Updating vertex buffers
  85630. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85631. kind = kinds[kindIndex];
  85632. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  85633. }
  85634. // Updating submeshes
  85635. this.releaseSubMeshes();
  85636. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  85637. var previousOne = previousSubmeshes[submeshIndex];
  85638. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  85639. }
  85640. this.synchronizeInstances();
  85641. return this;
  85642. };
  85643. /**
  85644. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  85645. * In other words, more vertices, no more indices and a single bigger VBO.
  85646. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  85647. * @returns current mesh
  85648. */
  85649. Mesh.prototype.convertToUnIndexedMesh = function () {
  85650. var kinds = this.getVerticesDataKinds();
  85651. var vbs = {};
  85652. var data = {};
  85653. var newdata = {};
  85654. var kindIndex;
  85655. var kind;
  85656. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85657. kind = kinds[kindIndex];
  85658. var vertexBuffer = this.getVertexBuffer(kind);
  85659. vbs[kind] = vertexBuffer;
  85660. data[kind] = vbs[kind].getData();
  85661. newdata[kind] = [];
  85662. }
  85663. // Save previous submeshes
  85664. var previousSubmeshes = this.subMeshes.slice(0);
  85665. var indices = this.getIndices();
  85666. var totalIndices = this.getTotalIndices();
  85667. // Generating unique vertices per face
  85668. var index;
  85669. for (index = 0; index < totalIndices; index++) {
  85670. var vertexIndex = indices[index];
  85671. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85672. kind = kinds[kindIndex];
  85673. var stride = vbs[kind].getStrideSize();
  85674. for (var offset = 0; offset < stride; offset++) {
  85675. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  85676. }
  85677. }
  85678. }
  85679. // Updating indices
  85680. for (index = 0; index < totalIndices; index += 3) {
  85681. indices[index] = index;
  85682. indices[index + 1] = index + 1;
  85683. indices[index + 2] = index + 2;
  85684. }
  85685. this.setIndices(indices);
  85686. // Updating vertex buffers
  85687. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85688. kind = kinds[kindIndex];
  85689. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  85690. }
  85691. // Updating submeshes
  85692. this.releaseSubMeshes();
  85693. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  85694. var previousOne = previousSubmeshes[submeshIndex];
  85695. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  85696. }
  85697. this._unIndexed = true;
  85698. this.synchronizeInstances();
  85699. return this;
  85700. };
  85701. /**
  85702. * Inverses facet orientations.
  85703. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  85704. * @param flipNormals will also inverts the normals
  85705. * @returns current mesh
  85706. */
  85707. Mesh.prototype.flipFaces = function (flipNormals) {
  85708. if (flipNormals === void 0) { flipNormals = false; }
  85709. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  85710. var i;
  85711. if (flipNormals && this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) && vertex_data.normals) {
  85712. for (i = 0; i < vertex_data.normals.length; i++) {
  85713. vertex_data.normals[i] *= -1;
  85714. }
  85715. }
  85716. if (vertex_data.indices) {
  85717. var temp;
  85718. for (i = 0; i < vertex_data.indices.length; i += 3) {
  85719. // reassign indices
  85720. temp = vertex_data.indices[i + 1];
  85721. vertex_data.indices[i + 1] = vertex_data.indices[i + 2];
  85722. vertex_data.indices[i + 2] = temp;
  85723. }
  85724. }
  85725. vertex_data.applyToMesh(this);
  85726. return this;
  85727. };
  85728. // Instances
  85729. /** @hidden */
  85730. Mesh._instancedMeshFactory = function (name, mesh) {
  85731. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("InstancedMesh");
  85732. };
  85733. /** @hidden */
  85734. Mesh._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  85735. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("PhysicsImpostor");
  85736. };
  85737. /**
  85738. * Creates a new InstancedMesh object from the mesh model.
  85739. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  85740. * @param name defines the name of the new instance
  85741. * @returns a new InstancedMesh
  85742. */
  85743. Mesh.prototype.createInstance = function (name) {
  85744. return Mesh._instancedMeshFactory(name, this);
  85745. };
  85746. /**
  85747. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  85748. * After this call, all the mesh instances have the same submeshes than the current mesh.
  85749. * @returns the current mesh
  85750. */
  85751. Mesh.prototype.synchronizeInstances = function () {
  85752. for (var instanceIndex = 0; instanceIndex < this.instances.length; instanceIndex++) {
  85753. var instance = this.instances[instanceIndex];
  85754. instance._syncSubMeshes();
  85755. }
  85756. return this;
  85757. };
  85758. /**
  85759. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  85760. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  85761. * This should be used together with the simplification to avoid disappearing triangles.
  85762. * @param successCallback an optional success callback to be called after the optimization finished.
  85763. * @returns the current mesh
  85764. */
  85765. Mesh.prototype.optimizeIndices = function (successCallback) {
  85766. var _this = this;
  85767. var indices = this.getIndices();
  85768. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  85769. if (!positions || !indices) {
  85770. return this;
  85771. }
  85772. var vectorPositions = new Array();
  85773. for (var pos = 0; pos < positions.length; pos = pos + 3) {
  85774. vectorPositions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, pos));
  85775. }
  85776. var dupes = new Array();
  85777. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["AsyncLoop"].SyncAsyncForLoop(vectorPositions.length, 40, function (iteration) {
  85778. var realPos = vectorPositions.length - 1 - iteration;
  85779. var testedPosition = vectorPositions[realPos];
  85780. for (var j = 0; j < realPos; ++j) {
  85781. var againstPosition = vectorPositions[j];
  85782. if (testedPosition.equals(againstPosition)) {
  85783. dupes[realPos] = j;
  85784. break;
  85785. }
  85786. }
  85787. }, function () {
  85788. for (var i = 0; i < indices.length; ++i) {
  85789. indices[i] = dupes[indices[i]] || indices[i];
  85790. }
  85791. //indices are now reordered
  85792. var originalSubMeshes = _this.subMeshes.slice(0);
  85793. _this.setIndices(indices);
  85794. _this.subMeshes = originalSubMeshes;
  85795. if (successCallback) {
  85796. successCallback(_this);
  85797. }
  85798. });
  85799. return this;
  85800. };
  85801. /**
  85802. * Serialize current mesh
  85803. * @param serializationObject defines the object which will receive the serialization data
  85804. */
  85805. Mesh.prototype.serialize = function (serializationObject) {
  85806. serializationObject.name = this.name;
  85807. serializationObject.id = this.id;
  85808. serializationObject.type = this.getClassName();
  85809. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(this)) {
  85810. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(this);
  85811. }
  85812. serializationObject.position = this.position.asArray();
  85813. if (this.rotationQuaternion) {
  85814. serializationObject.rotationQuaternion = this.rotationQuaternion.asArray();
  85815. }
  85816. else if (this.rotation) {
  85817. serializationObject.rotation = this.rotation.asArray();
  85818. }
  85819. serializationObject.scaling = this.scaling.asArray();
  85820. if (this._postMultiplyPivotMatrix) {
  85821. serializationObject.pivotMatrix = this.getPivotMatrix().asArray();
  85822. }
  85823. else {
  85824. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  85825. }
  85826. serializationObject.isEnabled = this.isEnabled(false);
  85827. serializationObject.isVisible = this.isVisible;
  85828. serializationObject.infiniteDistance = this.infiniteDistance;
  85829. serializationObject.pickable = this.isPickable;
  85830. serializationObject.receiveShadows = this.receiveShadows;
  85831. serializationObject.billboardMode = this.billboardMode;
  85832. serializationObject.visibility = this.visibility;
  85833. serializationObject.checkCollisions = this.checkCollisions;
  85834. serializationObject.isBlocker = this.isBlocker;
  85835. // Parent
  85836. if (this.parent) {
  85837. serializationObject.parentId = this.parent.id;
  85838. }
  85839. // Geometry
  85840. serializationObject.isUnIndexed = this.isUnIndexed;
  85841. var geometry = this._geometry;
  85842. if (geometry) {
  85843. var geometryId = geometry.id;
  85844. serializationObject.geometryId = geometryId;
  85845. // SubMeshes
  85846. serializationObject.subMeshes = [];
  85847. for (var subIndex = 0; subIndex < this.subMeshes.length; subIndex++) {
  85848. var subMesh = this.subMeshes[subIndex];
  85849. serializationObject.subMeshes.push({
  85850. materialIndex: subMesh.materialIndex,
  85851. verticesStart: subMesh.verticesStart,
  85852. verticesCount: subMesh.verticesCount,
  85853. indexStart: subMesh.indexStart,
  85854. indexCount: subMesh.indexCount
  85855. });
  85856. }
  85857. }
  85858. // Material
  85859. if (this.material) {
  85860. serializationObject.materialId = this.material.id;
  85861. }
  85862. else {
  85863. this.material = null;
  85864. }
  85865. // Morph targets
  85866. if (this.morphTargetManager) {
  85867. serializationObject.morphTargetManagerId = this.morphTargetManager.uniqueId;
  85868. }
  85869. // Skeleton
  85870. if (this.skeleton) {
  85871. serializationObject.skeletonId = this.skeleton.id;
  85872. }
  85873. // Physics
  85874. //TODO implement correct serialization for physics impostors.
  85875. var impostor = this.getPhysicsImpostor();
  85876. if (impostor) {
  85877. serializationObject.physicsMass = impostor.getParam("mass");
  85878. serializationObject.physicsFriction = impostor.getParam("friction");
  85879. serializationObject.physicsRestitution = impostor.getParam("mass");
  85880. serializationObject.physicsImpostor = impostor.type;
  85881. }
  85882. // Metadata
  85883. if (this.metadata) {
  85884. serializationObject.metadata = this.metadata;
  85885. }
  85886. // Instances
  85887. serializationObject.instances = [];
  85888. for (var index = 0; index < this.instances.length; index++) {
  85889. var instance = this.instances[index];
  85890. if (instance.doNotSerialize) {
  85891. continue;
  85892. }
  85893. var serializationInstance = {
  85894. name: instance.name,
  85895. id: instance.id,
  85896. position: instance.position.asArray(),
  85897. scaling: instance.scaling.asArray()
  85898. };
  85899. if (instance.parent) {
  85900. serializationInstance.parentId = instance.parent.id;
  85901. }
  85902. if (instance.rotationQuaternion) {
  85903. serializationInstance.rotationQuaternion = instance.rotationQuaternion.asArray();
  85904. }
  85905. else if (instance.rotation) {
  85906. serializationInstance.rotation = instance.rotation.asArray();
  85907. }
  85908. serializationObject.instances.push(serializationInstance);
  85909. // Animations
  85910. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(instance, serializationInstance);
  85911. serializationInstance.ranges = instance.serializeAnimationRanges();
  85912. }
  85913. //
  85914. // Animations
  85915. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  85916. serializationObject.ranges = this.serializeAnimationRanges();
  85917. // Layer mask
  85918. serializationObject.layerMask = this.layerMask;
  85919. // Alpha
  85920. serializationObject.alphaIndex = this.alphaIndex;
  85921. serializationObject.hasVertexAlpha = this.hasVertexAlpha;
  85922. // Overlay
  85923. serializationObject.overlayAlpha = this.overlayAlpha;
  85924. serializationObject.overlayColor = this.overlayColor.asArray();
  85925. serializationObject.renderOverlay = this.renderOverlay;
  85926. // Fog
  85927. serializationObject.applyFog = this.applyFog;
  85928. // Action Manager
  85929. if (this.actionManager) {
  85930. serializationObject.actions = this.actionManager.serialize(this.name);
  85931. }
  85932. };
  85933. /** @hidden */
  85934. Mesh.prototype._syncGeometryWithMorphTargetManager = function () {
  85935. if (!this.geometry) {
  85936. return;
  85937. }
  85938. this._markSubMeshesAsAttributesDirty();
  85939. var morphTargetManager = this._morphTargetManager;
  85940. if (morphTargetManager && morphTargetManager.vertexCount) {
  85941. if (morphTargetManager.vertexCount !== this.getTotalVertices()) {
  85942. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count.");
  85943. this.morphTargetManager = null;
  85944. return;
  85945. }
  85946. for (var index = 0; index < morphTargetManager.numInfluencers; index++) {
  85947. var morphTarget = morphTargetManager.getActiveTarget(index);
  85948. var positions = morphTarget.getPositions();
  85949. if (!positions) {
  85950. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Invalid morph target. Target must have positions.");
  85951. return;
  85952. }
  85953. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index, positions, false, 3);
  85954. var normals = morphTarget.getNormals();
  85955. if (normals) {
  85956. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index, normals, false, 3);
  85957. }
  85958. var tangents = morphTarget.getTangents();
  85959. if (tangents) {
  85960. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index, tangents, false, 3);
  85961. }
  85962. }
  85963. }
  85964. else {
  85965. var index = 0;
  85966. // Positions
  85967. while (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index)) {
  85968. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index);
  85969. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index)) {
  85970. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index);
  85971. }
  85972. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index)) {
  85973. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index);
  85974. }
  85975. index++;
  85976. }
  85977. }
  85978. };
  85979. /**
  85980. * Returns a new Mesh object parsed from the source provided.
  85981. * @param parsedMesh is the source
  85982. * @param scene defines the hosting scene
  85983. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  85984. * @returns a new Mesh
  85985. */
  85986. Mesh.Parse = function (parsedMesh, scene, rootUrl) {
  85987. var mesh;
  85988. if (parsedMesh.type && parsedMesh.type === "GroundMesh") {
  85989. mesh = Mesh._GroundMeshParser(parsedMesh, scene);
  85990. }
  85991. else {
  85992. mesh = new Mesh(parsedMesh.name, scene);
  85993. }
  85994. mesh.id = parsedMesh.id;
  85995. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  85996. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(mesh, parsedMesh.tags);
  85997. }
  85998. mesh.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.position);
  85999. if (parsedMesh.metadata !== undefined) {
  86000. mesh.metadata = parsedMesh.metadata;
  86001. }
  86002. if (parsedMesh.rotationQuaternion) {
  86003. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedMesh.rotationQuaternion);
  86004. }
  86005. else if (parsedMesh.rotation) {
  86006. mesh.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.rotation);
  86007. }
  86008. mesh.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.scaling);
  86009. if (parsedMesh.localMatrix) {
  86010. mesh.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.localMatrix));
  86011. }
  86012. else if (parsedMesh.pivotMatrix) {
  86013. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.pivotMatrix));
  86014. }
  86015. mesh.setEnabled(parsedMesh.isEnabled);
  86016. mesh.isVisible = parsedMesh.isVisible;
  86017. mesh.infiniteDistance = parsedMesh.infiniteDistance;
  86018. mesh.showBoundingBox = parsedMesh.showBoundingBox;
  86019. mesh.showSubMeshesBoundingBox = parsedMesh.showSubMeshesBoundingBox;
  86020. if (parsedMesh.applyFog !== undefined) {
  86021. mesh.applyFog = parsedMesh.applyFog;
  86022. }
  86023. if (parsedMesh.pickable !== undefined) {
  86024. mesh.isPickable = parsedMesh.pickable;
  86025. }
  86026. if (parsedMesh.alphaIndex !== undefined) {
  86027. mesh.alphaIndex = parsedMesh.alphaIndex;
  86028. }
  86029. mesh.receiveShadows = parsedMesh.receiveShadows;
  86030. mesh.billboardMode = parsedMesh.billboardMode;
  86031. if (parsedMesh.visibility !== undefined) {
  86032. mesh.visibility = parsedMesh.visibility;
  86033. }
  86034. mesh.checkCollisions = parsedMesh.checkCollisions;
  86035. if (parsedMesh.isBlocker !== undefined) {
  86036. mesh.isBlocker = parsedMesh.isBlocker;
  86037. }
  86038. mesh._shouldGenerateFlatShading = parsedMesh.useFlatShading;
  86039. // freezeWorldMatrix
  86040. if (parsedMesh.freezeWorldMatrix) {
  86041. mesh._waitingFreezeWorldMatrix = parsedMesh.freezeWorldMatrix;
  86042. }
  86043. // Parent
  86044. if (parsedMesh.parentId) {
  86045. mesh._waitingParentId = parsedMesh.parentId;
  86046. }
  86047. // Actions
  86048. if (parsedMesh.actions !== undefined) {
  86049. mesh._waitingActions = parsedMesh.actions;
  86050. }
  86051. // Overlay
  86052. if (parsedMesh.overlayAlpha !== undefined) {
  86053. mesh.overlayAlpha = parsedMesh.overlayAlpha;
  86054. }
  86055. if (parsedMesh.overlayColor !== undefined) {
  86056. mesh.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Color3"].FromArray(parsedMesh.overlayColor);
  86057. }
  86058. if (parsedMesh.renderOverlay !== undefined) {
  86059. mesh.renderOverlay = parsedMesh.renderOverlay;
  86060. }
  86061. // Geometry
  86062. mesh.isUnIndexed = !!parsedMesh.isUnIndexed;
  86063. mesh.hasVertexAlpha = parsedMesh.hasVertexAlpha;
  86064. if (parsedMesh.delayLoadingFile) {
  86065. mesh.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED;
  86066. mesh.delayLoadingFile = rootUrl + parsedMesh.delayLoadingFile;
  86067. 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));
  86068. if (parsedMesh._binaryInfo) {
  86069. mesh._binaryInfo = parsedMesh._binaryInfo;
  86070. }
  86071. mesh._delayInfo = [];
  86072. if (parsedMesh.hasUVs) {
  86073. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  86074. }
  86075. if (parsedMesh.hasUVs2) {
  86076. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  86077. }
  86078. if (parsedMesh.hasUVs3) {
  86079. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV3Kind);
  86080. }
  86081. if (parsedMesh.hasUVs4) {
  86082. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV4Kind);
  86083. }
  86084. if (parsedMesh.hasUVs5) {
  86085. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV5Kind);
  86086. }
  86087. if (parsedMesh.hasUVs6) {
  86088. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV6Kind);
  86089. }
  86090. if (parsedMesh.hasColors) {
  86091. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  86092. }
  86093. if (parsedMesh.hasMatricesIndices) {
  86094. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  86095. }
  86096. if (parsedMesh.hasMatricesWeights) {
  86097. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  86098. }
  86099. mesh._delayLoadingFunction = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry;
  86100. if (_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental) {
  86101. mesh._checkDelayState();
  86102. }
  86103. }
  86104. else {
  86105. _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry(parsedMesh, mesh);
  86106. }
  86107. // Material
  86108. if (parsedMesh.materialId) {
  86109. mesh.setMaterialByID(parsedMesh.materialId);
  86110. }
  86111. else {
  86112. mesh.material = null;
  86113. }
  86114. // Morph targets
  86115. if (parsedMesh.morphTargetManagerId > -1) {
  86116. mesh.morphTargetManager = scene.getMorphTargetManagerById(parsedMesh.morphTargetManagerId);
  86117. }
  86118. // Skeleton
  86119. if (parsedMesh.skeletonId > -1) {
  86120. mesh.skeleton = scene.getLastSkeletonByID(parsedMesh.skeletonId);
  86121. if (parsedMesh.numBoneInfluencers) {
  86122. mesh.numBoneInfluencers = parsedMesh.numBoneInfluencers;
  86123. }
  86124. }
  86125. // Animations
  86126. if (parsedMesh.animations) {
  86127. for (var animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
  86128. var parsedAnimation = parsedMesh.animations[animationIndex];
  86129. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  86130. if (internalClass) {
  86131. mesh.animations.push(internalClass.Parse(parsedAnimation));
  86132. }
  86133. }
  86134. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(mesh, parsedMesh, scene);
  86135. }
  86136. if (parsedMesh.autoAnimate) {
  86137. scene.beginAnimation(mesh, parsedMesh.autoAnimateFrom, parsedMesh.autoAnimateTo, parsedMesh.autoAnimateLoop, parsedMesh.autoAnimateSpeed || 1.0);
  86138. }
  86139. // Layer Mask
  86140. if (parsedMesh.layerMask && (!isNaN(parsedMesh.layerMask))) {
  86141. mesh.layerMask = Math.abs(parseInt(parsedMesh.layerMask));
  86142. }
  86143. else {
  86144. mesh.layerMask = 0x0FFFFFFF;
  86145. }
  86146. // Physics
  86147. if (parsedMesh.physicsImpostor) {
  86148. Mesh._PhysicsImpostorParser(scene, mesh, parsedMesh);
  86149. }
  86150. // Instances
  86151. if (parsedMesh.instances) {
  86152. for (var index = 0; index < parsedMesh.instances.length; index++) {
  86153. var parsedInstance = parsedMesh.instances[index];
  86154. var instance = mesh.createInstance(parsedInstance.name);
  86155. if (parsedInstance.id) {
  86156. instance.id = parsedInstance.id;
  86157. }
  86158. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  86159. if (parsedInstance.tags) {
  86160. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedInstance.tags);
  86161. }
  86162. else {
  86163. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedMesh.tags);
  86164. }
  86165. }
  86166. instance.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.position);
  86167. if (parsedInstance.parentId) {
  86168. instance._waitingParentId = parsedInstance.parentId;
  86169. }
  86170. if (parsedInstance.rotationQuaternion) {
  86171. instance.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedInstance.rotationQuaternion);
  86172. }
  86173. else if (parsedInstance.rotation) {
  86174. instance.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.rotation);
  86175. }
  86176. instance.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.scaling);
  86177. if (parsedInstance.checkCollisions != undefined && parsedInstance.checkCollisions != null) {
  86178. instance.checkCollisions = parsedInstance.checkCollisions;
  86179. }
  86180. if (parsedInstance.pickable != undefined && parsedInstance.pickable != null) {
  86181. instance.isPickable = parsedInstance.pickable;
  86182. }
  86183. if (parsedInstance.showBoundingBox != undefined && parsedInstance.showBoundingBox != null) {
  86184. instance.showBoundingBox = parsedInstance.showBoundingBox;
  86185. }
  86186. if (parsedInstance.showSubMeshesBoundingBox != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  86187. instance.showSubMeshesBoundingBox = parsedInstance.showSubMeshesBoundingBox;
  86188. }
  86189. if (parsedInstance.alphaIndex != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  86190. instance.alphaIndex = parsedInstance.alphaIndex;
  86191. }
  86192. // Physics
  86193. if (parsedInstance.physicsImpostor) {
  86194. Mesh._PhysicsImpostorParser(scene, instance, parsedInstance);
  86195. }
  86196. // Animation
  86197. if (parsedInstance.animations) {
  86198. for (animationIndex = 0; animationIndex < parsedInstance.animations.length; animationIndex++) {
  86199. parsedAnimation = parsedInstance.animations[animationIndex];
  86200. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  86201. if (internalClass) {
  86202. instance.animations.push(internalClass.Parse(parsedAnimation));
  86203. }
  86204. }
  86205. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(instance, parsedInstance, scene);
  86206. if (parsedInstance.autoAnimate) {
  86207. scene.beginAnimation(instance, parsedInstance.autoAnimateFrom, parsedInstance.autoAnimateTo, parsedInstance.autoAnimateLoop, parsedInstance.autoAnimateSpeed || 1.0);
  86208. }
  86209. }
  86210. }
  86211. }
  86212. return mesh;
  86213. };
  86214. /**
  86215. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  86216. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  86217. * @param name defines the name of the mesh to create
  86218. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  86219. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  86220. * @param closePath creates a seam between the first and the last points of each path of the path array
  86221. * @param offset is taken in account only if the `pathArray` is containing a single path
  86222. * @param scene defines the hosting scene
  86223. * @param updatable defines if the mesh must be flagged as updatable
  86224. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86225. * @param instance 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)
  86226. * @returns a new Mesh
  86227. */
  86228. Mesh.CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  86229. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86230. };
  86231. /**
  86232. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  86233. * @param name defines the name of the mesh to create
  86234. * @param radius sets the radius size (float) of the polygon (default 0.5)
  86235. * @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
  86236. * @param scene defines the hosting scene
  86237. * @param updatable defines if the mesh must be flagged as updatable
  86238. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86239. * @returns a new Mesh
  86240. */
  86241. Mesh.CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  86242. if (scene === void 0) { scene = null; }
  86243. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86244. };
  86245. /**
  86246. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  86247. * @param name defines the name of the mesh to create
  86248. * @param size sets the size (float) of each box side (default 1)
  86249. * @param scene defines the hosting scene
  86250. * @param updatable defines if the mesh must be flagged as updatable
  86251. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86252. * @returns a new Mesh
  86253. */
  86254. Mesh.CreateBox = function (name, size, scene, updatable, sideOrientation) {
  86255. if (scene === void 0) { scene = null; }
  86256. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86257. };
  86258. /**
  86259. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  86260. * @param name defines the name of the mesh to create
  86261. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  86262. * @param diameter sets the diameter size (float) of the sphere (default 1)
  86263. * @param scene defines the hosting scene
  86264. * @param updatable defines if the mesh must be flagged as updatable
  86265. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86266. * @returns a new Mesh
  86267. */
  86268. Mesh.CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  86269. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86270. };
  86271. /**
  86272. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  86273. * @param name defines the name of the mesh to create
  86274. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  86275. * @param diameterTop set the top cap diameter (floats, default 1)
  86276. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  86277. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  86278. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  86279. * @param scene defines the hosting scene
  86280. * @param updatable defines if the mesh must be flagged as updatable
  86281. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86282. * @returns a new Mesh
  86283. */
  86284. Mesh.CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  86285. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86286. };
  86287. // Torus (Code from SharpDX.org)
  86288. /**
  86289. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  86290. * @param name defines the name of the mesh to create
  86291. * @param diameter sets the diameter size (float) of the torus (default 1)
  86292. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  86293. * @param tessellation sets the number of torus sides (postive integer, default 16)
  86294. * @param scene defines the hosting scene
  86295. * @param updatable defines if the mesh must be flagged as updatable
  86296. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86297. * @returns a new Mesh
  86298. */
  86299. Mesh.CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  86300. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86301. };
  86302. /**
  86303. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  86304. * @param name defines the name of the mesh to create
  86305. * @param radius sets the global radius size (float) of the torus knot (default 2)
  86306. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  86307. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  86308. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  86309. * @param p the number of windings on X axis (positive integers, default 2)
  86310. * @param q the number of windings on Y axis (positive integers, default 3)
  86311. * @param scene defines the hosting scene
  86312. * @param updatable defines if the mesh must be flagged as updatable
  86313. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86314. * @returns a new Mesh
  86315. */
  86316. Mesh.CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  86317. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86318. };
  86319. /**
  86320. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  86321. * @param name defines the name of the mesh to create
  86322. * @param points is an array successive Vector3
  86323. * @param scene defines the hosting scene
  86324. * @param updatable defines if the mesh must be flagged as updatable
  86325. * @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).
  86326. * @returns a new Mesh
  86327. */
  86328. Mesh.CreateLines = function (name, points, scene, updatable, instance) {
  86329. if (scene === void 0) { scene = null; }
  86330. if (updatable === void 0) { updatable = false; }
  86331. if (instance === void 0) { instance = null; }
  86332. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86333. };
  86334. /**
  86335. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  86336. * @param name defines the name of the mesh to create
  86337. * @param points is an array successive Vector3
  86338. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  86339. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  86340. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  86341. * @param scene defines the hosting scene
  86342. * @param updatable defines if the mesh must be flagged as updatable
  86343. * @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)
  86344. * @returns a new Mesh
  86345. */
  86346. Mesh.CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  86347. if (scene === void 0) { scene = null; }
  86348. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86349. };
  86350. /**
  86351. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  86352. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  86353. * 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.
  86354. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86355. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  86356. * Remember you can only change the shape positions, not their number when updating a polygon.
  86357. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  86358. * @param name defines the name of the mesh to create
  86359. * @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
  86360. * @param scene defines the hosting scene
  86361. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  86362. * @param updatable defines if the mesh must be flagged as updatable
  86363. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86364. * @param earcutInjection can be used to inject your own earcut reference
  86365. * @returns a new Mesh
  86366. */
  86367. Mesh.CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  86368. if (earcutInjection === void 0) { earcutInjection = earcut; }
  86369. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86370. };
  86371. /**
  86372. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  86373. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  86374. * @param name defines the name of the mesh to create
  86375. * @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
  86376. * @param depth defines the height of extrusion
  86377. * @param scene defines the hosting scene
  86378. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  86379. * @param updatable defines if the mesh must be flagged as updatable
  86380. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86381. * @param earcutInjection can be used to inject your own earcut reference
  86382. * @returns a new Mesh
  86383. */
  86384. Mesh.ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  86385. if (earcutInjection === void 0) { earcutInjection = earcut; }
  86386. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86387. };
  86388. /**
  86389. * Creates an extruded shape mesh.
  86390. * 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
  86391. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  86392. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  86393. * @param name defines the name of the mesh to create
  86394. * @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
  86395. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  86396. * @param scale is the value to scale the shape
  86397. * @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
  86398. * @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
  86399. * @param scene defines the hosting scene
  86400. * @param updatable defines if the mesh must be flagged as updatable
  86401. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86402. * @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)
  86403. * @returns a new Mesh
  86404. */
  86405. Mesh.ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  86406. if (scene === void 0) { scene = null; }
  86407. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86408. };
  86409. /**
  86410. * Creates an custom extruded shape mesh.
  86411. * The custom extrusion is a parametric shape.
  86412. * It has no predefined shape. Its final shape will depend on the input parameters.
  86413. * Please consider using the same method from the MeshBuilder class instead
  86414. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  86415. * @param name defines the name of the mesh to create
  86416. * @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
  86417. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  86418. * @param scaleFunction is a custom Javascript function called on each path point
  86419. * @param rotationFunction is a custom Javascript function called on each path point
  86420. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  86421. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  86422. * @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
  86423. * @param scene defines the hosting scene
  86424. * @param updatable defines if the mesh must be flagged as updatable
  86425. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86426. * @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)
  86427. * @returns a new Mesh
  86428. */
  86429. Mesh.ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  86430. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86431. };
  86432. /**
  86433. * Creates lathe mesh.
  86434. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  86435. * Please consider using the same method from the MeshBuilder class instead
  86436. * @param name defines the name of the mesh to create
  86437. * @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
  86438. * @param radius is the radius value of the lathe
  86439. * @param tessellation is the side number of the lathe.
  86440. * @param scene defines the hosting scene
  86441. * @param updatable defines if the mesh must be flagged as updatable
  86442. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86443. * @returns a new Mesh
  86444. */
  86445. Mesh.CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  86446. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86447. };
  86448. /**
  86449. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  86450. * @param name defines the name of the mesh to create
  86451. * @param size sets the size (float) of both sides of the plane at once (default 1)
  86452. * @param scene defines the hosting scene
  86453. * @param updatable defines if the mesh must be flagged as updatable
  86454. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86455. * @returns a new Mesh
  86456. */
  86457. Mesh.CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  86458. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86459. };
  86460. /**
  86461. * Creates a ground mesh.
  86462. * Please consider using the same method from the MeshBuilder class instead
  86463. * @param name defines the name of the mesh to create
  86464. * @param width set the width of the ground
  86465. * @param height set the height of the ground
  86466. * @param subdivisions sets the number of subdivisions per side
  86467. * @param scene defines the hosting scene
  86468. * @param updatable defines if the mesh must be flagged as updatable
  86469. * @returns a new Mesh
  86470. */
  86471. Mesh.CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  86472. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86473. };
  86474. /**
  86475. * Creates a tiled ground mesh.
  86476. * Please consider using the same method from the MeshBuilder class instead
  86477. * @param name defines the name of the mesh to create
  86478. * @param xmin set the ground minimum X coordinate
  86479. * @param zmin set the ground minimum Y coordinate
  86480. * @param xmax set the ground maximum X coordinate
  86481. * @param zmax set the ground maximum Z coordinate
  86482. * @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
  86483. * @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
  86484. * @param scene defines the hosting scene
  86485. * @param updatable defines if the mesh must be flagged as updatable
  86486. * @returns a new Mesh
  86487. */
  86488. Mesh.CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  86489. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86490. };
  86491. /**
  86492. * Creates a ground mesh from a height map.
  86493. * Please consider using the same method from the MeshBuilder class instead
  86494. * @see http://doc.babylonjs.com/babylon101/height_map
  86495. * @param name defines the name of the mesh to create
  86496. * @param url sets the URL of the height map image resource
  86497. * @param width set the ground width size
  86498. * @param height set the ground height size
  86499. * @param subdivisions sets the number of subdivision per side
  86500. * @param minHeight is the minimum altitude on the ground
  86501. * @param maxHeight is the maximum altitude on the ground
  86502. * @param scene defines the hosting scene
  86503. * @param updatable defines if the mesh must be flagged as updatable
  86504. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  86505. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  86506. * @returns a new Mesh
  86507. */
  86508. Mesh.CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  86509. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86510. };
  86511. /**
  86512. * Creates a tube mesh.
  86513. * The tube is a parametric shape.
  86514. * It has no predefined shape. Its final shape will depend on the input parameters.
  86515. * Please consider using the same method from the MeshBuilder class instead
  86516. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  86517. * @param name defines the name of the mesh to create
  86518. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  86519. * @param radius sets the tube radius size
  86520. * @param tessellation is the number of sides on the tubular surface
  86521. * @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
  86522. * @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
  86523. * @param scene defines the hosting scene
  86524. * @param updatable defines if the mesh must be flagged as updatable
  86525. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86526. * @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)
  86527. * @returns a new Mesh
  86528. */
  86529. Mesh.CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  86530. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86531. };
  86532. /**
  86533. * Creates a polyhedron mesh.
  86534. * Please consider using the same method from the MeshBuilder class instead.
  86535. * * 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
  86536. * * The parameter `size` (positive float, default 1) sets the polygon size
  86537. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  86538. * * 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`
  86539. * * 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
  86540. * * 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)`)
  86541. * * 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
  86542. * * 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
  86543. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86544. * * 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
  86545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86546. * @param name defines the name of the mesh to create
  86547. * @param options defines the options used to create the mesh
  86548. * @param scene defines the hosting scene
  86549. * @returns a new Mesh
  86550. */
  86551. Mesh.CreatePolyhedron = function (name, options, scene) {
  86552. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86553. };
  86554. /**
  86555. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  86556. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  86557. * * 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`)
  86558. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  86559. * * 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
  86560. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86561. * * 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
  86562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86563. * @param name defines the name of the mesh
  86564. * @param options defines the options used to create the mesh
  86565. * @param scene defines the hosting scene
  86566. * @returns a new Mesh
  86567. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  86568. */
  86569. Mesh.CreateIcoSphere = function (name, options, scene) {
  86570. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86571. };
  86572. /**
  86573. * Creates a decal mesh.
  86574. * Please consider using the same method from the MeshBuilder class instead.
  86575. * A decal is a mesh usually applied as a model onto the surface of another mesh
  86576. * @param name defines the name of the mesh
  86577. * @param sourceMesh defines the mesh receiving the decal
  86578. * @param position sets the position of the decal in world coordinates
  86579. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  86580. * @param size sets the decal scaling
  86581. * @param angle sets the angle to rotate the decal
  86582. * @returns a new Mesh
  86583. */
  86584. Mesh.CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  86585. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86586. };
  86587. // Skeletons
  86588. /**
  86589. * Prepare internal position array for software CPU skinning
  86590. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  86591. */
  86592. Mesh.prototype.setPositionsForCPUSkinning = function () {
  86593. if (!this._sourcePositions) {
  86594. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  86595. if (!source) {
  86596. return this._sourcePositions;
  86597. }
  86598. this._sourcePositions = new Float32Array(source);
  86599. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  86600. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, source, true);
  86601. }
  86602. }
  86603. return this._sourcePositions;
  86604. };
  86605. /**
  86606. * Prepare internal normal array for software CPU skinning
  86607. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  86608. */
  86609. Mesh.prototype.setNormalsForCPUSkinning = function () {
  86610. if (!this._sourceNormals) {
  86611. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  86612. if (!source) {
  86613. return this._sourceNormals;
  86614. }
  86615. this._sourceNormals = new Float32Array(source);
  86616. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  86617. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, source, true);
  86618. }
  86619. }
  86620. return this._sourceNormals;
  86621. };
  86622. /**
  86623. * Updates the vertex buffer by applying transformation from the bones
  86624. * @param skeleton defines the skeleton to apply to current mesh
  86625. * @returns the current mesh
  86626. */
  86627. Mesh.prototype.applySkeleton = function (skeleton) {
  86628. if (!this.geometry) {
  86629. return this;
  86630. }
  86631. if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId()) {
  86632. return this;
  86633. }
  86634. this.geometry._softwareSkinningFrameId = this.getScene().getFrameId();
  86635. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  86636. return this;
  86637. }
  86638. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  86639. return this;
  86640. }
  86641. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind)) {
  86642. return this;
  86643. }
  86644. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  86645. return this;
  86646. }
  86647. if (!this._sourcePositions) {
  86648. var submeshes = this.subMeshes.slice();
  86649. this.setPositionsForCPUSkinning();
  86650. this.subMeshes = submeshes;
  86651. }
  86652. if (!this._sourceNormals) {
  86653. this.setNormalsForCPUSkinning();
  86654. }
  86655. // positionsData checks for not being Float32Array will only pass at most once
  86656. var positionsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  86657. if (!positionsData) {
  86658. return this;
  86659. }
  86660. if (!(positionsData instanceof Float32Array)) {
  86661. positionsData = new Float32Array(positionsData);
  86662. }
  86663. // normalsData checks for not being Float32Array will only pass at most once
  86664. var normalsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  86665. if (!normalsData) {
  86666. return this;
  86667. }
  86668. if (!(normalsData instanceof Float32Array)) {
  86669. normalsData = new Float32Array(normalsData);
  86670. }
  86671. var matricesIndicesData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  86672. var matricesWeightsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  86673. if (!matricesWeightsData || !matricesIndicesData) {
  86674. return this;
  86675. }
  86676. var needExtras = this.numBoneInfluencers > 4;
  86677. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  86678. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  86679. var skeletonMatrices = skeleton.getTransformMatrices(this);
  86680. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  86681. var finalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  86682. var tempMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  86683. var matWeightIdx = 0;
  86684. var inf;
  86685. for (var index = 0; index < positionsData.length; index += 3, matWeightIdx += 4) {
  86686. var weight;
  86687. for (inf = 0; inf < 4; inf++) {
  86688. weight = matricesWeightsData[matWeightIdx + inf];
  86689. if (weight > 0) {
  86690. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  86691. finalMatrix.addToSelf(tempMatrix);
  86692. }
  86693. }
  86694. if (needExtras) {
  86695. for (inf = 0; inf < 4; inf++) {
  86696. weight = matricesWeightsExtraData[matWeightIdx + inf];
  86697. if (weight > 0) {
  86698. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  86699. finalMatrix.addToSelf(tempMatrix);
  86700. }
  86701. }
  86702. }
  86703. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinatesFromFloatsToRef(this._sourcePositions[index], this._sourcePositions[index + 1], this._sourcePositions[index + 2], finalMatrix, tempVector3);
  86704. tempVector3.toArray(positionsData, index);
  86705. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalFromFloatsToRef(this._sourceNormals[index], this._sourceNormals[index + 1], this._sourceNormals[index + 2], finalMatrix, tempVector3);
  86706. tempVector3.toArray(normalsData, index);
  86707. finalMatrix.reset();
  86708. }
  86709. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positionsData);
  86710. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normalsData);
  86711. return this;
  86712. };
  86713. // Tools
  86714. /**
  86715. * 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
  86716. * @param meshes defines the list of meshes to scan
  86717. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  86718. */
  86719. Mesh.MinMax = function (meshes) {
  86720. var minVector = null;
  86721. var maxVector = null;
  86722. meshes.forEach(function (mesh) {
  86723. var boundingInfo = mesh.getBoundingInfo();
  86724. var boundingBox = boundingInfo.boundingBox;
  86725. if (!minVector || !maxVector) {
  86726. minVector = boundingBox.minimumWorld;
  86727. maxVector = boundingBox.maximumWorld;
  86728. }
  86729. else {
  86730. minVector.minimizeInPlace(boundingBox.minimumWorld);
  86731. maxVector.maximizeInPlace(boundingBox.maximumWorld);
  86732. }
  86733. });
  86734. if (!minVector || !maxVector) {
  86735. return {
  86736. min: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero(),
  86737. max: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero()
  86738. };
  86739. }
  86740. return {
  86741. min: minVector,
  86742. max: maxVector
  86743. };
  86744. };
  86745. /**
  86746. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  86747. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  86748. * @returns a vector3
  86749. */
  86750. Mesh.Center = function (meshesOrMinMaxVector) {
  86751. var minMaxVector = (meshesOrMinMaxVector instanceof Array) ? Mesh.MinMax(meshesOrMinMaxVector) : meshesOrMinMaxVector;
  86752. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Center(minMaxVector.min, minMaxVector.max);
  86753. };
  86754. /**
  86755. * Merge the array of meshes into a single mesh for performance reasons.
  86756. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  86757. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  86758. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  86759. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  86760. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  86761. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  86762. * @returns a new mesh
  86763. */
  86764. Mesh.MergeMeshes = function (meshes, disposeSource, allow32BitsIndices, meshSubclass, subdivideWithSubMeshes, multiMultiMaterials) {
  86765. if (disposeSource === void 0) { disposeSource = true; }
  86766. var index;
  86767. if (!allow32BitsIndices) {
  86768. var totalVertices = 0;
  86769. // Counting vertices
  86770. for (index = 0; index < meshes.length; index++) {
  86771. if (meshes[index]) {
  86772. totalVertices += meshes[index].getTotalVertices();
  86773. if (totalVertices > 65536) {
  86774. _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");
  86775. return null;
  86776. }
  86777. }
  86778. }
  86779. }
  86780. if (multiMultiMaterials) {
  86781. var newMultiMaterial = null;
  86782. var subIndex;
  86783. var matIndex;
  86784. subdivideWithSubMeshes = false;
  86785. }
  86786. var materialArray = new Array();
  86787. var materialIndexArray = new Array();
  86788. // Merge
  86789. var vertexData = null;
  86790. var otherVertexData;
  86791. var indiceArray = new Array();
  86792. var source = null;
  86793. for (index = 0; index < meshes.length; index++) {
  86794. if (meshes[index]) {
  86795. var mesh = meshes[index];
  86796. var wm = mesh.computeWorldMatrix(true);
  86797. otherVertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(mesh, true, true);
  86798. otherVertexData.transform(wm);
  86799. if (vertexData) {
  86800. vertexData.merge(otherVertexData, allow32BitsIndices);
  86801. }
  86802. else {
  86803. vertexData = otherVertexData;
  86804. source = mesh;
  86805. }
  86806. if (subdivideWithSubMeshes) {
  86807. indiceArray.push(mesh.getTotalIndices());
  86808. }
  86809. if (multiMultiMaterials) {
  86810. if (mesh.material) {
  86811. var material = mesh.material;
  86812. if (material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"]) {
  86813. for (matIndex = 0; matIndex < material.subMaterials.length; matIndex++) {
  86814. if (materialArray.indexOf(material.subMaterials[matIndex]) < 0) {
  86815. materialArray.push(material.subMaterials[matIndex]);
  86816. }
  86817. }
  86818. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  86819. materialIndexArray.push(materialArray.indexOf(material.subMaterials[mesh.subMeshes[subIndex].materialIndex]));
  86820. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  86821. }
  86822. }
  86823. else {
  86824. if (materialArray.indexOf(material) < 0) {
  86825. materialArray.push(material);
  86826. }
  86827. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  86828. materialIndexArray.push(materialArray.indexOf(material));
  86829. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  86830. }
  86831. }
  86832. }
  86833. else {
  86834. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  86835. materialIndexArray.push(0);
  86836. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  86837. }
  86838. }
  86839. }
  86840. }
  86841. }
  86842. source = source;
  86843. if (!meshSubclass) {
  86844. meshSubclass = new Mesh(source.name + "_merged", source.getScene());
  86845. }
  86846. vertexData.applyToMesh(meshSubclass);
  86847. // Setting properties
  86848. meshSubclass.checkCollisions = source.checkCollisions;
  86849. // Cleaning
  86850. if (disposeSource) {
  86851. for (index = 0; index < meshes.length; index++) {
  86852. if (meshes[index]) {
  86853. meshes[index].dispose();
  86854. }
  86855. }
  86856. }
  86857. // Subdivide
  86858. if (subdivideWithSubMeshes || multiMultiMaterials) {
  86859. //-- removal of global submesh
  86860. meshSubclass.releaseSubMeshes();
  86861. index = 0;
  86862. var offset = 0;
  86863. //-- apply subdivision according to index table
  86864. while (index < indiceArray.length) {
  86865. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, indiceArray[index], meshSubclass);
  86866. offset += indiceArray[index];
  86867. index++;
  86868. }
  86869. }
  86870. if (multiMultiMaterials) {
  86871. newMultiMaterial = new _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"](source.name + "_merged", source.getScene());
  86872. newMultiMaterial.subMaterials = materialArray;
  86873. for (subIndex = 0; subIndex < meshSubclass.subMeshes.length; subIndex++) {
  86874. meshSubclass.subMeshes[subIndex].materialIndex = materialIndexArray[subIndex];
  86875. }
  86876. meshSubclass.material = newMultiMaterial;
  86877. }
  86878. else {
  86879. meshSubclass.material = source.material;
  86880. }
  86881. return meshSubclass;
  86882. };
  86883. /** @hidden */
  86884. Mesh.prototype.addInstance = function (instance) {
  86885. instance._indexInSourceMeshInstanceArray = this.instances.length;
  86886. this.instances.push(instance);
  86887. };
  86888. /** @hidden */
  86889. Mesh.prototype.removeInstance = function (instance) {
  86890. // Remove from mesh
  86891. var index = instance._indexInSourceMeshInstanceArray;
  86892. if (index != -1) {
  86893. if (index !== this.instances.length - 1) {
  86894. var last = this.instances[this.instances.length - 1];
  86895. this.instances[index] = last;
  86896. last._indexInSourceMeshInstanceArray = index;
  86897. }
  86898. instance._indexInSourceMeshInstanceArray = -1;
  86899. this.instances.pop();
  86900. }
  86901. };
  86902. // Consts
  86903. /**
  86904. * Mesh side orientation : usually the external or front surface
  86905. */
  86906. Mesh.FRONTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].FRONTSIDE;
  86907. /**
  86908. * Mesh side orientation : usually the internal or back surface
  86909. */
  86910. Mesh.BACKSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].BACKSIDE;
  86911. /**
  86912. * Mesh side orientation : both internal and external or front and back surfaces
  86913. */
  86914. Mesh.DOUBLESIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DOUBLESIDE;
  86915. /**
  86916. * Mesh side orientation : by default, `FRONTSIDE`
  86917. */
  86918. Mesh.DEFAULTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DEFAULTSIDE;
  86919. /**
  86920. * Mesh cap setting : no cap
  86921. */
  86922. Mesh.NO_CAP = 0;
  86923. /**
  86924. * Mesh cap setting : one cap at the beginning of the mesh
  86925. */
  86926. Mesh.CAP_START = 1;
  86927. /**
  86928. * Mesh cap setting : one cap at the end of the mesh
  86929. */
  86930. Mesh.CAP_END = 2;
  86931. /**
  86932. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  86933. */
  86934. Mesh.CAP_ALL = 3;
  86935. // Statics
  86936. /** @hidden */
  86937. Mesh._GroundMeshParser = function (parsedMesh, scene) {
  86938. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("GroundMesh");
  86939. };
  86940. return Mesh;
  86941. }(_abstractMesh__WEBPACK_IMPORTED_MODULE_10__["AbstractMesh"]));
  86942. /***/ }),
  86943. /***/ "./Meshes/mesh.vertexData.ts":
  86944. /*!***********************************!*\
  86945. !*** ./Meshes/mesh.vertexData.ts ***!
  86946. \***********************************/
  86947. /*! exports provided: VertexData */
  86948. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  86949. "use strict";
  86950. __webpack_require__.r(__webpack_exports__);
  86951. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return VertexData; });
  86952. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  86953. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  86954. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  86955. /**
  86956. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  86957. */
  86958. var VertexData = /** @class */ (function () {
  86959. function VertexData() {
  86960. }
  86961. /**
  86962. * Uses the passed data array to set the set the values for the specified kind of data
  86963. * @param data a linear array of floating numbers
  86964. * @param kind the type of data that is being set, eg positions, colors etc
  86965. */
  86966. VertexData.prototype.set = function (data, kind) {
  86967. switch (kind) {
  86968. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind:
  86969. this.positions = data;
  86970. break;
  86971. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind:
  86972. this.normals = data;
  86973. break;
  86974. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind:
  86975. this.tangents = data;
  86976. break;
  86977. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind:
  86978. this.uvs = data;
  86979. break;
  86980. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind:
  86981. this.uvs2 = data;
  86982. break;
  86983. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind:
  86984. this.uvs3 = data;
  86985. break;
  86986. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind:
  86987. this.uvs4 = data;
  86988. break;
  86989. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind:
  86990. this.uvs5 = data;
  86991. break;
  86992. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind:
  86993. this.uvs6 = data;
  86994. break;
  86995. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind:
  86996. this.colors = data;
  86997. break;
  86998. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind:
  86999. this.matricesIndices = data;
  87000. break;
  87001. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind:
  87002. this.matricesWeights = data;
  87003. break;
  87004. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind:
  87005. this.matricesIndicesExtra = data;
  87006. break;
  87007. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind:
  87008. this.matricesWeightsExtra = data;
  87009. break;
  87010. }
  87011. };
  87012. /**
  87013. * Associates the vertexData to the passed Mesh.
  87014. * Sets it as updatable or not (default `false`)
  87015. * @param mesh the mesh the vertexData is applied to
  87016. * @param updatable when used and having the value true allows new data to update the vertexData
  87017. * @returns the VertexData
  87018. */
  87019. VertexData.prototype.applyToMesh = function (mesh, updatable) {
  87020. this._applyTo(mesh, updatable);
  87021. return this;
  87022. };
  87023. /**
  87024. * Associates the vertexData to the passed Geometry.
  87025. * Sets it as updatable or not (default `false`)
  87026. * @param geometry the geometry the vertexData is applied to
  87027. * @param updatable when used and having the value true allows new data to update the vertexData
  87028. * @returns VertexData
  87029. */
  87030. VertexData.prototype.applyToGeometry = function (geometry, updatable) {
  87031. this._applyTo(geometry, updatable);
  87032. return this;
  87033. };
  87034. /**
  87035. * Updates the associated mesh
  87036. * @param mesh the mesh to be updated
  87037. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87038. * @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
  87039. * @returns VertexData
  87040. */
  87041. VertexData.prototype.updateMesh = function (mesh) {
  87042. this._update(mesh);
  87043. return this;
  87044. };
  87045. /**
  87046. * Updates the associated geometry
  87047. * @param geometry the geometry to be updated
  87048. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87049. * @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
  87050. * @returns VertexData.
  87051. */
  87052. VertexData.prototype.updateGeometry = function (geometry) {
  87053. this._update(geometry);
  87054. return this;
  87055. };
  87056. VertexData.prototype._applyTo = function (meshOrGeometry, updatable) {
  87057. if (updatable === void 0) { updatable = false; }
  87058. if (this.positions) {
  87059. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updatable);
  87060. }
  87061. if (this.normals) {
  87062. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updatable);
  87063. }
  87064. if (this.tangents) {
  87065. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updatable);
  87066. }
  87067. if (this.uvs) {
  87068. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updatable);
  87069. }
  87070. if (this.uvs2) {
  87071. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updatable);
  87072. }
  87073. if (this.uvs3) {
  87074. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updatable);
  87075. }
  87076. if (this.uvs4) {
  87077. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updatable);
  87078. }
  87079. if (this.uvs5) {
  87080. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updatable);
  87081. }
  87082. if (this.uvs6) {
  87083. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updatable);
  87084. }
  87085. if (this.colors) {
  87086. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updatable);
  87087. }
  87088. if (this.matricesIndices) {
  87089. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updatable);
  87090. }
  87091. if (this.matricesWeights) {
  87092. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updatable);
  87093. }
  87094. if (this.matricesIndicesExtra) {
  87095. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updatable);
  87096. }
  87097. if (this.matricesWeightsExtra) {
  87098. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updatable);
  87099. }
  87100. if (this.indices) {
  87101. meshOrGeometry.setIndices(this.indices, null, updatable);
  87102. }
  87103. else {
  87104. meshOrGeometry.setIndices([], null);
  87105. }
  87106. return this;
  87107. };
  87108. VertexData.prototype._update = function (meshOrGeometry, updateExtends, makeItUnique) {
  87109. if (this.positions) {
  87110. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updateExtends, makeItUnique);
  87111. }
  87112. if (this.normals) {
  87113. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updateExtends, makeItUnique);
  87114. }
  87115. if (this.tangents) {
  87116. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updateExtends, makeItUnique);
  87117. }
  87118. if (this.uvs) {
  87119. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updateExtends, makeItUnique);
  87120. }
  87121. if (this.uvs2) {
  87122. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updateExtends, makeItUnique);
  87123. }
  87124. if (this.uvs3) {
  87125. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updateExtends, makeItUnique);
  87126. }
  87127. if (this.uvs4) {
  87128. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updateExtends, makeItUnique);
  87129. }
  87130. if (this.uvs5) {
  87131. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updateExtends, makeItUnique);
  87132. }
  87133. if (this.uvs6) {
  87134. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updateExtends, makeItUnique);
  87135. }
  87136. if (this.colors) {
  87137. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updateExtends, makeItUnique);
  87138. }
  87139. if (this.matricesIndices) {
  87140. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updateExtends, makeItUnique);
  87141. }
  87142. if (this.matricesWeights) {
  87143. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updateExtends, makeItUnique);
  87144. }
  87145. if (this.matricesIndicesExtra) {
  87146. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updateExtends, makeItUnique);
  87147. }
  87148. if (this.matricesWeightsExtra) {
  87149. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updateExtends, makeItUnique);
  87150. }
  87151. if (this.indices) {
  87152. meshOrGeometry.setIndices(this.indices, null);
  87153. }
  87154. return this;
  87155. };
  87156. /**
  87157. * Transforms each position and each normal of the vertexData according to the passed Matrix
  87158. * @param matrix the transforming matrix
  87159. * @returns the VertexData
  87160. */
  87161. VertexData.prototype.transform = function (matrix) {
  87162. var flip = matrix.m[0] * matrix.m[5] * matrix.m[10] < 0;
  87163. var transformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87164. var index;
  87165. if (this.positions) {
  87166. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87167. for (index = 0; index < this.positions.length; index += 3) {
  87168. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.positions, index, position);
  87169. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(position, matrix, transformed);
  87170. this.positions[index] = transformed.x;
  87171. this.positions[index + 1] = transformed.y;
  87172. this.positions[index + 2] = transformed.z;
  87173. }
  87174. }
  87175. if (this.normals) {
  87176. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87177. for (index = 0; index < this.normals.length; index += 3) {
  87178. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.normals, index, normal);
  87179. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(normal, matrix, transformed);
  87180. this.normals[index] = transformed.x;
  87181. this.normals[index + 1] = transformed.y;
  87182. this.normals[index + 2] = transformed.z;
  87183. }
  87184. }
  87185. if (this.tangents) {
  87186. var tangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  87187. var tangentTransformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  87188. for (index = 0; index < this.tangents.length; index += 4) {
  87189. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].FromArrayToRef(this.tangents, index, tangent);
  87190. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].TransformNormalToRef(tangent, matrix, tangentTransformed);
  87191. this.tangents[index] = tangentTransformed.x;
  87192. this.tangents[index + 1] = tangentTransformed.y;
  87193. this.tangents[index + 2] = tangentTransformed.z;
  87194. this.tangents[index + 3] = tangentTransformed.w;
  87195. }
  87196. }
  87197. if (flip && this.indices) {
  87198. for (index = 0; index < this.indices.length; index += 3) {
  87199. var tmp = this.indices[index + 1];
  87200. this.indices[index + 1] = this.indices[index + 2];
  87201. this.indices[index + 2] = tmp;
  87202. }
  87203. }
  87204. return this;
  87205. };
  87206. /**
  87207. * Merges the passed VertexData into the current one
  87208. * @param other the VertexData to be merged into the current one
  87209. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  87210. * @returns the modified VertexData
  87211. */
  87212. VertexData.prototype.merge = function (other, use32BitsIndices) {
  87213. if (use32BitsIndices === void 0) { use32BitsIndices = false; }
  87214. this._validate();
  87215. other._validate();
  87216. if (!this.normals !== !other.normals ||
  87217. !this.tangents !== !other.tangents ||
  87218. !this.uvs !== !other.uvs ||
  87219. !this.uvs2 !== !other.uvs2 ||
  87220. !this.uvs3 !== !other.uvs3 ||
  87221. !this.uvs4 !== !other.uvs4 ||
  87222. !this.uvs5 !== !other.uvs5 ||
  87223. !this.uvs6 !== !other.uvs6 ||
  87224. !this.colors !== !other.colors ||
  87225. !this.matricesIndices !== !other.matricesIndices ||
  87226. !this.matricesWeights !== !other.matricesWeights ||
  87227. !this.matricesIndicesExtra !== !other.matricesIndicesExtra ||
  87228. !this.matricesWeightsExtra !== !other.matricesWeightsExtra) {
  87229. throw new Error("Cannot merge vertex data that do not have the same set of attributes");
  87230. }
  87231. if (other.indices) {
  87232. if (!this.indices) {
  87233. this.indices = [];
  87234. }
  87235. var offset = this.positions ? this.positions.length / 3 : 0;
  87236. var isSrcTypedArray = this.indices.BYTES_PER_ELEMENT !== undefined;
  87237. if (isSrcTypedArray) {
  87238. var len = this.indices.length + other.indices.length;
  87239. var temp = use32BitsIndices || this.indices instanceof Uint32Array ? new Uint32Array(len) : new Uint16Array(len);
  87240. temp.set(this.indices);
  87241. var decal = this.indices.length;
  87242. for (var index = 0; index < other.indices.length; index++) {
  87243. temp[decal + index] = other.indices[index] + offset;
  87244. }
  87245. this.indices = temp;
  87246. }
  87247. else {
  87248. for (var index = 0; index < other.indices.length; index++) {
  87249. this.indices.push(other.indices[index] + offset);
  87250. }
  87251. }
  87252. }
  87253. this.positions = this._mergeElement(this.positions, other.positions);
  87254. this.normals = this._mergeElement(this.normals, other.normals);
  87255. this.tangents = this._mergeElement(this.tangents, other.tangents);
  87256. this.uvs = this._mergeElement(this.uvs, other.uvs);
  87257. this.uvs2 = this._mergeElement(this.uvs2, other.uvs2);
  87258. this.uvs3 = this._mergeElement(this.uvs3, other.uvs3);
  87259. this.uvs4 = this._mergeElement(this.uvs4, other.uvs4);
  87260. this.uvs5 = this._mergeElement(this.uvs5, other.uvs5);
  87261. this.uvs6 = this._mergeElement(this.uvs6, other.uvs6);
  87262. this.colors = this._mergeElement(this.colors, other.colors);
  87263. this.matricesIndices = this._mergeElement(this.matricesIndices, other.matricesIndices);
  87264. this.matricesWeights = this._mergeElement(this.matricesWeights, other.matricesWeights);
  87265. this.matricesIndicesExtra = this._mergeElement(this.matricesIndicesExtra, other.matricesIndicesExtra);
  87266. this.matricesWeightsExtra = this._mergeElement(this.matricesWeightsExtra, other.matricesWeightsExtra);
  87267. return this;
  87268. };
  87269. VertexData.prototype._mergeElement = function (source, other) {
  87270. if (!source) {
  87271. return other;
  87272. }
  87273. if (!other) {
  87274. return source;
  87275. }
  87276. var len = other.length + source.length;
  87277. var isSrcTypedArray = source instanceof Float32Array;
  87278. var isOthTypedArray = other instanceof Float32Array;
  87279. // use non-loop method when the source is Float32Array
  87280. if (isSrcTypedArray) {
  87281. var ret32 = new Float32Array(len);
  87282. ret32.set(source);
  87283. ret32.set(other, source.length);
  87284. return ret32;
  87285. // source is number[], when other is also use concat
  87286. }
  87287. else if (!isOthTypedArray) {
  87288. return source.concat(other);
  87289. // source is a number[], but other is a Float32Array, loop required
  87290. }
  87291. else {
  87292. var ret = source.slice(0); // copy source to a separate array
  87293. for (var i = 0, len = other.length; i < len; i++) {
  87294. ret.push(other[i]);
  87295. }
  87296. return ret;
  87297. }
  87298. };
  87299. VertexData.prototype._validate = function () {
  87300. if (!this.positions) {
  87301. throw new Error("Positions are required");
  87302. }
  87303. var getElementCount = function (kind, values) {
  87304. var stride = _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].DeduceStride(kind);
  87305. if ((values.length % stride) !== 0) {
  87306. throw new Error("The " + kind + "s array count must be a multiple of " + stride);
  87307. }
  87308. return values.length / stride;
  87309. };
  87310. var positionsElementCount = getElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions);
  87311. var validateElementCount = function (kind, values) {
  87312. var elementCount = getElementCount(kind, values);
  87313. if (elementCount !== positionsElementCount) {
  87314. throw new Error("The " + kind + "s element count (" + elementCount + ") does not match the positions count (" + positionsElementCount + ")");
  87315. }
  87316. };
  87317. if (this.normals) {
  87318. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals);
  87319. }
  87320. if (this.tangents) {
  87321. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents);
  87322. }
  87323. if (this.uvs) {
  87324. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs);
  87325. }
  87326. if (this.uvs2) {
  87327. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2);
  87328. }
  87329. if (this.uvs3) {
  87330. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3);
  87331. }
  87332. if (this.uvs4) {
  87333. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4);
  87334. }
  87335. if (this.uvs5) {
  87336. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5);
  87337. }
  87338. if (this.uvs6) {
  87339. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6);
  87340. }
  87341. if (this.colors) {
  87342. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors);
  87343. }
  87344. if (this.matricesIndices) {
  87345. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices);
  87346. }
  87347. if (this.matricesWeights) {
  87348. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights);
  87349. }
  87350. if (this.matricesIndicesExtra) {
  87351. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra);
  87352. }
  87353. if (this.matricesWeightsExtra) {
  87354. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra);
  87355. }
  87356. };
  87357. /**
  87358. * Serializes the VertexData
  87359. * @returns a serialized object
  87360. */
  87361. VertexData.prototype.serialize = function () {
  87362. var serializationObject = this.serialize();
  87363. if (this.positions) {
  87364. serializationObject.positions = this.positions;
  87365. }
  87366. if (this.normals) {
  87367. serializationObject.normals = this.normals;
  87368. }
  87369. if (this.tangents) {
  87370. serializationObject.tangents = this.tangents;
  87371. }
  87372. if (this.uvs) {
  87373. serializationObject.uvs = this.uvs;
  87374. }
  87375. if (this.uvs2) {
  87376. serializationObject.uvs2 = this.uvs2;
  87377. }
  87378. if (this.uvs3) {
  87379. serializationObject.uvs3 = this.uvs3;
  87380. }
  87381. if (this.uvs4) {
  87382. serializationObject.uvs4 = this.uvs4;
  87383. }
  87384. if (this.uvs5) {
  87385. serializationObject.uvs5 = this.uvs5;
  87386. }
  87387. if (this.uvs6) {
  87388. serializationObject.uvs6 = this.uvs6;
  87389. }
  87390. if (this.colors) {
  87391. serializationObject.colors = this.colors;
  87392. }
  87393. if (this.matricesIndices) {
  87394. serializationObject.matricesIndices = this.matricesIndices;
  87395. serializationObject.matricesIndices._isExpanded = true;
  87396. }
  87397. if (this.matricesWeights) {
  87398. serializationObject.matricesWeights = this.matricesWeights;
  87399. }
  87400. if (this.matricesIndicesExtra) {
  87401. serializationObject.matricesIndicesExtra = this.matricesIndicesExtra;
  87402. serializationObject.matricesIndicesExtra._isExpanded = true;
  87403. }
  87404. if (this.matricesWeightsExtra) {
  87405. serializationObject.matricesWeightsExtra = this.matricesWeightsExtra;
  87406. }
  87407. serializationObject.indices = this.indices;
  87408. return serializationObject;
  87409. };
  87410. // Statics
  87411. /**
  87412. * Extracts the vertexData from a mesh
  87413. * @param mesh the mesh from which to extract the VertexData
  87414. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  87415. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87416. * @returns the object VertexData associated to the passed mesh
  87417. */
  87418. VertexData.ExtractFromMesh = function (mesh, copyWhenShared, forceCopy) {
  87419. return VertexData._ExtractFrom(mesh, copyWhenShared, forceCopy);
  87420. };
  87421. /**
  87422. * Extracts the vertexData from the geometry
  87423. * @param geometry the geometry from which to extract the VertexData
  87424. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  87425. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87426. * @returns the object VertexData associated to the passed mesh
  87427. */
  87428. VertexData.ExtractFromGeometry = function (geometry, copyWhenShared, forceCopy) {
  87429. return VertexData._ExtractFrom(geometry, copyWhenShared, forceCopy);
  87430. };
  87431. VertexData._ExtractFrom = function (meshOrGeometry, copyWhenShared, forceCopy) {
  87432. var result = new VertexData();
  87433. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind)) {
  87434. result.positions = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, copyWhenShared, forceCopy);
  87435. }
  87436. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  87437. result.normals = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, copyWhenShared, forceCopy);
  87438. }
  87439. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind)) {
  87440. result.tangents = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, copyWhenShared, forceCopy);
  87441. }
  87442. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  87443. result.uvs = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, copyWhenShared, forceCopy);
  87444. }
  87445. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  87446. result.uvs2 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, copyWhenShared, forceCopy);
  87447. }
  87448. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind)) {
  87449. result.uvs3 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, copyWhenShared, forceCopy);
  87450. }
  87451. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind)) {
  87452. result.uvs4 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, copyWhenShared, forceCopy);
  87453. }
  87454. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind)) {
  87455. result.uvs5 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, copyWhenShared, forceCopy);
  87456. }
  87457. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind)) {
  87458. result.uvs6 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, copyWhenShared, forceCopy);
  87459. }
  87460. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind)) {
  87461. result.colors = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, copyWhenShared, forceCopy);
  87462. }
  87463. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind)) {
  87464. result.matricesIndices = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, copyWhenShared, forceCopy);
  87465. }
  87466. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind)) {
  87467. result.matricesWeights = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, copyWhenShared, forceCopy);
  87468. }
  87469. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind)) {
  87470. result.matricesIndicesExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, copyWhenShared, forceCopy);
  87471. }
  87472. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind)) {
  87473. result.matricesWeightsExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, copyWhenShared, forceCopy);
  87474. }
  87475. result.indices = meshOrGeometry.getIndices(copyWhenShared, forceCopy);
  87476. return result;
  87477. };
  87478. /**
  87479. * Creates the VertexData for a Ribbon
  87480. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  87481. * * pathArray array of paths, each of which an array of successive Vector3
  87482. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  87483. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  87484. * * 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
  87485. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87486. * * 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)
  87487. * * 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)
  87488. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  87489. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  87490. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  87491. * @returns the VertexData of the ribbon
  87492. */
  87493. VertexData.CreateRibbon = function (options) {
  87494. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ribbonBuilder");
  87495. };
  87496. /**
  87497. * Creates the VertexData for a box
  87498. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87499. * * size sets the width, height and depth of the box to the value of size, optional default 1
  87500. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  87501. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  87502. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  87503. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87504. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87505. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87506. * * 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)
  87507. * * 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)
  87508. * @returns the VertexData of the box
  87509. */
  87510. VertexData.CreateBox = function (options) {
  87511. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("boxBuilder");
  87512. };
  87513. /**
  87514. * Creates the VertexData for an ellipsoid, defaults to a sphere
  87515. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87516. * * segments sets the number of horizontal strips optional, default 32
  87517. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  87518. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  87519. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  87520. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  87521. * * 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
  87522. * * 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
  87523. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87524. * * 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)
  87525. * * 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)
  87526. * @returns the VertexData of the ellipsoid
  87527. */
  87528. VertexData.CreateSphere = function (options) {
  87529. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("sphereBuilder");
  87530. };
  87531. /**
  87532. * Creates the VertexData for a cylinder, cone or prism
  87533. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87534. * * height sets the height (y direction) of the cylinder, optional, default 2
  87535. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  87536. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  87537. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  87538. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87539. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  87540. * * 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
  87541. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87542. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87543. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  87544. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  87545. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87546. * * 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)
  87547. * * 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)
  87548. * @returns the VertexData of the cylinder, cone or prism
  87549. */
  87550. VertexData.CreateCylinder = function (options) {
  87551. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("cylinderBuilder");
  87552. };
  87553. /**
  87554. * Creates the VertexData for a torus
  87555. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87556. * * diameter the diameter of the torus, optional default 1
  87557. * * thickness the diameter of the tube forming the torus, optional default 0.5
  87558. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87559. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87560. * * 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)
  87561. * * 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)
  87562. * @returns the VertexData of the torus
  87563. */
  87564. VertexData.CreateTorus = function (options) {
  87565. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusBuilder");
  87566. };
  87567. /**
  87568. * Creates the VertexData of the LineSystem
  87569. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  87570. * - lines an array of lines, each line being an array of successive Vector3
  87571. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  87572. * @returns the VertexData of the LineSystem
  87573. */
  87574. VertexData.CreateLineSystem = function (options) {
  87575. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  87576. };
  87577. /**
  87578. * Create the VertexData for a DashedLines
  87579. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  87580. * - points an array successive Vector3
  87581. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  87582. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  87583. * - dashNb the intended total number of dashes, optional, default 200
  87584. * @returns the VertexData for the DashedLines
  87585. */
  87586. VertexData.CreateDashedLines = function (options) {
  87587. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  87588. };
  87589. /**
  87590. * Creates the VertexData for a Ground
  87591. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87592. * - width the width (x direction) of the ground, optional, default 1
  87593. * - height the height (z direction) of the ground, optional, default 1
  87594. * - subdivisions the number of subdivisions per side, optional, default 1
  87595. * @returns the VertexData of the Ground
  87596. */
  87597. VertexData.CreateGround = function (options) {
  87598. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  87599. };
  87600. /**
  87601. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  87602. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87603. * * xmin the ground minimum X coordinate, optional, default -1
  87604. * * zmin the ground minimum Z coordinate, optional, default -1
  87605. * * xmax the ground maximum X coordinate, optional, default 1
  87606. * * zmax the ground maximum Z coordinate, optional, default 1
  87607. * * 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}
  87608. * * 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}
  87609. * @returns the VertexData of the TiledGround
  87610. */
  87611. VertexData.CreateTiledGround = function (options) {
  87612. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  87613. };
  87614. /**
  87615. * Creates the VertexData of the Ground designed from a heightmap
  87616. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  87617. * * width the width (x direction) of the ground
  87618. * * height the height (z direction) of the ground
  87619. * * subdivisions the number of subdivisions per side
  87620. * * minHeight the minimum altitude on the ground, optional, default 0
  87621. * * maxHeight the maximum altitude on the ground, optional default 1
  87622. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  87623. * * buffer the array holding the image color data
  87624. * * bufferWidth the width of image
  87625. * * bufferHeight the height of image
  87626. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  87627. * @returns the VertexData of the Ground designed from a heightmap
  87628. */
  87629. VertexData.CreateGroundFromHeightMap = function (options) {
  87630. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  87631. };
  87632. /**
  87633. * Creates the VertexData for a Plane
  87634. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  87635. * * size sets the width and height of the plane to the value of size, optional default 1
  87636. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  87637. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  87638. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87639. * * 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)
  87640. * * 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)
  87641. * @returns the VertexData of the box
  87642. */
  87643. VertexData.CreatePlane = function (options) {
  87644. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("planeBuilder");
  87645. };
  87646. /**
  87647. * Creates the VertexData of the Disc or regular Polygon
  87648. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  87649. * * radius the radius of the disc, optional default 0.5
  87650. * * tessellation the number of polygon sides, optional, default 64
  87651. * * 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
  87652. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87653. * * 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)
  87654. * * 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)
  87655. * @returns the VertexData of the box
  87656. */
  87657. VertexData.CreateDisc = function (options) {
  87658. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("discBuilder");
  87659. };
  87660. /**
  87661. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  87662. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  87663. * @param polygon a mesh built from polygonTriangulation.build()
  87664. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87665. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87666. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87667. * @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)
  87668. * @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)
  87669. * @returns the VertexData of the Polygon
  87670. */
  87671. VertexData.CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  87672. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polygonBuilder");
  87673. };
  87674. /**
  87675. * Creates the VertexData of the IcoSphere
  87676. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  87677. * * radius the radius of the IcoSphere, optional default 1
  87678. * * radiusX allows stretching in the x direction, optional, default radius
  87679. * * radiusY allows stretching in the y direction, optional, default radius
  87680. * * radiusZ allows stretching in the z direction, optional, default radius
  87681. * * flat when true creates a flat shaded mesh, optional, default true
  87682. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87683. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87684. * * 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)
  87685. * * 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)
  87686. * @returns the VertexData of the IcoSphere
  87687. */
  87688. VertexData.CreateIcoSphere = function (options) {
  87689. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("icoSphereBuilder");
  87690. };
  87691. // inspired from // http://stemkoski.github.io/Three.js/Polyhedra.html
  87692. /**
  87693. * Creates the VertexData for a Polyhedron
  87694. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  87695. * * type provided types are:
  87696. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  87697. * * 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)
  87698. * * size the size of the IcoSphere, optional default 1
  87699. * * sizeX allows stretching in the x direction, optional, default size
  87700. * * sizeY allows stretching in the y direction, optional, default size
  87701. * * sizeZ allows stretching in the z direction, optional, default size
  87702. * * 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
  87703. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87704. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87705. * * flat when true creates a flat shaded mesh, optional, default true
  87706. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87707. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87708. * * 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)
  87709. * * 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)
  87710. * @returns the VertexData of the Polyhedron
  87711. */
  87712. VertexData.CreatePolyhedron = function (options) {
  87713. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polyhedronBuilder");
  87714. };
  87715. // based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/primitives/TorusKnot.as?spec=svn2473&r=2473
  87716. /**
  87717. * Creates the VertexData for a TorusKnot
  87718. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  87719. * * radius the radius of the torus knot, optional, default 2
  87720. * * tube the thickness of the tube, optional, default 0.5
  87721. * * radialSegments the number of sides on each tube segments, optional, default 32
  87722. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  87723. * * p the number of windings around the z axis, optional, default 2
  87724. * * q the number of windings around the x axis, optional, default 3
  87725. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87726. * * 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)
  87727. * * 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)
  87728. * @returns the VertexData of the Torus Knot
  87729. */
  87730. VertexData.CreateTorusKnot = function (options) {
  87731. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusKnotBuilder");
  87732. };
  87733. // Tools
  87734. /**
  87735. * Compute normals for given positions and indices
  87736. * @param positions an array of vertex positions, [...., x, y, z, ......]
  87737. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  87738. * @param normals an array of vertex normals, [...., x, y, z, ......]
  87739. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  87740. * * facetNormals : optional array of facet normals (vector3)
  87741. * * facetPositions : optional array of facet positions (vector3)
  87742. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  87743. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  87744. * * bInfo : optional bounding info, required for facetPartitioning computation
  87745. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  87746. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  87747. * * useRightHandedSystem: optional boolean to for right handed system computation
  87748. * * depthSort : optional boolean to enable the facet depth sort computation
  87749. * * distanceTo : optional Vector3 to compute the facet depth from this location
  87750. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  87751. */
  87752. VertexData.ComputeNormals = function (positions, indices, normals, options) {
  87753. // temporary scalar variables
  87754. var index = 0; // facet index
  87755. var p1p2x = 0.0; // p1p2 vector x coordinate
  87756. var p1p2y = 0.0; // p1p2 vector y coordinate
  87757. var p1p2z = 0.0; // p1p2 vector z coordinate
  87758. var p3p2x = 0.0; // p3p2 vector x coordinate
  87759. var p3p2y = 0.0; // p3p2 vector y coordinate
  87760. var p3p2z = 0.0; // p3p2 vector z coordinate
  87761. var faceNormalx = 0.0; // facet normal x coordinate
  87762. var faceNormaly = 0.0; // facet normal y coordinate
  87763. var faceNormalz = 0.0; // facet normal z coordinate
  87764. var length = 0.0; // facet normal length before normalization
  87765. var v1x = 0; // vector1 x index in the positions array
  87766. var v1y = 0; // vector1 y index in the positions array
  87767. var v1z = 0; // vector1 z index in the positions array
  87768. var v2x = 0; // vector2 x index in the positions array
  87769. var v2y = 0; // vector2 y index in the positions array
  87770. var v2z = 0; // vector2 z index in the positions array
  87771. var v3x = 0; // vector3 x index in the positions array
  87772. var v3y = 0; // vector3 y index in the positions array
  87773. var v3z = 0; // vector3 z index in the positions array
  87774. var computeFacetNormals = false;
  87775. var computeFacetPositions = false;
  87776. var computeFacetPartitioning = false;
  87777. var computeDepthSort = false;
  87778. var faceNormalSign = 1;
  87779. var ratio = 0;
  87780. var distanceTo = null;
  87781. if (options) {
  87782. computeFacetNormals = (options.facetNormals) ? true : false;
  87783. computeFacetPositions = (options.facetPositions) ? true : false;
  87784. computeFacetPartitioning = (options.facetPartitioning) ? true : false;
  87785. faceNormalSign = (options.useRightHandedSystem === true) ? -1 : 1;
  87786. ratio = options.ratio || 0;
  87787. computeDepthSort = (options.depthSort) ? true : false;
  87788. distanceTo = (options.distanceTo);
  87789. if (computeDepthSort) {
  87790. if (distanceTo === undefined) {
  87791. distanceTo = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87792. }
  87793. var depthSortedFacets = options.depthSortedFacets;
  87794. }
  87795. }
  87796. // facetPartitioning reinit if needed
  87797. var xSubRatio = 0;
  87798. var ySubRatio = 0;
  87799. var zSubRatio = 0;
  87800. var subSq = 0;
  87801. if (computeFacetPartitioning && options && options.bbSize) {
  87802. var ox = 0; // X partitioning index for facet position
  87803. var oy = 0; // Y partinioning index for facet position
  87804. var oz = 0; // Z partinioning index for facet position
  87805. var b1x = 0; // X partitioning index for facet v1 vertex
  87806. var b1y = 0; // Y partitioning index for facet v1 vertex
  87807. var b1z = 0; // z partitioning index for facet v1 vertex
  87808. var b2x = 0; // X partitioning index for facet v2 vertex
  87809. var b2y = 0; // Y partitioning index for facet v2 vertex
  87810. var b2z = 0; // Z partitioning index for facet v2 vertex
  87811. var b3x = 0; // X partitioning index for facet v3 vertex
  87812. var b3y = 0; // Y partitioning index for facet v3 vertex
  87813. var b3z = 0; // Z partitioning index for facet v3 vertex
  87814. var block_idx_o = 0; // facet barycenter block index
  87815. var block_idx_v1 = 0; // v1 vertex block index
  87816. var block_idx_v2 = 0; // v2 vertex block index
  87817. var block_idx_v3 = 0; // v3 vertex block index
  87818. var bbSizeMax = (options.bbSize.x > options.bbSize.y) ? options.bbSize.x : options.bbSize.y;
  87819. bbSizeMax = (bbSizeMax > options.bbSize.z) ? bbSizeMax : options.bbSize.z;
  87820. xSubRatio = options.subDiv.X * ratio / options.bbSize.x;
  87821. ySubRatio = options.subDiv.Y * ratio / options.bbSize.y;
  87822. zSubRatio = options.subDiv.Z * ratio / options.bbSize.z;
  87823. subSq = options.subDiv.max * options.subDiv.max;
  87824. options.facetPartitioning.length = 0;
  87825. }
  87826. // reset the normals
  87827. for (index = 0; index < positions.length; index++) {
  87828. normals[index] = 0.0;
  87829. }
  87830. // Loop : 1 indice triplet = 1 facet
  87831. var nbFaces = (indices.length / 3) | 0;
  87832. for (index = 0; index < nbFaces; index++) {
  87833. // get the indexes of the coordinates of each vertex of the facet
  87834. v1x = indices[index * 3] * 3;
  87835. v1y = v1x + 1;
  87836. v1z = v1x + 2;
  87837. v2x = indices[index * 3 + 1] * 3;
  87838. v2y = v2x + 1;
  87839. v2z = v2x + 2;
  87840. v3x = indices[index * 3 + 2] * 3;
  87841. v3y = v3x + 1;
  87842. v3z = v3x + 2;
  87843. p1p2x = positions[v1x] - positions[v2x]; // compute two vectors per facet : p1p2 and p3p2
  87844. p1p2y = positions[v1y] - positions[v2y];
  87845. p1p2z = positions[v1z] - positions[v2z];
  87846. p3p2x = positions[v3x] - positions[v2x];
  87847. p3p2y = positions[v3y] - positions[v2y];
  87848. p3p2z = positions[v3z] - positions[v2z];
  87849. // compute the face normal with the cross product
  87850. faceNormalx = faceNormalSign * (p1p2y * p3p2z - p1p2z * p3p2y);
  87851. faceNormaly = faceNormalSign * (p1p2z * p3p2x - p1p2x * p3p2z);
  87852. faceNormalz = faceNormalSign * (p1p2x * p3p2y - p1p2y * p3p2x);
  87853. // normalize this normal and store it in the array facetData
  87854. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  87855. length = (length === 0) ? 1.0 : length;
  87856. faceNormalx /= length;
  87857. faceNormaly /= length;
  87858. faceNormalz /= length;
  87859. if (computeFacetNormals && options) {
  87860. options.facetNormals[index].x = faceNormalx;
  87861. options.facetNormals[index].y = faceNormaly;
  87862. options.facetNormals[index].z = faceNormalz;
  87863. }
  87864. if (computeFacetPositions && options) {
  87865. // compute and the facet barycenter coordinates in the array facetPositions
  87866. options.facetPositions[index].x = (positions[v1x] + positions[v2x] + positions[v3x]) / 3.0;
  87867. options.facetPositions[index].y = (positions[v1y] + positions[v2y] + positions[v3y]) / 3.0;
  87868. options.facetPositions[index].z = (positions[v1z] + positions[v2z] + positions[v3z]) / 3.0;
  87869. }
  87870. if (computeFacetPartitioning && options) {
  87871. // store the facet indexes in arrays in the main facetPartitioning array :
  87872. // compute each facet vertex (+ facet barycenter) index in the partiniong array
  87873. ox = Math.floor((options.facetPositions[index].x - options.bInfo.minimum.x * ratio) * xSubRatio);
  87874. oy = Math.floor((options.facetPositions[index].y - options.bInfo.minimum.y * ratio) * ySubRatio);
  87875. oz = Math.floor((options.facetPositions[index].z - options.bInfo.minimum.z * ratio) * zSubRatio);
  87876. b1x = Math.floor((positions[v1x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  87877. b1y = Math.floor((positions[v1y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  87878. b1z = Math.floor((positions[v1z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  87879. b2x = Math.floor((positions[v2x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  87880. b2y = Math.floor((positions[v2y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  87881. b2z = Math.floor((positions[v2z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  87882. b3x = Math.floor((positions[v3x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  87883. b3y = Math.floor((positions[v3y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  87884. b3z = Math.floor((positions[v3z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  87885. block_idx_v1 = b1x + options.subDiv.max * b1y + subSq * b1z;
  87886. block_idx_v2 = b2x + options.subDiv.max * b2y + subSq * b2z;
  87887. block_idx_v3 = b3x + options.subDiv.max * b3y + subSq * b3z;
  87888. block_idx_o = ox + options.subDiv.max * oy + subSq * oz;
  87889. options.facetPartitioning[block_idx_o] = options.facetPartitioning[block_idx_o] ? options.facetPartitioning[block_idx_o] : new Array();
  87890. options.facetPartitioning[block_idx_v1] = options.facetPartitioning[block_idx_v1] ? options.facetPartitioning[block_idx_v1] : new Array();
  87891. options.facetPartitioning[block_idx_v2] = options.facetPartitioning[block_idx_v2] ? options.facetPartitioning[block_idx_v2] : new Array();
  87892. options.facetPartitioning[block_idx_v3] = options.facetPartitioning[block_idx_v3] ? options.facetPartitioning[block_idx_v3] : new Array();
  87893. // push each facet index in each block containing the vertex
  87894. options.facetPartitioning[block_idx_v1].push(index);
  87895. if (block_idx_v2 != block_idx_v1) {
  87896. options.facetPartitioning[block_idx_v2].push(index);
  87897. }
  87898. if (!(block_idx_v3 == block_idx_v2 || block_idx_v3 == block_idx_v1)) {
  87899. options.facetPartitioning[block_idx_v3].push(index);
  87900. }
  87901. if (!(block_idx_o == block_idx_v1 || block_idx_o == block_idx_v2 || block_idx_o == block_idx_v3)) {
  87902. options.facetPartitioning[block_idx_o].push(index);
  87903. }
  87904. }
  87905. if (computeDepthSort && options && options.facetPositions) {
  87906. var dsf = depthSortedFacets[index];
  87907. dsf.ind = index * 3;
  87908. dsf.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(options.facetPositions[index], distanceTo);
  87909. }
  87910. // compute the normals anyway
  87911. normals[v1x] += faceNormalx; // accumulate all the normals per face
  87912. normals[v1y] += faceNormaly;
  87913. normals[v1z] += faceNormalz;
  87914. normals[v2x] += faceNormalx;
  87915. normals[v2y] += faceNormaly;
  87916. normals[v2z] += faceNormalz;
  87917. normals[v3x] += faceNormalx;
  87918. normals[v3y] += faceNormaly;
  87919. normals[v3z] += faceNormalz;
  87920. }
  87921. // last normalization of each normal
  87922. for (index = 0; index < normals.length / 3; index++) {
  87923. faceNormalx = normals[index * 3];
  87924. faceNormaly = normals[index * 3 + 1];
  87925. faceNormalz = normals[index * 3 + 2];
  87926. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  87927. length = (length === 0) ? 1.0 : length;
  87928. faceNormalx /= length;
  87929. faceNormaly /= length;
  87930. faceNormalz /= length;
  87931. normals[index * 3] = faceNormalx;
  87932. normals[index * 3 + 1] = faceNormaly;
  87933. normals[index * 3 + 2] = faceNormalz;
  87934. }
  87935. };
  87936. /** @hidden */
  87937. VertexData._ComputeSides = function (sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs) {
  87938. var li = indices.length;
  87939. var ln = normals.length;
  87940. var i;
  87941. var n;
  87942. sideOrientation = sideOrientation || VertexData.DEFAULTSIDE;
  87943. switch (sideOrientation) {
  87944. case VertexData.FRONTSIDE:
  87945. // nothing changed
  87946. break;
  87947. case VertexData.BACKSIDE:
  87948. var tmp;
  87949. // indices
  87950. for (i = 0; i < li; i += 3) {
  87951. tmp = indices[i];
  87952. indices[i] = indices[i + 2];
  87953. indices[i + 2] = tmp;
  87954. }
  87955. // normals
  87956. for (n = 0; n < ln; n++) {
  87957. normals[n] = -normals[n];
  87958. }
  87959. break;
  87960. case VertexData.DOUBLESIDE:
  87961. // positions
  87962. var lp = positions.length;
  87963. var l = lp / 3;
  87964. for (var p = 0; p < lp; p++) {
  87965. positions[lp + p] = positions[p];
  87966. }
  87967. // indices
  87968. for (i = 0; i < li; i += 3) {
  87969. indices[i + li] = indices[i + 2] + l;
  87970. indices[i + 1 + li] = indices[i + 1] + l;
  87971. indices[i + 2 + li] = indices[i] + l;
  87972. }
  87973. // normals
  87974. for (n = 0; n < ln; n++) {
  87975. normals[ln + n] = -normals[n];
  87976. }
  87977. // uvs
  87978. var lu = uvs.length;
  87979. var u = 0;
  87980. for (u = 0; u < lu; u++) {
  87981. uvs[u + lu] = uvs[u];
  87982. }
  87983. frontUVs = frontUVs ? frontUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  87984. backUVs = backUVs ? backUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  87985. u = 0;
  87986. for (i = 0; i < lu / 2; i++) {
  87987. uvs[u] = frontUVs.x + (frontUVs.z - frontUVs.x) * uvs[u];
  87988. uvs[u + 1] = frontUVs.y + (frontUVs.w - frontUVs.y) * uvs[u + 1];
  87989. uvs[u + lu] = backUVs.x + (backUVs.z - backUVs.x) * uvs[u + lu];
  87990. uvs[u + lu + 1] = backUVs.y + (backUVs.w - backUVs.y) * uvs[u + lu + 1];
  87991. u += 2;
  87992. }
  87993. break;
  87994. }
  87995. };
  87996. /**
  87997. * Applies VertexData created from the imported parameters to the geometry
  87998. * @param parsedVertexData the parsed data from an imported file
  87999. * @param geometry the geometry to apply the VertexData to
  88000. */
  88001. VertexData.ImportVertexData = function (parsedVertexData, geometry) {
  88002. var vertexData = new VertexData();
  88003. // positions
  88004. var positions = parsedVertexData.positions;
  88005. if (positions) {
  88006. vertexData.set(positions, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  88007. }
  88008. // normals
  88009. var normals = parsedVertexData.normals;
  88010. if (normals) {
  88011. vertexData.set(normals, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  88012. }
  88013. // tangents
  88014. var tangents = parsedVertexData.tangents;
  88015. if (tangents) {
  88016. vertexData.set(tangents, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind);
  88017. }
  88018. // uvs
  88019. var uvs = parsedVertexData.uvs;
  88020. if (uvs) {
  88021. vertexData.set(uvs, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  88022. }
  88023. // uv2s
  88024. var uv2s = parsedVertexData.uv2s;
  88025. if (uv2s) {
  88026. vertexData.set(uv2s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  88027. }
  88028. // uv3s
  88029. var uv3s = parsedVertexData.uv3s;
  88030. if (uv3s) {
  88031. vertexData.set(uv3s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind);
  88032. }
  88033. // uv4s
  88034. var uv4s = parsedVertexData.uv4s;
  88035. if (uv4s) {
  88036. vertexData.set(uv4s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind);
  88037. }
  88038. // uv5s
  88039. var uv5s = parsedVertexData.uv5s;
  88040. if (uv5s) {
  88041. vertexData.set(uv5s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind);
  88042. }
  88043. // uv6s
  88044. var uv6s = parsedVertexData.uv6s;
  88045. if (uv6s) {
  88046. vertexData.set(uv6s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind);
  88047. }
  88048. // colors
  88049. var colors = parsedVertexData.colors;
  88050. if (colors) {
  88051. vertexData.set(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"].CheckColors4(colors, positions.length / 3), _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  88052. }
  88053. // matricesIndices
  88054. var matricesIndices = parsedVertexData.matricesIndices;
  88055. if (matricesIndices) {
  88056. vertexData.set(matricesIndices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  88057. }
  88058. // matricesWeights
  88059. var matricesWeights = parsedVertexData.matricesWeights;
  88060. if (matricesWeights) {
  88061. vertexData.set(matricesWeights, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  88062. }
  88063. // indices
  88064. var indices = parsedVertexData.indices;
  88065. if (indices) {
  88066. vertexData.indices = indices;
  88067. }
  88068. geometry.setAllVerticesData(vertexData, parsedVertexData.updatable);
  88069. };
  88070. /**
  88071. * Mesh side orientation : usually the external or front surface
  88072. */
  88073. VertexData.FRONTSIDE = 0;
  88074. /**
  88075. * Mesh side orientation : usually the internal or back surface
  88076. */
  88077. VertexData.BACKSIDE = 1;
  88078. /**
  88079. * Mesh side orientation : both internal and external or front and back surfaces
  88080. */
  88081. VertexData.DOUBLESIDE = 2;
  88082. /**
  88083. * Mesh side orientation : by default, `FRONTSIDE`
  88084. */
  88085. VertexData.DEFAULTSIDE = 0;
  88086. return VertexData;
  88087. }());
  88088. /***/ }),
  88089. /***/ "./Meshes/meshBuilder.ts":
  88090. /*!*******************************!*\
  88091. !*** ./Meshes/meshBuilder.ts ***!
  88092. \*******************************/
  88093. /*! exports provided: MeshBuilder */
  88094. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88095. "use strict";
  88096. __webpack_require__.r(__webpack_exports__);
  88097. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return MeshBuilder; });
  88098. /* harmony import */ var _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Builders/ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  88099. /* harmony import */ var _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  88100. /* harmony import */ var _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  88101. /* harmony import */ var _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  88102. /* harmony import */ var _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  88103. /* harmony import */ var _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  88104. /* harmony import */ var _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Builders/torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  88105. /* harmony import */ var _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  88106. /* harmony import */ var _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Builders/polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  88107. /* harmony import */ var _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Builders/shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  88108. /* harmony import */ var _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Builders/latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  88109. /* harmony import */ var _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  88110. /* harmony import */ var _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  88111. /* harmony import */ var _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Builders/tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  88112. /* harmony import */ var _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  88113. /* harmony import */ var _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Builders/icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  88114. /* harmony import */ var _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Builders/decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  88115. /**
  88116. * Class containing static functions to help procedurally build meshes
  88117. */
  88118. var MeshBuilder = /** @class */ (function () {
  88119. function MeshBuilder() {
  88120. }
  88121. /**
  88122. * Creates a box mesh
  88123. * * The parameter `size` sets the size (float) of each box side (default 1)
  88124. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  88125. * * 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)
  88126. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  88127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88128. * * 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
  88129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88130. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  88131. * @param name defines the name of the mesh
  88132. * @param options defines the options used to create the mesh
  88133. * @param scene defines the hosting scene
  88134. * @returns the box mesh
  88135. */
  88136. MeshBuilder.CreateBox = function (name, options, scene) {
  88137. if (scene === void 0) { scene = null; }
  88138. return _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(name, options, scene);
  88139. };
  88140. /**
  88141. * Creates a sphere mesh
  88142. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  88143. * * 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`)
  88144. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  88145. * * 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
  88146. * * 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)
  88147. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88148. * * 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
  88149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88150. * @param name defines the name of the mesh
  88151. * @param options defines the options used to create the mesh
  88152. * @param scene defines the hosting scene
  88153. * @returns the sphere mesh
  88154. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  88155. */
  88156. MeshBuilder.CreateSphere = function (name, options, scene) {
  88157. return _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"].CreateSphere(name, options, scene);
  88158. };
  88159. /**
  88160. * Creates a plane polygonal mesh. By default, this is a disc
  88161. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  88162. * * 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
  88163. * * 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
  88164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88165. * * 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
  88166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88167. * @param name defines the name of the mesh
  88168. * @param options defines the options used to create the mesh
  88169. * @param scene defines the hosting scene
  88170. * @returns the plane polygonal mesh
  88171. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  88172. */
  88173. MeshBuilder.CreateDisc = function (name, options, scene) {
  88174. if (scene === void 0) { scene = null; }
  88175. return _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"].CreateDisc(name, options, scene);
  88176. };
  88177. /**
  88178. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  88179. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  88180. * * 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`)
  88181. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  88182. * * 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
  88183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88184. * * 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
  88185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88186. * @param name defines the name of the mesh
  88187. * @param options defines the options used to create the mesh
  88188. * @param scene defines the hosting scene
  88189. * @returns the icosahedron mesh
  88190. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  88191. */
  88192. MeshBuilder.CreateIcoSphere = function (name, options, scene) {
  88193. return _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"].CreateIcoSphere(name, options, scene);
  88194. };
  88195. /**
  88196. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  88197. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  88198. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  88199. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  88200. * * 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
  88201. * * 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
  88202. * * 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
  88203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88204. * * 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
  88205. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  88206. * * 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
  88207. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  88208. * * 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
  88209. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  88210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88211. * @param name defines the name of the mesh
  88212. * @param options defines the options used to create the mesh
  88213. * @param scene defines the hosting scene
  88214. * @returns the ribbon mesh
  88215. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  88216. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  88217. */
  88218. MeshBuilder.CreateRibbon = function (name, options, scene) {
  88219. if (scene === void 0) { scene = null; }
  88220. return _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"].CreateRibbon(name, options, scene);
  88221. };
  88222. /**
  88223. * Creates a cylinder or a cone mesh
  88224. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  88225. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  88226. * * 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.
  88227. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  88228. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  88229. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  88230. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  88231. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  88232. * * 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).
  88233. * * 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
  88234. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  88235. * * 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
  88236. * * 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.
  88237. * * If `enclose` is false, a ring surface is one element.
  88238. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  88239. * * 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
  88240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88241. * * 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
  88242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88243. * @param name defines the name of the mesh
  88244. * @param options defines the options used to create the mesh
  88245. * @param scene defines the hosting scene
  88246. * @returns the cylinder mesh
  88247. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  88248. */
  88249. MeshBuilder.CreateCylinder = function (name, options, scene) {
  88250. return _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder(name, options, scene);
  88251. };
  88252. /**
  88253. * Creates a torus mesh
  88254. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  88255. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  88256. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  88257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88258. * * 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
  88259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88260. * @param name defines the name of the mesh
  88261. * @param options defines the options used to create the mesh
  88262. * @param scene defines the hosting scene
  88263. * @returns the torus mesh
  88264. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  88265. */
  88266. MeshBuilder.CreateTorus = function (name, options, scene) {
  88267. return _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"].CreateTorus(name, options, scene);
  88268. };
  88269. /**
  88270. * Creates a torus knot mesh
  88271. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  88272. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  88273. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  88274. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  88275. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88276. * * 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
  88277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88278. * @param name defines the name of the mesh
  88279. * @param options defines the options used to create the mesh
  88280. * @param scene defines the hosting scene
  88281. * @returns the torus knot mesh
  88282. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  88283. */
  88284. MeshBuilder.CreateTorusKnot = function (name, options, scene) {
  88285. return _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"].CreateTorusKnot(name, options, scene);
  88286. };
  88287. /**
  88288. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  88289. * * 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
  88290. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  88291. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  88292. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  88293. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  88294. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  88295. * * 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
  88296. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  88297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88298. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  88299. * @param name defines the name of the new line system
  88300. * @param options defines the options used to create the line system
  88301. * @param scene defines the hosting scene
  88302. * @returns a new line system mesh
  88303. */
  88304. MeshBuilder.CreateLineSystem = function (name, options, scene) {
  88305. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLineSystem(name, options, scene);
  88306. };
  88307. /**
  88308. * Creates a line mesh
  88309. * 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
  88310. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  88311. * * The parameter `points` is an array successive Vector3
  88312. * * 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
  88313. * * The optional parameter `colors` is an array of successive Color4, one per line point
  88314. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  88315. * * When updating an instance, remember that only point positions can change, not the number of points
  88316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88317. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  88318. * @param name defines the name of the new line system
  88319. * @param options defines the options used to create the line system
  88320. * @param scene defines the hosting scene
  88321. * @returns a new line mesh
  88322. */
  88323. MeshBuilder.CreateLines = function (name, options, scene) {
  88324. if (scene === void 0) { scene = null; }
  88325. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLines(name, options, scene);
  88326. };
  88327. /**
  88328. * Creates a dashed line mesh
  88329. * * 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
  88330. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  88331. * * The parameter `points` is an array successive Vector3
  88332. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  88333. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  88334. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  88335. * * 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
  88336. * * When updating an instance, remember that only point positions can change, not the number of points
  88337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88338. * @param name defines the name of the mesh
  88339. * @param options defines the options used to create the mesh
  88340. * @param scene defines the hosting scene
  88341. * @returns the dashed line mesh
  88342. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  88343. */
  88344. MeshBuilder.CreateDashedLines = function (name, options, scene) {
  88345. if (scene === void 0) { scene = null; }
  88346. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateDashedLines(name, options, scene);
  88347. };
  88348. /**
  88349. * 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.
  88350. * * 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.
  88351. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  88352. * * 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.
  88353. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  88354. * * 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
  88355. * * 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
  88356. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  88357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88358. * * 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
  88359. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  88360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88361. * @param name defines the name of the mesh
  88362. * @param options defines the options used to create the mesh
  88363. * @param scene defines the hosting scene
  88364. * @returns the extruded shape mesh
  88365. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  88366. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88367. */
  88368. MeshBuilder.ExtrudeShape = function (name, options, scene) {
  88369. if (scene === void 0) { scene = null; }
  88370. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShape(name, options, scene);
  88371. };
  88372. /**
  88373. * Creates an custom extruded shape mesh.
  88374. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  88375. * * 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.
  88376. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  88377. * * 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
  88378. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  88379. * * 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
  88380. * * It must returns a float value that will be the scale value applied to the shape on each path point
  88381. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  88382. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  88383. * * 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
  88384. * * 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
  88385. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  88386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88387. * * 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
  88388. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  88389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88390. * @param name defines the name of the mesh
  88391. * @param options defines the options used to create the mesh
  88392. * @param scene defines the hosting scene
  88393. * @returns the custom extruded shape mesh
  88394. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  88395. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  88396. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88397. */
  88398. MeshBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  88399. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShapeCustom(name, options, scene);
  88400. };
  88401. /**
  88402. * Creates lathe mesh.
  88403. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  88404. * * 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
  88405. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  88406. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  88407. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  88408. * * 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
  88409. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  88410. * * 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
  88411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88412. * * 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
  88413. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  88414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88415. * @param name defines the name of the mesh
  88416. * @param options defines the options used to create the mesh
  88417. * @param scene defines the hosting scene
  88418. * @returns the lathe mesh
  88419. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  88420. */
  88421. MeshBuilder.CreateLathe = function (name, options, scene) {
  88422. return _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"].CreateLathe(name, options, scene);
  88423. };
  88424. /**
  88425. * Creates a plane mesh
  88426. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  88427. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  88428. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  88429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88430. * * 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
  88431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88432. * @param name defines the name of the mesh
  88433. * @param options defines the options used to create the mesh
  88434. * @param scene defines the hosting scene
  88435. * @returns the plane mesh
  88436. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  88437. */
  88438. MeshBuilder.CreatePlane = function (name, options, scene) {
  88439. return _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"].CreatePlane(name, options, scene);
  88440. };
  88441. /**
  88442. * Creates a ground mesh
  88443. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  88444. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  88445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88446. * @param name defines the name of the mesh
  88447. * @param options defines the options used to create the mesh
  88448. * @param scene defines the hosting scene
  88449. * @returns the ground mesh
  88450. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  88451. */
  88452. MeshBuilder.CreateGround = function (name, options, scene) {
  88453. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGround(name, options, scene);
  88454. };
  88455. /**
  88456. * Creates a tiled ground mesh
  88457. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  88458. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  88459. * * 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
  88460. * * 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
  88461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88462. * @param name defines the name of the mesh
  88463. * @param options defines the options used to create the mesh
  88464. * @param scene defines the hosting scene
  88465. * @returns the tiled ground mesh
  88466. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  88467. */
  88468. MeshBuilder.CreateTiledGround = function (name, options, scene) {
  88469. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateTiledGround(name, options, scene);
  88470. };
  88471. /**
  88472. * Creates a ground mesh from a height map
  88473. * * The parameter `url` sets the URL of the height map image resource.
  88474. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  88475. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  88476. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  88477. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  88478. * * 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.
  88479. * * 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).
  88480. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  88481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88482. * @param name defines the name of the mesh
  88483. * @param url defines the url to the height map
  88484. * @param options defines the options used to create the mesh
  88485. * @param scene defines the hosting scene
  88486. * @returns the ground mesh
  88487. * @see https://doc.babylonjs.com/babylon101/height_map
  88488. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  88489. */
  88490. MeshBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  88491. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGroundFromHeightMap(name, url, options, scene);
  88492. };
  88493. /**
  88494. * Creates a polygon mesh
  88495. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  88496. * * 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
  88497. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88499. * * 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)
  88500. * * Remember you can only change the shape positions, not their number when updating a polygon
  88501. * @param name defines the name of the mesh
  88502. * @param options defines the options used to create the mesh
  88503. * @param scene defines the hosting scene
  88504. * @param earcutInjection can be used to inject your own earcut reference
  88505. * @returns the polygon mesh
  88506. */
  88507. MeshBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  88508. if (earcutInjection === void 0) { earcutInjection = earcut; }
  88509. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].CreatePolygon(name, options, scene, earcutInjection);
  88510. };
  88511. /**
  88512. * Creates an extruded polygon mesh, with depth in the Y direction.
  88513. * * 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)
  88514. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  88515. * @param name defines the name of the mesh
  88516. * @param options defines the options used to create the mesh
  88517. * @param scene defines the hosting scene
  88518. * @param earcutInjection can be used to inject your own earcut reference
  88519. * @returns the polygon mesh
  88520. */
  88521. MeshBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  88522. if (earcutInjection === void 0) { earcutInjection = earcut; }
  88523. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].ExtrudePolygon(name, options, scene, earcutInjection);
  88524. };
  88525. /**
  88526. * Creates a tube mesh.
  88527. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  88528. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  88529. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  88530. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  88531. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  88532. * * 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)
  88533. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  88534. * * 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
  88535. * * 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
  88536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88537. * * 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
  88538. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  88539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88540. * @param name defines the name of the mesh
  88541. * @param options defines the options used to create the mesh
  88542. * @param scene defines the hosting scene
  88543. * @returns the tube mesh
  88544. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  88545. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  88546. */
  88547. MeshBuilder.CreateTube = function (name, options, scene) {
  88548. return _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"].CreateTube(name, options, scene);
  88549. };
  88550. /**
  88551. * Creates a polyhedron mesh
  88552. * * 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
  88553. * * The parameter `size` (positive float, default 1) sets the polygon size
  88554. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  88555. * * 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`
  88556. * * 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
  88557. * * 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)`)
  88558. * * 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
  88559. * * 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
  88560. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88561. * * 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
  88562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88563. * @param name defines the name of the mesh
  88564. * @param options defines the options used to create the mesh
  88565. * @param scene defines the hosting scene
  88566. * @returns the polyhedron mesh
  88567. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  88568. */
  88569. MeshBuilder.CreatePolyhedron = function (name, options, scene) {
  88570. return _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"].CreatePolyhedron(name, options, scene);
  88571. };
  88572. /**
  88573. * Creates a decal mesh.
  88574. * 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
  88575. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  88576. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  88577. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  88578. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  88579. * @param name defines the name of the mesh
  88580. * @param sourceMesh defines the mesh where the decal must be applied
  88581. * @param options defines the options used to create the mesh
  88582. * @param scene defines the hosting scene
  88583. * @returns the decal mesh
  88584. * @see https://doc.babylonjs.com/how_to/decals
  88585. */
  88586. MeshBuilder.CreateDecal = function (name, sourceMesh, options) {
  88587. return _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"].CreateDecal(name, sourceMesh, options);
  88588. };
  88589. return MeshBuilder;
  88590. }());
  88591. /***/ }),
  88592. /***/ "./Meshes/meshSimplification.ts":
  88593. /*!**************************************!*\
  88594. !*** ./Meshes/meshSimplification.ts ***!
  88595. \**************************************/
  88596. /*! exports provided: SimplificationSettings, SimplificationQueue, SimplificationType */
  88597. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88598. "use strict";
  88599. __webpack_require__.r(__webpack_exports__);
  88600. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return SimplificationSettings; });
  88601. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return SimplificationQueue; });
  88602. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return SimplificationType; });
  88603. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  88604. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  88605. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  88606. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  88607. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  88608. /**
  88609. * Class used to specify simplification options
  88610. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  88611. */
  88612. var SimplificationSettings = /** @class */ (function () {
  88613. /**
  88614. * Creates a SimplificationSettings
  88615. * @param quality expected quality
  88616. * @param distance distance when this optimized version should be used
  88617. * @param optimizeMesh already optimized mesh
  88618. */
  88619. function SimplificationSettings(
  88620. /** expected quality */
  88621. quality,
  88622. /** distance when this optimized version should be used */
  88623. distance,
  88624. /** already optimized mesh */
  88625. optimizeMesh) {
  88626. this.quality = quality;
  88627. this.distance = distance;
  88628. this.optimizeMesh = optimizeMesh;
  88629. }
  88630. return SimplificationSettings;
  88631. }());
  88632. /**
  88633. * Queue used to order the simplification tasks
  88634. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  88635. */
  88636. var SimplificationQueue = /** @class */ (function () {
  88637. /**
  88638. * Creates a new queue
  88639. */
  88640. function SimplificationQueue() {
  88641. this.running = false;
  88642. this._simplificationArray = [];
  88643. }
  88644. /**
  88645. * Adds a new simplification task
  88646. * @param task defines a task to add
  88647. */
  88648. SimplificationQueue.prototype.addTask = function (task) {
  88649. this._simplificationArray.push(task);
  88650. };
  88651. /**
  88652. * Execute next task
  88653. */
  88654. SimplificationQueue.prototype.executeNext = function () {
  88655. var task = this._simplificationArray.pop();
  88656. if (task) {
  88657. this.running = true;
  88658. this.runSimplification(task);
  88659. }
  88660. else {
  88661. this.running = false;
  88662. }
  88663. };
  88664. /**
  88665. * Execute a simplification task
  88666. * @param task defines the task to run
  88667. */
  88668. SimplificationQueue.prototype.runSimplification = function (task) {
  88669. var _this = this;
  88670. if (task.parallelProcessing) {
  88671. //parallel simplifier
  88672. task.settings.forEach(function (setting) {
  88673. var simplifier = _this.getSimplifier(task);
  88674. simplifier.simplify(setting, function (newMesh) {
  88675. task.mesh.addLODLevel(setting.distance, newMesh);
  88676. newMesh.isVisible = true;
  88677. //check if it is the last
  88678. if (setting.quality === task.settings[task.settings.length - 1].quality && task.successCallback) {
  88679. //all done, run the success callback.
  88680. task.successCallback();
  88681. }
  88682. _this.executeNext();
  88683. });
  88684. });
  88685. }
  88686. else {
  88687. //single simplifier.
  88688. var simplifier = this.getSimplifier(task);
  88689. var runDecimation = function (setting, callback) {
  88690. simplifier.simplify(setting, function (newMesh) {
  88691. task.mesh.addLODLevel(setting.distance, newMesh);
  88692. newMesh.isVisible = true;
  88693. //run the next quality level
  88694. callback();
  88695. });
  88696. };
  88697. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(task.settings.length, function (loop) {
  88698. runDecimation(task.settings[loop.index], function () {
  88699. loop.executeNext();
  88700. });
  88701. }, function () {
  88702. //execution ended, run the success callback.
  88703. if (task.successCallback) {
  88704. task.successCallback();
  88705. }
  88706. _this.executeNext();
  88707. });
  88708. }
  88709. };
  88710. SimplificationQueue.prototype.getSimplifier = function (task) {
  88711. switch (task.simplificationType) {
  88712. case SimplificationType.QUADRATIC:
  88713. default:
  88714. return new QuadraticErrorSimplification(task.mesh);
  88715. }
  88716. };
  88717. return SimplificationQueue;
  88718. }());
  88719. /**
  88720. * The implemented types of simplification
  88721. * At the moment only Quadratic Error Decimation is implemented
  88722. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  88723. */
  88724. var SimplificationType;
  88725. (function (SimplificationType) {
  88726. /** Quadratic error decimation */
  88727. SimplificationType[SimplificationType["QUADRATIC"] = 0] = "QUADRATIC";
  88728. })(SimplificationType || (SimplificationType = {}));
  88729. var DecimationTriangle = /** @class */ (function () {
  88730. function DecimationTriangle(vertices) {
  88731. this.vertices = vertices;
  88732. this.error = new Array(4);
  88733. this.deleted = false;
  88734. this.isDirty = false;
  88735. this.deletePending = false;
  88736. this.borderFactor = 0;
  88737. }
  88738. return DecimationTriangle;
  88739. }());
  88740. var DecimationVertex = /** @class */ (function () {
  88741. function DecimationVertex(position, id) {
  88742. this.position = position;
  88743. this.id = id;
  88744. this.isBorder = true;
  88745. this.q = new QuadraticMatrix();
  88746. this.triangleCount = 0;
  88747. this.triangleStart = 0;
  88748. this.originalOffsets = [];
  88749. }
  88750. DecimationVertex.prototype.updatePosition = function (newPosition) {
  88751. this.position.copyFrom(newPosition);
  88752. };
  88753. return DecimationVertex;
  88754. }());
  88755. var QuadraticMatrix = /** @class */ (function () {
  88756. function QuadraticMatrix(data) {
  88757. this.data = new Array(10);
  88758. for (var i = 0; i < 10; ++i) {
  88759. if (data && data[i]) {
  88760. this.data[i] = data[i];
  88761. }
  88762. else {
  88763. this.data[i] = 0;
  88764. }
  88765. }
  88766. }
  88767. QuadraticMatrix.prototype.det = function (a11, a12, a13, a21, a22, a23, a31, a32, a33) {
  88768. var det = this.data[a11] * this.data[a22] * this.data[a33] + this.data[a13] * this.data[a21] * this.data[a32] +
  88769. this.data[a12] * this.data[a23] * this.data[a31] - this.data[a13] * this.data[a22] * this.data[a31] -
  88770. this.data[a11] * this.data[a23] * this.data[a32] - this.data[a12] * this.data[a21] * this.data[a33];
  88771. return det;
  88772. };
  88773. QuadraticMatrix.prototype.addInPlace = function (matrix) {
  88774. for (var i = 0; i < 10; ++i) {
  88775. this.data[i] += matrix.data[i];
  88776. }
  88777. };
  88778. QuadraticMatrix.prototype.addArrayInPlace = function (data) {
  88779. for (var i = 0; i < 10; ++i) {
  88780. this.data[i] += data[i];
  88781. }
  88782. };
  88783. QuadraticMatrix.prototype.add = function (matrix) {
  88784. var m = new QuadraticMatrix();
  88785. for (var i = 0; i < 10; ++i) {
  88786. m.data[i] = this.data[i] + matrix.data[i];
  88787. }
  88788. return m;
  88789. };
  88790. QuadraticMatrix.FromData = function (a, b, c, d) {
  88791. return new QuadraticMatrix(QuadraticMatrix.DataFromNumbers(a, b, c, d));
  88792. };
  88793. //returning an array to avoid garbage collection
  88794. QuadraticMatrix.DataFromNumbers = function (a, b, c, d) {
  88795. return [a * a, a * b, a * c, a * d, b * b, b * c, b * d, c * c, c * d, d * d];
  88796. };
  88797. return QuadraticMatrix;
  88798. }());
  88799. var Reference = /** @class */ (function () {
  88800. function Reference(vertexId, triangleId) {
  88801. this.vertexId = vertexId;
  88802. this.triangleId = triangleId;
  88803. }
  88804. return Reference;
  88805. }());
  88806. /**
  88807. * An implementation of the Quadratic Error simplification algorithm.
  88808. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  88809. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  88810. * @author RaananW
  88811. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  88812. */
  88813. var QuadraticErrorSimplification = /** @class */ (function () {
  88814. function QuadraticErrorSimplification(_mesh) {
  88815. this._mesh = _mesh;
  88816. this.syncIterations = 5000;
  88817. this.aggressiveness = 7;
  88818. this.decimationIterations = 100;
  88819. this.boundingBoxEpsilon = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"];
  88820. }
  88821. QuadraticErrorSimplification.prototype.simplify = function (settings, successCallback) {
  88822. var _this = this;
  88823. this.initDecimatedMesh();
  88824. //iterating through the submeshes array, one after the other.
  88825. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this._mesh.subMeshes.length, function (loop) {
  88826. _this.initWithMesh(loop.index, function () {
  88827. _this.runDecimation(settings, loop.index, function () {
  88828. loop.executeNext();
  88829. });
  88830. }, settings.optimizeMesh);
  88831. }, function () {
  88832. setTimeout(function () {
  88833. successCallback(_this._reconstructedMesh);
  88834. }, 0);
  88835. });
  88836. };
  88837. QuadraticErrorSimplification.prototype.runDecimation = function (settings, submeshIndex, successCallback) {
  88838. var _this = this;
  88839. var targetCount = ~~(this.triangles.length * settings.quality);
  88840. var deletedTriangles = 0;
  88841. var triangleCount = this.triangles.length;
  88842. var iterationFunction = function (iteration, callback) {
  88843. setTimeout(function () {
  88844. if (iteration % 5 === 0) {
  88845. _this.updateMesh(iteration === 0);
  88846. }
  88847. for (var i = 0; i < _this.triangles.length; ++i) {
  88848. _this.triangles[i].isDirty = false;
  88849. }
  88850. var threshold = 0.000000001 * Math.pow((iteration + 3), _this.aggressiveness);
  88851. var trianglesIterator = function (i) {
  88852. var tIdx = ~~(((_this.triangles.length / 2) + i) % _this.triangles.length);
  88853. var t = _this.triangles[tIdx];
  88854. if (!t) {
  88855. return;
  88856. }
  88857. if (t.error[3] > threshold || t.deleted || t.isDirty) {
  88858. return;
  88859. }
  88860. for (var j = 0; j < 3; ++j) {
  88861. if (t.error[j] < threshold) {
  88862. var deleted0 = [];
  88863. var deleted1 = [];
  88864. var v0 = t.vertices[j];
  88865. var v1 = t.vertices[(j + 1) % 3];
  88866. if (v0.isBorder || v1.isBorder) {
  88867. continue;
  88868. }
  88869. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  88870. // var n = Vector3.Zero();
  88871. // var uv = Vector2.Zero();
  88872. // var color = new Color4(0, 0, 0, 1);
  88873. _this.calculateError(v0, v1, p);
  88874. var delTr = new Array();
  88875. if (_this.isFlipped(v0, v1, p, deleted0, delTr)) {
  88876. continue;
  88877. }
  88878. if (_this.isFlipped(v1, v0, p, deleted1, delTr)) {
  88879. continue;
  88880. }
  88881. if (deleted0.indexOf(true) < 0 || deleted1.indexOf(true) < 0) {
  88882. continue;
  88883. }
  88884. var uniqueArray = new Array();
  88885. delTr.forEach(function (deletedT) {
  88886. if (uniqueArray.indexOf(deletedT) === -1) {
  88887. deletedT.deletePending = true;
  88888. uniqueArray.push(deletedT);
  88889. }
  88890. });
  88891. if (uniqueArray.length % 2 !== 0) {
  88892. continue;
  88893. }
  88894. v0.q = v1.q.add(v0.q);
  88895. v0.updatePosition(p);
  88896. var tStart = _this.references.length;
  88897. deletedTriangles = _this.updateTriangles(v0, v0, deleted0, deletedTriangles);
  88898. deletedTriangles = _this.updateTriangles(v0, v1, deleted1, deletedTriangles);
  88899. var tCount = _this.references.length - tStart;
  88900. if (tCount <= v0.triangleCount) {
  88901. if (tCount) {
  88902. for (var c = 0; c < tCount; c++) {
  88903. _this.references[v0.triangleStart + c] = _this.references[tStart + c];
  88904. }
  88905. }
  88906. }
  88907. else {
  88908. v0.triangleStart = tStart;
  88909. }
  88910. v0.triangleCount = tCount;
  88911. break;
  88912. }
  88913. }
  88914. };
  88915. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, trianglesIterator, callback, function () { return (triangleCount - deletedTriangles <= targetCount); });
  88916. }, 0);
  88917. };
  88918. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this.decimationIterations, function (loop) {
  88919. if (triangleCount - deletedTriangles <= targetCount) {
  88920. loop.breakLoop();
  88921. }
  88922. else {
  88923. iterationFunction(loop.index, function () {
  88924. loop.executeNext();
  88925. });
  88926. }
  88927. }, function () {
  88928. setTimeout(function () {
  88929. //reconstruct this part of the mesh
  88930. _this.reconstructMesh(submeshIndex);
  88931. successCallback();
  88932. }, 0);
  88933. });
  88934. };
  88935. QuadraticErrorSimplification.prototype.initWithMesh = function (submeshIndex, callback, optimizeMesh) {
  88936. var _this = this;
  88937. this.vertices = [];
  88938. this.triangles = [];
  88939. var positionData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  88940. var indices = this._mesh.getIndices();
  88941. var submesh = this._mesh.subMeshes[submeshIndex];
  88942. var findInVertices = function (positionToSearch) {
  88943. if (optimizeMesh) {
  88944. for (var ii = 0; ii < _this.vertices.length; ++ii) {
  88945. if (_this.vertices[ii].position.equals(positionToSearch)) {
  88946. return _this.vertices[ii];
  88947. }
  88948. }
  88949. }
  88950. return null;
  88951. };
  88952. var vertexReferences = [];
  88953. var vertexInit = function (i) {
  88954. if (!positionData) {
  88955. return;
  88956. }
  88957. var offset = i + submesh.verticesStart;
  88958. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positionData, offset * 3);
  88959. var vertex = findInVertices(position) || new DecimationVertex(position, _this.vertices.length);
  88960. vertex.originalOffsets.push(offset);
  88961. if (vertex.id === _this.vertices.length) {
  88962. _this.vertices.push(vertex);
  88963. }
  88964. vertexReferences.push(vertex.id);
  88965. };
  88966. //var totalVertices = mesh.getTotalVertices();
  88967. var totalVertices = submesh.verticesCount;
  88968. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(totalVertices, (this.syncIterations / 4) >> 0, vertexInit, function () {
  88969. var indicesInit = function (i) {
  88970. if (!indices) {
  88971. return;
  88972. }
  88973. var offset = (submesh.indexStart / 3) + i;
  88974. var pos = (offset * 3);
  88975. var i0 = indices[pos + 0];
  88976. var i1 = indices[pos + 1];
  88977. var i2 = indices[pos + 2];
  88978. var v0 = _this.vertices[vertexReferences[i0 - submesh.verticesStart]];
  88979. var v1 = _this.vertices[vertexReferences[i1 - submesh.verticesStart]];
  88980. var v2 = _this.vertices[vertexReferences[i2 - submesh.verticesStart]];
  88981. var triangle = new DecimationTriangle([v0, v1, v2]);
  88982. triangle.originalOffset = pos;
  88983. _this.triangles.push(triangle);
  88984. };
  88985. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(submesh.indexCount / 3, _this.syncIterations, indicesInit, function () {
  88986. _this.init(callback);
  88987. });
  88988. });
  88989. };
  88990. QuadraticErrorSimplification.prototype.init = function (callback) {
  88991. var _this = this;
  88992. var triangleInit1 = function (i) {
  88993. var t = _this.triangles[i];
  88994. 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();
  88995. for (var j = 0; j < 3; j++) {
  88996. 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))));
  88997. }
  88998. };
  88999. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(this.triangles.length, this.syncIterations, triangleInit1, function () {
  89000. var triangleInit2 = function (i) {
  89001. var t = _this.triangles[i];
  89002. for (var j = 0; j < 3; ++j) {
  89003. t.error[j] = _this.calculateError(t.vertices[j], t.vertices[(j + 1) % 3]);
  89004. }
  89005. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  89006. };
  89007. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, triangleInit2, function () {
  89008. callback();
  89009. });
  89010. });
  89011. };
  89012. QuadraticErrorSimplification.prototype.reconstructMesh = function (submeshIndex) {
  89013. var newTriangles = [];
  89014. var i;
  89015. for (i = 0; i < this.vertices.length; ++i) {
  89016. this.vertices[i].triangleCount = 0;
  89017. }
  89018. var t;
  89019. var j;
  89020. for (i = 0; i < this.triangles.length; ++i) {
  89021. if (!this.triangles[i].deleted) {
  89022. t = this.triangles[i];
  89023. for (j = 0; j < 3; ++j) {
  89024. t.vertices[j].triangleCount = 1;
  89025. }
  89026. newTriangles.push(t);
  89027. }
  89028. }
  89029. var newPositionData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind) || []);
  89030. var newNormalData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind) || []);
  89031. var newUVsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind) || []);
  89032. var newColorsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind) || []);
  89033. var normalData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  89034. var uvs = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  89035. var colorsData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  89036. var vertexCount = 0;
  89037. for (i = 0; i < this.vertices.length; ++i) {
  89038. var vertex = this.vertices[i];
  89039. vertex.id = vertexCount;
  89040. if (vertex.triangleCount) {
  89041. vertex.originalOffsets.forEach(function (originalOffset) {
  89042. if (!normalData) {
  89043. return;
  89044. }
  89045. newPositionData.push(vertex.position.x);
  89046. newPositionData.push(vertex.position.y);
  89047. newPositionData.push(vertex.position.z);
  89048. newNormalData.push(normalData[originalOffset * 3]);
  89049. newNormalData.push(normalData[(originalOffset * 3) + 1]);
  89050. newNormalData.push(normalData[(originalOffset * 3) + 2]);
  89051. if (uvs && uvs.length) {
  89052. newUVsData.push(uvs[(originalOffset * 2)]);
  89053. newUVsData.push(uvs[(originalOffset * 2) + 1]);
  89054. }
  89055. else if (colorsData && colorsData.length) {
  89056. newColorsData.push(colorsData[(originalOffset * 4)]);
  89057. newColorsData.push(colorsData[(originalOffset * 4) + 1]);
  89058. newColorsData.push(colorsData[(originalOffset * 4) + 2]);
  89059. newColorsData.push(colorsData[(originalOffset * 4) + 3]);
  89060. }
  89061. ++vertexCount;
  89062. });
  89063. }
  89064. }
  89065. var startingIndex = this._reconstructedMesh.getTotalIndices();
  89066. var startingVertex = this._reconstructedMesh.getTotalVertices();
  89067. var submeshesArray = this._reconstructedMesh.subMeshes;
  89068. this._reconstructedMesh.subMeshes = [];
  89069. var newIndicesArray = this._reconstructedMesh.getIndices(); //[];
  89070. var originalIndices = this._mesh.getIndices();
  89071. for (i = 0; i < newTriangles.length; ++i) {
  89072. t = newTriangles[i]; //now get the new referencing point for each vertex
  89073. [0, 1, 2].forEach(function (idx) {
  89074. var id = originalIndices[t.originalOffset + idx];
  89075. var offset = t.vertices[idx].originalOffsets.indexOf(id);
  89076. if (offset < 0) {
  89077. offset = 0;
  89078. }
  89079. newIndicesArray.push(t.vertices[idx].id + offset + startingVertex);
  89080. });
  89081. }
  89082. //overwriting the old vertex buffers and indices.
  89083. this._reconstructedMesh.setIndices(newIndicesArray);
  89084. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, newPositionData);
  89085. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, newNormalData);
  89086. if (newUVsData.length > 0) {
  89087. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, newUVsData);
  89088. }
  89089. if (newColorsData.length > 0) {
  89090. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, newColorsData);
  89091. }
  89092. //create submesh
  89093. var originalSubmesh = this._mesh.subMeshes[submeshIndex];
  89094. if (submeshIndex > 0) {
  89095. this._reconstructedMesh.subMeshes = [];
  89096. submeshesArray.forEach(function (submesh) {
  89097. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(submesh.materialIndex, submesh.verticesStart, submesh.verticesCount, /* 0, newPositionData.length/3, */ submesh.indexStart, submesh.indexCount, submesh.getMesh());
  89098. });
  89099. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(originalSubmesh.materialIndex, startingVertex, vertexCount, /* 0, newPositionData.length / 3, */ startingIndex, newTriangles.length * 3, this._reconstructedMesh);
  89100. }
  89101. };
  89102. QuadraticErrorSimplification.prototype.initDecimatedMesh = function () {
  89103. this._reconstructedMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this._mesh.name + "Decimated", this._mesh.getScene());
  89104. this._reconstructedMesh.material = this._mesh.material;
  89105. this._reconstructedMesh.parent = this._mesh.parent;
  89106. this._reconstructedMesh.isVisible = false;
  89107. this._reconstructedMesh.renderingGroupId = this._mesh.renderingGroupId;
  89108. };
  89109. QuadraticErrorSimplification.prototype.isFlipped = function (vertex1, vertex2, point, deletedArray, delTr) {
  89110. for (var i = 0; i < vertex1.triangleCount; ++i) {
  89111. var t = this.triangles[this.references[vertex1.triangleStart + i].triangleId];
  89112. if (t.deleted) {
  89113. continue;
  89114. }
  89115. var s = this.references[vertex1.triangleStart + i].vertexId;
  89116. var v1 = t.vertices[(s + 1) % 3];
  89117. var v2 = t.vertices[(s + 2) % 3];
  89118. if ((v1 === vertex2 || v2 === vertex2)) {
  89119. deletedArray[i] = true;
  89120. delTr.push(t);
  89121. continue;
  89122. }
  89123. var d1 = v1.position.subtract(point);
  89124. d1 = d1.normalize();
  89125. var d2 = v2.position.subtract(point);
  89126. d2 = d2.normalize();
  89127. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(d1, d2)) > 0.999) {
  89128. return true;
  89129. }
  89130. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(d1, d2).normalize();
  89131. deletedArray[i] = false;
  89132. if (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(normal, t.normal) < 0.2) {
  89133. return true;
  89134. }
  89135. }
  89136. return false;
  89137. };
  89138. QuadraticErrorSimplification.prototype.updateTriangles = function (origVertex, vertex, deletedArray, deletedTriangles) {
  89139. var newDeleted = deletedTriangles;
  89140. for (var i = 0; i < vertex.triangleCount; ++i) {
  89141. var ref = this.references[vertex.triangleStart + i];
  89142. var t = this.triangles[ref.triangleId];
  89143. if (t.deleted) {
  89144. continue;
  89145. }
  89146. if (deletedArray[i] && t.deletePending) {
  89147. t.deleted = true;
  89148. newDeleted++;
  89149. continue;
  89150. }
  89151. t.vertices[ref.vertexId] = origVertex;
  89152. t.isDirty = true;
  89153. t.error[0] = this.calculateError(t.vertices[0], t.vertices[1]) + (t.borderFactor / 2);
  89154. t.error[1] = this.calculateError(t.vertices[1], t.vertices[2]) + (t.borderFactor / 2);
  89155. t.error[2] = this.calculateError(t.vertices[2], t.vertices[0]) + (t.borderFactor / 2);
  89156. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  89157. this.references.push(ref);
  89158. }
  89159. return newDeleted;
  89160. };
  89161. QuadraticErrorSimplification.prototype.identifyBorder = function () {
  89162. for (var i = 0; i < this.vertices.length; ++i) {
  89163. var vCount = [];
  89164. var vId = [];
  89165. var v = this.vertices[i];
  89166. var j;
  89167. for (j = 0; j < v.triangleCount; ++j) {
  89168. var triangle = this.triangles[this.references[v.triangleStart + j].triangleId];
  89169. for (var ii = 0; ii < 3; ii++) {
  89170. var ofs = 0;
  89171. var vv = triangle.vertices[ii];
  89172. while (ofs < vCount.length) {
  89173. if (vId[ofs] === vv.id) {
  89174. break;
  89175. }
  89176. ++ofs;
  89177. }
  89178. if (ofs === vCount.length) {
  89179. vCount.push(1);
  89180. vId.push(vv.id);
  89181. }
  89182. else {
  89183. vCount[ofs]++;
  89184. }
  89185. }
  89186. }
  89187. for (j = 0; j < vCount.length; ++j) {
  89188. if (vCount[j] === 1) {
  89189. this.vertices[vId[j]].isBorder = true;
  89190. }
  89191. else {
  89192. this.vertices[vId[j]].isBorder = false;
  89193. }
  89194. }
  89195. }
  89196. };
  89197. QuadraticErrorSimplification.prototype.updateMesh = function (identifyBorders) {
  89198. if (identifyBorders === void 0) { identifyBorders = false; }
  89199. var i;
  89200. if (!identifyBorders) {
  89201. var newTrianglesVector = [];
  89202. for (i = 0; i < this.triangles.length; ++i) {
  89203. if (!this.triangles[i].deleted) {
  89204. newTrianglesVector.push(this.triangles[i]);
  89205. }
  89206. }
  89207. this.triangles = newTrianglesVector;
  89208. }
  89209. for (i = 0; i < this.vertices.length; ++i) {
  89210. this.vertices[i].triangleCount = 0;
  89211. this.vertices[i].triangleStart = 0;
  89212. }
  89213. var t;
  89214. var j;
  89215. var v;
  89216. for (i = 0; i < this.triangles.length; ++i) {
  89217. t = this.triangles[i];
  89218. for (j = 0; j < 3; ++j) {
  89219. v = t.vertices[j];
  89220. v.triangleCount++;
  89221. }
  89222. }
  89223. var tStart = 0;
  89224. for (i = 0; i < this.vertices.length; ++i) {
  89225. this.vertices[i].triangleStart = tStart;
  89226. tStart += this.vertices[i].triangleCount;
  89227. this.vertices[i].triangleCount = 0;
  89228. }
  89229. var newReferences = new Array(this.triangles.length * 3);
  89230. for (i = 0; i < this.triangles.length; ++i) {
  89231. t = this.triangles[i];
  89232. for (j = 0; j < 3; ++j) {
  89233. v = t.vertices[j];
  89234. newReferences[v.triangleStart + v.triangleCount] = new Reference(j, i);
  89235. v.triangleCount++;
  89236. }
  89237. }
  89238. this.references = newReferences;
  89239. if (identifyBorders) {
  89240. this.identifyBorder();
  89241. }
  89242. };
  89243. QuadraticErrorSimplification.prototype.vertexError = function (q, point) {
  89244. var x = point.x;
  89245. var y = point.y;
  89246. var z = point.z;
  89247. 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
  89248. + 2 * q.data[5] * y * z + 2 * q.data[6] * y + q.data[7] * z * z + 2 * q.data[8] * z + q.data[9];
  89249. };
  89250. QuadraticErrorSimplification.prototype.calculateError = function (vertex1, vertex2, pointResult) {
  89251. var q = vertex1.q.add(vertex2.q);
  89252. var border = vertex1.isBorder && vertex2.isBorder;
  89253. var error = 0;
  89254. var qDet = q.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
  89255. if (qDet !== 0 && !border) {
  89256. if (!pointResult) {
  89257. pointResult = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  89258. }
  89259. pointResult.x = -1 / qDet * (q.det(1, 2, 3, 4, 5, 6, 5, 7, 8));
  89260. pointResult.y = 1 / qDet * (q.det(0, 2, 3, 1, 5, 6, 2, 7, 8));
  89261. pointResult.z = -1 / qDet * (q.det(0, 1, 3, 1, 4, 6, 2, 5, 8));
  89262. error = this.vertexError(q, pointResult);
  89263. }
  89264. else {
  89265. var p3 = (vertex1.position.add(vertex2.position)).divide(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](2, 2, 2));
  89266. //var norm3 = (vertex1.normal.add(vertex2.normal)).divide(new Vector3(2, 2, 2)).normalize();
  89267. var error1 = this.vertexError(q, vertex1.position);
  89268. var error2 = this.vertexError(q, vertex2.position);
  89269. var error3 = this.vertexError(q, p3);
  89270. error = Math.min(error1, error2, error3);
  89271. if (error === error1) {
  89272. if (pointResult) {
  89273. pointResult.copyFrom(vertex1.position);
  89274. }
  89275. }
  89276. else if (error === error2) {
  89277. if (pointResult) {
  89278. pointResult.copyFrom(vertex2.position);
  89279. }
  89280. }
  89281. else {
  89282. if (pointResult) {
  89283. pointResult.copyFrom(p3);
  89284. }
  89285. }
  89286. }
  89287. return error;
  89288. };
  89289. return QuadraticErrorSimplification;
  89290. }());
  89291. /***/ }),
  89292. /***/ "./Meshes/meshSimplificationSceneComponent.ts":
  89293. /*!****************************************************!*\
  89294. !*** ./Meshes/meshSimplificationSceneComponent.ts ***!
  89295. \****************************************************/
  89296. /*! exports provided: SimplicationQueueSceneComponent */
  89297. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89298. "use strict";
  89299. __webpack_require__.r(__webpack_exports__);
  89300. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return SimplicationQueueSceneComponent; });
  89301. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  89302. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  89303. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  89304. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  89305. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "simplificationQueue", {
  89306. get: function () {
  89307. if (!this._simplificationQueue) {
  89308. this._simplificationQueue = new _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationQueue"]();
  89309. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE);
  89310. if (!component) {
  89311. component = new SimplicationQueueSceneComponent(this);
  89312. this._addComponent(component);
  89313. }
  89314. }
  89315. return this._simplificationQueue;
  89316. },
  89317. set: function (value) {
  89318. this._simplificationQueue = value;
  89319. },
  89320. enumerable: true,
  89321. configurable: true
  89322. });
  89323. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].prototype.simplify = function (settings, parallelProcessing, simplificationType, successCallback) {
  89324. if (parallelProcessing === void 0) { parallelProcessing = true; }
  89325. if (simplificationType === void 0) { simplificationType = _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationType"].QUADRATIC; }
  89326. this.getScene().simplificationQueue.addTask({
  89327. settings: settings,
  89328. parallelProcessing: parallelProcessing,
  89329. mesh: this,
  89330. simplificationType: simplificationType,
  89331. successCallback: successCallback
  89332. });
  89333. return this;
  89334. };
  89335. /**
  89336. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  89337. * created in a scene
  89338. */
  89339. var SimplicationQueueSceneComponent = /** @class */ (function () {
  89340. /**
  89341. * Creates a new instance of the component for the given scene
  89342. * @param scene Defines the scene to register the component in
  89343. */
  89344. function SimplicationQueueSceneComponent(scene) {
  89345. /**
  89346. * The component name helpfull to identify the component in the list of scene components.
  89347. */
  89348. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE;
  89349. this.scene = scene;
  89350. }
  89351. /**
  89352. * Registers the component in a given scene
  89353. */
  89354. SimplicationQueueSceneComponent.prototype.register = function () {
  89355. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE, this, this._beforeCameraUpdate);
  89356. };
  89357. /**
  89358. * Rebuilds the elements related to this component in case of
  89359. * context lost for instance.
  89360. */
  89361. SimplicationQueueSceneComponent.prototype.rebuild = function () {
  89362. // Nothing to do for this component
  89363. };
  89364. /**
  89365. * Disposes the component and the associated ressources
  89366. */
  89367. SimplicationQueueSceneComponent.prototype.dispose = function () {
  89368. // Nothing to do for this component
  89369. };
  89370. SimplicationQueueSceneComponent.prototype._beforeCameraUpdate = function () {
  89371. if (this.scene._simplificationQueue && !this.scene._simplificationQueue.running) {
  89372. this.scene._simplificationQueue.executeNext();
  89373. }
  89374. };
  89375. return SimplicationQueueSceneComponent;
  89376. }());
  89377. /***/ }),
  89378. /***/ "./Meshes/polygonMesh.ts":
  89379. /*!*******************************!*\
  89380. !*** ./Meshes/polygonMesh.ts ***!
  89381. \*******************************/
  89382. /*! exports provided: Polygon, PolygonMeshBuilder */
  89383. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89384. "use strict";
  89385. __webpack_require__.r(__webpack_exports__);
  89386. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return Polygon; });
  89387. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return PolygonMeshBuilder; });
  89388. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  89389. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  89390. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  89391. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  89392. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  89393. /**
  89394. * Vector2 wth index property
  89395. */
  89396. var IndexedVector2 = /** @class */ (function (_super) {
  89397. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IndexedVector2, _super);
  89398. function IndexedVector2(original,
  89399. /** Index of the vector2 */
  89400. index) {
  89401. var _this = _super.call(this, original.x, original.y) || this;
  89402. _this.index = index;
  89403. return _this;
  89404. }
  89405. return IndexedVector2;
  89406. }(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"]));
  89407. /**
  89408. * Defines points to create a polygon
  89409. */
  89410. var PolygonPoints = /** @class */ (function () {
  89411. function PolygonPoints() {
  89412. this.elements = new Array();
  89413. }
  89414. PolygonPoints.prototype.add = function (originalPoints) {
  89415. var _this = this;
  89416. var result = new Array();
  89417. originalPoints.forEach(function (point) {
  89418. if (result.length === 0 || !point.equalsWithEpsilon(result[0])) {
  89419. var newPoint = new IndexedVector2(point, _this.elements.length);
  89420. result.push(newPoint);
  89421. _this.elements.push(newPoint);
  89422. }
  89423. });
  89424. return result;
  89425. };
  89426. PolygonPoints.prototype.computeBounds = function () {
  89427. var lmin = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  89428. var lmax = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  89429. this.elements.forEach(function (point) {
  89430. // x
  89431. if (point.x < lmin.x) {
  89432. lmin.x = point.x;
  89433. }
  89434. else if (point.x > lmax.x) {
  89435. lmax.x = point.x;
  89436. }
  89437. // y
  89438. if (point.y < lmin.y) {
  89439. lmin.y = point.y;
  89440. }
  89441. else if (point.y > lmax.y) {
  89442. lmax.y = point.y;
  89443. }
  89444. });
  89445. return {
  89446. min: lmin,
  89447. max: lmax,
  89448. width: lmax.x - lmin.x,
  89449. height: lmax.y - lmin.y
  89450. };
  89451. };
  89452. return PolygonPoints;
  89453. }());
  89454. /**
  89455. * Polygon
  89456. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  89457. */
  89458. var Polygon = /** @class */ (function () {
  89459. function Polygon() {
  89460. }
  89461. /**
  89462. * Creates a rectangle
  89463. * @param xmin bottom X coord
  89464. * @param ymin bottom Y coord
  89465. * @param xmax top X coord
  89466. * @param ymax top Y coord
  89467. * @returns points that make the resulting rectation
  89468. */
  89469. Polygon.Rectangle = function (xmin, ymin, xmax, ymax) {
  89470. return [
  89471. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymin),
  89472. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymin),
  89473. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymax),
  89474. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymax)
  89475. ];
  89476. };
  89477. /**
  89478. * Creates a circle
  89479. * @param radius radius of circle
  89480. * @param cx scale in x
  89481. * @param cy scale in y
  89482. * @param numberOfSides number of sides that make up the circle
  89483. * @returns points that make the resulting circle
  89484. */
  89485. Polygon.Circle = function (radius, cx, cy, numberOfSides) {
  89486. if (cx === void 0) { cx = 0; }
  89487. if (cy === void 0) { cy = 0; }
  89488. if (numberOfSides === void 0) { numberOfSides = 32; }
  89489. var result = new Array();
  89490. var angle = 0;
  89491. var increment = (Math.PI * 2) / numberOfSides;
  89492. for (var i = 0; i < numberOfSides; i++) {
  89493. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](cx + Math.cos(angle) * radius, cy + Math.sin(angle) * radius));
  89494. angle -= increment;
  89495. }
  89496. return result;
  89497. };
  89498. /**
  89499. * Creates a polygon from input string
  89500. * @param input Input polygon data
  89501. * @returns the parsed points
  89502. */
  89503. Polygon.Parse = function (input) {
  89504. var floats = input.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function (val) { return (!isNaN(val)); });
  89505. var i, result = [];
  89506. for (i = 0; i < (floats.length & 0x7FFFFFFE); i += 2) {
  89507. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](floats[i], floats[i + 1]));
  89508. }
  89509. return result;
  89510. };
  89511. /**
  89512. * Starts building a polygon from x and y coordinates
  89513. * @param x x coordinate
  89514. * @param y y coordinate
  89515. * @returns the started path2
  89516. */
  89517. Polygon.StartingAt = function (x, y) {
  89518. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"].StartingAt(x, y);
  89519. };
  89520. return Polygon;
  89521. }());
  89522. /**
  89523. * Builds a polygon
  89524. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  89525. */
  89526. var PolygonMeshBuilder = /** @class */ (function () {
  89527. /**
  89528. * Creates a PolygonMeshBuilder
  89529. * @param name name of the builder
  89530. * @param contours Path of the polygon
  89531. * @param scene scene to add to
  89532. * @param earcutInjection can be used to inject your own earcut reference
  89533. */
  89534. function PolygonMeshBuilder(name, contours, scene, earcutInjection) {
  89535. if (earcutInjection === void 0) { earcutInjection = earcut; }
  89536. this._points = new PolygonPoints();
  89537. this._outlinepoints = new PolygonPoints();
  89538. this._holes = new Array();
  89539. this._epoints = new Array();
  89540. this._eholes = new Array();
  89541. this.bjsEarcut = earcutInjection;
  89542. this._name = name;
  89543. this._scene = scene;
  89544. var points;
  89545. if (contours instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"]) {
  89546. points = contours.getPoints();
  89547. }
  89548. else {
  89549. points = contours;
  89550. }
  89551. this._addToepoint(points);
  89552. this._points.add(points);
  89553. this._outlinepoints.add(points);
  89554. if (typeof this.bjsEarcut === 'undefined') {
  89555. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Earcut was not found, the polygon will not be built.");
  89556. }
  89557. }
  89558. PolygonMeshBuilder.prototype._addToepoint = function (points) {
  89559. for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
  89560. var p = points_1[_i];
  89561. this._epoints.push(p.x, p.y);
  89562. }
  89563. };
  89564. /**
  89565. * Adds a whole within the polygon
  89566. * @param hole Array of points defining the hole
  89567. * @returns this
  89568. */
  89569. PolygonMeshBuilder.prototype.addHole = function (hole) {
  89570. this._points.add(hole);
  89571. var holepoints = new PolygonPoints();
  89572. holepoints.add(hole);
  89573. this._holes.push(holepoints);
  89574. this._eholes.push(this._epoints.length / 2);
  89575. this._addToepoint(hole);
  89576. return this;
  89577. };
  89578. /**
  89579. * Creates the polygon
  89580. * @param updatable If the mesh should be updatable
  89581. * @param depth The depth of the mesh created
  89582. * @returns the created mesh
  89583. */
  89584. PolygonMeshBuilder.prototype.build = function (updatable, depth) {
  89585. var _this = this;
  89586. if (updatable === void 0) { updatable = false; }
  89587. if (depth === void 0) { depth = 0; }
  89588. var result = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this._name, this._scene);
  89589. var normals = new Array();
  89590. var positions = new Array();
  89591. var uvs = new Array();
  89592. var bounds = this._points.computeBounds();
  89593. this._points.elements.forEach(function (p) {
  89594. normals.push(0, 1.0, 0);
  89595. positions.push(p.x, 0, p.y);
  89596. uvs.push((p.x - bounds.min.x) / bounds.width, (p.y - bounds.min.y) / bounds.height);
  89597. });
  89598. var indices = new Array();
  89599. var res = this.bjsEarcut(this._epoints, this._eholes, 2);
  89600. for (var i = 0; i < res.length; i++) {
  89601. indices.push(res[i]);
  89602. }
  89603. if (depth > 0) {
  89604. var positionscount = (positions.length / 3); //get the current pointcount
  89605. this._points.elements.forEach(function (p) {
  89606. normals.push(0, -1.0, 0);
  89607. positions.push(p.x, -depth, p.y);
  89608. uvs.push(1 - (p.x - bounds.min.x) / bounds.width, 1 - (p.y - bounds.min.y) / bounds.height);
  89609. });
  89610. var totalCount = indices.length;
  89611. for (var i = 0; i < totalCount; i += 3) {
  89612. var i0 = indices[i + 0];
  89613. var i1 = indices[i + 1];
  89614. var i2 = indices[i + 2];
  89615. indices.push(i2 + positionscount);
  89616. indices.push(i1 + positionscount);
  89617. indices.push(i0 + positionscount);
  89618. }
  89619. //Add the sides
  89620. this.addSide(positions, normals, uvs, indices, bounds, this._outlinepoints, depth, false);
  89621. this._holes.forEach(function (hole) {
  89622. _this.addSide(positions, normals, uvs, indices, bounds, hole, depth, true);
  89623. });
  89624. }
  89625. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positions, updatable);
  89626. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normals, updatable);
  89627. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, uvs, updatable);
  89628. result.setIndices(indices);
  89629. return result;
  89630. };
  89631. /**
  89632. * Adds a side to the polygon
  89633. * @param positions points that make the polygon
  89634. * @param normals normals of the polygon
  89635. * @param uvs uvs of the polygon
  89636. * @param indices indices of the polygon
  89637. * @param bounds bounds of the polygon
  89638. * @param points points of the polygon
  89639. * @param depth depth of the polygon
  89640. * @param flip flip of the polygon
  89641. */
  89642. PolygonMeshBuilder.prototype.addSide = function (positions, normals, uvs, indices, bounds, points, depth, flip) {
  89643. var StartIndex = positions.length / 3;
  89644. var ulength = 0;
  89645. for (var i = 0; i < points.elements.length; i++) {
  89646. var p = points.elements[i];
  89647. var p1;
  89648. if ((i + 1) > points.elements.length - 1) {
  89649. p1 = points.elements[0];
  89650. }
  89651. else {
  89652. p1 = points.elements[i + 1];
  89653. }
  89654. positions.push(p.x, 0, p.y);
  89655. positions.push(p.x, -depth, p.y);
  89656. positions.push(p1.x, 0, p1.y);
  89657. positions.push(p1.x, -depth, p1.y);
  89658. var v1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p.x, 0, p.y);
  89659. var v2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p1.x, 0, p1.y);
  89660. var v3 = v2.subtract(v1);
  89661. var v4 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1, 0);
  89662. var vn = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(v3, v4);
  89663. vn = vn.normalize();
  89664. uvs.push(ulength / bounds.width, 0);
  89665. uvs.push(ulength / bounds.width, 1);
  89666. ulength += v3.length();
  89667. uvs.push((ulength / bounds.width), 0);
  89668. uvs.push((ulength / bounds.width), 1);
  89669. if (!flip) {
  89670. normals.push(-vn.x, -vn.y, -vn.z);
  89671. normals.push(-vn.x, -vn.y, -vn.z);
  89672. normals.push(-vn.x, -vn.y, -vn.z);
  89673. normals.push(-vn.x, -vn.y, -vn.z);
  89674. indices.push(StartIndex);
  89675. indices.push(StartIndex + 1);
  89676. indices.push(StartIndex + 2);
  89677. indices.push(StartIndex + 1);
  89678. indices.push(StartIndex + 3);
  89679. indices.push(StartIndex + 2);
  89680. }
  89681. else {
  89682. normals.push(vn.x, vn.y, vn.z);
  89683. normals.push(vn.x, vn.y, vn.z);
  89684. normals.push(vn.x, vn.y, vn.z);
  89685. normals.push(vn.x, vn.y, vn.z);
  89686. indices.push(StartIndex);
  89687. indices.push(StartIndex + 2);
  89688. indices.push(StartIndex + 1);
  89689. indices.push(StartIndex + 1);
  89690. indices.push(StartIndex + 2);
  89691. indices.push(StartIndex + 3);
  89692. }
  89693. StartIndex += 4;
  89694. }
  89695. };
  89696. return PolygonMeshBuilder;
  89697. }());
  89698. /***/ }),
  89699. /***/ "./Meshes/subMesh.ts":
  89700. /*!***************************!*\
  89701. !*** ./Meshes/subMesh.ts ***!
  89702. \***************************/
  89703. /*! exports provided: BaseSubMesh, SubMesh */
  89704. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89705. "use strict";
  89706. __webpack_require__.r(__webpack_exports__);
  89707. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return BaseSubMesh; });
  89708. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return SubMesh; });
  89709. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  89710. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  89711. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  89712. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  89713. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  89714. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  89715. /**
  89716. * Base class for submeshes
  89717. */
  89718. var BaseSubMesh = /** @class */ (function () {
  89719. function BaseSubMesh() {
  89720. }
  89721. Object.defineProperty(BaseSubMesh.prototype, "effect", {
  89722. /**
  89723. * Gets associated effect
  89724. */
  89725. get: function () {
  89726. return this._materialEffect;
  89727. },
  89728. enumerable: true,
  89729. configurable: true
  89730. });
  89731. /**
  89732. * Sets associated effect (effect used to render this submesh)
  89733. * @param effect defines the effect to associate with
  89734. * @param defines defines the set of defines used to compile this effect
  89735. */
  89736. BaseSubMesh.prototype.setEffect = function (effect, defines) {
  89737. if (defines === void 0) { defines = null; }
  89738. if (this._materialEffect === effect) {
  89739. if (!effect) {
  89740. this._materialDefines = null;
  89741. }
  89742. return;
  89743. }
  89744. this._materialDefines = defines;
  89745. this._materialEffect = effect;
  89746. };
  89747. return BaseSubMesh;
  89748. }());
  89749. /**
  89750. * Defines a subdivision inside a mesh
  89751. */
  89752. var SubMesh = /** @class */ (function (_super) {
  89753. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SubMesh, _super);
  89754. /**
  89755. * Creates a new submesh
  89756. * @param materialIndex defines the material index to use
  89757. * @param verticesStart defines vertex index start
  89758. * @param verticesCount defines vertices count
  89759. * @param indexStart defines index start
  89760. * @param indexCount defines indices count
  89761. * @param mesh defines the parent mesh
  89762. * @param renderingMesh defines an optional rendering mesh
  89763. * @param createBoundingBox defines if bounding box should be created for this submesh
  89764. */
  89765. function SubMesh(
  89766. /** the material index to use */
  89767. materialIndex,
  89768. /** vertex index start */
  89769. verticesStart,
  89770. /** vertices count */
  89771. verticesCount,
  89772. /** index start */
  89773. indexStart,
  89774. /** indices count */
  89775. indexCount, mesh, renderingMesh, createBoundingBox) {
  89776. if (createBoundingBox === void 0) { createBoundingBox = true; }
  89777. var _this = _super.call(this) || this;
  89778. _this.materialIndex = materialIndex;
  89779. _this.verticesStart = verticesStart;
  89780. _this.verticesCount = verticesCount;
  89781. _this.indexStart = indexStart;
  89782. _this.indexCount = indexCount;
  89783. /** @hidden */
  89784. _this._renderId = 0;
  89785. _this._mesh = mesh;
  89786. _this._renderingMesh = renderingMesh || mesh;
  89787. mesh.subMeshes.push(_this);
  89788. _this._trianglePlanes = [];
  89789. _this._id = mesh.subMeshes.length - 1;
  89790. if (createBoundingBox) {
  89791. _this.refreshBoundingInfo();
  89792. mesh.computeWorldMatrix(true);
  89793. }
  89794. return _this;
  89795. }
  89796. /**
  89797. * Add a new submesh to a mesh
  89798. * @param materialIndex defines the material index to use
  89799. * @param verticesStart defines vertex index start
  89800. * @param verticesCount defines vertices count
  89801. * @param indexStart defines index start
  89802. * @param indexCount defines indices count
  89803. * @param mesh defines the parent mesh
  89804. * @param renderingMesh defines an optional rendering mesh
  89805. * @param createBoundingBox defines if bounding box should be created for this submesh
  89806. * @returns the new submesh
  89807. */
  89808. SubMesh.AddToMesh = function (materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox) {
  89809. if (createBoundingBox === void 0) { createBoundingBox = true; }
  89810. return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);
  89811. };
  89812. Object.defineProperty(SubMesh.prototype, "IsGlobal", {
  89813. /**
  89814. * Returns true if this submesh covers the entire parent mesh
  89815. * @ignorenaming
  89816. */
  89817. get: function () {
  89818. return (this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices());
  89819. },
  89820. enumerable: true,
  89821. configurable: true
  89822. });
  89823. /**
  89824. * Returns the submesh BoudingInfo object
  89825. * @returns current bounding info (or mesh's one if the submesh is global)
  89826. */
  89827. SubMesh.prototype.getBoundingInfo = function () {
  89828. if (this.IsGlobal) {
  89829. return this._mesh.getBoundingInfo();
  89830. }
  89831. return this._boundingInfo;
  89832. };
  89833. /**
  89834. * Sets the submesh BoundingInfo
  89835. * @param boundingInfo defines the new bounding info to use
  89836. * @returns the SubMesh
  89837. */
  89838. SubMesh.prototype.setBoundingInfo = function (boundingInfo) {
  89839. this._boundingInfo = boundingInfo;
  89840. return this;
  89841. };
  89842. /**
  89843. * Returns the mesh of the current submesh
  89844. * @return the parent mesh
  89845. */
  89846. SubMesh.prototype.getMesh = function () {
  89847. return this._mesh;
  89848. };
  89849. /**
  89850. * Returns the rendering mesh of the submesh
  89851. * @returns the rendering mesh (could be different from parent mesh)
  89852. */
  89853. SubMesh.prototype.getRenderingMesh = function () {
  89854. return this._renderingMesh;
  89855. };
  89856. /**
  89857. * Returns the submesh material
  89858. * @returns null or the current material
  89859. */
  89860. SubMesh.prototype.getMaterial = function () {
  89861. var rootMaterial = this._renderingMesh.material;
  89862. if (rootMaterial === null || rootMaterial === undefined) {
  89863. return this._mesh.getScene().defaultMaterial;
  89864. }
  89865. else if (rootMaterial.getSubMaterial) {
  89866. var multiMaterial = rootMaterial;
  89867. var effectiveMaterial = multiMaterial.getSubMaterial(this.materialIndex);
  89868. if (this._currentMaterial !== effectiveMaterial) {
  89869. this._currentMaterial = effectiveMaterial;
  89870. this._materialDefines = null;
  89871. }
  89872. return effectiveMaterial;
  89873. }
  89874. return rootMaterial;
  89875. };
  89876. // Methods
  89877. /**
  89878. * Sets a new updated BoundingInfo object to the submesh
  89879. * @returns the SubMesh
  89880. */
  89881. SubMesh.prototype.refreshBoundingInfo = function () {
  89882. this._lastColliderWorldVertices = null;
  89883. if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {
  89884. return this;
  89885. }
  89886. var data = this._renderingMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  89887. if (!data) {
  89888. this._boundingInfo = this._mesh.getBoundingInfo();
  89889. return this;
  89890. }
  89891. var indices = this._renderingMesh.getIndices();
  89892. var extend;
  89893. //is this the only submesh?
  89894. if (this.indexStart === 0 && this.indexCount === indices.length) {
  89895. var boundingInfo = this._renderingMesh.getBoundingInfo();
  89896. //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.
  89897. extend = { minimum: boundingInfo.minimum.clone(), maximum: boundingInfo.maximum.clone() };
  89898. }
  89899. else {
  89900. extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
  89901. }
  89902. if (this._boundingInfo) {
  89903. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  89904. }
  89905. else {
  89906. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](extend.minimum, extend.maximum);
  89907. }
  89908. return this;
  89909. };
  89910. /** @hidden */
  89911. SubMesh.prototype._checkCollision = function (collider) {
  89912. var boundingInfo = this.getBoundingInfo();
  89913. return boundingInfo._checkCollision(collider);
  89914. };
  89915. /**
  89916. * Updates the submesh BoundingInfo
  89917. * @param world defines the world matrix to use to update the bounding info
  89918. * @returns the submesh
  89919. */
  89920. SubMesh.prototype.updateBoundingInfo = function (world) {
  89921. var boundingInfo = this.getBoundingInfo();
  89922. if (!boundingInfo) {
  89923. this.refreshBoundingInfo();
  89924. boundingInfo = this.getBoundingInfo();
  89925. }
  89926. boundingInfo.update(world);
  89927. return this;
  89928. };
  89929. /**
  89930. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  89931. * @param frustumPlanes defines the frustum planes
  89932. * @returns true if the submesh is intersecting with the frustum
  89933. */
  89934. SubMesh.prototype.isInFrustum = function (frustumPlanes) {
  89935. var boundingInfo = this.getBoundingInfo();
  89936. if (!boundingInfo) {
  89937. return false;
  89938. }
  89939. return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);
  89940. };
  89941. /**
  89942. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  89943. * @param frustumPlanes defines the frustum planes
  89944. * @returns true if the submesh is inside the frustum
  89945. */
  89946. SubMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  89947. var boundingInfo = this.getBoundingInfo();
  89948. if (!boundingInfo) {
  89949. return false;
  89950. }
  89951. return boundingInfo.isCompletelyInFrustum(frustumPlanes);
  89952. };
  89953. /**
  89954. * Renders the submesh
  89955. * @param enableAlphaMode defines if alpha needs to be used
  89956. * @returns the submesh
  89957. */
  89958. SubMesh.prototype.render = function (enableAlphaMode) {
  89959. this._renderingMesh.render(this, enableAlphaMode);
  89960. return this;
  89961. };
  89962. /**
  89963. * @hidden
  89964. */
  89965. SubMesh.prototype._getLinesIndexBuffer = function (indices, engine) {
  89966. if (!this._linesIndexBuffer) {
  89967. var linesIndices = [];
  89968. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  89969. linesIndices.push(indices[index], indices[index + 1], indices[index + 1], indices[index + 2], indices[index + 2], indices[index]);
  89970. }
  89971. this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);
  89972. this._linesIndexCount = linesIndices.length;
  89973. }
  89974. return this._linesIndexBuffer;
  89975. };
  89976. /**
  89977. * Checks if the submesh intersects with a ray
  89978. * @param ray defines the ray to test
  89979. * @returns true is the passed ray intersects the submesh bounding box
  89980. */
  89981. SubMesh.prototype.canIntersects = function (ray) {
  89982. var boundingInfo = this.getBoundingInfo();
  89983. if (!boundingInfo) {
  89984. return false;
  89985. }
  89986. return ray.intersectsBox(boundingInfo.boundingBox);
  89987. };
  89988. /**
  89989. * Intersects current submesh with a ray
  89990. * @param ray defines the ray to test
  89991. * @param positions defines mesh's positions array
  89992. * @param indices defines mesh's indices array
  89993. * @param fastCheck defines if only bounding info should be used
  89994. * @returns intersection info or null if no intersection
  89995. */
  89996. SubMesh.prototype.intersects = function (ray, positions, indices, fastCheck) {
  89997. var material = this.getMaterial();
  89998. if (!material) {
  89999. return null;
  90000. }
  90001. switch (material.fillMode) {
  90002. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_PointListDrawMode:
  90003. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineListDrawMode:
  90004. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineLoopDrawMode:
  90005. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineStripDrawMode:
  90006. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleFanDrawMode:
  90007. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleStripDrawMode:
  90008. return null;
  90009. }
  90010. // LineMesh first as it's also a Mesh...
  90011. if (this._mesh.getClassName() === "InstancedLinesMesh" || this._mesh.getClassName() === "LinesMesh") {
  90012. return this._intersectLines(ray, positions, indices, this._mesh.intersectionThreshold, fastCheck);
  90013. }
  90014. return this._intersectTriangles(ray, positions, indices, fastCheck);
  90015. };
  90016. /** @hidden */
  90017. SubMesh.prototype._intersectLines = function (ray, positions, indices, intersectionThreshold, fastCheck) {
  90018. var intersectInfo = null;
  90019. // Line test
  90020. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) {
  90021. var p0 = positions[indices[index]];
  90022. var p1 = positions[indices[index + 1]];
  90023. var length = ray.intersectionSegment(p0, p1, intersectionThreshold);
  90024. if (length < 0) {
  90025. continue;
  90026. }
  90027. if (fastCheck || !intersectInfo || length < intersectInfo.distance) {
  90028. intersectInfo = new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](null, null, length);
  90029. intersectInfo.faceId = index / 2;
  90030. if (fastCheck) {
  90031. break;
  90032. }
  90033. }
  90034. }
  90035. return intersectInfo;
  90036. };
  90037. /** @hidden */
  90038. SubMesh.prototype._intersectTriangles = function (ray, positions, indices, fastCheck) {
  90039. var intersectInfo = null;
  90040. // Triangles test
  90041. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  90042. var p0 = positions[indices[index]];
  90043. var p1 = positions[indices[index + 1]];
  90044. var p2 = positions[indices[index + 2]];
  90045. var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
  90046. if (currentIntersectInfo) {
  90047. if (currentIntersectInfo.distance < 0) {
  90048. continue;
  90049. }
  90050. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  90051. intersectInfo = currentIntersectInfo;
  90052. intersectInfo.faceId = index / 3;
  90053. if (fastCheck) {
  90054. break;
  90055. }
  90056. }
  90057. }
  90058. }
  90059. return intersectInfo;
  90060. };
  90061. /** @hidden */
  90062. SubMesh.prototype._rebuild = function () {
  90063. if (this._linesIndexBuffer) {
  90064. this._linesIndexBuffer = null;
  90065. }
  90066. };
  90067. // Clone
  90068. /**
  90069. * Creates a new submesh from the passed mesh
  90070. * @param newMesh defines the new hosting mesh
  90071. * @param newRenderingMesh defines an optional rendering mesh
  90072. * @returns the new submesh
  90073. */
  90074. SubMesh.prototype.clone = function (newMesh, newRenderingMesh) {
  90075. var result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);
  90076. if (!this.IsGlobal) {
  90077. var boundingInfo = this.getBoundingInfo();
  90078. if (!boundingInfo) {
  90079. return result;
  90080. }
  90081. result._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](boundingInfo.minimum, boundingInfo.maximum);
  90082. }
  90083. return result;
  90084. };
  90085. // Dispose
  90086. /**
  90087. * Release associated resources
  90088. */
  90089. SubMesh.prototype.dispose = function () {
  90090. if (this._linesIndexBuffer) {
  90091. this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);
  90092. this._linesIndexBuffer = null;
  90093. }
  90094. // Remove from mesh
  90095. var index = this._mesh.subMeshes.indexOf(this);
  90096. this._mesh.subMeshes.splice(index, 1);
  90097. };
  90098. /**
  90099. * Gets the class name
  90100. * @returns the string "SubMesh".
  90101. */
  90102. SubMesh.prototype.getClassName = function () {
  90103. return "SubMesh";
  90104. };
  90105. // Statics
  90106. /**
  90107. * Creates a new submesh from indices data
  90108. * @param materialIndex the index of the main mesh material
  90109. * @param startIndex the index where to start the copy in the mesh indices array
  90110. * @param indexCount the number of indices to copy then from the startIndex
  90111. * @param mesh the main mesh to create the submesh from
  90112. * @param renderingMesh the optional rendering mesh
  90113. * @returns a new submesh
  90114. */
  90115. SubMesh.CreateFromIndices = function (materialIndex, startIndex, indexCount, mesh, renderingMesh) {
  90116. var minVertexIndex = Number.MAX_VALUE;
  90117. var maxVertexIndex = -Number.MAX_VALUE;
  90118. var whatWillRender = (renderingMesh || mesh);
  90119. var indices = whatWillRender.getIndices();
  90120. for (var index = startIndex; index < startIndex + indexCount; index++) {
  90121. var vertexIndex = indices[index];
  90122. if (vertexIndex < minVertexIndex) {
  90123. minVertexIndex = vertexIndex;
  90124. }
  90125. if (vertexIndex > maxVertexIndex) {
  90126. maxVertexIndex = vertexIndex;
  90127. }
  90128. }
  90129. return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh);
  90130. };
  90131. return SubMesh;
  90132. }(BaseSubMesh));
  90133. /***/ }),
  90134. /***/ "./Meshes/transformNode.ts":
  90135. /*!*********************************!*\
  90136. !*** ./Meshes/transformNode.ts ***!
  90137. \*********************************/
  90138. /*! exports provided: TransformNode */
  90139. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90140. "use strict";
  90141. __webpack_require__.r(__webpack_exports__);
  90142. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return TransformNode; });
  90143. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  90144. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  90145. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  90146. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  90147. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  90148. /**
  90149. * 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.
  90150. * @see https://doc.babylonjs.com/how_to/transformnode
  90151. */
  90152. var TransformNode = /** @class */ (function (_super) {
  90153. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TransformNode, _super);
  90154. function TransformNode(name, scene, isPure) {
  90155. if (scene === void 0) { scene = null; }
  90156. if (isPure === void 0) { isPure = true; }
  90157. var _this = _super.call(this, name, scene) || this;
  90158. _this._forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  90159. _this._forwardInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  90160. _this._up = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0);
  90161. _this._right = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  90162. _this._rightInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-1, 0, 0);
  90163. // Properties
  90164. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90165. _this._rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90166. _this._scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].One();
  90167. _this._isDirty = false;
  90168. /**
  90169. * Set the billboard mode. Default is 0.
  90170. *
  90171. * | Value | Type | Description |
  90172. * | --- | --- | --- |
  90173. * | 0 | BILLBOARDMODE_NONE | |
  90174. * | 1 | BILLBOARDMODE_X | |
  90175. * | 2 | BILLBOARDMODE_Y | |
  90176. * | 4 | BILLBOARDMODE_Z | |
  90177. * | 7 | BILLBOARDMODE_ALL | |
  90178. *
  90179. */
  90180. _this.billboardMode = TransformNode.BILLBOARDMODE_NONE;
  90181. /**
  90182. * 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
  90183. */
  90184. _this.scalingDeterminant = 1;
  90185. /**
  90186. * Sets the distance of the object to max, often used by skybox
  90187. */
  90188. _this.infiniteDistance = false;
  90189. /**
  90190. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  90191. * By default the system will update normals to compensate
  90192. */
  90193. _this.ignoreNonUniformScaling = false;
  90194. /** @hidden */
  90195. _this._localMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  90196. _this._absolutePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90197. _this._pivotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  90198. _this._postMultiplyPivotMatrix = false;
  90199. _this._isWorldMatrixFrozen = false;
  90200. /** @hidden */
  90201. _this._indexInSceneTransformNodesArray = -1;
  90202. /**
  90203. * An event triggered after the world matrix is updated
  90204. */
  90205. _this.onAfterWorldMatrixUpdateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  90206. _this._nonUniformScaling = false;
  90207. if (isPure) {
  90208. _this.getScene().addTransformNode(_this);
  90209. }
  90210. return _this;
  90211. }
  90212. /**
  90213. * Gets a string identifying the name of the class
  90214. * @returns "TransformNode" string
  90215. */
  90216. TransformNode.prototype.getClassName = function () {
  90217. return "TransformNode";
  90218. };
  90219. Object.defineProperty(TransformNode.prototype, "position", {
  90220. /**
  90221. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  90222. */
  90223. get: function () {
  90224. return this._position;
  90225. },
  90226. set: function (newPosition) {
  90227. this._position = newPosition;
  90228. this._isDirty = true;
  90229. },
  90230. enumerable: true,
  90231. configurable: true
  90232. });
  90233. Object.defineProperty(TransformNode.prototype, "rotation", {
  90234. /**
  90235. * 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)).
  90236. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  90237. */
  90238. get: function () {
  90239. return this._rotation;
  90240. },
  90241. set: function (newRotation) {
  90242. this._rotation = newRotation;
  90243. this._isDirty = true;
  90244. },
  90245. enumerable: true,
  90246. configurable: true
  90247. });
  90248. Object.defineProperty(TransformNode.prototype, "scaling", {
  90249. /**
  90250. * 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)).
  90251. */
  90252. get: function () {
  90253. return this._scaling;
  90254. },
  90255. set: function (newScaling) {
  90256. this._scaling = newScaling;
  90257. this._isDirty = true;
  90258. },
  90259. enumerable: true,
  90260. configurable: true
  90261. });
  90262. Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
  90263. /**
  90264. * 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).
  90265. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  90266. */
  90267. get: function () {
  90268. return this._rotationQuaternion;
  90269. },
  90270. set: function (quaternion) {
  90271. this._rotationQuaternion = quaternion;
  90272. //reset the rotation vector.
  90273. if (quaternion) {
  90274. this.rotation.setAll(0.0);
  90275. }
  90276. },
  90277. enumerable: true,
  90278. configurable: true
  90279. });
  90280. Object.defineProperty(TransformNode.prototype, "forward", {
  90281. /**
  90282. * The forward direction of that transform in world space.
  90283. */
  90284. get: function () {
  90285. 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()));
  90286. },
  90287. enumerable: true,
  90288. configurable: true
  90289. });
  90290. Object.defineProperty(TransformNode.prototype, "up", {
  90291. /**
  90292. * The up direction of that transform in world space.
  90293. */
  90294. get: function () {
  90295. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this._up, this.getWorldMatrix()));
  90296. },
  90297. enumerable: true,
  90298. configurable: true
  90299. });
  90300. Object.defineProperty(TransformNode.prototype, "right", {
  90301. /**
  90302. * The right direction of that transform in world space.
  90303. */
  90304. get: function () {
  90305. 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()));
  90306. },
  90307. enumerable: true,
  90308. configurable: true
  90309. });
  90310. /**
  90311. * Copies the parameter passed Matrix into the mesh Pose matrix.
  90312. * @param matrix the matrix to copy the pose from
  90313. * @returns this TransformNode.
  90314. */
  90315. TransformNode.prototype.updatePoseMatrix = function (matrix) {
  90316. this._poseMatrix.copyFrom(matrix);
  90317. return this;
  90318. };
  90319. /**
  90320. * Returns the mesh Pose matrix.
  90321. * @returns the pose matrix
  90322. */
  90323. TransformNode.prototype.getPoseMatrix = function () {
  90324. return this._poseMatrix;
  90325. };
  90326. /** @hidden */
  90327. TransformNode.prototype._isSynchronized = function () {
  90328. if (this._isDirty) {
  90329. return false;
  90330. }
  90331. if (this.billboardMode !== this._cache.billboardMode || this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  90332. return false;
  90333. }
  90334. if (this._cache.pivotMatrixUpdated) {
  90335. return false;
  90336. }
  90337. if (this.infiniteDistance) {
  90338. return false;
  90339. }
  90340. if (!this._cache.position.equals(this._position)) {
  90341. return false;
  90342. }
  90343. if (this._rotationQuaternion) {
  90344. if (!this._cache.rotationQuaternion.equals(this._rotationQuaternion)) {
  90345. return false;
  90346. }
  90347. }
  90348. if (!this._cache.rotation.equals(this._rotation)) {
  90349. return false;
  90350. }
  90351. if (!this._cache.scaling.equals(this._scaling)) {
  90352. return false;
  90353. }
  90354. return true;
  90355. };
  90356. /** @hidden */
  90357. TransformNode.prototype._initCache = function () {
  90358. _super.prototype._initCache.call(this);
  90359. this._cache.localMatrixUpdated = false;
  90360. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90361. this._cache.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90362. this._cache.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90363. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](0, 0, 0, 0);
  90364. this._cache.billboardMode = -1;
  90365. this._cache.infiniteDistance = false;
  90366. };
  90367. /**
  90368. * Flag the transform node as dirty (Forcing it to update everything)
  90369. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  90370. * @returns this transform node
  90371. */
  90372. TransformNode.prototype.markAsDirty = function (property) {
  90373. if (property === "rotation") {
  90374. this.rotationQuaternion = null;
  90375. }
  90376. this._currentRenderId = Number.MAX_VALUE;
  90377. this._isDirty = true;
  90378. return this;
  90379. };
  90380. Object.defineProperty(TransformNode.prototype, "absolutePosition", {
  90381. /**
  90382. * Returns the current mesh absolute position.
  90383. * Returns a Vector3.
  90384. */
  90385. get: function () {
  90386. return this._absolutePosition;
  90387. },
  90388. enumerable: true,
  90389. configurable: true
  90390. });
  90391. /**
  90392. * Sets a new matrix to apply before all other transformation
  90393. * @param matrix defines the transform matrix
  90394. * @returns the current TransformNode
  90395. */
  90396. TransformNode.prototype.setPreTransformMatrix = function (matrix) {
  90397. return this.setPivotMatrix(matrix, false);
  90398. };
  90399. /**
  90400. * Sets a new pivot matrix to the current node
  90401. * @param matrix defines the new pivot matrix to use
  90402. * @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
  90403. * @returns the current TransformNode
  90404. */
  90405. TransformNode.prototype.setPivotMatrix = function (matrix, postMultiplyPivotMatrix) {
  90406. if (postMultiplyPivotMatrix === void 0) { postMultiplyPivotMatrix = true; }
  90407. this._pivotMatrix.copyFrom(matrix);
  90408. this._cache.pivotMatrixUpdated = true;
  90409. this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
  90410. if (this._postMultiplyPivotMatrix) {
  90411. if (!this._pivotMatrixInverse) {
  90412. this._pivotMatrixInverse = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._pivotMatrix);
  90413. }
  90414. else {
  90415. this._pivotMatrix.invertToRef(this._pivotMatrixInverse);
  90416. }
  90417. }
  90418. return this;
  90419. };
  90420. /**
  90421. * Returns the mesh pivot matrix.
  90422. * Default : Identity.
  90423. * @returns the matrix
  90424. */
  90425. TransformNode.prototype.getPivotMatrix = function () {
  90426. return this._pivotMatrix;
  90427. };
  90428. /**
  90429. * Prevents the World matrix to be computed any longer.
  90430. * @returns the TransformNode.
  90431. */
  90432. TransformNode.prototype.freezeWorldMatrix = function () {
  90433. this._isWorldMatrixFrozen = false; // no guarantee world is not already frozen, switch off temporarily
  90434. this.computeWorldMatrix(true);
  90435. this._isWorldMatrixFrozen = true;
  90436. return this;
  90437. };
  90438. /**
  90439. * Allows back the World matrix computation.
  90440. * @returns the TransformNode.
  90441. */
  90442. TransformNode.prototype.unfreezeWorldMatrix = function () {
  90443. this._isWorldMatrixFrozen = false;
  90444. this.computeWorldMatrix(true);
  90445. return this;
  90446. };
  90447. Object.defineProperty(TransformNode.prototype, "isWorldMatrixFrozen", {
  90448. /**
  90449. * True if the World matrix has been frozen.
  90450. */
  90451. get: function () {
  90452. return this._isWorldMatrixFrozen;
  90453. },
  90454. enumerable: true,
  90455. configurable: true
  90456. });
  90457. /**
  90458. * Retuns the mesh absolute position in the World.
  90459. * @returns a Vector3.
  90460. */
  90461. TransformNode.prototype.getAbsolutePosition = function () {
  90462. this.computeWorldMatrix();
  90463. return this._absolutePosition;
  90464. };
  90465. /**
  90466. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  90467. * @param absolutePosition the absolute position to set
  90468. * @returns the TransformNode.
  90469. */
  90470. TransformNode.prototype.setAbsolutePosition = function (absolutePosition) {
  90471. if (!absolutePosition) {
  90472. return this;
  90473. }
  90474. var absolutePositionX;
  90475. var absolutePositionY;
  90476. var absolutePositionZ;
  90477. if (absolutePosition.x === undefined) {
  90478. if (arguments.length < 3) {
  90479. return this;
  90480. }
  90481. absolutePositionX = arguments[0];
  90482. absolutePositionY = arguments[1];
  90483. absolutePositionZ = arguments[2];
  90484. }
  90485. else {
  90486. absolutePositionX = absolutePosition.x;
  90487. absolutePositionY = absolutePosition.y;
  90488. absolutePositionZ = absolutePosition.z;
  90489. }
  90490. if (this.parent) {
  90491. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90492. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  90493. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(absolutePositionX, absolutePositionY, absolutePositionZ, invertParentWorldMatrix, this.position);
  90494. }
  90495. else {
  90496. this.position.x = absolutePositionX;
  90497. this.position.y = absolutePositionY;
  90498. this.position.z = absolutePositionZ;
  90499. }
  90500. return this;
  90501. };
  90502. /**
  90503. * Sets the mesh position in its local space.
  90504. * @param vector3 the position to set in localspace
  90505. * @returns the TransformNode.
  90506. */
  90507. TransformNode.prototype.setPositionWithLocalVector = function (vector3) {
  90508. this.computeWorldMatrix();
  90509. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(vector3, this._localMatrix);
  90510. return this;
  90511. };
  90512. /**
  90513. * Returns the mesh position in the local space from the current World matrix values.
  90514. * @returns a new Vector3.
  90515. */
  90516. TransformNode.prototype.getPositionExpressedInLocalSpace = function () {
  90517. this.computeWorldMatrix();
  90518. var invLocalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90519. this._localMatrix.invertToRef(invLocalWorldMatrix);
  90520. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this.position, invLocalWorldMatrix);
  90521. };
  90522. /**
  90523. * Translates the mesh along the passed Vector3 in its local space.
  90524. * @param vector3 the distance to translate in localspace
  90525. * @returns the TransformNode.
  90526. */
  90527. TransformNode.prototype.locallyTranslate = function (vector3) {
  90528. this.computeWorldMatrix(true);
  90529. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(vector3, this._localMatrix);
  90530. return this;
  90531. };
  90532. /**
  90533. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  90534. * @param targetPoint the position (must be in same space as current mesh) to look at
  90535. * @param yawCor optional yaw (y-axis) correction in radians
  90536. * @param pitchCor optional pitch (x-axis) correction in radians
  90537. * @param rollCor optional roll (z-axis) correction in radians
  90538. * @param space the choosen space of the target
  90539. * @returns the TransformNode.
  90540. */
  90541. TransformNode.prototype.lookAt = function (targetPoint, yawCor, pitchCor, rollCor, space) {
  90542. if (yawCor === void 0) { yawCor = 0; }
  90543. if (pitchCor === void 0) { pitchCor = 0; }
  90544. if (rollCor === void 0) { rollCor = 0; }
  90545. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  90546. var dv = TransformNode._lookAtVectorCache;
  90547. var pos = space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL ? this.position : this.getAbsolutePosition();
  90548. targetPoint.subtractToRef(pos, dv);
  90549. this.setDirection(dv, yawCor, pitchCor, rollCor);
  90550. // Correct for parent's rotation offset
  90551. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD && this.parent) {
  90552. if (this.rotationQuaternion) {
  90553. // Get local rotation matrix of the looking object
  90554. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90555. this.rotationQuaternion.toRotationMatrix(rotationMatrix);
  90556. // Offset rotation by parent's inverted rotation matrix to correct in world space
  90557. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  90558. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  90559. parentRotationMatrix.invert();
  90560. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  90561. this.rotationQuaternion.fromRotationMatrix(rotationMatrix);
  90562. }
  90563. else {
  90564. // Get local rotation matrix of the looking object
  90565. var quaternionRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  90566. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, quaternionRotation);
  90567. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90568. quaternionRotation.toRotationMatrix(rotationMatrix);
  90569. // Offset rotation by parent's inverted rotation matrix to correct in world space
  90570. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  90571. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  90572. parentRotationMatrix.invert();
  90573. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  90574. quaternionRotation.fromRotationMatrix(rotationMatrix);
  90575. quaternionRotation.toEulerAnglesToRef(this.rotation);
  90576. }
  90577. }
  90578. return this;
  90579. };
  90580. /**
  90581. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  90582. * This Vector3 is expressed in the World space.
  90583. * @param localAxis axis to rotate
  90584. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  90585. */
  90586. TransformNode.prototype.getDirection = function (localAxis) {
  90587. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90588. this.getDirectionToRef(localAxis, result);
  90589. return result;
  90590. };
  90591. /**
  90592. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  90593. * localAxis is expressed in the mesh local space.
  90594. * result is computed in the Wordl space from the mesh World matrix.
  90595. * @param localAxis axis to rotate
  90596. * @param result the resulting transformnode
  90597. * @returns this TransformNode.
  90598. */
  90599. TransformNode.prototype.getDirectionToRef = function (localAxis, result) {
  90600. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  90601. return this;
  90602. };
  90603. /**
  90604. * Sets this transform node rotation to the given local axis.
  90605. * @param localAxis the axis in local space
  90606. * @param yawCor optional yaw (y-axis) correction in radians
  90607. * @param pitchCor optional pitch (x-axis) correction in radians
  90608. * @param rollCor optional roll (z-axis) correction in radians
  90609. * @returns this TransformNode
  90610. */
  90611. TransformNode.prototype.setDirection = function (localAxis, yawCor, pitchCor, rollCor) {
  90612. if (yawCor === void 0) { yawCor = 0; }
  90613. if (pitchCor === void 0) { pitchCor = 0; }
  90614. if (rollCor === void 0) { rollCor = 0; }
  90615. var yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2;
  90616. var len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);
  90617. var pitch = -Math.atan2(localAxis.y, len);
  90618. if (this.rotationQuaternion) {
  90619. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(yaw + yawCor, pitch + pitchCor, rollCor, this.rotationQuaternion);
  90620. }
  90621. else {
  90622. this.rotation.x = pitch + pitchCor;
  90623. this.rotation.y = yaw + yawCor;
  90624. this.rotation.z = rollCor;
  90625. }
  90626. return this;
  90627. };
  90628. /**
  90629. * Sets a new pivot point to the current node
  90630. * @param point defines the new pivot point to use
  90631. * @param space defines if the point is in world or local space (local by default)
  90632. * @returns the current TransformNode
  90633. */
  90634. TransformNode.prototype.setPivotPoint = function (point, space) {
  90635. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  90636. if (this.getScene().getRenderId() == 0) {
  90637. this.computeWorldMatrix(true);
  90638. }
  90639. var wm = this.getWorldMatrix();
  90640. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD) {
  90641. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90642. wm.invertToRef(tmat);
  90643. point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(point, tmat);
  90644. }
  90645. return this.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(-point.x, -point.y, -point.z), true);
  90646. };
  90647. /**
  90648. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  90649. * @returns the pivot point
  90650. */
  90651. TransformNode.prototype.getPivotPoint = function () {
  90652. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90653. this.getPivotPointToRef(point);
  90654. return point;
  90655. };
  90656. /**
  90657. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  90658. * @param result the vector3 to store the result
  90659. * @returns this TransformNode.
  90660. */
  90661. TransformNode.prototype.getPivotPointToRef = function (result) {
  90662. result.x = -this._pivotMatrix.m[12];
  90663. result.y = -this._pivotMatrix.m[13];
  90664. result.z = -this._pivotMatrix.m[14];
  90665. return this;
  90666. };
  90667. /**
  90668. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  90669. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  90670. */
  90671. TransformNode.prototype.getAbsolutePivotPoint = function () {
  90672. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90673. this.getAbsolutePivotPointToRef(point);
  90674. return point;
  90675. };
  90676. /**
  90677. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  90678. * @param result vector3 to store the result
  90679. * @returns this TransformNode.
  90680. */
  90681. TransformNode.prototype.getAbsolutePivotPointToRef = function (result) {
  90682. result.x = this._pivotMatrix.m[12];
  90683. result.y = this._pivotMatrix.m[13];
  90684. result.z = this._pivotMatrix.m[14];
  90685. this.getPivotPointToRef(result);
  90686. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(result, this.getWorldMatrix(), result);
  90687. return this;
  90688. };
  90689. /**
  90690. * Defines the passed node as the parent of the current node.
  90691. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  90692. * @param node the node ot set as the parent
  90693. * @returns this TransformNode.
  90694. */
  90695. TransformNode.prototype.setParent = function (node) {
  90696. if (!node && !this.parent) {
  90697. return this;
  90698. }
  90699. var quatRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  90700. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  90701. var scale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  90702. if (!node) {
  90703. if (this.parent && this.parent.computeWorldMatrix) {
  90704. this.parent.computeWorldMatrix(true);
  90705. }
  90706. this.computeWorldMatrix(true);
  90707. this.getWorldMatrix().decompose(scale, quatRotation, position);
  90708. }
  90709. else {
  90710. var diffMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90711. var invParentMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  90712. this.computeWorldMatrix(true);
  90713. node.computeWorldMatrix(true);
  90714. node.getWorldMatrix().invertToRef(invParentMatrix);
  90715. this.getWorldMatrix().multiplyToRef(invParentMatrix, diffMatrix);
  90716. diffMatrix.decompose(scale, quatRotation, position);
  90717. }
  90718. if (this.rotationQuaternion) {
  90719. this.rotationQuaternion.copyFrom(quatRotation);
  90720. }
  90721. else {
  90722. quatRotation.toEulerAnglesToRef(this.rotation);
  90723. }
  90724. this.scaling.copyFrom(scale);
  90725. this.position.copyFrom(position);
  90726. this.parent = node;
  90727. return this;
  90728. };
  90729. Object.defineProperty(TransformNode.prototype, "nonUniformScaling", {
  90730. /**
  90731. * True if the scaling property of this object is non uniform eg. (1,2,1)
  90732. */
  90733. get: function () {
  90734. return this._nonUniformScaling;
  90735. },
  90736. enumerable: true,
  90737. configurable: true
  90738. });
  90739. /** @hidden */
  90740. TransformNode.prototype._updateNonUniformScalingState = function (value) {
  90741. if (this._nonUniformScaling === value) {
  90742. return false;
  90743. }
  90744. this._nonUniformScaling = value;
  90745. return true;
  90746. };
  90747. /**
  90748. * Attach the current TransformNode to another TransformNode associated with a bone
  90749. * @param bone Bone affecting the TransformNode
  90750. * @param affectedTransformNode TransformNode associated with the bone
  90751. * @returns this object
  90752. */
  90753. TransformNode.prototype.attachToBone = function (bone, affectedTransformNode) {
  90754. this._transformToBoneReferal = affectedTransformNode;
  90755. this.parent = bone;
  90756. if (bone.getWorldMatrix().determinant() < 0) {
  90757. this.scalingDeterminant *= -1;
  90758. }
  90759. return this;
  90760. };
  90761. /**
  90762. * Detach the transform node if its associated with a bone
  90763. * @returns this object
  90764. */
  90765. TransformNode.prototype.detachFromBone = function () {
  90766. if (!this.parent) {
  90767. return this;
  90768. }
  90769. if (this.parent.getWorldMatrix().determinant() < 0) {
  90770. this.scalingDeterminant *= -1;
  90771. }
  90772. this._transformToBoneReferal = null;
  90773. this.parent = null;
  90774. return this;
  90775. };
  90776. /**
  90777. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  90778. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  90779. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  90780. * The passed axis is also normalized.
  90781. * @param axis the axis to rotate around
  90782. * @param amount the amount to rotate in radians
  90783. * @param space Space to rotate in (Default: local)
  90784. * @returns the TransformNode.
  90785. */
  90786. TransformNode.prototype.rotate = function (axis, amount, space) {
  90787. axis.normalize();
  90788. if (!this.rotationQuaternion) {
  90789. this.rotationQuaternion = this.rotation.toQuaternion();
  90790. this.rotation.setAll(0);
  90791. }
  90792. var rotationQuaternion;
  90793. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  90794. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  90795. this.rotationQuaternion.multiplyToRef(rotationQuaternion, this.rotationQuaternion);
  90796. }
  90797. else {
  90798. if (this.parent) {
  90799. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90800. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  90801. axis = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(axis, invertParentWorldMatrix);
  90802. }
  90803. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  90804. rotationQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  90805. }
  90806. return this;
  90807. };
  90808. /**
  90809. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  90810. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  90811. * The passed axis is also normalized. .
  90812. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  90813. * @param point the point to rotate around
  90814. * @param axis the axis to rotate around
  90815. * @param amount the amount to rotate in radians
  90816. * @returns the TransformNode
  90817. */
  90818. TransformNode.prototype.rotateAround = function (point, axis, amount) {
  90819. axis.normalize();
  90820. if (!this.rotationQuaternion) {
  90821. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  90822. this.rotation.setAll(0);
  90823. }
  90824. var tmpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  90825. var finalScale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  90826. var finalTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[2];
  90827. var finalRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  90828. var translationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]; // T
  90829. var translationMatrixInv = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1]; // T'
  90830. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2]; // R
  90831. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[3]; // T' x R x T
  90832. point.subtractToRef(this.position, tmpVector);
  90833. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(tmpVector.x, tmpVector.y, tmpVector.z, translationMatrix); // T
  90834. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-tmpVector.x, -tmpVector.y, -tmpVector.z, translationMatrixInv); // T'
  90835. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(axis, amount, rotationMatrix); // R
  90836. translationMatrixInv.multiplyToRef(rotationMatrix, finalMatrix); // T' x R
  90837. finalMatrix.multiplyToRef(translationMatrix, finalMatrix); // T' x R x T
  90838. finalMatrix.decompose(finalScale, finalRotation, finalTranslation);
  90839. this.position.addInPlace(finalTranslation);
  90840. finalRotation.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  90841. return this;
  90842. };
  90843. /**
  90844. * Translates the mesh along the axis vector for the passed distance in the given space.
  90845. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  90846. * @param axis the axis to translate in
  90847. * @param distance the distance to translate
  90848. * @param space Space to rotate in (Default: local)
  90849. * @returns the TransformNode.
  90850. */
  90851. TransformNode.prototype.translate = function (axis, distance, space) {
  90852. var displacementVector = axis.scale(distance);
  90853. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  90854. var tempV3 = this.getPositionExpressedInLocalSpace().add(displacementVector);
  90855. this.setPositionWithLocalVector(tempV3);
  90856. }
  90857. else {
  90858. this.setAbsolutePosition(this.getAbsolutePosition().add(displacementVector));
  90859. }
  90860. return this;
  90861. };
  90862. /**
  90863. * Adds a rotation step to the mesh current rotation.
  90864. * x, y, z are Euler angles expressed in radians.
  90865. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  90866. * This means this rotation is made in the mesh local space only.
  90867. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  90868. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  90869. * ```javascript
  90870. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  90871. * ```
  90872. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  90873. * 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.
  90874. * @param x Rotation to add
  90875. * @param y Rotation to add
  90876. * @param z Rotation to add
  90877. * @returns the TransformNode.
  90878. */
  90879. TransformNode.prototype.addRotation = function (x, y, z) {
  90880. var rotationQuaternion;
  90881. if (this.rotationQuaternion) {
  90882. rotationQuaternion = this.rotationQuaternion;
  90883. }
  90884. else {
  90885. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[1];
  90886. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, rotationQuaternion);
  90887. }
  90888. var accumulation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  90889. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(y, x, z, accumulation);
  90890. rotationQuaternion.multiplyInPlace(accumulation);
  90891. if (!this.rotationQuaternion) {
  90892. rotationQuaternion.toEulerAnglesToRef(this.rotation);
  90893. }
  90894. return this;
  90895. };
  90896. /**
  90897. * Computes the world matrix of the node
  90898. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90899. * @returns the world matrix
  90900. */
  90901. TransformNode.prototype.computeWorldMatrix = function (force) {
  90902. if (this._isWorldMatrixFrozen) {
  90903. return this._worldMatrix;
  90904. }
  90905. if (!force && this.isSynchronized()) {
  90906. this._currentRenderId = this.getScene().getRenderId();
  90907. return this._worldMatrix;
  90908. }
  90909. this._updateCache();
  90910. this._cache.position.copyFrom(this.position);
  90911. this._cache.scaling.copyFrom(this.scaling);
  90912. this._cache.pivotMatrixUpdated = false;
  90913. this._cache.billboardMode = this.billboardMode;
  90914. this._cache.infiniteDistance = this.infiniteDistance;
  90915. this._currentRenderId = this.getScene().getRenderId();
  90916. this._childRenderId = this.getScene().getRenderId();
  90917. this._isDirty = false;
  90918. // Scaling
  90919. _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]);
  90920. // Rotation
  90921. //rotate, if quaternion is set and rotation was used
  90922. if (this.rotationQuaternion) {
  90923. var len = this.rotation.length();
  90924. if (len) {
  90925. this.rotationQuaternion.multiplyInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z));
  90926. this.rotation.copyFromFloats(0, 0, 0);
  90927. }
  90928. }
  90929. if (this.rotationQuaternion) {
  90930. this.rotationQuaternion.toRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  90931. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  90932. }
  90933. else {
  90934. _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]);
  90935. this._cache.rotation.copyFrom(this.rotation);
  90936. }
  90937. // Translation
  90938. var camera = this.getScene().activeCamera;
  90939. if (this.infiniteDistance && !this.parent && camera) {
  90940. var cameraWorldMatrix = camera.getWorldMatrix();
  90941. var cameraGlobalPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](cameraWorldMatrix.m[12], cameraWorldMatrix.m[13], cameraWorldMatrix.m[14]);
  90942. _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]);
  90943. }
  90944. else {
  90945. _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]);
  90946. }
  90947. // Composing transformations
  90948. this._pivotMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[4]);
  90949. _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]);
  90950. // Billboarding (testing PG:http://www.babylonjs-playground.com/#UJEIL#13)
  90951. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE && camera) {
  90952. if ((this.billboardMode & TransformNode.BILLBOARDMODE_ALL) !== TransformNode.BILLBOARDMODE_ALL) {
  90953. // Need to decompose each rotation here
  90954. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[3];
  90955. if (this.parent && this.parent.getWorldMatrix) {
  90956. if (this._transformToBoneReferal) {
  90957. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  90958. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6], currentPosition);
  90959. }
  90960. else {
  90961. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), currentPosition);
  90962. }
  90963. }
  90964. else {
  90965. currentPosition.copyFrom(this.position);
  90966. }
  90967. currentPosition.subtractInPlace(camera.globalPosition);
  90968. var finalEuler = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[4].copyFromFloats(0, 0, 0);
  90969. if ((this.billboardMode & TransformNode.BILLBOARDMODE_X) === TransformNode.BILLBOARDMODE_X) {
  90970. finalEuler.x = Math.atan2(-currentPosition.y, currentPosition.z);
  90971. }
  90972. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Y) === TransformNode.BILLBOARDMODE_Y) {
  90973. finalEuler.y = Math.atan2(currentPosition.x, currentPosition.z);
  90974. }
  90975. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Z) === TransformNode.BILLBOARDMODE_Z) {
  90976. finalEuler.z = Math.atan2(currentPosition.y, currentPosition.x);
  90977. }
  90978. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(finalEuler.y, finalEuler.x, finalEuler.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  90979. }
  90980. else {
  90981. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].copyFrom(camera.getViewMatrix());
  90982. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].setTranslationFromFloats(0, 0, 0);
  90983. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  90984. }
  90985. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5]);
  90986. _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]);
  90987. }
  90988. // Post multiply inverse of pivotMatrix
  90989. if (this._postMultiplyPivotMatrix) {
  90990. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5].multiplyToRef(this._pivotMatrixInverse, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5]);
  90991. }
  90992. // Local world
  90993. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2], this._localMatrix);
  90994. // Parent
  90995. if (this.parent && this.parent.getWorldMatrix) {
  90996. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  90997. if (this._transformToBoneReferal) {
  90998. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  90999. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5].copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  91000. }
  91001. else {
  91002. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5].copyFrom(this.parent.getWorldMatrix());
  91003. }
  91004. this._localMatrix.getTranslationToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5]);
  91005. _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]);
  91006. this._worldMatrix.copyFrom(this._localMatrix);
  91007. this._worldMatrix.setTranslation(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5]);
  91008. }
  91009. else {
  91010. if (this._transformToBoneReferal) {
  91011. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  91012. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix);
  91013. }
  91014. else {
  91015. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  91016. }
  91017. }
  91018. this._markSyncedWithParent();
  91019. }
  91020. else {
  91021. this._worldMatrix.copyFrom(this._localMatrix);
  91022. }
  91023. // Normal matrix
  91024. if (!this.ignoreNonUniformScaling) {
  91025. if (this.scaling.isNonUniform) {
  91026. this._updateNonUniformScalingState(true);
  91027. }
  91028. else if (this.parent && this.parent._nonUniformScaling) {
  91029. this._updateNonUniformScalingState(this.parent._nonUniformScaling);
  91030. }
  91031. else {
  91032. this._updateNonUniformScalingState(false);
  91033. }
  91034. }
  91035. else {
  91036. this._updateNonUniformScalingState(false);
  91037. }
  91038. this._afterComputeWorldMatrix();
  91039. // Absolute position
  91040. this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
  91041. // Callbacks
  91042. this.onAfterWorldMatrixUpdateObservable.notifyObservers(this);
  91043. if (!this._poseMatrix) {
  91044. this._poseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._worldMatrix);
  91045. }
  91046. // Cache the determinant
  91047. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  91048. return this._worldMatrix;
  91049. };
  91050. TransformNode.prototype._afterComputeWorldMatrix = function () {
  91051. };
  91052. /**
  91053. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  91054. * @param func callback function to add
  91055. *
  91056. * @returns the TransformNode.
  91057. */
  91058. TransformNode.prototype.registerAfterWorldMatrixUpdate = function (func) {
  91059. this.onAfterWorldMatrixUpdateObservable.add(func);
  91060. return this;
  91061. };
  91062. /**
  91063. * Removes a registered callback function.
  91064. * @param func callback function to remove
  91065. * @returns the TransformNode.
  91066. */
  91067. TransformNode.prototype.unregisterAfterWorldMatrixUpdate = function (func) {
  91068. this.onAfterWorldMatrixUpdateObservable.removeCallback(func);
  91069. return this;
  91070. };
  91071. /**
  91072. * Gets the position of the current mesh in camera space
  91073. * @param camera defines the camera to use
  91074. * @returns a position
  91075. */
  91076. TransformNode.prototype.getPositionInCameraSpace = function (camera) {
  91077. if (camera === void 0) { camera = null; }
  91078. if (!camera) {
  91079. camera = this.getScene().activeCamera;
  91080. }
  91081. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this.absolutePosition, camera.getViewMatrix());
  91082. };
  91083. /**
  91084. * Returns the distance from the mesh to the active camera
  91085. * @param camera defines the camera to use
  91086. * @returns the distance
  91087. */
  91088. TransformNode.prototype.getDistanceToCamera = function (camera) {
  91089. if (camera === void 0) { camera = null; }
  91090. if (!camera) {
  91091. camera = this.getScene().activeCamera;
  91092. }
  91093. return this.absolutePosition.subtract(camera.position).length();
  91094. };
  91095. /**
  91096. * Clone the current transform node
  91097. * @param name Name of the new clone
  91098. * @param newParent New parent for the clone
  91099. * @param doNotCloneChildren Do not clone children hierarchy
  91100. * @returns the new transform node
  91101. */
  91102. TransformNode.prototype.clone = function (name, newParent, doNotCloneChildren) {
  91103. var _this = this;
  91104. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new TransformNode(name, _this.getScene()); }, this);
  91105. result.name = name;
  91106. result.id = name;
  91107. if (newParent) {
  91108. result.parent = newParent;
  91109. }
  91110. if (!doNotCloneChildren) {
  91111. // Children
  91112. var directDescendants = this.getDescendants(true);
  91113. for (var index = 0; index < directDescendants.length; index++) {
  91114. var child = directDescendants[index];
  91115. if (child.clone) {
  91116. child.clone(name + "." + child.name, result);
  91117. }
  91118. }
  91119. }
  91120. return result;
  91121. };
  91122. /**
  91123. * Serializes the objects information.
  91124. * @param currentSerializationObject defines the object to serialize in
  91125. * @returns the serialized object
  91126. */
  91127. TransformNode.prototype.serialize = function (currentSerializationObject) {
  91128. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, currentSerializationObject);
  91129. serializationObject.type = this.getClassName();
  91130. // Parent
  91131. if (this.parent) {
  91132. serializationObject.parentId = this.parent.id;
  91133. }
  91134. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  91135. serializationObject.isEnabled = this.isEnabled();
  91136. // Parent
  91137. if (this.parent) {
  91138. serializationObject.parentId = this.parent.id;
  91139. }
  91140. return serializationObject;
  91141. };
  91142. // Statics
  91143. /**
  91144. * Returns a new TransformNode object parsed from the source provided.
  91145. * @param parsedTransformNode is the source.
  91146. * @param scene the scne the object belongs to
  91147. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  91148. * @returns a new TransformNode object parsed from the source provided.
  91149. */
  91150. TransformNode.Parse = function (parsedTransformNode, scene, rootUrl) {
  91151. var transformNode = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new TransformNode(parsedTransformNode.name, scene); }, parsedTransformNode, scene, rootUrl);
  91152. if (parsedTransformNode.localMatrix) {
  91153. transformNode.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.localMatrix));
  91154. }
  91155. else if (parsedTransformNode.pivotMatrix) {
  91156. transformNode.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.pivotMatrix));
  91157. }
  91158. transformNode.setEnabled(parsedTransformNode.isEnabled);
  91159. // Parent
  91160. if (parsedTransformNode.parentId) {
  91161. transformNode._waitingParentId = parsedTransformNode.parentId;
  91162. }
  91163. return transformNode;
  91164. };
  91165. /**
  91166. * Get all child-transformNodes of this node
  91167. * @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
  91168. * @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
  91169. * @returns an array of TransformNode
  91170. */
  91171. TransformNode.prototype.getChildTransformNodes = function (directDescendantsOnly, predicate) {
  91172. var results = [];
  91173. this._getDescendants(results, directDescendantsOnly, function (node) {
  91174. return ((!predicate || predicate(node)) && (node instanceof TransformNode));
  91175. });
  91176. return results;
  91177. };
  91178. /**
  91179. * Releases resources associated with this transform node.
  91180. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91181. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91182. */
  91183. TransformNode.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  91184. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  91185. // Animations
  91186. this.getScene().stopAnimation(this);
  91187. // Remove from scene
  91188. this.getScene().removeTransformNode(this);
  91189. this.onAfterWorldMatrixUpdateObservable.clear();
  91190. if (doNotRecurse) {
  91191. var transformNodes = this.getChildTransformNodes(true);
  91192. for (var _i = 0, transformNodes_1 = transformNodes; _i < transformNodes_1.length; _i++) {
  91193. var transformNode = transformNodes_1[_i];
  91194. transformNode.parent = null;
  91195. transformNode.computeWorldMatrix(true);
  91196. }
  91197. }
  91198. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  91199. };
  91200. // Statics
  91201. /**
  91202. * Object will not rotate to face the camera
  91203. */
  91204. TransformNode.BILLBOARDMODE_NONE = 0;
  91205. /**
  91206. * Object will rotate to face the camera but only on the x axis
  91207. */
  91208. TransformNode.BILLBOARDMODE_X = 1;
  91209. /**
  91210. * Object will rotate to face the camera but only on the y axis
  91211. */
  91212. TransformNode.BILLBOARDMODE_Y = 2;
  91213. /**
  91214. * Object will rotate to face the camera but only on the z axis
  91215. */
  91216. TransformNode.BILLBOARDMODE_Z = 4;
  91217. /**
  91218. * Object will rotate to face the camera
  91219. */
  91220. TransformNode.BILLBOARDMODE_ALL = 7;
  91221. TransformNode._lookAtVectorCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  91222. TransformNode._rotationAxisCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  91223. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91224. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  91225. ], TransformNode.prototype, "_position", void 0);
  91226. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91227. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("rotation")
  91228. ], TransformNode.prototype, "_rotation", void 0);
  91229. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91230. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsQuaternion"])("rotationQuaternion")
  91231. ], TransformNode.prototype, "_rotationQuaternion", void 0);
  91232. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91233. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("scaling")
  91234. ], TransformNode.prototype, "_scaling", void 0);
  91235. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91236. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  91237. ], TransformNode.prototype, "billboardMode", void 0);
  91238. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91239. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  91240. ], TransformNode.prototype, "scalingDeterminant", void 0);
  91241. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91242. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  91243. ], TransformNode.prototype, "infiniteDistance", void 0);
  91244. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91245. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  91246. ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
  91247. return TransformNode;
  91248. }(_node__WEBPACK_IMPORTED_MODULE_4__["Node"]));
  91249. /***/ }),
  91250. /***/ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts":
  91251. /*!***************************************************************!*\
  91252. !*** ./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts ***!
  91253. \***************************************************************/
  91254. /*! exports provided: CubeMapToSphericalPolynomialTools */
  91255. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91256. "use strict";
  91257. __webpack_require__.r(__webpack_exports__);
  91258. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return CubeMapToSphericalPolynomialTools; });
  91259. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  91260. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  91261. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  91262. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  91263. var FileFaceOrientation = /** @class */ (function () {
  91264. function FileFaceOrientation(name, worldAxisForNormal, worldAxisForFileX, worldAxisForFileY) {
  91265. this.name = name;
  91266. this.worldAxisForNormal = worldAxisForNormal;
  91267. this.worldAxisForFileX = worldAxisForFileX;
  91268. this.worldAxisForFileY = worldAxisForFileY;
  91269. }
  91270. return FileFaceOrientation;
  91271. }());
  91272. /**
  91273. * Helper class dealing with the extraction of spherical polynomial dataArray
  91274. * from a cube map.
  91275. */
  91276. var CubeMapToSphericalPolynomialTools = /** @class */ (function () {
  91277. function CubeMapToSphericalPolynomialTools() {
  91278. }
  91279. /**
  91280. * Converts a texture to the according Spherical Polynomial data.
  91281. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91282. *
  91283. * @param texture The texture to extract the information from.
  91284. * @return The Spherical Polynomial data.
  91285. */
  91286. CubeMapToSphericalPolynomialTools.ConvertCubeMapTextureToSphericalPolynomial = function (texture) {
  91287. if (!texture.isCube) {
  91288. // Only supports cube Textures currently.
  91289. return null;
  91290. }
  91291. var size = texture.getSize().width;
  91292. var right = texture.readPixels(0);
  91293. var left = texture.readPixels(1);
  91294. var up;
  91295. var down;
  91296. if (texture.isRenderTarget) {
  91297. up = texture.readPixels(3);
  91298. down = texture.readPixels(2);
  91299. }
  91300. else {
  91301. up = texture.readPixels(2);
  91302. down = texture.readPixels(3);
  91303. }
  91304. var front = texture.readPixels(4);
  91305. var back = texture.readPixels(5);
  91306. var gammaSpace = texture.gammaSpace;
  91307. // Always read as RGBA.
  91308. var format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA;
  91309. var type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  91310. if (texture.textureType && texture.textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  91311. type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_FLOAT;
  91312. }
  91313. var cubeInfo = {
  91314. size: size,
  91315. right: right,
  91316. left: left,
  91317. up: up,
  91318. down: down,
  91319. front: front,
  91320. back: back,
  91321. format: format,
  91322. type: type,
  91323. gammaSpace: gammaSpace,
  91324. };
  91325. return this.ConvertCubeMapToSphericalPolynomial(cubeInfo);
  91326. };
  91327. /**
  91328. * Converts a cubemap to the according Spherical Polynomial data.
  91329. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91330. *
  91331. * @param cubeInfo The Cube map to extract the information from.
  91332. * @return The Spherical Polynomial data.
  91333. */
  91334. CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial = function (cubeInfo) {
  91335. var sphericalHarmonics = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]();
  91336. var totalSolidAngle = 0.0;
  91337. // The (u,v) range is [-1,+1], so the distance between each texel is 2/Size.
  91338. var du = 2.0 / cubeInfo.size;
  91339. var dv = du;
  91340. // The (u,v) of the first texel is half a texel from the corner (-1,-1).
  91341. var minUV = du * 0.5 - 1.0;
  91342. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  91343. var fileFace = this.FileFaces[faceIndex];
  91344. var dataArray = cubeInfo[fileFace.name];
  91345. var v = minUV;
  91346. // TODO: we could perform the summation directly into a SphericalPolynomial (SP), which is more efficient than SphericalHarmonic (SH).
  91347. // This is possible because during the summation we do not need the SH-specific properties, e.g. orthogonality.
  91348. // Because SP is still linear, so summation is fine in that basis.
  91349. var stride = cubeInfo.format === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA ? 4 : 3;
  91350. for (var y = 0; y < cubeInfo.size; y++) {
  91351. var u = minUV;
  91352. for (var x = 0; x < cubeInfo.size; x++) {
  91353. // World direction (not normalised)
  91354. var worldDirection = fileFace.worldAxisForFileX.scale(u).add(fileFace.worldAxisForFileY.scale(v)).add(fileFace.worldAxisForNormal);
  91355. worldDirection.normalize();
  91356. var deltaSolidAngle = Math.pow(1.0 + u * u + v * v, -3.0 / 2.0);
  91357. var r = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 0];
  91358. var g = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 1];
  91359. var b = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 2];
  91360. // Handle Integer types.
  91361. if (cubeInfo.type === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  91362. r /= 255;
  91363. g /= 255;
  91364. b /= 255;
  91365. }
  91366. // Handle Gamma space textures.
  91367. if (cubeInfo.gammaSpace) {
  91368. r = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(r), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  91369. g = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(g), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  91370. b = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(b), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  91371. }
  91372. var color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](r, g, b);
  91373. sphericalHarmonics.addLight(worldDirection, color, deltaSolidAngle);
  91374. totalSolidAngle += deltaSolidAngle;
  91375. u += du;
  91376. }
  91377. v += dv;
  91378. }
  91379. }
  91380. // Solid angle for entire sphere is 4*pi
  91381. var sphereSolidAngle = 4.0 * Math.PI;
  91382. // Adjust the solid angle to allow for how many faces we processed.
  91383. var facesProcessed = 6.0;
  91384. var expectedSolidAngle = sphereSolidAngle * facesProcessed / 6.0;
  91385. // Adjust the harmonics so that the accumulated solid angle matches the expected solid angle.
  91386. // This is needed because the numerical integration over the cube uses a
  91387. // small angle approximation of solid angle for each texel (see deltaSolidAngle),
  91388. // and also to compensate for accumulative error due to float precision in the summation.
  91389. var correctionFactor = expectedSolidAngle / totalSolidAngle;
  91390. sphericalHarmonics.scale(correctionFactor);
  91391. sphericalHarmonics.convertIncidentRadianceToIrradiance();
  91392. sphericalHarmonics.convertIrradianceToLambertianRadiance();
  91393. return _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"].FromHarmonics(sphericalHarmonics);
  91394. };
  91395. CubeMapToSphericalPolynomialTools.FileFaces = [
  91396. 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)),
  91397. 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)),
  91398. 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)),
  91399. 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)),
  91400. 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)),
  91401. 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
  91402. ];
  91403. return CubeMapToSphericalPolynomialTools;
  91404. }());
  91405. /***/ }),
  91406. /***/ "./Misc/HighDynamicRange/hdr.ts":
  91407. /*!**************************************!*\
  91408. !*** ./Misc/HighDynamicRange/hdr.ts ***!
  91409. \**************************************/
  91410. /*! exports provided: HDRTools */
  91411. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91412. "use strict";
  91413. __webpack_require__.r(__webpack_exports__);
  91414. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return HDRTools; });
  91415. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  91416. /**
  91417. * This groups tools to convert HDR texture to native colors array.
  91418. */
  91419. var HDRTools = /** @class */ (function () {
  91420. function HDRTools() {
  91421. }
  91422. HDRTools.Ldexp = function (mantissa, exponent) {
  91423. if (exponent > 1023) {
  91424. return mantissa * Math.pow(2, 1023) * Math.pow(2, exponent - 1023);
  91425. }
  91426. if (exponent < -1074) {
  91427. return mantissa * Math.pow(2, -1074) * Math.pow(2, exponent + 1074);
  91428. }
  91429. return mantissa * Math.pow(2, exponent);
  91430. };
  91431. HDRTools.Rgbe2float = function (float32array, red, green, blue, exponent, index) {
  91432. if (exponent > 0) { /*nonzero pixel*/
  91433. exponent = this.Ldexp(1.0, exponent - (128 + 8));
  91434. float32array[index + 0] = red * exponent;
  91435. float32array[index + 1] = green * exponent;
  91436. float32array[index + 2] = blue * exponent;
  91437. }
  91438. else {
  91439. float32array[index + 0] = 0;
  91440. float32array[index + 1] = 0;
  91441. float32array[index + 2] = 0;
  91442. }
  91443. };
  91444. HDRTools.readStringLine = function (uint8array, startIndex) {
  91445. var line = "";
  91446. var character = "";
  91447. for (var i = startIndex; i < uint8array.length - startIndex; i++) {
  91448. character = String.fromCharCode(uint8array[i]);
  91449. if (character == "\n") {
  91450. break;
  91451. }
  91452. line += character;
  91453. }
  91454. return line;
  91455. };
  91456. /**
  91457. * Reads header information from an RGBE texture stored in a native array.
  91458. * More information on this format are available here:
  91459. * https://en.wikipedia.org/wiki/RGBE_image_format
  91460. *
  91461. * @param uint8array The binary file stored in native array.
  91462. * @return The header information.
  91463. */
  91464. HDRTools.RGBE_ReadHeader = function (uint8array) {
  91465. var height = 0;
  91466. var width = 0;
  91467. var line = this.readStringLine(uint8array, 0);
  91468. if (line[0] != '#' || line[1] != '?') {
  91469. throw "Bad HDR Format.";
  91470. }
  91471. var endOfHeader = false;
  91472. var findFormat = false;
  91473. var lineIndex = 0;
  91474. do {
  91475. lineIndex += (line.length + 1);
  91476. line = this.readStringLine(uint8array, lineIndex);
  91477. if (line == "FORMAT=32-bit_rle_rgbe") {
  91478. findFormat = true;
  91479. }
  91480. else if (line.length == 0) {
  91481. endOfHeader = true;
  91482. }
  91483. } while (!endOfHeader);
  91484. if (!findFormat) {
  91485. throw "HDR Bad header format, unsupported FORMAT";
  91486. }
  91487. lineIndex += (line.length + 1);
  91488. line = this.readStringLine(uint8array, lineIndex);
  91489. var sizeRegexp = /^\-Y (.*) \+X (.*)$/g;
  91490. var match = sizeRegexp.exec(line);
  91491. // TODO. Support +Y and -X if needed.
  91492. if (!match || match.length < 3) {
  91493. throw "HDR Bad header format, no size";
  91494. }
  91495. width = parseInt(match[2]);
  91496. height = parseInt(match[1]);
  91497. if (width < 8 || width > 0x7fff) {
  91498. throw "HDR Bad header format, unsupported size";
  91499. }
  91500. lineIndex += (line.length + 1);
  91501. return {
  91502. height: height,
  91503. width: width,
  91504. dataPosition: lineIndex
  91505. };
  91506. };
  91507. /**
  91508. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  91509. * This RGBE texture needs to store the information as a panorama.
  91510. *
  91511. * More information on this format are available here:
  91512. * https://en.wikipedia.org/wiki/RGBE_image_format
  91513. *
  91514. * @param buffer The binary file stored in an array buffer.
  91515. * @param size The expected size of the extracted cubemap.
  91516. * @return The Cube Map information.
  91517. */
  91518. HDRTools.GetCubeMapTextureData = function (buffer, size) {
  91519. var uint8array = new Uint8Array(buffer);
  91520. var hdrInfo = this.RGBE_ReadHeader(uint8array);
  91521. var data = this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  91522. var cubeMapData = _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(data, hdrInfo.width, hdrInfo.height, size);
  91523. return cubeMapData;
  91524. };
  91525. /**
  91526. * Returns the pixels data extracted from an RGBE texture.
  91527. * This pixels will be stored left to right up to down in the R G B order in one array.
  91528. *
  91529. * More information on this format are available here:
  91530. * https://en.wikipedia.org/wiki/RGBE_image_format
  91531. *
  91532. * @param uint8array The binary file stored in an array buffer.
  91533. * @param hdrInfo The header information of the file.
  91534. * @return The pixels data in RGB right to left up to down order.
  91535. */
  91536. HDRTools.RGBE_ReadPixels = function (uint8array, hdrInfo) {
  91537. // Keep for multi format supports.
  91538. return this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  91539. };
  91540. HDRTools.RGBE_ReadPixels_RLE = function (uint8array, hdrInfo) {
  91541. var num_scanlines = hdrInfo.height;
  91542. var scanline_width = hdrInfo.width;
  91543. var a, b, c, d, count;
  91544. var dataIndex = hdrInfo.dataPosition;
  91545. var index = 0, endIndex = 0, i = 0;
  91546. var scanLineArrayBuffer = new ArrayBuffer(scanline_width * 4); // four channel R G B E
  91547. var scanLineArray = new Uint8Array(scanLineArrayBuffer);
  91548. // 3 channels of 4 bytes per pixel in float.
  91549. var resultBuffer = new ArrayBuffer(hdrInfo.width * hdrInfo.height * 4 * 3);
  91550. var resultArray = new Float32Array(resultBuffer);
  91551. // read in each successive scanline
  91552. while (num_scanlines > 0) {
  91553. a = uint8array[dataIndex++];
  91554. b = uint8array[dataIndex++];
  91555. c = uint8array[dataIndex++];
  91556. d = uint8array[dataIndex++];
  91557. if (a != 2 || b != 2 || (c & 0x80)) {
  91558. // this file is not run length encoded
  91559. throw "HDR Bad header format, not RLE";
  91560. }
  91561. if (((c << 8) | d) != scanline_width) {
  91562. throw "HDR Bad header format, wrong scan line width";
  91563. }
  91564. index = 0;
  91565. // read each of the four channels for the scanline into the buffer
  91566. for (i = 0; i < 4; i++) {
  91567. endIndex = (i + 1) * scanline_width;
  91568. while (index < endIndex) {
  91569. a = uint8array[dataIndex++];
  91570. b = uint8array[dataIndex++];
  91571. if (a > 128) {
  91572. // a run of the same value
  91573. count = a - 128;
  91574. if ((count == 0) || (count > endIndex - index)) {
  91575. throw "HDR Bad Format, bad scanline data (run)";
  91576. }
  91577. while (count-- > 0) {
  91578. scanLineArray[index++] = b;
  91579. }
  91580. }
  91581. else {
  91582. // a non-run
  91583. count = a;
  91584. if ((count == 0) || (count > endIndex - index)) {
  91585. throw "HDR Bad Format, bad scanline data (non-run)";
  91586. }
  91587. scanLineArray[index++] = b;
  91588. if (--count > 0) {
  91589. for (var j = 0; j < count; j++) {
  91590. scanLineArray[index++] = uint8array[dataIndex++];
  91591. }
  91592. }
  91593. }
  91594. }
  91595. }
  91596. // now convert data from buffer into floats
  91597. for (i = 0; i < scanline_width; i++) {
  91598. a = scanLineArray[i];
  91599. b = scanLineArray[i + scanline_width];
  91600. c = scanLineArray[i + 2 * scanline_width];
  91601. d = scanLineArray[i + 3 * scanline_width];
  91602. this.Rgbe2float(resultArray, a, b, c, d, (hdrInfo.height - num_scanlines) * scanline_width * 3 + i * 3);
  91603. }
  91604. num_scanlines--;
  91605. }
  91606. return resultArray;
  91607. };
  91608. return HDRTools;
  91609. }());
  91610. /***/ }),
  91611. /***/ "./Misc/HighDynamicRange/index.ts":
  91612. /*!****************************************!*\
  91613. !*** ./Misc/HighDynamicRange/index.ts ***!
  91614. \****************************************/
  91615. /*! exports provided: CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  91616. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91617. "use strict";
  91618. __webpack_require__.r(__webpack_exports__);
  91619. /* harmony import */ var _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  91620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  91621. /* harmony import */ var _hdr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hdr */ "./Misc/HighDynamicRange/hdr.ts");
  91622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _hdr__WEBPACK_IMPORTED_MODULE_1__["HDRTools"]; });
  91623. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  91624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__["PanoramaToCubeMapTools"]; });
  91625. /***/ }),
  91626. /***/ "./Misc/HighDynamicRange/panoramaToCubemap.ts":
  91627. /*!****************************************************!*\
  91628. !*** ./Misc/HighDynamicRange/panoramaToCubemap.ts ***!
  91629. \****************************************************/
  91630. /*! exports provided: PanoramaToCubeMapTools */
  91631. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91632. "use strict";
  91633. __webpack_require__.r(__webpack_exports__);
  91634. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return PanoramaToCubeMapTools; });
  91635. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  91636. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  91637. /**
  91638. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  91639. */
  91640. var PanoramaToCubeMapTools = /** @class */ (function () {
  91641. function PanoramaToCubeMapTools() {
  91642. }
  91643. /**
  91644. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  91645. *
  91646. * @param float32Array The source data.
  91647. * @param inputWidth The width of the input panorama.
  91648. * @param inputHeight The height of the input panorama.
  91649. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  91650. * @return The cubemap data
  91651. */
  91652. PanoramaToCubeMapTools.ConvertPanoramaToCubemap = function (float32Array, inputWidth, inputHeight, size) {
  91653. if (!float32Array) {
  91654. throw "ConvertPanoramaToCubemap: input cannot be null";
  91655. }
  91656. if (float32Array.length != inputWidth * inputHeight * 3) {
  91657. throw "ConvertPanoramaToCubemap: input size is wrong";
  91658. }
  91659. var textureFront = this.CreateCubemapTexture(size, this.FACE_FRONT, float32Array, inputWidth, inputHeight);
  91660. var textureBack = this.CreateCubemapTexture(size, this.FACE_BACK, float32Array, inputWidth, inputHeight);
  91661. var textureLeft = this.CreateCubemapTexture(size, this.FACE_LEFT, float32Array, inputWidth, inputHeight);
  91662. var textureRight = this.CreateCubemapTexture(size, this.FACE_RIGHT, float32Array, inputWidth, inputHeight);
  91663. var textureUp = this.CreateCubemapTexture(size, this.FACE_UP, float32Array, inputWidth, inputHeight);
  91664. var textureDown = this.CreateCubemapTexture(size, this.FACE_DOWN, float32Array, inputWidth, inputHeight);
  91665. return {
  91666. front: textureFront,
  91667. back: textureBack,
  91668. left: textureLeft,
  91669. right: textureRight,
  91670. up: textureUp,
  91671. down: textureDown,
  91672. size: size,
  91673. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT,
  91674. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGB,
  91675. gammaSpace: false,
  91676. };
  91677. };
  91678. PanoramaToCubeMapTools.CreateCubemapTexture = function (texSize, faceData, float32Array, inputWidth, inputHeight) {
  91679. var buffer = new ArrayBuffer(texSize * texSize * 4 * 3);
  91680. var textureArray = new Float32Array(buffer);
  91681. var rotDX1 = faceData[1].subtract(faceData[0]).scale(1 / texSize);
  91682. var rotDX2 = faceData[3].subtract(faceData[2]).scale(1 / texSize);
  91683. var dy = 1 / texSize;
  91684. var fy = 0;
  91685. for (var y = 0; y < texSize; y++) {
  91686. var xv1 = faceData[0];
  91687. var xv2 = faceData[2];
  91688. for (var x = 0; x < texSize; x++) {
  91689. var v = xv2.subtract(xv1).scale(fy).add(xv1);
  91690. v.normalize();
  91691. var color = this.CalcProjectionSpherical(v, float32Array, inputWidth, inputHeight);
  91692. // 3 channels per pixels
  91693. textureArray[y * texSize * 3 + (x * 3) + 0] = color.r;
  91694. textureArray[y * texSize * 3 + (x * 3) + 1] = color.g;
  91695. textureArray[y * texSize * 3 + (x * 3) + 2] = color.b;
  91696. xv1 = xv1.add(rotDX1);
  91697. xv2 = xv2.add(rotDX2);
  91698. }
  91699. fy += dy;
  91700. }
  91701. return textureArray;
  91702. };
  91703. PanoramaToCubeMapTools.CalcProjectionSpherical = function (vDir, float32Array, inputWidth, inputHeight) {
  91704. var theta = Math.atan2(vDir.z, vDir.x);
  91705. var phi = Math.acos(vDir.y);
  91706. while (theta < -Math.PI) {
  91707. theta += 2 * Math.PI;
  91708. }
  91709. while (theta > Math.PI) {
  91710. theta -= 2 * Math.PI;
  91711. }
  91712. var dx = theta / Math.PI;
  91713. var dy = phi / Math.PI;
  91714. // recenter.
  91715. dx = dx * 0.5 + 0.5;
  91716. var px = Math.round(dx * inputWidth);
  91717. if (px < 0) {
  91718. px = 0;
  91719. }
  91720. else if (px >= inputWidth) {
  91721. px = inputWidth - 1;
  91722. }
  91723. var py = Math.round(dy * inputHeight);
  91724. if (py < 0) {
  91725. py = 0;
  91726. }
  91727. else if (py >= inputHeight) {
  91728. py = inputHeight - 1;
  91729. }
  91730. var inputY = (inputHeight - py - 1);
  91731. var r = float32Array[inputY * inputWidth * 3 + (px * 3) + 0];
  91732. var g = float32Array[inputY * inputWidth * 3 + (px * 3) + 1];
  91733. var b = float32Array[inputY * inputWidth * 3 + (px * 3) + 2];
  91734. return {
  91735. r: r,
  91736. g: g,
  91737. b: b
  91738. };
  91739. };
  91740. PanoramaToCubeMapTools.FACE_FRONT = [
  91741. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  91742. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  91743. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  91744. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0)
  91745. ];
  91746. PanoramaToCubeMapTools.FACE_BACK = [
  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. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0),
  91750. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0)
  91751. ];
  91752. PanoramaToCubeMapTools.FACE_RIGHT = [
  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. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  91756. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  91757. ];
  91758. PanoramaToCubeMapTools.FACE_LEFT = [
  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. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  91762. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0)
  91763. ];
  91764. PanoramaToCubeMapTools.FACE_DOWN = [
  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. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  91768. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  91769. ];
  91770. PanoramaToCubeMapTools.FACE_UP = [
  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. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  91774. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0)
  91775. ];
  91776. return PanoramaToCubeMapTools;
  91777. }());
  91778. /***/ }),
  91779. /***/ "./Misc/andOrNotEvaluator.ts":
  91780. /*!***********************************!*\
  91781. !*** ./Misc/andOrNotEvaluator.ts ***!
  91782. \***********************************/
  91783. /*! exports provided: AndOrNotEvaluator */
  91784. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91785. "use strict";
  91786. __webpack_require__.r(__webpack_exports__);
  91787. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return AndOrNotEvaluator; });
  91788. /**
  91789. * Class used to evalaute queries containing `and` and `or` operators
  91790. */
  91791. var AndOrNotEvaluator = /** @class */ (function () {
  91792. function AndOrNotEvaluator() {
  91793. }
  91794. /**
  91795. * Evaluate a query
  91796. * @param query defines the query to evaluate
  91797. * @param evaluateCallback defines the callback used to filter result
  91798. * @returns true if the query matches
  91799. */
  91800. AndOrNotEvaluator.Eval = function (query, evaluateCallback) {
  91801. if (!query.match(/\([^\(\)]*\)/g)) {
  91802. query = AndOrNotEvaluator._HandleParenthesisContent(query, evaluateCallback);
  91803. }
  91804. else {
  91805. query = query.replace(/\([^\(\)]*\)/g, function (r) {
  91806. // remove parenthesis
  91807. r = r.slice(1, r.length - 1);
  91808. return AndOrNotEvaluator._HandleParenthesisContent(r, evaluateCallback);
  91809. });
  91810. }
  91811. if (query === "true") {
  91812. return true;
  91813. }
  91814. if (query === "false") {
  91815. return false;
  91816. }
  91817. return AndOrNotEvaluator.Eval(query, evaluateCallback);
  91818. };
  91819. AndOrNotEvaluator._HandleParenthesisContent = function (parenthesisContent, evaluateCallback) {
  91820. evaluateCallback = evaluateCallback || (function (r) {
  91821. return r === "true" ? true : false;
  91822. });
  91823. var result;
  91824. var or = parenthesisContent.split("||");
  91825. for (var i in or) {
  91826. if (or.hasOwnProperty(i)) {
  91827. var ori = AndOrNotEvaluator._SimplifyNegation(or[i].trim());
  91828. var and = ori.split("&&");
  91829. if (and.length > 1) {
  91830. for (var j = 0; j < and.length; ++j) {
  91831. var andj = AndOrNotEvaluator._SimplifyNegation(and[j].trim());
  91832. if (andj !== "true" && andj !== "false") {
  91833. if (andj[0] === "!") {
  91834. result = !evaluateCallback(andj.substring(1));
  91835. }
  91836. else {
  91837. result = evaluateCallback(andj);
  91838. }
  91839. }
  91840. else {
  91841. result = andj === "true" ? true : false;
  91842. }
  91843. if (!result) { // no need to continue since 'false && ... && ...' will always return false
  91844. ori = "false";
  91845. break;
  91846. }
  91847. }
  91848. }
  91849. if (result || ori === "true") { // no need to continue since 'true || ... || ...' will always return true
  91850. result = true;
  91851. break;
  91852. }
  91853. // result equals false (or undefined)
  91854. if (ori !== "true" && ori !== "false") {
  91855. if (ori[0] === "!") {
  91856. result = !evaluateCallback(ori.substring(1));
  91857. }
  91858. else {
  91859. result = evaluateCallback(ori);
  91860. }
  91861. }
  91862. else {
  91863. result = ori === "true" ? true : false;
  91864. }
  91865. }
  91866. }
  91867. // the whole parenthesis scope is replaced by 'true' or 'false'
  91868. return result ? "true" : "false";
  91869. };
  91870. AndOrNotEvaluator._SimplifyNegation = function (booleanString) {
  91871. booleanString = booleanString.replace(/^[\s!]+/, function (r) {
  91872. // remove whitespaces
  91873. r = r.replace(/[\s]/g, function () { return ""; });
  91874. return r.length % 2 ? "!" : "";
  91875. });
  91876. booleanString = booleanString.trim();
  91877. if (booleanString === "!true") {
  91878. booleanString = "false";
  91879. }
  91880. else if (booleanString === "!false") {
  91881. booleanString = "true";
  91882. }
  91883. return booleanString;
  91884. };
  91885. return AndOrNotEvaluator;
  91886. }());
  91887. /***/ }),
  91888. /***/ "./Misc/arrayTools.ts":
  91889. /*!****************************!*\
  91890. !*** ./Misc/arrayTools.ts ***!
  91891. \****************************/
  91892. /*! exports provided: ArrayTools */
  91893. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91894. "use strict";
  91895. __webpack_require__.r(__webpack_exports__);
  91896. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayTools", function() { return ArrayTools; });
  91897. /**
  91898. * Class containing a set of static utilities functions for arrays.
  91899. */
  91900. var ArrayTools = /** @class */ (function () {
  91901. function ArrayTools() {
  91902. }
  91903. /**
  91904. * Returns an array of the given size filled with element built from the given constructor and the paramters
  91905. * @param size the number of element to construct and put in the array
  91906. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  91907. * @returns a new array filled with new objects
  91908. */
  91909. ArrayTools.BuildArray = function (size, itemBuilder) {
  91910. var a = [];
  91911. for (var i = 0; i < size; ++i) {
  91912. a.push(itemBuilder());
  91913. }
  91914. return a;
  91915. };
  91916. return ArrayTools;
  91917. }());
  91918. /***/ }),
  91919. /***/ "./Misc/assetsManager.ts":
  91920. /*!*******************************!*\
  91921. !*** ./Misc/assetsManager.ts ***!
  91922. \*******************************/
  91923. /*! exports provided: AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager */
  91924. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91925. "use strict";
  91926. __webpack_require__.r(__webpack_exports__);
  91927. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return AssetTaskState; });
  91928. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return AbstractAssetTask; });
  91929. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return AssetsProgressEvent; });
  91930. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return MeshAssetTask; });
  91931. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return TextFileAssetTask; });
  91932. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return BinaryFileAssetTask; });
  91933. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return ImageAssetTask; });
  91934. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return TextureAssetTask; });
  91935. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return CubeTextureAssetTask; });
  91936. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return HDRCubeTextureAssetTask; });
  91937. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return AssetsManager; });
  91938. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  91939. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  91940. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  91941. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  91942. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  91943. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  91944. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  91945. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  91946. /**
  91947. * Defines the list of states available for a task inside a AssetsManager
  91948. */
  91949. var AssetTaskState;
  91950. (function (AssetTaskState) {
  91951. /**
  91952. * Initialization
  91953. */
  91954. AssetTaskState[AssetTaskState["INIT"] = 0] = "INIT";
  91955. /**
  91956. * Running
  91957. */
  91958. AssetTaskState[AssetTaskState["RUNNING"] = 1] = "RUNNING";
  91959. /**
  91960. * Done
  91961. */
  91962. AssetTaskState[AssetTaskState["DONE"] = 2] = "DONE";
  91963. /**
  91964. * Error
  91965. */
  91966. AssetTaskState[AssetTaskState["ERROR"] = 3] = "ERROR";
  91967. })(AssetTaskState || (AssetTaskState = {}));
  91968. /**
  91969. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  91970. */
  91971. var AbstractAssetTask = /** @class */ (function () {
  91972. /**
  91973. * Creates a new AssetsManager
  91974. * @param name defines the name of the task
  91975. */
  91976. function AbstractAssetTask(
  91977. /**
  91978. * Task name
  91979. */ name) {
  91980. this.name = name;
  91981. this._isCompleted = false;
  91982. this._taskState = AssetTaskState.INIT;
  91983. }
  91984. Object.defineProperty(AbstractAssetTask.prototype, "isCompleted", {
  91985. /**
  91986. * Get if the task is completed
  91987. */
  91988. get: function () {
  91989. return this._isCompleted;
  91990. },
  91991. enumerable: true,
  91992. configurable: true
  91993. });
  91994. Object.defineProperty(AbstractAssetTask.prototype, "taskState", {
  91995. /**
  91996. * Gets the current state of the task
  91997. */
  91998. get: function () {
  91999. return this._taskState;
  92000. },
  92001. enumerable: true,
  92002. configurable: true
  92003. });
  92004. Object.defineProperty(AbstractAssetTask.prototype, "errorObject", {
  92005. /**
  92006. * Gets the current error object (if task is in error)
  92007. */
  92008. get: function () {
  92009. return this._errorObject;
  92010. },
  92011. enumerable: true,
  92012. configurable: true
  92013. });
  92014. /**
  92015. * Internal only
  92016. * @hidden
  92017. */
  92018. AbstractAssetTask.prototype._setErrorObject = function (message, exception) {
  92019. if (this._errorObject) {
  92020. return;
  92021. }
  92022. this._errorObject = {
  92023. message: message,
  92024. exception: exception
  92025. };
  92026. };
  92027. /**
  92028. * Execute the current task
  92029. * @param scene defines the scene where you want your assets to be loaded
  92030. * @param onSuccess is a callback called when the task is successfully executed
  92031. * @param onError is a callback called if an error occurs
  92032. */
  92033. AbstractAssetTask.prototype.run = function (scene, onSuccess, onError) {
  92034. var _this = this;
  92035. this._taskState = AssetTaskState.RUNNING;
  92036. this.runTask(scene, function () {
  92037. _this.onDoneCallback(onSuccess, onError);
  92038. }, function (msg, exception) {
  92039. _this.onErrorCallback(onError, msg, exception);
  92040. });
  92041. };
  92042. /**
  92043. * Execute the current task
  92044. * @param scene defines the scene where you want your assets to be loaded
  92045. * @param onSuccess is a callback called when the task is successfully executed
  92046. * @param onError is a callback called if an error occurs
  92047. */
  92048. AbstractAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92049. throw new Error("runTask is not implemented");
  92050. };
  92051. /**
  92052. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  92053. * This can be used with failed tasks that have the reason for failure fixed.
  92054. */
  92055. AbstractAssetTask.prototype.reset = function () {
  92056. this._taskState = AssetTaskState.INIT;
  92057. };
  92058. AbstractAssetTask.prototype.onErrorCallback = function (onError, message, exception) {
  92059. this._taskState = AssetTaskState.ERROR;
  92060. this._errorObject = {
  92061. message: message,
  92062. exception: exception
  92063. };
  92064. if (this.onError) {
  92065. this.onError(this, message, exception);
  92066. }
  92067. onError();
  92068. };
  92069. AbstractAssetTask.prototype.onDoneCallback = function (onSuccess, onError) {
  92070. try {
  92071. this._taskState = AssetTaskState.DONE;
  92072. this._isCompleted = true;
  92073. if (this.onSuccess) {
  92074. this.onSuccess(this);
  92075. }
  92076. onSuccess();
  92077. }
  92078. catch (e) {
  92079. this.onErrorCallback(onError, "Task is done, error executing success callback(s)", e);
  92080. }
  92081. };
  92082. return AbstractAssetTask;
  92083. }());
  92084. /**
  92085. * Class used to share progress information about assets loading
  92086. */
  92087. var AssetsProgressEvent = /** @class */ (function () {
  92088. /**
  92089. * Creates a AssetsProgressEvent
  92090. * @param remainingCount defines the number of remaining tasks to process
  92091. * @param totalCount defines the total number of tasks
  92092. * @param task defines the task that was just processed
  92093. */
  92094. function AssetsProgressEvent(remainingCount, totalCount, task) {
  92095. this.remainingCount = remainingCount;
  92096. this.totalCount = totalCount;
  92097. this.task = task;
  92098. }
  92099. return AssetsProgressEvent;
  92100. }());
  92101. /**
  92102. * Define a task used by AssetsManager to load meshes
  92103. */
  92104. var MeshAssetTask = /** @class */ (function (_super) {
  92105. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshAssetTask, _super);
  92106. /**
  92107. * Creates a new MeshAssetTask
  92108. * @param name defines the name of the task
  92109. * @param meshesNames defines the list of mesh's names you want to load
  92110. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  92111. * @param sceneFilename defines the filename of the scene to load from
  92112. */
  92113. function MeshAssetTask(
  92114. /**
  92115. * Defines the name of the task
  92116. */
  92117. name,
  92118. /**
  92119. * Defines the list of mesh's names you want to load
  92120. */
  92121. meshesNames,
  92122. /**
  92123. * Defines the root url to use as a base to load your meshes and associated resources
  92124. */
  92125. rootUrl,
  92126. /**
  92127. * Defines the filename of the scene to load from
  92128. */
  92129. sceneFilename) {
  92130. var _this = _super.call(this, name) || this;
  92131. _this.name = name;
  92132. _this.meshesNames = meshesNames;
  92133. _this.rootUrl = rootUrl;
  92134. _this.sceneFilename = sceneFilename;
  92135. return _this;
  92136. }
  92137. /**
  92138. * Execute the current task
  92139. * @param scene defines the scene where you want your assets to be loaded
  92140. * @param onSuccess is a callback called when the task is successfully executed
  92141. * @param onError is a callback called if an error occurs
  92142. */
  92143. MeshAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92144. var _this = this;
  92145. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  92146. _this.loadedMeshes = meshes;
  92147. _this.loadedParticleSystems = particleSystems;
  92148. _this.loadedSkeletons = skeletons;
  92149. _this.loadedAnimationGroups = animationGroups;
  92150. onSuccess();
  92151. }, null, function (scene, message, exception) {
  92152. onError(message, exception);
  92153. });
  92154. };
  92155. return MeshAssetTask;
  92156. }(AbstractAssetTask));
  92157. /**
  92158. * Define a task used by AssetsManager to load text content
  92159. */
  92160. var TextFileAssetTask = /** @class */ (function (_super) {
  92161. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextFileAssetTask, _super);
  92162. /**
  92163. * Creates a new TextFileAssetTask object
  92164. * @param name defines the name of the task
  92165. * @param url defines the location of the file to load
  92166. */
  92167. function TextFileAssetTask(
  92168. /**
  92169. * Defines the name of the task
  92170. */
  92171. name,
  92172. /**
  92173. * Defines the location of the file to load
  92174. */
  92175. url) {
  92176. var _this = _super.call(this, name) || this;
  92177. _this.name = name;
  92178. _this.url = url;
  92179. return _this;
  92180. }
  92181. /**
  92182. * Execute the current task
  92183. * @param scene defines the scene where you want your assets to be loaded
  92184. * @param onSuccess is a callback called when the task is successfully executed
  92185. * @param onError is a callback called if an error occurs
  92186. */
  92187. TextFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92188. var _this = this;
  92189. scene._loadFile(this.url, function (data) {
  92190. _this.text = data;
  92191. onSuccess();
  92192. }, undefined, false, false, function (request, exception) {
  92193. if (request) {
  92194. onError(request.status + " " + request.statusText, exception);
  92195. }
  92196. });
  92197. };
  92198. return TextFileAssetTask;
  92199. }(AbstractAssetTask));
  92200. /**
  92201. * Define a task used by AssetsManager to load binary data
  92202. */
  92203. var BinaryFileAssetTask = /** @class */ (function (_super) {
  92204. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BinaryFileAssetTask, _super);
  92205. /**
  92206. * Creates a new BinaryFileAssetTask object
  92207. * @param name defines the name of the new task
  92208. * @param url defines the location of the file to load
  92209. */
  92210. function BinaryFileAssetTask(
  92211. /**
  92212. * Defines the name of the task
  92213. */
  92214. name,
  92215. /**
  92216. * Defines the location of the file to load
  92217. */
  92218. url) {
  92219. var _this = _super.call(this, name) || this;
  92220. _this.name = name;
  92221. _this.url = url;
  92222. return _this;
  92223. }
  92224. /**
  92225. * Execute the current task
  92226. * @param scene defines the scene where you want your assets to be loaded
  92227. * @param onSuccess is a callback called when the task is successfully executed
  92228. * @param onError is a callback called if an error occurs
  92229. */
  92230. BinaryFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92231. var _this = this;
  92232. scene._loadFile(this.url, function (data) {
  92233. _this.data = data;
  92234. onSuccess();
  92235. }, undefined, true, true, function (request, exception) {
  92236. if (request) {
  92237. onError(request.status + " " + request.statusText, exception);
  92238. }
  92239. });
  92240. };
  92241. return BinaryFileAssetTask;
  92242. }(AbstractAssetTask));
  92243. /**
  92244. * Define a task used by AssetsManager to load images
  92245. */
  92246. var ImageAssetTask = /** @class */ (function (_super) {
  92247. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageAssetTask, _super);
  92248. /**
  92249. * Creates a new ImageAssetTask
  92250. * @param name defines the name of the task
  92251. * @param url defines the location of the image to load
  92252. */
  92253. function ImageAssetTask(
  92254. /**
  92255. * Defines the name of the task
  92256. */
  92257. name,
  92258. /**
  92259. * Defines the location of the image to load
  92260. */
  92261. url) {
  92262. var _this = _super.call(this, name) || this;
  92263. _this.name = name;
  92264. _this.url = url;
  92265. return _this;
  92266. }
  92267. /**
  92268. * Execute the current task
  92269. * @param scene defines the scene where you want your assets to be loaded
  92270. * @param onSuccess is a callback called when the task is successfully executed
  92271. * @param onError is a callback called if an error occurs
  92272. */
  92273. ImageAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92274. var _this = this;
  92275. var img = new Image();
  92276. _tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(this.url, img);
  92277. img.onload = function () {
  92278. _this.image = img;
  92279. onSuccess();
  92280. };
  92281. img.onerror = function (err) {
  92282. onError("Error loading image", err);
  92283. };
  92284. img.src = this.url;
  92285. };
  92286. return ImageAssetTask;
  92287. }(AbstractAssetTask));
  92288. /**
  92289. * Define a task used by AssetsManager to load 2D textures
  92290. */
  92291. var TextureAssetTask = /** @class */ (function (_super) {
  92292. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureAssetTask, _super);
  92293. /**
  92294. * Creates a new TextureAssetTask object
  92295. * @param name defines the name of the task
  92296. * @param url defines the location of the file to load
  92297. * @param noMipmap defines if mipmap should not be generated (default is false)
  92298. * @param invertY defines if texture must be inverted on Y axis (default is false)
  92299. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  92300. */
  92301. function TextureAssetTask(
  92302. /**
  92303. * Defines the name of the task
  92304. */
  92305. name,
  92306. /**
  92307. * Defines the location of the file to load
  92308. */
  92309. url,
  92310. /**
  92311. * Defines if mipmap should not be generated (default is false)
  92312. */
  92313. noMipmap,
  92314. /**
  92315. * Defines if texture must be inverted on Y axis (default is false)
  92316. */
  92317. invertY,
  92318. /**
  92319. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  92320. */
  92321. samplingMode) {
  92322. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  92323. var _this = _super.call(this, name) || this;
  92324. _this.name = name;
  92325. _this.url = url;
  92326. _this.noMipmap = noMipmap;
  92327. _this.invertY = invertY;
  92328. _this.samplingMode = samplingMode;
  92329. return _this;
  92330. }
  92331. /**
  92332. * Execute the current task
  92333. * @param scene defines the scene where you want your assets to be loaded
  92334. * @param onSuccess is a callback called when the task is successfully executed
  92335. * @param onError is a callback called if an error occurs
  92336. */
  92337. TextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92338. var onload = function () {
  92339. onSuccess();
  92340. };
  92341. var onerror = function (message, exception) {
  92342. onError(message, exception);
  92343. };
  92344. this.texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](this.url, scene, this.noMipmap, this.invertY, this.samplingMode, onload, onerror);
  92345. };
  92346. return TextureAssetTask;
  92347. }(AbstractAssetTask));
  92348. /**
  92349. * Define a task used by AssetsManager to load cube textures
  92350. */
  92351. var CubeTextureAssetTask = /** @class */ (function (_super) {
  92352. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTextureAssetTask, _super);
  92353. /**
  92354. * Creates a new CubeTextureAssetTask
  92355. * @param name defines the name of the task
  92356. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  92357. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  92358. * @param noMipmap defines if mipmaps should not be generated (default is false)
  92359. * @param files defines the explicit list of files (undefined by default)
  92360. */
  92361. function CubeTextureAssetTask(
  92362. /**
  92363. * Defines the name of the task
  92364. */
  92365. name,
  92366. /**
  92367. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  92368. */
  92369. url,
  92370. /**
  92371. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  92372. */
  92373. extensions,
  92374. /**
  92375. * Defines if mipmaps should not be generated (default is false)
  92376. */
  92377. noMipmap,
  92378. /**
  92379. * Defines the explicit list of files (undefined by default)
  92380. */
  92381. files) {
  92382. var _this = _super.call(this, name) || this;
  92383. _this.name = name;
  92384. _this.url = url;
  92385. _this.extensions = extensions;
  92386. _this.noMipmap = noMipmap;
  92387. _this.files = files;
  92388. return _this;
  92389. }
  92390. /**
  92391. * Execute the current task
  92392. * @param scene defines the scene where you want your assets to be loaded
  92393. * @param onSuccess is a callback called when the task is successfully executed
  92394. * @param onError is a callback called if an error occurs
  92395. */
  92396. CubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92397. var onload = function () {
  92398. onSuccess();
  92399. };
  92400. var onerror = function (message, exception) {
  92401. onError(message, exception);
  92402. };
  92403. this.texture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__["CubeTexture"](this.url, scene, this.extensions, this.noMipmap, this.files, onload, onerror);
  92404. };
  92405. return CubeTextureAssetTask;
  92406. }(AbstractAssetTask));
  92407. /**
  92408. * Define a task used by AssetsManager to load HDR cube textures
  92409. */
  92410. var HDRCubeTextureAssetTask = /** @class */ (function (_super) {
  92411. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTextureAssetTask, _super);
  92412. /**
  92413. * Creates a new HDRCubeTextureAssetTask object
  92414. * @param name defines the name of the task
  92415. * @param url defines the location of the file to load
  92416. * @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.
  92417. * @param noMipmap defines if mipmaps should not be generated (default is false)
  92418. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  92419. * @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)
  92420. * @param reserved Internal use only
  92421. */
  92422. function HDRCubeTextureAssetTask(
  92423. /**
  92424. * Defines the name of the task
  92425. */
  92426. name,
  92427. /**
  92428. * Defines the location of the file to load
  92429. */
  92430. url,
  92431. /**
  92432. * Defines the desired size (the more it increases the longer the generation will be)
  92433. */
  92434. size,
  92435. /**
  92436. * Defines if mipmaps should not be generated (default is false)
  92437. */
  92438. noMipmap,
  92439. /**
  92440. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  92441. */
  92442. generateHarmonics,
  92443. /**
  92444. * 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)
  92445. */
  92446. gammaSpace,
  92447. /**
  92448. * Internal Use Only
  92449. */
  92450. reserved) {
  92451. if (noMipmap === void 0) { noMipmap = false; }
  92452. if (generateHarmonics === void 0) { generateHarmonics = true; }
  92453. if (gammaSpace === void 0) { gammaSpace = false; }
  92454. if (reserved === void 0) { reserved = false; }
  92455. var _this = _super.call(this, name) || this;
  92456. _this.name = name;
  92457. _this.url = url;
  92458. _this.size = size;
  92459. _this.noMipmap = noMipmap;
  92460. _this.generateHarmonics = generateHarmonics;
  92461. _this.gammaSpace = gammaSpace;
  92462. _this.reserved = reserved;
  92463. return _this;
  92464. }
  92465. /**
  92466. * Execute the current task
  92467. * @param scene defines the scene where you want your assets to be loaded
  92468. * @param onSuccess is a callback called when the task is successfully executed
  92469. * @param onError is a callback called if an error occurs
  92470. */
  92471. HDRCubeTextureAssetTask.prototype.run = function (scene, onSuccess, onError) {
  92472. var onload = function () {
  92473. onSuccess();
  92474. };
  92475. var onerror = function (message, exception) {
  92476. onError(message, exception);
  92477. };
  92478. 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);
  92479. };
  92480. return HDRCubeTextureAssetTask;
  92481. }(AbstractAssetTask));
  92482. /**
  92483. * This class can be used to easily import assets into a scene
  92484. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  92485. */
  92486. var AssetsManager = /** @class */ (function () {
  92487. /**
  92488. * Creates a new AssetsManager
  92489. * @param scene defines the scene to work on
  92490. */
  92491. function AssetsManager(scene) {
  92492. this._isLoading = false;
  92493. this._tasks = new Array();
  92494. this._waitingTasksCount = 0;
  92495. this._totalTasksCount = 0;
  92496. /**
  92497. * Observable called when all tasks are processed
  92498. */
  92499. this.onTaskSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  92500. /**
  92501. * Observable called when a task had an error
  92502. */
  92503. this.onTaskErrorObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  92504. /**
  92505. * Observable called when a task is successful
  92506. */
  92507. this.onTasksDoneObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  92508. /**
  92509. * Observable called when a task is done (whatever the result is)
  92510. */
  92511. this.onProgressObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  92512. /**
  92513. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  92514. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92515. */
  92516. this.useDefaultLoadingScreen = true;
  92517. this._scene = scene;
  92518. }
  92519. /**
  92520. * Add a MeshAssetTask to the list of active tasks
  92521. * @param taskName defines the name of the new task
  92522. * @param meshesNames defines the name of meshes to load
  92523. * @param rootUrl defines the root url to use to locate files
  92524. * @param sceneFilename defines the filename of the scene file
  92525. * @returns a new MeshAssetTask object
  92526. */
  92527. AssetsManager.prototype.addMeshTask = function (taskName, meshesNames, rootUrl, sceneFilename) {
  92528. var task = new MeshAssetTask(taskName, meshesNames, rootUrl, sceneFilename);
  92529. this._tasks.push(task);
  92530. return task;
  92531. };
  92532. /**
  92533. * Add a TextFileAssetTask to the list of active tasks
  92534. * @param taskName defines the name of the new task
  92535. * @param url defines the url of the file to load
  92536. * @returns a new TextFileAssetTask object
  92537. */
  92538. AssetsManager.prototype.addTextFileTask = function (taskName, url) {
  92539. var task = new TextFileAssetTask(taskName, url);
  92540. this._tasks.push(task);
  92541. return task;
  92542. };
  92543. /**
  92544. * Add a BinaryFileAssetTask to the list of active tasks
  92545. * @param taskName defines the name of the new task
  92546. * @param url defines the url of the file to load
  92547. * @returns a new BinaryFileAssetTask object
  92548. */
  92549. AssetsManager.prototype.addBinaryFileTask = function (taskName, url) {
  92550. var task = new BinaryFileAssetTask(taskName, url);
  92551. this._tasks.push(task);
  92552. return task;
  92553. };
  92554. /**
  92555. * Add a ImageAssetTask to the list of active tasks
  92556. * @param taskName defines the name of the new task
  92557. * @param url defines the url of the file to load
  92558. * @returns a new ImageAssetTask object
  92559. */
  92560. AssetsManager.prototype.addImageTask = function (taskName, url) {
  92561. var task = new ImageAssetTask(taskName, url);
  92562. this._tasks.push(task);
  92563. return task;
  92564. };
  92565. /**
  92566. * Add a TextureAssetTask to the list of active tasks
  92567. * @param taskName defines the name of the new task
  92568. * @param url defines the url of the file to load
  92569. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  92570. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  92571. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  92572. * @returns a new TextureAssetTask object
  92573. */
  92574. AssetsManager.prototype.addTextureTask = function (taskName, url, noMipmap, invertY, samplingMode) {
  92575. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  92576. var task = new TextureAssetTask(taskName, url, noMipmap, invertY, samplingMode);
  92577. this._tasks.push(task);
  92578. return task;
  92579. };
  92580. /**
  92581. * Add a CubeTextureAssetTask to the list of active tasks
  92582. * @param taskName defines the name of the new task
  92583. * @param url defines the url of the file to load
  92584. * @param extensions defines the extension to use to load the cube map (can be null)
  92585. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  92586. * @param files defines the list of files to load (can be null)
  92587. * @returns a new CubeTextureAssetTask object
  92588. */
  92589. AssetsManager.prototype.addCubeTextureTask = function (taskName, url, extensions, noMipmap, files) {
  92590. var task = new CubeTextureAssetTask(taskName, url, extensions, noMipmap, files);
  92591. this._tasks.push(task);
  92592. return task;
  92593. };
  92594. /**
  92595. *
  92596. * Add a HDRCubeTextureAssetTask to the list of active tasks
  92597. * @param taskName defines the name of the new task
  92598. * @param url defines the url of the file to load
  92599. * @param size defines the size you want for the cubemap (can be null)
  92600. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  92601. * @param generateHarmonics defines if you want to automatically generate (true by default)
  92602. * @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)
  92603. * @param reserved Internal use only
  92604. * @returns a new HDRCubeTextureAssetTask object
  92605. */
  92606. AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved) {
  92607. if (noMipmap === void 0) { noMipmap = false; }
  92608. if (generateHarmonics === void 0) { generateHarmonics = true; }
  92609. if (gammaSpace === void 0) { gammaSpace = false; }
  92610. if (reserved === void 0) { reserved = false; }
  92611. var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved);
  92612. this._tasks.push(task);
  92613. return task;
  92614. };
  92615. /**
  92616. * Remove a task from the assets manager.
  92617. * @param task the task to remove
  92618. */
  92619. AssetsManager.prototype.removeTask = function (task) {
  92620. var index = this._tasks.indexOf(task);
  92621. if (index > -1) {
  92622. this._tasks.splice(index, 1);
  92623. }
  92624. };
  92625. AssetsManager.prototype._decreaseWaitingTasksCount = function (task) {
  92626. this._waitingTasksCount--;
  92627. try {
  92628. if (this.onProgress) {
  92629. this.onProgress(this._waitingTasksCount, this._totalTasksCount, task);
  92630. }
  92631. this.onProgressObservable.notifyObservers(new AssetsProgressEvent(this._waitingTasksCount, this._totalTasksCount, task));
  92632. }
  92633. catch (e) {
  92634. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running progress callbacks.");
  92635. console.log(e);
  92636. }
  92637. if (this._waitingTasksCount === 0) {
  92638. try {
  92639. if (this.onFinish) {
  92640. this.onFinish(this._tasks);
  92641. }
  92642. // Let's remove successfull tasks
  92643. var currentTasks = this._tasks.slice();
  92644. for (var _i = 0, currentTasks_1 = currentTasks; _i < currentTasks_1.length; _i++) {
  92645. var task = currentTasks_1[_i];
  92646. if (task.taskState === AssetTaskState.DONE) {
  92647. var index = this._tasks.indexOf(task);
  92648. if (index > -1) {
  92649. this._tasks.splice(index, 1);
  92650. }
  92651. }
  92652. }
  92653. this.onTasksDoneObservable.notifyObservers(this._tasks);
  92654. }
  92655. catch (e) {
  92656. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running tasks-done callbacks.");
  92657. console.log(e);
  92658. }
  92659. this._isLoading = false;
  92660. this._scene.getEngine().hideLoadingUI();
  92661. }
  92662. };
  92663. AssetsManager.prototype._runTask = function (task) {
  92664. var _this = this;
  92665. var done = function () {
  92666. try {
  92667. if (_this.onTaskSuccess) {
  92668. _this.onTaskSuccess(task);
  92669. }
  92670. _this.onTaskSuccessObservable.notifyObservers(task);
  92671. _this._decreaseWaitingTasksCount(task);
  92672. }
  92673. catch (e) {
  92674. error("Error executing task success callbacks", e);
  92675. }
  92676. };
  92677. var error = function (message, exception) {
  92678. task._setErrorObject(message, exception);
  92679. if (_this.onTaskError) {
  92680. _this.onTaskError(task);
  92681. }
  92682. _this.onTaskErrorObservable.notifyObservers(task);
  92683. _this._decreaseWaitingTasksCount(task);
  92684. };
  92685. task.run(this._scene, done, error);
  92686. };
  92687. /**
  92688. * Reset the AssetsManager and remove all tasks
  92689. * @return the current instance of the AssetsManager
  92690. */
  92691. AssetsManager.prototype.reset = function () {
  92692. this._isLoading = false;
  92693. this._tasks = new Array();
  92694. return this;
  92695. };
  92696. /**
  92697. * Start the loading process
  92698. * @return the current instance of the AssetsManager
  92699. */
  92700. AssetsManager.prototype.load = function () {
  92701. if (this._isLoading) {
  92702. return this;
  92703. }
  92704. this._isLoading = true;
  92705. this._waitingTasksCount = this._tasks.length;
  92706. this._totalTasksCount = this._tasks.length;
  92707. if (this._waitingTasksCount === 0) {
  92708. this._isLoading = false;
  92709. if (this.onFinish) {
  92710. this.onFinish(this._tasks);
  92711. }
  92712. this.onTasksDoneObservable.notifyObservers(this._tasks);
  92713. return this;
  92714. }
  92715. if (this.useDefaultLoadingScreen) {
  92716. this._scene.getEngine().displayLoadingUI();
  92717. }
  92718. for (var index = 0; index < this._tasks.length; index++) {
  92719. var task = this._tasks[index];
  92720. if (task.taskState === AssetTaskState.INIT) {
  92721. this._runTask(task);
  92722. }
  92723. }
  92724. return this;
  92725. };
  92726. return AssetsManager;
  92727. }());
  92728. /***/ }),
  92729. /***/ "./Misc/dds.ts":
  92730. /*!*********************!*\
  92731. !*** ./Misc/dds.ts ***!
  92732. \*********************/
  92733. /*! exports provided: DDSTools */
  92734. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92735. "use strict";
  92736. __webpack_require__.r(__webpack_exports__);
  92737. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return DDSTools; });
  92738. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  92739. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  92740. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  92741. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  92742. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  92743. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  92744. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  92745. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  92746. // Based on demo done by Brandon Jones - http://media.tojicode.com/webgl-samples/dds.html
  92747. // All values and structures referenced from:
  92748. // http://msdn.microsoft.com/en-us/library/bb943991.aspx/
  92749. var DDS_MAGIC = 0x20534444;
  92750. var
  92751. //DDSD_CAPS = 0x1,
  92752. //DDSD_HEIGHT = 0x2,
  92753. //DDSD_WIDTH = 0x4,
  92754. //DDSD_PITCH = 0x8,
  92755. //DDSD_PIXELFORMAT = 0x1000,
  92756. DDSD_MIPMAPCOUNT = 0x20000;
  92757. //DDSD_LINEARSIZE = 0x80000,
  92758. //DDSD_DEPTH = 0x800000;
  92759. // var DDSCAPS_COMPLEX = 0x8,
  92760. // DDSCAPS_MIPMAP = 0x400000,
  92761. // DDSCAPS_TEXTURE = 0x1000;
  92762. var DDSCAPS2_CUBEMAP = 0x200;
  92763. // DDSCAPS2_CUBEMAP_POSITIVEX = 0x400,
  92764. // DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800,
  92765. // DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000,
  92766. // DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000,
  92767. // DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000,
  92768. // DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000,
  92769. // DDSCAPS2_VOLUME = 0x200000;
  92770. var
  92771. //DDPF_ALPHAPIXELS = 0x1,
  92772. //DDPF_ALPHA = 0x2,
  92773. DDPF_FOURCC = 0x4, DDPF_RGB = 0x40,
  92774. //DDPF_YUV = 0x200,
  92775. DDPF_LUMINANCE = 0x20000;
  92776. function FourCCToInt32(value) {
  92777. return value.charCodeAt(0) +
  92778. (value.charCodeAt(1) << 8) +
  92779. (value.charCodeAt(2) << 16) +
  92780. (value.charCodeAt(3) << 24);
  92781. }
  92782. function Int32ToFourCC(value) {
  92783. return String.fromCharCode(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >> 24) & 0xff);
  92784. }
  92785. var FOURCC_DXT1 = FourCCToInt32("DXT1");
  92786. var FOURCC_DXT3 = FourCCToInt32("DXT3");
  92787. var FOURCC_DXT5 = FourCCToInt32("DXT5");
  92788. var FOURCC_DX10 = FourCCToInt32("DX10");
  92789. var FOURCC_D3DFMT_R16G16B16A16F = 113;
  92790. var FOURCC_D3DFMT_R32G32B32A32F = 116;
  92791. var DXGI_FORMAT_R16G16B16A16_FLOAT = 10;
  92792. var DXGI_FORMAT_B8G8R8X8_UNORM = 88;
  92793. var headerLengthInt = 31; // The header length in 32 bit ints
  92794. // Offsets into the header array
  92795. var off_magic = 0;
  92796. var off_size = 1;
  92797. var off_flags = 2;
  92798. var off_height = 3;
  92799. var off_width = 4;
  92800. var off_mipmapCount = 7;
  92801. var off_pfFlags = 20;
  92802. var off_pfFourCC = 21;
  92803. var off_RGBbpp = 22;
  92804. var off_RMask = 23;
  92805. var off_GMask = 24;
  92806. var off_BMask = 25;
  92807. var off_AMask = 26;
  92808. // var off_caps1 = 27;
  92809. var off_caps2 = 28;
  92810. // var off_caps3 = 29;
  92811. // var off_caps4 = 30;
  92812. var off_dxgiFormat = 32;
  92813. /**
  92814. * Class used to provide DDS decompression tools
  92815. */
  92816. var DDSTools = /** @class */ (function () {
  92817. function DDSTools() {
  92818. }
  92819. /**
  92820. * Gets DDS information from an array buffer
  92821. * @param arrayBuffer defines the array buffer to read data from
  92822. * @returns the DDS information
  92823. */
  92824. DDSTools.GetDDSInfo = function (arrayBuffer) {
  92825. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  92826. var extendedHeader = new Int32Array(arrayBuffer, 0, headerLengthInt + 4);
  92827. var mipmapCount = 1;
  92828. if (header[off_flags] & DDSD_MIPMAPCOUNT) {
  92829. mipmapCount = Math.max(1, header[off_mipmapCount]);
  92830. }
  92831. var fourCC = header[off_pfFourCC];
  92832. var dxgiFormat = (fourCC === FOURCC_DX10) ? extendedHeader[off_dxgiFormat] : 0;
  92833. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  92834. switch (fourCC) {
  92835. case FOURCC_D3DFMT_R16G16B16A16F:
  92836. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  92837. break;
  92838. case FOURCC_D3DFMT_R32G32B32A32F:
  92839. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  92840. break;
  92841. case FOURCC_DX10:
  92842. if (dxgiFormat === DXGI_FORMAT_R16G16B16A16_FLOAT) {
  92843. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  92844. break;
  92845. }
  92846. }
  92847. return {
  92848. width: header[off_width],
  92849. height: header[off_height],
  92850. mipmapCount: mipmapCount,
  92851. isFourCC: (header[off_pfFlags] & DDPF_FOURCC) === DDPF_FOURCC,
  92852. isRGB: (header[off_pfFlags] & DDPF_RGB) === DDPF_RGB,
  92853. isLuminance: (header[off_pfFlags] & DDPF_LUMINANCE) === DDPF_LUMINANCE,
  92854. isCube: (header[off_caps2] & DDSCAPS2_CUBEMAP) === DDSCAPS2_CUBEMAP,
  92855. isCompressed: (fourCC === FOURCC_DXT1 || fourCC === FOURCC_DXT3 || fourCC === FOURCC_DXT5),
  92856. dxgiFormat: dxgiFormat,
  92857. textureType: textureType
  92858. };
  92859. };
  92860. DDSTools._ToHalfFloat = function (value) {
  92861. if (!DDSTools._FloatView) {
  92862. DDSTools._FloatView = new Float32Array(1);
  92863. DDSTools._Int32View = new Int32Array(DDSTools._FloatView.buffer);
  92864. }
  92865. DDSTools._FloatView[0] = value;
  92866. var x = DDSTools._Int32View[0];
  92867. var bits = (x >> 16) & 0x8000; /* Get the sign */
  92868. var m = (x >> 12) & 0x07ff; /* Keep one extra bit for rounding */
  92869. var e = (x >> 23) & 0xff; /* Using int is faster here */
  92870. /* If zero, or denormal, or exponent underflows too much for a denormal
  92871. * half, return signed zero. */
  92872. if (e < 103) {
  92873. return bits;
  92874. }
  92875. /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */
  92876. if (e > 142) {
  92877. bits |= 0x7c00;
  92878. /* If exponent was 0xff and one mantissa bit was set, it means NaN,
  92879. * not Inf, so make sure we set one mantissa bit too. */
  92880. bits |= ((e == 255) ? 0 : 1) && (x & 0x007fffff);
  92881. return bits;
  92882. }
  92883. /* If exponent underflows but not too much, return a denormal */
  92884. if (e < 113) {
  92885. m |= 0x0800;
  92886. /* Extra rounding may overflow and set mantissa to 0 and exponent
  92887. * to 1, which is OK. */
  92888. bits |= (m >> (114 - e)) + ((m >> (113 - e)) & 1);
  92889. return bits;
  92890. }
  92891. bits |= ((e - 112) << 10) | (m >> 1);
  92892. bits += m & 1;
  92893. return bits;
  92894. };
  92895. DDSTools._FromHalfFloat = function (value) {
  92896. var s = (value & 0x8000) >> 15;
  92897. var e = (value & 0x7C00) >> 10;
  92898. var f = value & 0x03FF;
  92899. if (e === 0) {
  92900. return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));
  92901. }
  92902. else if (e == 0x1F) {
  92903. return f ? NaN : ((s ? -1 : 1) * Infinity);
  92904. }
  92905. return (s ? -1 : 1) * Math.pow(2, e - 15) * (1 + (f / Math.pow(2, 10)));
  92906. };
  92907. DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92908. var destArray = new Float32Array(dataLength);
  92909. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  92910. var index = 0;
  92911. for (var y = 0; y < height; y++) {
  92912. for (var x = 0; x < width; x++) {
  92913. var srcPos = (x + y * width) * 4;
  92914. destArray[index] = DDSTools._FromHalfFloat(srcData[srcPos]);
  92915. destArray[index + 1] = DDSTools._FromHalfFloat(srcData[srcPos + 1]);
  92916. destArray[index + 2] = DDSTools._FromHalfFloat(srcData[srcPos + 2]);
  92917. if (DDSTools.StoreLODInAlphaChannel) {
  92918. destArray[index + 3] = lod;
  92919. }
  92920. else {
  92921. destArray[index + 3] = DDSTools._FromHalfFloat(srcData[srcPos + 3]);
  92922. }
  92923. index += 4;
  92924. }
  92925. }
  92926. return destArray;
  92927. };
  92928. DDSTools._GetHalfFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92929. if (DDSTools.StoreLODInAlphaChannel) {
  92930. var destArray = new Uint16Array(dataLength);
  92931. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  92932. var index = 0;
  92933. for (var y = 0; y < height; y++) {
  92934. for (var x = 0; x < width; x++) {
  92935. var srcPos = (x + y * width) * 4;
  92936. destArray[index] = srcData[srcPos];
  92937. destArray[index + 1] = srcData[srcPos + 1];
  92938. destArray[index + 2] = srcData[srcPos + 2];
  92939. destArray[index + 3] = DDSTools._ToHalfFloat(lod);
  92940. index += 4;
  92941. }
  92942. }
  92943. return destArray;
  92944. }
  92945. return new Uint16Array(arrayBuffer, dataOffset, dataLength);
  92946. };
  92947. DDSTools._GetFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92948. if (DDSTools.StoreLODInAlphaChannel) {
  92949. var destArray = new Float32Array(dataLength);
  92950. var srcData = new Float32Array(arrayBuffer, dataOffset);
  92951. var index = 0;
  92952. for (var y = 0; y < height; y++) {
  92953. for (var x = 0; x < width; x++) {
  92954. var srcPos = (x + y * width) * 4;
  92955. destArray[index] = srcData[srcPos];
  92956. destArray[index + 1] = srcData[srcPos + 1];
  92957. destArray[index + 2] = srcData[srcPos + 2];
  92958. destArray[index + 3] = lod;
  92959. index += 4;
  92960. }
  92961. }
  92962. return destArray;
  92963. }
  92964. return new Float32Array(arrayBuffer, dataOffset, dataLength);
  92965. };
  92966. DDSTools._GetFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92967. var destArray = new Uint8Array(dataLength);
  92968. var srcData = new Float32Array(arrayBuffer, dataOffset);
  92969. var index = 0;
  92970. for (var y = 0; y < height; y++) {
  92971. for (var x = 0; x < width; x++) {
  92972. var srcPos = (x + y * width) * 4;
  92973. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos]) * 255;
  92974. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 1]) * 255;
  92975. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 2]) * 255;
  92976. if (DDSTools.StoreLODInAlphaChannel) {
  92977. destArray[index + 3] = lod;
  92978. }
  92979. else {
  92980. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 3]) * 255;
  92981. }
  92982. index += 4;
  92983. }
  92984. }
  92985. return destArray;
  92986. };
  92987. DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92988. var destArray = new Uint8Array(dataLength);
  92989. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  92990. var index = 0;
  92991. for (var y = 0; y < height; y++) {
  92992. for (var x = 0; x < width; x++) {
  92993. var srcPos = (x + y * width) * 4;
  92994. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos])) * 255;
  92995. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 1])) * 255;
  92996. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 2])) * 255;
  92997. if (DDSTools.StoreLODInAlphaChannel) {
  92998. destArray[index + 3] = lod;
  92999. }
  93000. else {
  93001. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 3])) * 255;
  93002. }
  93003. index += 4;
  93004. }
  93005. }
  93006. return destArray;
  93007. };
  93008. DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset) {
  93009. var byteArray = new Uint8Array(dataLength);
  93010. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  93011. var index = 0;
  93012. for (var y = 0; y < height; y++) {
  93013. for (var x = 0; x < width; x++) {
  93014. var srcPos = (x + y * width) * 4;
  93015. byteArray[index] = srcData[srcPos + rOffset];
  93016. byteArray[index + 1] = srcData[srcPos + gOffset];
  93017. byteArray[index + 2] = srcData[srcPos + bOffset];
  93018. byteArray[index + 3] = srcData[srcPos + aOffset];
  93019. index += 4;
  93020. }
  93021. }
  93022. return byteArray;
  93023. };
  93024. DDSTools._ExtractLongWordOrder = function (value) {
  93025. if (value === 0 || value === 255 || value === -16777216) {
  93026. return 0;
  93027. }
  93028. return 1 + DDSTools._ExtractLongWordOrder(value >> 8);
  93029. };
  93030. DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset) {
  93031. var byteArray = new Uint8Array(dataLength);
  93032. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  93033. var index = 0;
  93034. for (var y = 0; y < height; y++) {
  93035. for (var x = 0; x < width; x++) {
  93036. var srcPos = (x + y * width) * 3;
  93037. byteArray[index] = srcData[srcPos + rOffset];
  93038. byteArray[index + 1] = srcData[srcPos + gOffset];
  93039. byteArray[index + 2] = srcData[srcPos + bOffset];
  93040. index += 3;
  93041. }
  93042. }
  93043. return byteArray;
  93044. };
  93045. DDSTools._GetLuminanceArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
  93046. var byteArray = new Uint8Array(dataLength);
  93047. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  93048. var index = 0;
  93049. for (var y = 0; y < height; y++) {
  93050. for (var x = 0; x < width; x++) {
  93051. var srcPos = (x + y * width);
  93052. byteArray[index] = srcData[srcPos];
  93053. index++;
  93054. }
  93055. }
  93056. return byteArray;
  93057. };
  93058. /**
  93059. * Uploads DDS Levels to a Babylon Texture
  93060. * @hidden
  93061. */
  93062. DDSTools.UploadDDSLevels = function (engine, texture, arrayBuffer, info, loadMipmaps, faces, lodIndex, currentFace) {
  93063. if (lodIndex === void 0) { lodIndex = -1; }
  93064. var sphericalPolynomialFaces = null;
  93065. if (info.sphericalPolynomial) {
  93066. sphericalPolynomialFaces = new Array();
  93067. }
  93068. var ext = engine.getCaps().s3tc;
  93069. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  93070. var fourCC, width, height, dataLength = 0, dataOffset;
  93071. var byteArray, mipmapCount, mip;
  93072. var internalCompressedFormat = 0;
  93073. var blockBytes = 1;
  93074. if (header[off_magic] !== DDS_MAGIC) {
  93075. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Invalid magic number in DDS header");
  93076. return;
  93077. }
  93078. if (!info.isFourCC && !info.isRGB && !info.isLuminance) {
  93079. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
  93080. return;
  93081. }
  93082. if (info.isCompressed && !ext) {
  93083. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Compressed textures are not supported on this platform.");
  93084. return;
  93085. }
  93086. var bpp = header[off_RGBbpp];
  93087. dataOffset = header[off_size] + 4;
  93088. var computeFormats = false;
  93089. if (info.isFourCC) {
  93090. fourCC = header[off_pfFourCC];
  93091. switch (fourCC) {
  93092. case FOURCC_DXT1:
  93093. blockBytes = 8;
  93094. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT1_EXT;
  93095. break;
  93096. case FOURCC_DXT3:
  93097. blockBytes = 16;
  93098. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT3_EXT;
  93099. break;
  93100. case FOURCC_DXT5:
  93101. blockBytes = 16;
  93102. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT5_EXT;
  93103. break;
  93104. case FOURCC_D3DFMT_R16G16B16A16F:
  93105. computeFormats = true;
  93106. break;
  93107. case FOURCC_D3DFMT_R32G32B32A32F:
  93108. computeFormats = true;
  93109. break;
  93110. case FOURCC_DX10:
  93111. // There is an additionnal header so dataOffset need to be changed
  93112. dataOffset += 5 * 4; // 5 uints
  93113. var supported = false;
  93114. switch (info.dxgiFormat) {
  93115. case DXGI_FORMAT_R16G16B16A16_FLOAT:
  93116. computeFormats = true;
  93117. supported = true;
  93118. break;
  93119. case DXGI_FORMAT_B8G8R8X8_UNORM:
  93120. info.isRGB = true;
  93121. info.isFourCC = false;
  93122. bpp = 32;
  93123. supported = true;
  93124. break;
  93125. }
  93126. if (supported) {
  93127. break;
  93128. }
  93129. default:
  93130. console.error("Unsupported FourCC code:", Int32ToFourCC(fourCC));
  93131. return;
  93132. }
  93133. }
  93134. var rOffset = DDSTools._ExtractLongWordOrder(header[off_RMask]);
  93135. var gOffset = DDSTools._ExtractLongWordOrder(header[off_GMask]);
  93136. var bOffset = DDSTools._ExtractLongWordOrder(header[off_BMask]);
  93137. var aOffset = DDSTools._ExtractLongWordOrder(header[off_AMask]);
  93138. if (computeFormats) {
  93139. internalCompressedFormat = engine._getRGBABufferInternalSizedFormat(info.textureType);
  93140. }
  93141. mipmapCount = 1;
  93142. if (header[off_flags] & DDSD_MIPMAPCOUNT && loadMipmaps !== false) {
  93143. mipmapCount = Math.max(1, header[off_mipmapCount]);
  93144. }
  93145. for (var face = 0; face < faces; face++) {
  93146. width = header[off_width];
  93147. height = header[off_height];
  93148. for (mip = 0; mip < mipmapCount; ++mip) {
  93149. if (lodIndex === -1 || lodIndex === mip) {
  93150. // In case of fixed LOD, if the lod has just been uploaded, early exit.
  93151. var i = (lodIndex === -1) ? mip : 0;
  93152. if (!info.isCompressed && info.isFourCC) {
  93153. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  93154. dataLength = width * height * 4;
  93155. var floatArray = null;
  93156. if (engine._badOS || engine._badDesktopOS || (!engine.getCaps().textureHalfFloat && !engine.getCaps().textureFloat)) { // Required because iOS has many issues with float and half float generation
  93157. if (bpp === 128) {
  93158. floatArray = DDSTools._GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  93159. if (sphericalPolynomialFaces && i == 0) {
  93160. sphericalPolynomialFaces.push(DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  93161. }
  93162. }
  93163. else if (bpp === 64) {
  93164. floatArray = DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  93165. if (sphericalPolynomialFaces && i == 0) {
  93166. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  93167. }
  93168. }
  93169. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93170. }
  93171. else {
  93172. if (bpp === 128) {
  93173. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  93174. floatArray = DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  93175. if (sphericalPolynomialFaces && i == 0) {
  93176. sphericalPolynomialFaces.push(floatArray);
  93177. }
  93178. }
  93179. else if (bpp === 64 && !engine.getCaps().textureHalfFloat) {
  93180. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  93181. floatArray = DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  93182. if (sphericalPolynomialFaces && i == 0) {
  93183. sphericalPolynomialFaces.push(floatArray);
  93184. }
  93185. }
  93186. else { // 64
  93187. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  93188. floatArray = DDSTools._GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  93189. if (sphericalPolynomialFaces && i == 0) {
  93190. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  93191. }
  93192. }
  93193. }
  93194. if (floatArray) {
  93195. engine._uploadDataToTextureDirectly(texture, floatArray, face, i);
  93196. }
  93197. }
  93198. else if (info.isRGB) {
  93199. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93200. if (bpp === 24) {
  93201. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB;
  93202. dataLength = width * height * 3;
  93203. byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  93204. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  93205. }
  93206. else { // 32
  93207. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  93208. dataLength = width * height * 4;
  93209. byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  93210. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  93211. }
  93212. }
  93213. else if (info.isLuminance) {
  93214. var unpackAlignment = engine._getUnpackAlignement();
  93215. var unpaddedRowSize = width;
  93216. var paddedRowSize = Math.floor((width + unpackAlignment - 1) / unpackAlignment) * unpackAlignment;
  93217. dataLength = paddedRowSize * (height - 1) + unpaddedRowSize;
  93218. byteArray = DDSTools._GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  93219. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE;
  93220. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93221. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  93222. }
  93223. else {
  93224. dataLength = Math.max(4, width) / 4 * Math.max(4, height) / 4 * blockBytes;
  93225. byteArray = new Uint8Array(arrayBuffer, dataOffset, dataLength);
  93226. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93227. engine._uploadCompressedDataToTextureDirectly(texture, internalCompressedFormat, width, height, byteArray, face, i);
  93228. }
  93229. }
  93230. dataOffset += bpp ? (width * height * (bpp / 8)) : dataLength;
  93231. width *= 0.5;
  93232. height *= 0.5;
  93233. width = Math.max(1.0, width);
  93234. height = Math.max(1.0, height);
  93235. }
  93236. if (currentFace !== undefined) {
  93237. // Loading a single face
  93238. break;
  93239. }
  93240. }
  93241. if (sphericalPolynomialFaces && sphericalPolynomialFaces.length > 0) {
  93242. info.sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial({
  93243. size: header[off_width],
  93244. right: sphericalPolynomialFaces[0],
  93245. left: sphericalPolynomialFaces[1],
  93246. up: sphericalPolynomialFaces[2],
  93247. down: sphericalPolynomialFaces[3],
  93248. front: sphericalPolynomialFaces[4],
  93249. back: sphericalPolynomialFaces[5],
  93250. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA,
  93251. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT,
  93252. gammaSpace: false,
  93253. });
  93254. }
  93255. else {
  93256. info.sphericalPolynomial = undefined;
  93257. }
  93258. };
  93259. /**
  93260. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  93261. */
  93262. DDSTools.StoreLODInAlphaChannel = false;
  93263. return DDSTools;
  93264. }());
  93265. /**
  93266. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  93267. * @param rootUrl defines the url where the file to load is located
  93268. * @param scene defines the current scene
  93269. * @param lodScale defines scale to apply to the mip map selection
  93270. * @param lodOffset defines offset to apply to the mip map selection
  93271. * @param onLoad defines an optional callback raised when the texture is loaded
  93272. * @param onError defines an optional callback raised if there is an issue to load the texture
  93273. * @param format defines the format of the data
  93274. * @param forcedExtension defines the extension to use to pick the right loader
  93275. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  93276. * @returns the cube texture as an InternalTexture
  93277. */
  93278. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createPrefilteredCubeTexture = function (rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, createPolynomials) {
  93279. var _this = this;
  93280. if (onLoad === void 0) { onLoad = null; }
  93281. if (onError === void 0) { onError = null; }
  93282. if (forcedExtension === void 0) { forcedExtension = null; }
  93283. if (createPolynomials === void 0) { createPolynomials = true; }
  93284. var callback = function (loadData) {
  93285. if (!loadData) {
  93286. if (onLoad) {
  93287. onLoad(null);
  93288. }
  93289. return;
  93290. }
  93291. var texture = loadData.texture;
  93292. if (!createPolynomials) {
  93293. texture._sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__["SphericalPolynomial"]();
  93294. }
  93295. else if (loadData.info.sphericalPolynomial) {
  93296. texture._sphericalPolynomial = loadData.info.sphericalPolynomial;
  93297. }
  93298. texture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBEPREFILTERED;
  93299. if (_this.getCaps().textureLOD) {
  93300. // Do not add extra process if texture lod is supported.
  93301. if (onLoad) {
  93302. onLoad(texture);
  93303. }
  93304. return;
  93305. }
  93306. var mipSlices = 3;
  93307. var gl = _this._gl;
  93308. var width = loadData.width;
  93309. if (!width) {
  93310. return;
  93311. }
  93312. var textures = [];
  93313. for (var i = 0; i < mipSlices; i++) {
  93314. //compute LOD from even spacing in smoothness (matching shader calculation)
  93315. var smoothness = i / (mipSlices - 1);
  93316. var roughness = 1 - smoothness;
  93317. var minLODIndex = lodOffset; // roughness = 0
  93318. var maxLODIndex = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) * lodScale + lodOffset; // roughness = 1
  93319. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  93320. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  93321. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  93322. glTextureFromLod.type = texture.type;
  93323. glTextureFromLod.format = texture.format;
  93324. glTextureFromLod.width = Math.pow(2, Math.max(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) - mipmapIndex, 0));
  93325. glTextureFromLod.height = glTextureFromLod.width;
  93326. glTextureFromLod.isCube = true;
  93327. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, glTextureFromLod, true);
  93328. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  93329. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  93330. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  93331. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  93332. if (loadData.isDDS) {
  93333. var info = loadData.info;
  93334. var data = loadData.data;
  93335. _this._unpackFlipY(info.isCompressed);
  93336. DDSTools.UploadDDSLevels(_this, glTextureFromLod, data, info, true, 6, mipmapIndex);
  93337. }
  93338. else {
  93339. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Warn("DDS is the only prefiltered cube map supported so far.");
  93340. }
  93341. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  93342. // Wrap in a base texture for easy binding.
  93343. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__["BaseTexture"](scene);
  93344. lodTexture.isCube = true;
  93345. lodTexture._texture = glTextureFromLod;
  93346. glTextureFromLod.isReady = true;
  93347. textures.push(lodTexture);
  93348. }
  93349. texture._lodTextureHigh = textures[2];
  93350. texture._lodTextureMid = textures[1];
  93351. texture._lodTextureLow = textures[0];
  93352. if (onLoad) {
  93353. onLoad(texture);
  93354. }
  93355. };
  93356. return this.createCubeTexture(rootUrl, scene, null, false, callback, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset);
  93357. };
  93358. /***/ }),
  93359. /***/ "./Misc/decorators.ts":
  93360. /*!****************************!*\
  93361. !*** ./Misc/decorators.ts ***!
  93362. \****************************/
  93363. /*! exports provided: expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper */
  93364. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93365. "use strict";
  93366. __webpack_require__.r(__webpack_exports__);
  93367. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return expandToProperty; });
  93368. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return serialize; });
  93369. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return serializeAsTexture; });
  93370. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return serializeAsColor3; });
  93371. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return serializeAsFresnelParameters; });
  93372. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return serializeAsVector2; });
  93373. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return serializeAsVector3; });
  93374. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return serializeAsMeshReference; });
  93375. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return serializeAsColorCurves; });
  93376. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return serializeAsColor4; });
  93377. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return serializeAsImageProcessingConfiguration; });
  93378. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return serializeAsQuaternion; });
  93379. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return serializeAsCameraReference; });
  93380. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return SerializationHelper; });
  93381. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  93382. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  93383. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  93384. var __decoratorInitialStore = {};
  93385. var __mergedStore = {};
  93386. var _copySource = function (creationFunction, source, instanciate) {
  93387. var destination = creationFunction();
  93388. // Tags
  93389. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  93390. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  93391. }
  93392. var classStore = getMergedStore(destination);
  93393. // Properties
  93394. for (var property in classStore) {
  93395. var propertyDescriptor = classStore[property];
  93396. var sourceProperty = source[property];
  93397. var propertyType = propertyDescriptor.type;
  93398. if (sourceProperty !== undefined && sourceProperty !== null && property !== "uniqueId") {
  93399. switch (propertyType) {
  93400. case 0: // Value
  93401. case 6: // Mesh reference
  93402. case 11: // Camera reference
  93403. destination[property] = sourceProperty;
  93404. break;
  93405. case 1: // Texture
  93406. destination[property] = (instanciate || sourceProperty.isRenderTarget) ? sourceProperty : sourceProperty.clone();
  93407. break;
  93408. case 2: // Color3
  93409. case 3: // FresnelParameters
  93410. case 4: // Vector2
  93411. case 5: // Vector3
  93412. case 7: // Color Curves
  93413. case 10: // Quaternion
  93414. destination[property] = instanciate ? sourceProperty : sourceProperty.clone();
  93415. break;
  93416. }
  93417. }
  93418. }
  93419. return destination;
  93420. };
  93421. function getDirectStore(target) {
  93422. var classKey = target.getClassName();
  93423. if (!__decoratorInitialStore[classKey]) {
  93424. __decoratorInitialStore[classKey] = {};
  93425. }
  93426. return __decoratorInitialStore[classKey];
  93427. }
  93428. /**
  93429. * Return the list of properties flagged as serializable
  93430. * @param target: host object
  93431. */
  93432. function getMergedStore(target) {
  93433. var classKey = target.getClassName();
  93434. if (__mergedStore[classKey]) {
  93435. return __mergedStore[classKey];
  93436. }
  93437. __mergedStore[classKey] = {};
  93438. var store = __mergedStore[classKey];
  93439. var currentTarget = target;
  93440. var currentKey = classKey;
  93441. while (currentKey) {
  93442. var initialStore = __decoratorInitialStore[currentKey];
  93443. for (var property in initialStore) {
  93444. store[property] = initialStore[property];
  93445. }
  93446. var parent_1 = void 0;
  93447. var done = false;
  93448. do {
  93449. parent_1 = Object.getPrototypeOf(currentTarget);
  93450. if (!parent_1.getClassName) {
  93451. done = true;
  93452. break;
  93453. }
  93454. if (parent_1.getClassName() !== currentKey) {
  93455. break;
  93456. }
  93457. currentTarget = parent_1;
  93458. } while (parent_1);
  93459. if (done) {
  93460. break;
  93461. }
  93462. currentKey = parent_1.getClassName();
  93463. currentTarget = parent_1;
  93464. }
  93465. return store;
  93466. }
  93467. function generateSerializableMember(type, sourceName) {
  93468. return function (target, propertyKey) {
  93469. var classStore = getDirectStore(target);
  93470. if (!classStore[propertyKey]) {
  93471. classStore[propertyKey] = { type: type, sourceName: sourceName };
  93472. }
  93473. };
  93474. }
  93475. function generateExpandMember(setCallback, targetKey) {
  93476. if (targetKey === void 0) { targetKey = null; }
  93477. return function (target, propertyKey) {
  93478. var key = targetKey || ("_" + propertyKey);
  93479. Object.defineProperty(target, propertyKey, {
  93480. get: function () {
  93481. return this[key];
  93482. },
  93483. set: function (value) {
  93484. if (this[key] === value) {
  93485. return;
  93486. }
  93487. this[key] = value;
  93488. target[setCallback].apply(this);
  93489. },
  93490. enumerable: true,
  93491. configurable: true
  93492. });
  93493. };
  93494. }
  93495. function expandToProperty(callback, targetKey) {
  93496. if (targetKey === void 0) { targetKey = null; }
  93497. return generateExpandMember(callback, targetKey);
  93498. }
  93499. function serialize(sourceName) {
  93500. return generateSerializableMember(0, sourceName); // value member
  93501. }
  93502. function serializeAsTexture(sourceName) {
  93503. return generateSerializableMember(1, sourceName); // texture member
  93504. }
  93505. function serializeAsColor3(sourceName) {
  93506. return generateSerializableMember(2, sourceName); // color3 member
  93507. }
  93508. function serializeAsFresnelParameters(sourceName) {
  93509. return generateSerializableMember(3, sourceName); // fresnel parameters member
  93510. }
  93511. function serializeAsVector2(sourceName) {
  93512. return generateSerializableMember(4, sourceName); // vector2 member
  93513. }
  93514. function serializeAsVector3(sourceName) {
  93515. return generateSerializableMember(5, sourceName); // vector3 member
  93516. }
  93517. function serializeAsMeshReference(sourceName) {
  93518. return generateSerializableMember(6, sourceName); // mesh reference member
  93519. }
  93520. function serializeAsColorCurves(sourceName) {
  93521. return generateSerializableMember(7, sourceName); // color curves
  93522. }
  93523. function serializeAsColor4(sourceName) {
  93524. return generateSerializableMember(8, sourceName); // color 4
  93525. }
  93526. function serializeAsImageProcessingConfiguration(sourceName) {
  93527. return generateSerializableMember(9, sourceName); // image processing
  93528. }
  93529. function serializeAsQuaternion(sourceName) {
  93530. return generateSerializableMember(10, sourceName); // quaternion member
  93531. }
  93532. /**
  93533. * Decorator used to define property that can be serialized as reference to a camera
  93534. * @param sourceName defines the name of the property to decorate
  93535. */
  93536. function serializeAsCameraReference(sourceName) {
  93537. return generateSerializableMember(11, sourceName); // camera reference member
  93538. }
  93539. /**
  93540. * Class used to help serialization objects
  93541. */
  93542. var SerializationHelper = /** @class */ (function () {
  93543. function SerializationHelper() {
  93544. }
  93545. /**
  93546. * Appends the serialized animations from the source animations
  93547. * @param source Source containing the animations
  93548. * @param destination Target to store the animations
  93549. */
  93550. SerializationHelper.AppendSerializedAnimations = function (source, destination) {
  93551. if (source.animations) {
  93552. destination.animations = [];
  93553. for (var animationIndex = 0; animationIndex < source.animations.length; animationIndex++) {
  93554. var animation = source.animations[animationIndex];
  93555. destination.animations.push(animation.serialize());
  93556. }
  93557. }
  93558. };
  93559. /**
  93560. * Static function used to serialized a specific entity
  93561. * @param entity defines the entity to serialize
  93562. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93563. * @returns a JSON compatible object representing the serialization of the entity
  93564. */
  93565. SerializationHelper.Serialize = function (entity, serializationObject) {
  93566. if (!serializationObject) {
  93567. serializationObject = {};
  93568. }
  93569. // Tags
  93570. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  93571. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].GetTags(entity);
  93572. }
  93573. var serializedProperties = getMergedStore(entity);
  93574. // Properties
  93575. for (var property in serializedProperties) {
  93576. var propertyDescriptor = serializedProperties[property];
  93577. var targetPropertyName = propertyDescriptor.sourceName || property;
  93578. var propertyType = propertyDescriptor.type;
  93579. var sourceProperty = entity[property];
  93580. if (sourceProperty !== undefined && sourceProperty !== null) {
  93581. switch (propertyType) {
  93582. case 0: // Value
  93583. serializationObject[targetPropertyName] = sourceProperty;
  93584. break;
  93585. case 1: // Texture
  93586. serializationObject[targetPropertyName] = sourceProperty.serialize();
  93587. break;
  93588. case 2: // Color3
  93589. serializationObject[targetPropertyName] = sourceProperty.asArray();
  93590. break;
  93591. case 3: // FresnelParameters
  93592. serializationObject[targetPropertyName] = sourceProperty.serialize();
  93593. break;
  93594. case 4: // Vector2
  93595. serializationObject[targetPropertyName] = sourceProperty.asArray();
  93596. break;
  93597. case 5: // Vector3
  93598. serializationObject[targetPropertyName] = sourceProperty.asArray();
  93599. break;
  93600. case 6: // Mesh reference
  93601. serializationObject[targetPropertyName] = sourceProperty.id;
  93602. break;
  93603. case 7: // Color Curves
  93604. serializationObject[targetPropertyName] = sourceProperty.serialize();
  93605. break;
  93606. case 8: // Color 4
  93607. serializationObject[targetPropertyName] = sourceProperty.asArray();
  93608. break;
  93609. case 9: // Image Processing
  93610. serializationObject[targetPropertyName] = sourceProperty.serialize();
  93611. break;
  93612. case 10: // Quaternion
  93613. serializationObject[targetPropertyName] = sourceProperty.asArray();
  93614. break;
  93615. case 11: // Camera reference
  93616. serializationObject[targetPropertyName] = sourceProperty.id;
  93617. break;
  93618. }
  93619. }
  93620. }
  93621. return serializationObject;
  93622. };
  93623. /**
  93624. * Creates a new entity from a serialization data object
  93625. * @param creationFunction defines a function used to instanciated the new entity
  93626. * @param source defines the source serialization data
  93627. * @param scene defines the hosting scene
  93628. * @param rootUrl defines the root url for resources
  93629. * @returns a new entity
  93630. */
  93631. SerializationHelper.Parse = function (creationFunction, source, scene, rootUrl) {
  93632. if (rootUrl === void 0) { rootUrl = null; }
  93633. var destination = creationFunction();
  93634. if (!rootUrl) {
  93635. rootUrl = "";
  93636. }
  93637. // Tags
  93638. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  93639. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  93640. }
  93641. var classStore = getMergedStore(destination);
  93642. // Properties
  93643. for (var property in classStore) {
  93644. var propertyDescriptor = classStore[property];
  93645. var sourceProperty = source[propertyDescriptor.sourceName || property];
  93646. var propertyType = propertyDescriptor.type;
  93647. if (sourceProperty !== undefined && sourceProperty !== null) {
  93648. var dest = destination;
  93649. switch (propertyType) {
  93650. case 0: // Value
  93651. dest[property] = sourceProperty;
  93652. break;
  93653. case 1: // Texture
  93654. if (scene) {
  93655. dest[property] = SerializationHelper._TextureParser(sourceProperty, scene, rootUrl);
  93656. }
  93657. break;
  93658. case 2: // Color3
  93659. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(sourceProperty);
  93660. break;
  93661. case 3: // FresnelParameters
  93662. dest[property] = SerializationHelper._FresnelParametersParser(sourceProperty);
  93663. break;
  93664. case 4: // Vector2
  93665. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"].FromArray(sourceProperty);
  93666. break;
  93667. case 5: // Vector3
  93668. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(sourceProperty);
  93669. break;
  93670. case 6: // Mesh reference
  93671. if (scene) {
  93672. dest[property] = scene.getLastMeshByID(sourceProperty);
  93673. }
  93674. break;
  93675. case 7: // Color Curves
  93676. dest[property] = SerializationHelper._ColorCurvesParser(sourceProperty);
  93677. break;
  93678. case 8: // Color 4
  93679. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(sourceProperty);
  93680. break;
  93681. case 9: // Image Processing
  93682. dest[property] = SerializationHelper._ImageProcessingConfigurationParser(sourceProperty);
  93683. break;
  93684. case 10: // Quaternion
  93685. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromArray(sourceProperty);
  93686. break;
  93687. case 11: // Camera reference
  93688. if (scene) {
  93689. dest[property] = scene.getCameraByID(sourceProperty);
  93690. }
  93691. break;
  93692. }
  93693. }
  93694. }
  93695. return destination;
  93696. };
  93697. /**
  93698. * Clones an object
  93699. * @param creationFunction defines the function used to instanciate the new object
  93700. * @param source defines the source object
  93701. * @returns the cloned object
  93702. */
  93703. SerializationHelper.Clone = function (creationFunction, source) {
  93704. return _copySource(creationFunction, source, false);
  93705. };
  93706. /**
  93707. * Instanciates a new object based on a source one (some data will be shared between both object)
  93708. * @param creationFunction defines the function used to instanciate the new object
  93709. * @param source defines the source object
  93710. * @returns the new object
  93711. */
  93712. SerializationHelper.Instanciate = function (creationFunction, source) {
  93713. return _copySource(creationFunction, source, true);
  93714. };
  93715. /** hidden */
  93716. SerializationHelper._ImageProcessingConfigurationParser = function (sourceProperty) {
  93717. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ImageProcessingConfiguration");
  93718. };
  93719. /** hidden */
  93720. SerializationHelper._FresnelParametersParser = function (sourceProperty) {
  93721. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("FresnelParameters");
  93722. };
  93723. /** hidden */
  93724. SerializationHelper._ColorCurvesParser = function (sourceProperty) {
  93725. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ColorCurves");
  93726. };
  93727. /** hidden */
  93728. SerializationHelper._TextureParser = function (sourceProperty, scene, rootUrl) {
  93729. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("Texture");
  93730. };
  93731. return SerializationHelper;
  93732. }());
  93733. /***/ }),
  93734. /***/ "./Misc/deepCopier.ts":
  93735. /*!****************************!*\
  93736. !*** ./Misc/deepCopier.ts ***!
  93737. \****************************/
  93738. /*! exports provided: DeepCopier */
  93739. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93740. "use strict";
  93741. __webpack_require__.r(__webpack_exports__);
  93742. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return DeepCopier; });
  93743. var cloneValue = function (source, destinationObject) {
  93744. if (!source) {
  93745. return null;
  93746. }
  93747. if (source.getClassName && source.getClassName() === "Mesh") {
  93748. return null;
  93749. }
  93750. if (source.getClassName && source.getClassName() === "SubMesh") {
  93751. return source.clone(destinationObject);
  93752. }
  93753. else if (source.clone) {
  93754. return source.clone();
  93755. }
  93756. return null;
  93757. };
  93758. /**
  93759. * Class containing a set of static utilities functions for deep copy.
  93760. */
  93761. var DeepCopier = /** @class */ (function () {
  93762. function DeepCopier() {
  93763. }
  93764. /**
  93765. * Tries to copy an object by duplicating every property
  93766. * @param source defines the source object
  93767. * @param destination defines the target object
  93768. * @param doNotCopyList defines a list of properties to avoid
  93769. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  93770. */
  93771. DeepCopier.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  93772. for (var prop in source) {
  93773. if (prop[0] === "_" && (!mustCopyList || mustCopyList.indexOf(prop) === -1)) {
  93774. continue;
  93775. }
  93776. if (doNotCopyList && doNotCopyList.indexOf(prop) !== -1) {
  93777. continue;
  93778. }
  93779. var sourceValue = source[prop];
  93780. var typeOfSourceValue = typeof sourceValue;
  93781. if (typeOfSourceValue === "function") {
  93782. continue;
  93783. }
  93784. try {
  93785. if (typeOfSourceValue === "object") {
  93786. if (sourceValue instanceof Array) {
  93787. destination[prop] = [];
  93788. if (sourceValue.length > 0) {
  93789. if (typeof sourceValue[0] == "object") {
  93790. for (var index = 0; index < sourceValue.length; index++) {
  93791. var clonedValue = cloneValue(sourceValue[index], destination);
  93792. if (destination[prop].indexOf(clonedValue) === -1) { // Test if auto inject was not done
  93793. destination[prop].push(clonedValue);
  93794. }
  93795. }
  93796. }
  93797. else {
  93798. destination[prop] = sourceValue.slice(0);
  93799. }
  93800. }
  93801. }
  93802. else {
  93803. destination[prop] = cloneValue(sourceValue, destination);
  93804. }
  93805. }
  93806. else {
  93807. destination[prop] = sourceValue;
  93808. }
  93809. }
  93810. catch (e) {
  93811. // Just ignore error (it could be because of a read-only property)
  93812. }
  93813. }
  93814. };
  93815. return DeepCopier;
  93816. }());
  93817. /***/ }),
  93818. /***/ "./Misc/deferred.ts":
  93819. /*!**************************!*\
  93820. !*** ./Misc/deferred.ts ***!
  93821. \**************************/
  93822. /*! exports provided: Deferred */
  93823. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93824. "use strict";
  93825. __webpack_require__.r(__webpack_exports__);
  93826. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return Deferred; });
  93827. /**
  93828. * Wrapper class for promise with external resolve and reject.
  93829. */
  93830. var Deferred = /** @class */ (function () {
  93831. /**
  93832. * Constructor for this deferred object.
  93833. */
  93834. function Deferred() {
  93835. var _this = this;
  93836. this.promise = new Promise(function (resolve, reject) {
  93837. _this._resolve = resolve;
  93838. _this._reject = reject;
  93839. });
  93840. }
  93841. Object.defineProperty(Deferred.prototype, "resolve", {
  93842. /**
  93843. * The resolve method of the promise associated with this deferred object.
  93844. */
  93845. get: function () {
  93846. return this._resolve;
  93847. },
  93848. enumerable: true,
  93849. configurable: true
  93850. });
  93851. Object.defineProperty(Deferred.prototype, "reject", {
  93852. /**
  93853. * The reject method of the promise associated with this deferred object.
  93854. */
  93855. get: function () {
  93856. return this._reject;
  93857. },
  93858. enumerable: true,
  93859. configurable: true
  93860. });
  93861. return Deferred;
  93862. }());
  93863. /***/ }),
  93864. /***/ "./Misc/devTools.ts":
  93865. /*!**************************!*\
  93866. !*** ./Misc/devTools.ts ***!
  93867. \**************************/
  93868. /*! exports provided: _DevTools */
  93869. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93870. "use strict";
  93871. __webpack_require__.r(__webpack_exports__);
  93872. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DevTools", function() { return _DevTools; });
  93873. /** @hidden */
  93874. var _DevTools = /** @class */ (function () {
  93875. function _DevTools() {
  93876. }
  93877. _DevTools.WarnImport = function (name) {
  93878. return name + " needs to be imported before as it contains a side-effect required by your code.";
  93879. };
  93880. return _DevTools;
  93881. }());
  93882. /***/ }),
  93883. /***/ "./Misc/domManagement.ts":
  93884. /*!*******************************!*\
  93885. !*** ./Misc/domManagement.ts ***!
  93886. \*******************************/
  93887. /*! exports provided: DomManagement */
  93888. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93889. "use strict";
  93890. __webpack_require__.r(__webpack_exports__);
  93891. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DomManagement", function() { return DomManagement; });
  93892. /**
  93893. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  93894. * Babylon.js
  93895. */
  93896. var DomManagement = /** @class */ (function () {
  93897. function DomManagement() {
  93898. }
  93899. /**
  93900. * Checks if the window object exists
  93901. * @returns true if the window object exists
  93902. */
  93903. DomManagement.IsWindowObjectExist = function () {
  93904. return (typeof window) !== "undefined";
  93905. };
  93906. /**
  93907. * Extracts text content from a DOM element hierarchy
  93908. * @param element defines the root element
  93909. * @returns a string
  93910. */
  93911. DomManagement.GetDOMTextContent = function (element) {
  93912. var result = "";
  93913. var child = element.firstChild;
  93914. while (child) {
  93915. if (child.nodeType === 3) {
  93916. result += child.textContent;
  93917. }
  93918. child = (child.nextSibling);
  93919. }
  93920. return result;
  93921. };
  93922. return DomManagement;
  93923. }());
  93924. /***/ }),
  93925. /***/ "./Misc/environmentTextureTools.ts":
  93926. /*!*****************************************!*\
  93927. !*** ./Misc/environmentTextureTools.ts ***!
  93928. \*****************************************/
  93929. /*! exports provided: EnvironmentTextureTools */
  93930. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93931. "use strict";
  93932. __webpack_require__.r(__webpack_exports__);
  93933. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return EnvironmentTextureTools; });
  93934. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  93935. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  93936. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  93937. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  93938. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  93939. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  93940. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  93941. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  93942. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  93943. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  93944. /* harmony import */ var _Shaders_rgbdEncode_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/rgbdEncode.fragment */ "./Shaders/rgbdEncode.fragment.ts");
  93945. /* harmony import */ var _Shaders_rgbdDecode_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/rgbdDecode.fragment */ "./Shaders/rgbdDecode.fragment.ts");
  93946. /**
  93947. * Sets of helpers addressing the serialization and deserialization of environment texture
  93948. * stored in a BabylonJS env file.
  93949. * Those files are usually stored as .env files.
  93950. */
  93951. var EnvironmentTextureTools = /** @class */ (function () {
  93952. function EnvironmentTextureTools() {
  93953. }
  93954. /**
  93955. * Gets the environment info from an env file.
  93956. * @param data The array buffer containing the .env bytes.
  93957. * @returns the environment file info (the json header) if successfully parsed.
  93958. */
  93959. EnvironmentTextureTools.GetEnvInfo = function (data) {
  93960. var dataView = new DataView(data);
  93961. var pos = 0;
  93962. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  93963. if (dataView.getUint8(pos++) !== EnvironmentTextureTools._MagicBytes[i]) {
  93964. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Error('Not a babylon environment map');
  93965. return null;
  93966. }
  93967. }
  93968. // Read json manifest - collect characters up to null terminator
  93969. var manifestString = '';
  93970. var charCode = 0x00;
  93971. while ((charCode = dataView.getUint8(pos++))) {
  93972. manifestString += String.fromCharCode(charCode);
  93973. }
  93974. var manifest = JSON.parse(manifestString);
  93975. if (manifest.specular) {
  93976. // Extend the header with the position of the payload.
  93977. manifest.specular.specularDataPosition = pos;
  93978. // Fallback to 0.8 exactly if lodGenerationScale is not defined for backward compatibility.
  93979. manifest.specular.lodGenerationScale = manifest.specular.lodGenerationScale || 0.8;
  93980. }
  93981. return manifest;
  93982. };
  93983. /**
  93984. * Creates an environment texture from a loaded cube texture.
  93985. * @param texture defines the cube texture to convert in env file
  93986. * @return a promise containing the environment data if succesfull.
  93987. */
  93988. EnvironmentTextureTools.CreateEnvTextureAsync = function (texture) {
  93989. var _this = this;
  93990. var internalTexture = texture.getInternalTexture();
  93991. if (!internalTexture) {
  93992. return Promise.reject("The cube texture is invalid.");
  93993. }
  93994. if (!texture._prefiltered) {
  93995. return Promise.reject("The cube texture is invalid (not prefiltered).");
  93996. }
  93997. var engine = internalTexture.getEngine();
  93998. if (engine && engine.premultipliedAlpha) {
  93999. return Promise.reject("Env texture can only be created when the engine is created with the premultipliedAlpha option set to false.");
  94000. }
  94001. if (texture.textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  94002. return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");
  94003. }
  94004. var canvas = engine.getRenderingCanvas();
  94005. if (!canvas) {
  94006. return Promise.reject("Env texture can only be created when the engine is associated to a canvas.");
  94007. }
  94008. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  94009. if (!engine.getCaps().textureFloatRender) {
  94010. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  94011. if (!engine.getCaps().textureHalfFloatRender) {
  94012. return Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.");
  94013. }
  94014. }
  94015. var cubeWidth = internalTexture.width;
  94016. var hostingScene = new _scene__WEBPACK_IMPORTED_MODULE_7__["Scene"](engine);
  94017. var specularTextures = {};
  94018. var promises = [];
  94019. // Read and collect all mipmaps data from the cube.
  94020. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(internalTexture.width);
  94021. mipmapsCount = Math.round(mipmapsCount);
  94022. var _loop_1 = function (i) {
  94023. var faceWidth = Math.pow(2, mipmapsCount - i);
  94024. var _loop_2 = function (face) {
  94025. var data = texture.readPixels(face, i);
  94026. // Creates a temp texture with the face data.
  94027. 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);
  94028. // And rgbdEncode them.
  94029. var promise = new Promise(function (resolve, reject) {
  94030. 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);
  94031. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  94032. rgbdPostProcess.onApply = function (effect) {
  94033. effect._bindTexture("textureSampler", tempTexture);
  94034. };
  94035. // As the process needs to happen on the main canvas, keep track of the current size
  94036. var currentW = engine.getRenderWidth();
  94037. var currentH = engine.getRenderHeight();
  94038. // Set the desired size for the texture
  94039. engine.setSize(faceWidth, faceWidth);
  94040. hostingScene.postProcessManager.directRender([rgbdPostProcess], null);
  94041. // Reading datas from WebGL
  94042. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ToBlob(canvas, function (blob) {
  94043. var fileReader = new FileReader();
  94044. fileReader.onload = function (event) {
  94045. var arrayBuffer = event.target.result;
  94046. specularTextures[i * 6 + face] = arrayBuffer;
  94047. resolve();
  94048. };
  94049. fileReader.readAsArrayBuffer(blob);
  94050. });
  94051. // Reapply the previous canvas size
  94052. engine.setSize(currentW, currentH);
  94053. });
  94054. });
  94055. promises.push(promise);
  94056. };
  94057. // All faces of the cube.
  94058. for (var face = 0; face < 6; face++) {
  94059. _loop_2(face);
  94060. }
  94061. };
  94062. for (var i = 0; i <= mipmapsCount; i++) {
  94063. _loop_1(i);
  94064. }
  94065. // Once all the textures haves been collected as RGBD stored in PNGs
  94066. return Promise.all(promises).then(function () {
  94067. // We can delete the hosting scene keeping track of all the creation objects
  94068. hostingScene.dispose();
  94069. // Creates the json header for the env texture
  94070. var info = {
  94071. version: 1,
  94072. width: cubeWidth,
  94073. irradiance: _this._CreateEnvTextureIrradiance(texture),
  94074. specular: {
  94075. mipmaps: [],
  94076. lodGenerationScale: texture.lodGenerationScale
  94077. }
  94078. };
  94079. // Sets the specular image data information
  94080. var position = 0;
  94081. for (var i = 0; i <= mipmapsCount; i++) {
  94082. for (var face = 0; face < 6; face++) {
  94083. var byteLength = specularTextures[i * 6 + face].byteLength;
  94084. info.specular.mipmaps.push({
  94085. length: byteLength,
  94086. position: position
  94087. });
  94088. position += byteLength;
  94089. }
  94090. }
  94091. // Encode the JSON as an array buffer
  94092. var infoString = JSON.stringify(info);
  94093. var infoBuffer = new ArrayBuffer(infoString.length + 1);
  94094. var infoView = new Uint8Array(infoBuffer); // Limited to ascii subset matching unicode.
  94095. for (var i = 0, strLen = infoString.length; i < strLen; i++) {
  94096. infoView[i] = infoString.charCodeAt(i);
  94097. }
  94098. // Ends up with a null terminator for easier parsing
  94099. infoView[infoString.length] = 0x00;
  94100. // Computes the final required size and creates the storage
  94101. var totalSize = EnvironmentTextureTools._MagicBytes.length + position + infoBuffer.byteLength;
  94102. var finalBuffer = new ArrayBuffer(totalSize);
  94103. var finalBufferView = new Uint8Array(finalBuffer);
  94104. var dataView = new DataView(finalBuffer);
  94105. // Copy the magic bytes identifying the file in
  94106. var pos = 0;
  94107. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  94108. dataView.setUint8(pos++, EnvironmentTextureTools._MagicBytes[i]);
  94109. }
  94110. // Add the json info
  94111. finalBufferView.set(new Uint8Array(infoBuffer), pos);
  94112. pos += infoBuffer.byteLength;
  94113. // Finally inserts the texture data
  94114. for (var i = 0; i <= mipmapsCount; i++) {
  94115. for (var face = 0; face < 6; face++) {
  94116. var dataBuffer = specularTextures[i * 6 + face];
  94117. finalBufferView.set(new Uint8Array(dataBuffer), pos);
  94118. pos += dataBuffer.byteLength;
  94119. }
  94120. }
  94121. // Voila
  94122. return finalBuffer;
  94123. });
  94124. };
  94125. /**
  94126. * Creates a JSON representation of the spherical data.
  94127. * @param texture defines the texture containing the polynomials
  94128. * @return the JSON representation of the spherical info
  94129. */
  94130. EnvironmentTextureTools._CreateEnvTextureIrradiance = function (texture) {
  94131. var polynmials = texture.sphericalPolynomial;
  94132. if (polynmials == null) {
  94133. return null;
  94134. }
  94135. return {
  94136. x: [polynmials.x.x, polynmials.x.y, polynmials.x.z],
  94137. y: [polynmials.y.x, polynmials.y.y, polynmials.y.z],
  94138. z: [polynmials.z.x, polynmials.z.y, polynmials.z.z],
  94139. xx: [polynmials.xx.x, polynmials.xx.y, polynmials.xx.z],
  94140. yy: [polynmials.yy.x, polynmials.yy.y, polynmials.yy.z],
  94141. zz: [polynmials.zz.x, polynmials.zz.y, polynmials.zz.z],
  94142. yz: [polynmials.yz.x, polynmials.yz.y, polynmials.yz.z],
  94143. zx: [polynmials.zx.x, polynmials.zx.y, polynmials.zx.z],
  94144. xy: [polynmials.xy.x, polynmials.xy.y, polynmials.xy.z]
  94145. };
  94146. };
  94147. /**
  94148. * Uploads the texture info contained in the env file to the GPU.
  94149. * @param texture defines the internal texture to upload to
  94150. * @param arrayBuffer defines the buffer cotaining the data to load
  94151. * @param info defines the texture info retrieved through the GetEnvInfo method
  94152. * @returns a promise
  94153. */
  94154. EnvironmentTextureTools.UploadEnvLevelsAsync = function (texture, arrayBuffer, info) {
  94155. if (info.version !== 1) {
  94156. throw new Error("Unsupported babylon environment map version \"" + info.version + "\"");
  94157. }
  94158. var specularInfo = info.specular;
  94159. if (!specularInfo) {
  94160. // Nothing else parsed so far
  94161. return Promise.resolve();
  94162. }
  94163. // Double checks the enclosed info
  94164. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(info.width);
  94165. mipmapsCount = Math.round(mipmapsCount) + 1;
  94166. if (specularInfo.mipmaps.length !== 6 * mipmapsCount) {
  94167. throw new Error("Unsupported specular mipmaps number \"" + specularInfo.mipmaps.length + "\"");
  94168. }
  94169. texture._lodGenerationScale = specularInfo.lodGenerationScale;
  94170. var imageData = new Array(mipmapsCount);
  94171. for (var i = 0; i < mipmapsCount; i++) {
  94172. imageData[i] = new Array(6);
  94173. for (var face = 0; face < 6; face++) {
  94174. var imageInfo = specularInfo.mipmaps[i * 6 + face];
  94175. imageData[i][face] = new Uint8Array(arrayBuffer, specularInfo.specularDataPosition + imageInfo.position, imageInfo.length);
  94176. }
  94177. }
  94178. return EnvironmentTextureTools.UploadLevelsAsync(texture, imageData);
  94179. };
  94180. /**
  94181. * Uploads the levels of image data to the GPU.
  94182. * @param texture defines the internal texture to upload to
  94183. * @param imageData defines the array buffer views of image data [mipmap][face]
  94184. * @returns a promise
  94185. */
  94186. EnvironmentTextureTools.UploadLevelsAsync = function (texture, imageData) {
  94187. if (!_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsExponentOfTwo(texture.width)) {
  94188. throw new Error("Texture size must be a power of two");
  94189. }
  94190. var mipmapsCount = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(texture.width)) + 1;
  94191. // Gets everything ready.
  94192. var engine = texture.getEngine();
  94193. var expandTexture = false;
  94194. var generateNonLODTextures = false;
  94195. var rgbdPostProcess = null;
  94196. var cubeRtt = null;
  94197. var lodTextures = null;
  94198. var caps = engine.getCaps();
  94199. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA;
  94200. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  94201. texture.generateMipMaps = true;
  94202. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE, texture);
  94203. // Add extra process if texture lod is not supported
  94204. if (!caps.textureLOD) {
  94205. expandTexture = false;
  94206. generateNonLODTextures = true;
  94207. lodTextures = {};
  94208. }
  94209. // in webgl 1 there are no ways to either render or copy lod level information for float textures.
  94210. else if (engine.webGLVersion < 2) {
  94211. expandTexture = false;
  94212. }
  94213. // If half float available we can uncompress the texture
  94214. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  94215. expandTexture = true;
  94216. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  94217. }
  94218. // If full float available we can uncompress the texture
  94219. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  94220. expandTexture = true;
  94221. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  94222. }
  94223. // Expand the texture if possible
  94224. if (expandTexture) {
  94225. // Simply run through the decode PP
  94226. 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);
  94227. texture._isRGBD = false;
  94228. texture.invertY = false;
  94229. cubeRtt = engine.createRenderTargetCubeTexture(texture.width, {
  94230. generateDepthBuffer: false,
  94231. generateMipMaps: true,
  94232. generateStencilBuffer: false,
  94233. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE,
  94234. type: texture.type,
  94235. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA
  94236. });
  94237. }
  94238. else {
  94239. texture._isRGBD = true;
  94240. texture.invertY = true;
  94241. // In case of missing support, applies the same patch than DDS files.
  94242. if (generateNonLODTextures) {
  94243. var mipSlices = 3;
  94244. var scale = texture._lodGenerationScale;
  94245. var offset = texture._lodGenerationOffset;
  94246. for (var i = 0; i < mipSlices; i++) {
  94247. //compute LOD from even spacing in smoothness (matching shader calculation)
  94248. var smoothness = i / (mipSlices - 1);
  94249. var roughness = 1 - smoothness;
  94250. var minLODIndex = offset; // roughness = 0
  94251. var maxLODIndex = (mipmapsCount - 1) * scale + offset; // roughness = 1 (mipmaps start from 0)
  94252. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  94253. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  94254. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](engine, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  94255. glTextureFromLod.isCube = true;
  94256. glTextureFromLod.invertY = true;
  94257. glTextureFromLod.generateMipMaps = false;
  94258. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR, glTextureFromLod);
  94259. // Wrap in a base texture for easy binding.
  94260. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"](null);
  94261. lodTexture.isCube = true;
  94262. lodTexture._texture = glTextureFromLod;
  94263. lodTextures[mipmapIndex] = lodTexture;
  94264. switch (i) {
  94265. case 0:
  94266. texture._lodTextureLow = lodTexture;
  94267. break;
  94268. case 1:
  94269. texture._lodTextureMid = lodTexture;
  94270. break;
  94271. case 2:
  94272. texture._lodTextureHigh = lodTexture;
  94273. break;
  94274. }
  94275. }
  94276. }
  94277. }
  94278. var promises = [];
  94279. var _loop_3 = function (i) {
  94280. var _loop_4 = function (face) {
  94281. // Constructs an image element from image data
  94282. var bytes = imageData[i][face];
  94283. var blob = new Blob([bytes], { type: 'image/png' });
  94284. var url = URL.createObjectURL(blob);
  94285. var image = new Image();
  94286. image.src = url;
  94287. // Enqueue promise to upload to the texture.
  94288. var promise = new Promise(function (resolve, reject) {
  94289. image.onload = function () {
  94290. if (expandTexture) {
  94291. var tempTexture_1 = engine.createTexture(null, true, true, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, null, function (message) {
  94292. reject(message);
  94293. }, image);
  94294. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  94295. // Uncompress the data to a RTT
  94296. rgbdPostProcess.onApply = function (effect) {
  94297. effect._bindTexture("textureSampler", tempTexture_1);
  94298. effect.setFloat2("scale", 1, 1);
  94299. };
  94300. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess], cubeRtt, true, face, i);
  94301. // Cleanup
  94302. engine.restoreDefaultFramebuffer();
  94303. tempTexture_1.dispose();
  94304. window.URL.revokeObjectURL(url);
  94305. resolve();
  94306. });
  94307. }
  94308. else {
  94309. engine._uploadImageToTexture(texture, image, face, i);
  94310. // Upload the face to the non lod texture support
  94311. if (generateNonLODTextures) {
  94312. var lodTexture = lodTextures[i];
  94313. if (lodTexture) {
  94314. engine._uploadImageToTexture(lodTexture._texture, image, face, 0);
  94315. }
  94316. }
  94317. resolve();
  94318. }
  94319. };
  94320. image.onerror = function (error) {
  94321. reject(error);
  94322. };
  94323. });
  94324. promises.push(promise);
  94325. };
  94326. // All faces
  94327. for (var face = 0; face < 6; face++) {
  94328. _loop_4(face);
  94329. }
  94330. };
  94331. // All mipmaps up to provided number of images
  94332. for (var i = 0; i < imageData.length; i++) {
  94333. _loop_3(i);
  94334. }
  94335. // Fill remaining mipmaps with black textures.
  94336. if (imageData.length < mipmapsCount) {
  94337. var data = void 0;
  94338. var size = Math.pow(2, mipmapsCount - 1 - imageData.length);
  94339. var dataLength = size * size * 4;
  94340. switch (texture.type) {
  94341. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT: {
  94342. data = new Uint8Array(dataLength);
  94343. break;
  94344. }
  94345. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT: {
  94346. data = new Uint16Array(dataLength);
  94347. break;
  94348. }
  94349. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT: {
  94350. data = new Float32Array(dataLength);
  94351. break;
  94352. }
  94353. }
  94354. for (var i = imageData.length; i < mipmapsCount; i++) {
  94355. for (var face = 0; face < 6; face++) {
  94356. engine._uploadArrayBufferViewToTexture(texture, data, face, i);
  94357. }
  94358. }
  94359. }
  94360. // Once all done, finishes the cleanup and return
  94361. return Promise.all(promises).then(function () {
  94362. // Release temp RTT.
  94363. if (cubeRtt) {
  94364. engine._releaseFramebufferObjects(cubeRtt);
  94365. cubeRtt._swapAndDie(texture);
  94366. }
  94367. // Release temp Post Process.
  94368. if (rgbdPostProcess) {
  94369. rgbdPostProcess.dispose();
  94370. }
  94371. // Flag internal texture as ready in case they are in use.
  94372. if (generateNonLODTextures) {
  94373. if (texture._lodTextureHigh && texture._lodTextureHigh._texture) {
  94374. texture._lodTextureHigh._texture.isReady = true;
  94375. }
  94376. if (texture._lodTextureMid && texture._lodTextureMid._texture) {
  94377. texture._lodTextureMid._texture.isReady = true;
  94378. }
  94379. if (texture._lodTextureLow && texture._lodTextureLow._texture) {
  94380. texture._lodTextureLow._texture.isReady = true;
  94381. }
  94382. }
  94383. });
  94384. };
  94385. /**
  94386. * Uploads spherical polynomials information to the texture.
  94387. * @param texture defines the texture we are trying to upload the information to
  94388. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  94389. */
  94390. EnvironmentTextureTools.UploadEnvSpherical = function (texture, info) {
  94391. if (info.version !== 1) {
  94392. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn('Unsupported babylon environment map version "' + info.version + '"');
  94393. }
  94394. var irradianceInfo = info.irradiance;
  94395. if (!irradianceInfo) {
  94396. return;
  94397. }
  94398. var sp = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__["SphericalPolynomial"]();
  94399. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.x, 0, sp.x);
  94400. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.y, 0, sp.y);
  94401. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.z, 0, sp.z);
  94402. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xx, 0, sp.xx);
  94403. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yy, 0, sp.yy);
  94404. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zz, 0, sp.zz);
  94405. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yz, 0, sp.yz);
  94406. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zx, 0, sp.zx);
  94407. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xy, 0, sp.xy);
  94408. texture._sphericalPolynomial = sp;
  94409. };
  94410. /** @hidden */
  94411. EnvironmentTextureTools._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  94412. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  94413. internalTexture._bufferViewArrayArray = data;
  94414. internalTexture._lodGenerationScale = lodScale;
  94415. internalTexture._lodGenerationOffset = lodOffset;
  94416. internalTexture._sphericalPolynomial = sphericalPolynomial;
  94417. return EnvironmentTextureTools.UploadLevelsAsync(internalTexture, data).then(function () {
  94418. internalTexture.isReady = true;
  94419. });
  94420. };
  94421. /**
  94422. * Magic number identifying the env file.
  94423. */
  94424. EnvironmentTextureTools._MagicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];
  94425. return EnvironmentTextureTools;
  94426. }());
  94427. // References the dependencies.
  94428. _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"]._UpdateRGBDAsync = EnvironmentTextureTools._UpdateRGBDAsync;
  94429. /***/ }),
  94430. /***/ "./Misc/filesInput.ts":
  94431. /*!****************************!*\
  94432. !*** ./Misc/filesInput.ts ***!
  94433. \****************************/
  94434. /*! exports provided: FilesInput */
  94435. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94436. "use strict";
  94437. __webpack_require__.r(__webpack_exports__);
  94438. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return FilesInput; });
  94439. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  94440. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  94441. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  94442. /**
  94443. * Class used to help managing file picking and drag'n'drop
  94444. */
  94445. var FilesInput = /** @class */ (function () {
  94446. /**
  94447. * Creates a new FilesInput
  94448. * @param engine defines the rendering engine
  94449. * @param scene defines the hosting scene
  94450. * @param sceneLoadedCallback callback called when scene is loaded
  94451. * @param progressCallback callback called to track progress
  94452. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  94453. * @param textureLoadingCallback callback called when a texture is loading
  94454. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  94455. * @param onReloadCallback callback called when a reload is requested
  94456. * @param errorCallback callback call if an error occurs
  94457. */
  94458. function FilesInput(engine, scene, sceneLoadedCallback, progressCallback, additionalRenderLoopLogicCallback, textureLoadingCallback, startingProcessingFilesCallback, onReloadCallback, errorCallback) {
  94459. /**
  94460. * Callback called when a file is processed
  94461. */
  94462. this.onProcessFileCallback = function () { return true; };
  94463. this._engine = engine;
  94464. this._currentScene = scene;
  94465. this._sceneLoadedCallback = sceneLoadedCallback;
  94466. this._progressCallback = progressCallback;
  94467. this._additionalRenderLoopLogicCallback = additionalRenderLoopLogicCallback;
  94468. this._textureLoadingCallback = textureLoadingCallback;
  94469. this._startingProcessingFilesCallback = startingProcessingFilesCallback;
  94470. this._onReloadCallback = onReloadCallback;
  94471. this._errorCallback = errorCallback;
  94472. }
  94473. Object.defineProperty(FilesInput, "FilesToLoad", {
  94474. /**
  94475. * List of files ready to be loaded
  94476. */
  94477. get: function () {
  94478. return _filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad;
  94479. },
  94480. enumerable: true,
  94481. configurable: true
  94482. });
  94483. /**
  94484. * Calls this function to listen to drag'n'drop events on a specific DOM element
  94485. * @param elementToMonitor defines the DOM element to track
  94486. */
  94487. FilesInput.prototype.monitorElementForDragNDrop = function (elementToMonitor) {
  94488. var _this = this;
  94489. if (elementToMonitor) {
  94490. this._elementToMonitor = elementToMonitor;
  94491. this._dragEnterHandler = function (e) { _this.drag(e); };
  94492. this._dragOverHandler = function (e) { _this.drag(e); };
  94493. this._dropHandler = function (e) { _this.drop(e); };
  94494. this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, false);
  94495. this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, false);
  94496. this._elementToMonitor.addEventListener("drop", this._dropHandler, false);
  94497. }
  94498. };
  94499. /**
  94500. * Release all associated resources
  94501. */
  94502. FilesInput.prototype.dispose = function () {
  94503. if (!this._elementToMonitor) {
  94504. return;
  94505. }
  94506. this._elementToMonitor.removeEventListener("dragenter", this._dragEnterHandler);
  94507. this._elementToMonitor.removeEventListener("dragover", this._dragOverHandler);
  94508. this._elementToMonitor.removeEventListener("drop", this._dropHandler);
  94509. };
  94510. FilesInput.prototype.renderFunction = function () {
  94511. if (this._additionalRenderLoopLogicCallback) {
  94512. this._additionalRenderLoopLogicCallback();
  94513. }
  94514. if (this._currentScene) {
  94515. if (this._textureLoadingCallback) {
  94516. var remaining = this._currentScene.getWaitingItemsCount();
  94517. if (remaining > 0) {
  94518. this._textureLoadingCallback(remaining);
  94519. }
  94520. }
  94521. this._currentScene.render();
  94522. }
  94523. };
  94524. FilesInput.prototype.drag = function (e) {
  94525. e.stopPropagation();
  94526. e.preventDefault();
  94527. };
  94528. FilesInput.prototype.drop = function (eventDrop) {
  94529. eventDrop.stopPropagation();
  94530. eventDrop.preventDefault();
  94531. this.loadFiles(eventDrop);
  94532. };
  94533. FilesInput.prototype._traverseFolder = function (folder, files, remaining, callback) {
  94534. var _this = this;
  94535. var reader = folder.createReader();
  94536. var relativePath = folder.fullPath.replace(/^\//, "").replace(/(.+?)\/?$/, "$1/");
  94537. reader.readEntries(function (entries) {
  94538. remaining.count += entries.length;
  94539. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  94540. var entry = entries_1[_i];
  94541. if (entry.isFile) {
  94542. entry.file(function (file) {
  94543. file.correctName = relativePath + file.name;
  94544. files.push(file);
  94545. if (--remaining.count === 0) {
  94546. callback();
  94547. }
  94548. });
  94549. }
  94550. else if (entry.isDirectory) {
  94551. _this._traverseFolder(entry, files, remaining, callback);
  94552. }
  94553. }
  94554. if (--remaining.count) {
  94555. callback();
  94556. }
  94557. });
  94558. };
  94559. FilesInput.prototype._processFiles = function (files) {
  94560. for (var i = 0; i < files.length; i++) {
  94561. var name = files[i].correctName.toLowerCase();
  94562. var extension = name.split('.').pop();
  94563. if (!this.onProcessFileCallback(files[i], name, extension)) {
  94564. continue;
  94565. }
  94566. if ((extension === "babylon" || extension === "stl" || extension === "obj" || extension === "gltf" || extension === "glb")
  94567. && name.indexOf(".binary.babylon") === -1 && name.indexOf(".incremental.babylon") === -1) {
  94568. this._sceneFileToLoad = files[i];
  94569. }
  94570. FilesInput.FilesToLoad[name] = files[i];
  94571. }
  94572. };
  94573. /**
  94574. * Load files from a drop event
  94575. * @param event defines the drop event to use as source
  94576. */
  94577. FilesInput.prototype.loadFiles = function (event) {
  94578. var _this = this;
  94579. // Handling data transfer via drag'n'drop
  94580. if (event && event.dataTransfer && event.dataTransfer.files) {
  94581. this._filesToLoad = event.dataTransfer.files;
  94582. }
  94583. // Handling files from input files
  94584. if (event && event.target && event.target.files) {
  94585. this._filesToLoad = event.target.files;
  94586. }
  94587. if (!this._filesToLoad || this._filesToLoad.length === 0) {
  94588. return;
  94589. }
  94590. if (this._startingProcessingFilesCallback) {
  94591. this._startingProcessingFilesCallback(this._filesToLoad);
  94592. }
  94593. if (this._filesToLoad && this._filesToLoad.length > 0) {
  94594. var files_1 = new Array();
  94595. var folders = [];
  94596. var items = event.dataTransfer ? event.dataTransfer.items : null;
  94597. for (var i = 0; i < this._filesToLoad.length; i++) {
  94598. var fileToLoad = this._filesToLoad[i];
  94599. var name_1 = fileToLoad.name.toLowerCase();
  94600. var entry = void 0;
  94601. fileToLoad.correctName = name_1;
  94602. if (items) {
  94603. var item = items[i];
  94604. if (item.getAsEntry) {
  94605. entry = item.getAsEntry();
  94606. }
  94607. else if (item.webkitGetAsEntry) {
  94608. entry = item.webkitGetAsEntry();
  94609. }
  94610. }
  94611. if (!entry) {
  94612. files_1.push(fileToLoad);
  94613. }
  94614. else {
  94615. if (entry.isDirectory) {
  94616. folders.push(entry);
  94617. }
  94618. else {
  94619. files_1.push(fileToLoad);
  94620. }
  94621. }
  94622. }
  94623. if (folders.length === 0) {
  94624. this._processFiles(files_1);
  94625. this._processReload();
  94626. }
  94627. else {
  94628. var remaining = { count: folders.length };
  94629. for (var _i = 0, folders_1 = folders; _i < folders_1.length; _i++) {
  94630. var folder = folders_1[_i];
  94631. this._traverseFolder(folder, files_1, remaining, function () {
  94632. _this._processFiles(files_1);
  94633. if (remaining.count === 0) {
  94634. _this._processReload();
  94635. }
  94636. });
  94637. }
  94638. }
  94639. }
  94640. };
  94641. FilesInput.prototype._processReload = function () {
  94642. if (this._onReloadCallback) {
  94643. this._onReloadCallback(this._sceneFileToLoad);
  94644. }
  94645. else {
  94646. this.reload();
  94647. }
  94648. };
  94649. /**
  94650. * Reload the current scene from the loaded files
  94651. */
  94652. FilesInput.prototype.reload = function () {
  94653. var _this = this;
  94654. // If a scene file has been provided
  94655. if (this._sceneFileToLoad) {
  94656. if (this._currentScene) {
  94657. if (_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].errorsCount > 0) {
  94658. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].ClearLogCache();
  94659. }
  94660. this._engine.stopRenderLoop();
  94661. }
  94662. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"].LoadAsync("file:", this._sceneFileToLoad, this._engine, function (progress) {
  94663. if (_this._progressCallback) {
  94664. _this._progressCallback(progress);
  94665. }
  94666. }).then(function (scene) {
  94667. if (_this._currentScene) {
  94668. _this._currentScene.dispose();
  94669. }
  94670. _this._currentScene = scene;
  94671. if (_this._sceneLoadedCallback) {
  94672. _this._sceneLoadedCallback(_this._sceneFileToLoad, _this._currentScene);
  94673. }
  94674. // Wait for textures and shaders to be ready
  94675. _this._currentScene.executeWhenReady(function () {
  94676. _this._engine.runRenderLoop(function () {
  94677. _this.renderFunction();
  94678. });
  94679. });
  94680. }).catch(function (error) {
  94681. if (_this._errorCallback) {
  94682. _this._errorCallback(_this._sceneFileToLoad, _this._currentScene, error.message);
  94683. }
  94684. });
  94685. }
  94686. else {
  94687. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Please provide a valid .babylon file.");
  94688. }
  94689. };
  94690. return FilesInput;
  94691. }());
  94692. /***/ }),
  94693. /***/ "./Misc/filesInputStore.ts":
  94694. /*!*********************************!*\
  94695. !*** ./Misc/filesInputStore.ts ***!
  94696. \*********************************/
  94697. /*! exports provided: FilesInputStore */
  94698. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94699. "use strict";
  94700. __webpack_require__.r(__webpack_exports__);
  94701. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return FilesInputStore; });
  94702. /**
  94703. * Class used to help managing file picking and drag'n'drop
  94704. * File Storage
  94705. */
  94706. var FilesInputStore = /** @class */ (function () {
  94707. function FilesInputStore() {
  94708. }
  94709. /**
  94710. * List of files ready to be loaded
  94711. */
  94712. FilesInputStore.FilesToLoad = {};
  94713. return FilesInputStore;
  94714. }());
  94715. /***/ }),
  94716. /***/ "./Misc/index.ts":
  94717. /*!***********************!*\
  94718. !*** ./Misc/index.ts ***!
  94719. \***********************/
  94720. /*! 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 */
  94721. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94722. "use strict";
  94723. __webpack_require__.r(__webpack_exports__);
  94724. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  94725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  94726. /* harmony import */ var _assetsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./assetsManager */ "./Misc/assetsManager.ts");
  94727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetTaskState"]; });
  94728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AbstractAssetTask"]; });
  94729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsProgressEvent"]; });
  94730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["MeshAssetTask"]; });
  94731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextFileAssetTask"]; });
  94732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["BinaryFileAssetTask"]; });
  94733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["ImageAssetTask"]; });
  94734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextureAssetTask"]; });
  94735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["CubeTextureAssetTask"]; });
  94736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["HDRCubeTextureAssetTask"]; });
  94737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsManager"]; });
  94738. /* harmony import */ var _dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dds */ "./Misc/dds.ts");
  94739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"]; });
  94740. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  94741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["expandToProperty"]; });
  94742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"]; });
  94743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsTexture"]; });
  94744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor3"]; });
  94745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsFresnelParameters"]; });
  94746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector2"]; });
  94747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector3"]; });
  94748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMeshReference"]; });
  94749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColorCurves"]; });
  94750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor4"]; });
  94751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsImageProcessingConfiguration"]; });
  94752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsQuaternion"]; });
  94753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsCameraReference"]; });
  94754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]; });
  94755. /* harmony import */ var _deferred__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./deferred */ "./Misc/deferred.ts");
  94756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _deferred__WEBPACK_IMPORTED_MODULE_4__["Deferred"]; });
  94757. /* harmony import */ var _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  94758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__["EnvironmentTextureTools"]; });
  94759. /* harmony import */ var _filesInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./filesInput */ "./Misc/filesInput.ts");
  94760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _filesInput__WEBPACK_IMPORTED_MODULE_6__["FilesInput"]; });
  94761. /* harmony import */ var _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./HighDynamicRange/index */ "./Misc/HighDynamicRange/index.ts");
  94762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"]; });
  94763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["HDRTools"]; });
  94764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["PanoramaToCubeMapTools"]; });
  94765. /* harmony import */ var _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  94766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_8__["KhronosTextureContainer"]; });
  94767. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  94768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["EventState"]; });
  94769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["Observer"]; });
  94770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["MultiObserver"]; });
  94771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["Observable"]; });
  94772. /* harmony import */ var _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./performanceMonitor */ "./Misc/performanceMonitor.ts");
  94773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__["PerformanceMonitor"]; });
  94774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__["RollingAverage"]; });
  94775. /* harmony import */ var _promise__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./promise */ "./Misc/promise.ts");
  94776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _promise__WEBPACK_IMPORTED_MODULE_11__["PromisePolyfill"]; });
  94777. /* harmony import */ var _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./sceneOptimizer */ "./Misc/sceneOptimizer.ts");
  94778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimization"]; });
  94779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["TextureOptimization"]; });
  94780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["HardwareScalingOptimization"]; });
  94781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["ShadowsOptimization"]; });
  94782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["PostProcessesOptimization"]; });
  94783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["LensFlaresOptimization"]; });
  94784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["CustomOptimization"]; });
  94785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["ParticlesOptimization"]; });
  94786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["RenderTargetsOptimization"]; });
  94787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["MergeMeshesOptimization"]; });
  94788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimizerOptions"]; });
  94789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimizer"]; });
  94790. /* harmony import */ var _sceneSerializer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./sceneSerializer */ "./Misc/sceneSerializer.ts");
  94791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _sceneSerializer__WEBPACK_IMPORTED_MODULE_13__["SceneSerializer"]; });
  94792. /* harmony import */ var _smartArray__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./smartArray */ "./Misc/smartArray.ts");
  94793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_14__["SmartArray"]; });
  94794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_14__["SmartArrayNoDuplicate"]; });
  94795. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  94796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _stringDictionary__WEBPACK_IMPORTED_MODULE_15__["StringDictionary"]; });
  94797. /* harmony import */ var _tags__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./tags */ "./Misc/tags.ts");
  94798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _tags__WEBPACK_IMPORTED_MODULE_16__["Tags"]; });
  94799. /* harmony import */ var _textureTools__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./textureTools */ "./Misc/textureTools.ts");
  94800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _textureTools__WEBPACK_IMPORTED_MODULE_17__["TextureTools"]; });
  94801. /* harmony import */ var _tga__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./tga */ "./Misc/tga.ts");
  94802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _tga__WEBPACK_IMPORTED_MODULE_18__["TGATools"]; });
  94803. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  94804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["ColorGradient"]; });
  94805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["Color3Gradient"]; });
  94806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["FactorGradient"]; });
  94807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["LoadFileError"]; });
  94808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["RetryStrategy"]; });
  94809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["Tools"]; });
  94810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["PerfCounter"]; });
  94811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["className"]; });
  94812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["AsyncLoop"]; });
  94813. /* harmony import */ var _videoRecorder__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./videoRecorder */ "./Misc/videoRecorder.ts");
  94814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _videoRecorder__WEBPACK_IMPORTED_MODULE_20__["VideoRecorder"]; });
  94815. /* harmony import */ var _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./virtualJoystick */ "./Misc/virtualJoystick.ts");
  94816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__["JoystickAxis"]; });
  94817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__["VirtualJoystick"]; });
  94818. /* harmony import */ var _workerPool__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./workerPool */ "./Misc/workerPool.ts");
  94819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _workerPool__WEBPACK_IMPORTED_MODULE_22__["WorkerPool"]; });
  94820. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  94821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _logger__WEBPACK_IMPORTED_MODULE_23__["Logger"]; });
  94822. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  94823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _typeStore__WEBPACK_IMPORTED_MODULE_24__["_TypeStore"]; });
  94824. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  94825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _filesInputStore__WEBPACK_IMPORTED_MODULE_25__["FilesInputStore"]; });
  94826. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  94827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _deepCopier__WEBPACK_IMPORTED_MODULE_26__["DeepCopier"]; });
  94828. /* harmony import */ var _pivotTools__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./pivotTools */ "./Misc/pivotTools.ts");
  94829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _pivotTools__WEBPACK_IMPORTED_MODULE_27__["PivotTools"]; });
  94830. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  94831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _precisionDate__WEBPACK_IMPORTED_MODULE_28__["PrecisionDate"]; });
  94832. /* harmony import */ var _screenshotTools__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./screenshotTools */ "./Misc/screenshotTools.ts");
  94833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _screenshotTools__WEBPACK_IMPORTED_MODULE_29__["ScreenshotTools"]; });
  94834. /* empty/unused harmony star reexport */
  94835. /***/ }),
  94836. /***/ "./Misc/khronosTextureContainer.ts":
  94837. /*!*****************************************!*\
  94838. !*** ./Misc/khronosTextureContainer.ts ***!
  94839. \*****************************************/
  94840. /*! exports provided: KhronosTextureContainer */
  94841. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94842. "use strict";
  94843. __webpack_require__.r(__webpack_exports__);
  94844. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return KhronosTextureContainer; });
  94845. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  94846. /**
  94847. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  94848. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  94849. */
  94850. var KhronosTextureContainer = /** @class */ (function () {
  94851. /**
  94852. * Creates a new KhronosTextureContainer
  94853. * @param arrayBuffer contents of the KTX container file
  94854. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  94855. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  94856. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  94857. */
  94858. function KhronosTextureContainer(
  94859. /** contents of the KTX container file */
  94860. arrayBuffer, facesExpected, threeDExpected, textureArrayExpected) {
  94861. this.arrayBuffer = arrayBuffer;
  94862. /**
  94863. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  94864. */
  94865. this.isInvalid = false;
  94866. // Test that it is a ktx formatted file, based on the first 12 bytes, character representation is:
  94867. // '�', 'K', 'T', 'X', ' ', '1', '1', '�', '\r', '\n', '\x1A', '\n'
  94868. // 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
  94869. var identifier = new Uint8Array(this.arrayBuffer, 0, 12);
  94870. if (identifier[0] !== 0xAB || identifier[1] !== 0x4B || identifier[2] !== 0x54 || identifier[3] !== 0x58 || identifier[4] !== 0x20 || identifier[5] !== 0x31 ||
  94871. identifier[6] !== 0x31 || identifier[7] !== 0xBB || identifier[8] !== 0x0D || identifier[9] !== 0x0A || identifier[10] !== 0x1A || identifier[11] !== 0x0A) {
  94872. this.isInvalid = true;
  94873. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture missing KTX identifier");
  94874. return;
  94875. }
  94876. // load the reset of the header in native 32 bit uint
  94877. var dataSize = Uint32Array.BYTES_PER_ELEMENT;
  94878. var headerDataView = new DataView(this.arrayBuffer, 12, 13 * dataSize);
  94879. var endianness = headerDataView.getUint32(0, true);
  94880. var littleEndian = endianness === 0x04030201;
  94881. this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures
  94882. this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures
  94883. this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures
  94884. this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,)
  94885. this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only)
  94886. this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,)
  94887. this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,)
  94888. this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,)
  94889. this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays
  94890. this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6
  94891. this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures
  94892. this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data
  94893. // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing.
  94894. if (this.glType !== 0) {
  94895. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only compressed formats currently supported");
  94896. return;
  94897. }
  94898. else {
  94899. // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
  94900. this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
  94901. }
  94902. if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
  94903. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only 2D textures currently supported");
  94904. return;
  94905. }
  94906. if (this.numberOfArrayElements !== 0) {
  94907. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture arrays not currently supported");
  94908. return;
  94909. }
  94910. if (this.numberOfFaces !== facesExpected) {
  94911. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("number of faces expected" + facesExpected + ", but found " + this.numberOfFaces);
  94912. return;
  94913. }
  94914. // we now have a completely validated file, so could use existence of loadType as success
  94915. // would need to make this more elaborate & adjust checks above to support more than one load type
  94916. this.loadType = KhronosTextureContainer.COMPRESSED_2D;
  94917. }
  94918. /**
  94919. * Uploads KTX content to a Babylon Texture.
  94920. * It is assumed that the texture has already been created & is currently bound
  94921. * @hidden
  94922. */
  94923. KhronosTextureContainer.prototype.uploadLevels = function (texture, loadMipmaps) {
  94924. switch (this.loadType) {
  94925. case KhronosTextureContainer.COMPRESSED_2D:
  94926. this._upload2DCompressedLevels(texture, loadMipmaps);
  94927. break;
  94928. case KhronosTextureContainer.TEX_2D:
  94929. case KhronosTextureContainer.COMPRESSED_3D:
  94930. case KhronosTextureContainer.TEX_3D:
  94931. }
  94932. };
  94933. KhronosTextureContainer.prototype._upload2DCompressedLevels = function (texture, loadMipmaps) {
  94934. // initialize width & height for level 1
  94935. var dataOffset = KhronosTextureContainer.HEADER_LEN + this.bytesOfKeyValueData;
  94936. var width = this.pixelWidth;
  94937. var height = this.pixelHeight;
  94938. var mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1;
  94939. for (var level = 0; level < mipmapCount; level++) {
  94940. var imageSize = new Int32Array(this.arrayBuffer, dataOffset, 1)[0]; // size per face, since not supporting array cubemaps
  94941. dataOffset += 4; //image data starts from next multiple of 4 offset. Each face refers to same imagesize field above.
  94942. for (var face = 0; face < this.numberOfFaces; face++) {
  94943. var byteArray = new Uint8Array(this.arrayBuffer, dataOffset, imageSize);
  94944. var engine = texture.getEngine();
  94945. engine._uploadCompressedDataToTextureDirectly(texture, this.glInternalFormat, width, height, byteArray, face, level);
  94946. dataOffset += imageSize; // add size of the image for the next face/mipmap
  94947. dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image
  94948. }
  94949. width = Math.max(1.0, width * 0.5);
  94950. height = Math.max(1.0, height * 0.5);
  94951. }
  94952. };
  94953. KhronosTextureContainer.HEADER_LEN = 12 + (13 * 4); // identifier + header elements (not including key value meta-data pairs)
  94954. // load types
  94955. KhronosTextureContainer.COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()
  94956. KhronosTextureContainer.COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()
  94957. KhronosTextureContainer.TEX_2D = 2; // uses a gl.texImage2D()
  94958. KhronosTextureContainer.TEX_3D = 3; // uses a gl.texImage3D()
  94959. return KhronosTextureContainer;
  94960. }());
  94961. /***/ }),
  94962. /***/ "./Misc/logger.ts":
  94963. /*!************************!*\
  94964. !*** ./Misc/logger.ts ***!
  94965. \************************/
  94966. /*! exports provided: Logger */
  94967. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94968. "use strict";
  94969. __webpack_require__.r(__webpack_exports__);
  94970. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return Logger; });
  94971. /**
  94972. * Logger used througouht the application to allow configuration of
  94973. * the log level required for the messages.
  94974. */
  94975. var Logger = /** @class */ (function () {
  94976. function Logger() {
  94977. }
  94978. Logger._AddLogEntry = function (entry) {
  94979. Logger._LogCache = entry + Logger._LogCache;
  94980. if (Logger.OnNewCacheEntry) {
  94981. Logger.OnNewCacheEntry(entry);
  94982. }
  94983. };
  94984. Logger._FormatMessage = function (message) {
  94985. var padStr = function (i) { return (i < 10) ? "0" + i : "" + i; };
  94986. var date = new Date();
  94987. return "[" + padStr(date.getHours()) + ":" + padStr(date.getMinutes()) + ":" + padStr(date.getSeconds()) + "]: " + message;
  94988. };
  94989. Logger._LogDisabled = function (message) {
  94990. // nothing to do
  94991. };
  94992. Logger._LogEnabled = function (message) {
  94993. var formattedMessage = Logger._FormatMessage(message);
  94994. console.log("BJS - " + formattedMessage);
  94995. var entry = "<div style='color:white'>" + formattedMessage + "</div><br>";
  94996. Logger._AddLogEntry(entry);
  94997. };
  94998. Logger._WarnDisabled = function (message) {
  94999. // nothing to do
  95000. };
  95001. Logger._WarnEnabled = function (message) {
  95002. var formattedMessage = Logger._FormatMessage(message);
  95003. console.warn("BJS - " + formattedMessage);
  95004. var entry = "<div style='color:orange'>" + formattedMessage + "</div><br>";
  95005. Logger._AddLogEntry(entry);
  95006. };
  95007. Logger._ErrorDisabled = function (message) {
  95008. // nothing to do
  95009. };
  95010. Logger._ErrorEnabled = function (message) {
  95011. Logger.errorsCount++;
  95012. var formattedMessage = Logger._FormatMessage(message);
  95013. console.error("BJS - " + formattedMessage);
  95014. var entry = "<div style='color:red'>" + formattedMessage + "</div><br>";
  95015. Logger._AddLogEntry(entry);
  95016. };
  95017. Object.defineProperty(Logger, "LogCache", {
  95018. /**
  95019. * Gets current log cache (list of logs)
  95020. */
  95021. get: function () {
  95022. return Logger._LogCache;
  95023. },
  95024. enumerable: true,
  95025. configurable: true
  95026. });
  95027. /**
  95028. * Clears the log cache
  95029. */
  95030. Logger.ClearLogCache = function () {
  95031. Logger._LogCache = "";
  95032. Logger.errorsCount = 0;
  95033. };
  95034. Object.defineProperty(Logger, "LogLevels", {
  95035. /**
  95036. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  95037. */
  95038. set: function (level) {
  95039. if ((level & Logger.MessageLogLevel) === Logger.MessageLogLevel) {
  95040. Logger.Log = Logger._LogEnabled;
  95041. }
  95042. else {
  95043. Logger.Log = Logger._LogDisabled;
  95044. }
  95045. if ((level & Logger.WarningLogLevel) === Logger.WarningLogLevel) {
  95046. Logger.Warn = Logger._WarnEnabled;
  95047. }
  95048. else {
  95049. Logger.Warn = Logger._WarnDisabled;
  95050. }
  95051. if ((level & Logger.ErrorLogLevel) === Logger.ErrorLogLevel) {
  95052. Logger.Error = Logger._ErrorEnabled;
  95053. }
  95054. else {
  95055. Logger.Error = Logger._ErrorDisabled;
  95056. }
  95057. },
  95058. enumerable: true,
  95059. configurable: true
  95060. });
  95061. /**
  95062. * No log
  95063. */
  95064. Logger.NoneLogLevel = 0;
  95065. /**
  95066. * Only message logs
  95067. */
  95068. Logger.MessageLogLevel = 1;
  95069. /**
  95070. * Only warning logs
  95071. */
  95072. Logger.WarningLogLevel = 2;
  95073. /**
  95074. * Only error logs
  95075. */
  95076. Logger.ErrorLogLevel = 4;
  95077. /**
  95078. * All logs
  95079. */
  95080. Logger.AllLogLevel = 7;
  95081. Logger._LogCache = "";
  95082. /**
  95083. * Gets a value indicating the number of loading errors
  95084. * @ignorenaming
  95085. */
  95086. Logger.errorsCount = 0;
  95087. /**
  95088. * Log a message to the console
  95089. */
  95090. Logger.Log = Logger._LogEnabled;
  95091. /**
  95092. * Write a warning message to the console
  95093. */
  95094. Logger.Warn = Logger._WarnEnabled;
  95095. /**
  95096. * Write an error message to the console
  95097. */
  95098. Logger.Error = Logger._ErrorEnabled;
  95099. return Logger;
  95100. }());
  95101. /***/ }),
  95102. /***/ "./Misc/observable.ts":
  95103. /*!****************************!*\
  95104. !*** ./Misc/observable.ts ***!
  95105. \****************************/
  95106. /*! exports provided: EventState, Observer, MultiObserver, Observable */
  95107. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95108. "use strict";
  95109. __webpack_require__.r(__webpack_exports__);
  95110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return EventState; });
  95111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return Observer; });
  95112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return MultiObserver; });
  95113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return Observable; });
  95114. /**
  95115. * A class serves as a medium between the observable and its observers
  95116. */
  95117. var EventState = /** @class */ (function () {
  95118. /**
  95119. * Create a new EventState
  95120. * @param mask defines the mask associated with this state
  95121. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  95122. * @param target defines the original target of the state
  95123. * @param currentTarget defines the current target of the state
  95124. */
  95125. function EventState(mask, skipNextObservers, target, currentTarget) {
  95126. if (skipNextObservers === void 0) { skipNextObservers = false; }
  95127. this.initalize(mask, skipNextObservers, target, currentTarget);
  95128. }
  95129. /**
  95130. * Initialize the current event state
  95131. * @param mask defines the mask associated with this state
  95132. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  95133. * @param target defines the original target of the state
  95134. * @param currentTarget defines the current target of the state
  95135. * @returns the current event state
  95136. */
  95137. EventState.prototype.initalize = function (mask, skipNextObservers, target, currentTarget) {
  95138. if (skipNextObservers === void 0) { skipNextObservers = false; }
  95139. this.mask = mask;
  95140. this.skipNextObservers = skipNextObservers;
  95141. this.target = target;
  95142. this.currentTarget = currentTarget;
  95143. return this;
  95144. };
  95145. return EventState;
  95146. }());
  95147. /**
  95148. * Represent an Observer registered to a given Observable object.
  95149. */
  95150. var Observer = /** @class */ (function () {
  95151. /**
  95152. * Creates a new observer
  95153. * @param callback defines the callback to call when the observer is notified
  95154. * @param mask defines the mask of the observer (used to filter notifications)
  95155. * @param scope defines the current scope used to restore the JS context
  95156. */
  95157. function Observer(
  95158. /**
  95159. * Defines the callback to call when the observer is notified
  95160. */
  95161. callback,
  95162. /**
  95163. * Defines the mask of the observer (used to filter notifications)
  95164. */
  95165. mask,
  95166. /**
  95167. * Defines the current scope used to restore the JS context
  95168. */
  95169. scope) {
  95170. if (scope === void 0) { scope = null; }
  95171. this.callback = callback;
  95172. this.mask = mask;
  95173. this.scope = scope;
  95174. /** @hidden */
  95175. this._willBeUnregistered = false;
  95176. /**
  95177. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  95178. */
  95179. this.unregisterOnNextCall = false;
  95180. }
  95181. return Observer;
  95182. }());
  95183. /**
  95184. * Represent a list of observers registered to multiple Observables object.
  95185. */
  95186. var MultiObserver = /** @class */ (function () {
  95187. function MultiObserver() {
  95188. }
  95189. /**
  95190. * Release associated resources
  95191. */
  95192. MultiObserver.prototype.dispose = function () {
  95193. if (this._observers && this._observables) {
  95194. for (var index = 0; index < this._observers.length; index++) {
  95195. this._observables[index].remove(this._observers[index]);
  95196. }
  95197. }
  95198. this._observers = null;
  95199. this._observables = null;
  95200. };
  95201. /**
  95202. * Raise a callback when one of the observable will notify
  95203. * @param observables defines a list of observables to watch
  95204. * @param callback defines the callback to call on notification
  95205. * @param mask defines the mask used to filter notifications
  95206. * @param scope defines the current scope used to restore the JS context
  95207. * @returns the new MultiObserver
  95208. */
  95209. MultiObserver.Watch = function (observables, callback, mask, scope) {
  95210. if (mask === void 0) { mask = -1; }
  95211. if (scope === void 0) { scope = null; }
  95212. var result = new MultiObserver();
  95213. result._observers = new Array();
  95214. result._observables = observables;
  95215. for (var _i = 0, observables_1 = observables; _i < observables_1.length; _i++) {
  95216. var observable = observables_1[_i];
  95217. var observer = observable.add(callback, mask, false, scope);
  95218. if (observer) {
  95219. result._observers.push(observer);
  95220. }
  95221. }
  95222. return result;
  95223. };
  95224. return MultiObserver;
  95225. }());
  95226. /**
  95227. * The Observable class is a simple implementation of the Observable pattern.
  95228. *
  95229. * 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.
  95230. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  95231. * 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).
  95232. * 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.
  95233. */
  95234. var Observable = /** @class */ (function () {
  95235. /**
  95236. * Creates a new observable
  95237. * @param onObserverAdded defines a callback to call when a new observer is added
  95238. */
  95239. function Observable(onObserverAdded) {
  95240. this._observers = new Array();
  95241. this._eventState = new EventState(0);
  95242. if (onObserverAdded) {
  95243. this._onObserverAdded = onObserverAdded;
  95244. }
  95245. }
  95246. /**
  95247. * Create a new Observer with the specified callback
  95248. * @param callback the callback that will be executed for that Observer
  95249. * @param mask the mask used to filter observers
  95250. * @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.
  95251. * @param scope optional scope for the callback to be called from
  95252. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  95253. * @returns the new observer created for the callback
  95254. */
  95255. Observable.prototype.add = function (callback, mask, insertFirst, scope, unregisterOnFirstCall) {
  95256. if (mask === void 0) { mask = -1; }
  95257. if (insertFirst === void 0) { insertFirst = false; }
  95258. if (scope === void 0) { scope = null; }
  95259. if (unregisterOnFirstCall === void 0) { unregisterOnFirstCall = false; }
  95260. if (!callback) {
  95261. return null;
  95262. }
  95263. var observer = new Observer(callback, mask, scope);
  95264. observer.unregisterOnNextCall = unregisterOnFirstCall;
  95265. if (insertFirst) {
  95266. this._observers.unshift(observer);
  95267. }
  95268. else {
  95269. this._observers.push(observer);
  95270. }
  95271. if (this._onObserverAdded) {
  95272. this._onObserverAdded(observer);
  95273. }
  95274. return observer;
  95275. };
  95276. /**
  95277. * Create a new Observer with the specified callback and unregisters after the next notification
  95278. * @param callback the callback that will be executed for that Observer
  95279. * @returns the new observer created for the callback
  95280. */
  95281. Observable.prototype.addOnce = function (callback) {
  95282. return this.add(callback, undefined, undefined, undefined, true);
  95283. };
  95284. /**
  95285. * Remove an Observer from the Observable object
  95286. * @param observer the instance of the Observer to remove
  95287. * @returns false if it doesn't belong to this Observable
  95288. */
  95289. Observable.prototype.remove = function (observer) {
  95290. if (!observer) {
  95291. return false;
  95292. }
  95293. var index = this._observers.indexOf(observer);
  95294. if (index !== -1) {
  95295. this._deferUnregister(observer);
  95296. return true;
  95297. }
  95298. return false;
  95299. };
  95300. /**
  95301. * Remove a callback from the Observable object
  95302. * @param callback the callback to remove
  95303. * @param scope optional scope. If used only the callbacks with this scope will be removed
  95304. * @returns false if it doesn't belong to this Observable
  95305. */
  95306. Observable.prototype.removeCallback = function (callback, scope) {
  95307. for (var index = 0; index < this._observers.length; index++) {
  95308. if (this._observers[index].callback === callback && (!scope || scope === this._observers[index].scope)) {
  95309. this._deferUnregister(this._observers[index]);
  95310. return true;
  95311. }
  95312. }
  95313. return false;
  95314. };
  95315. Observable.prototype._deferUnregister = function (observer) {
  95316. var _this = this;
  95317. observer.unregisterOnNextCall = false;
  95318. observer._willBeUnregistered = true;
  95319. setTimeout(function () {
  95320. _this._remove(observer);
  95321. }, 0);
  95322. };
  95323. // This should only be called when not iterating over _observers to avoid callback skipping.
  95324. // Removes an observer from the _observer Array.
  95325. Observable.prototype._remove = function (observer) {
  95326. if (!observer) {
  95327. return false;
  95328. }
  95329. var index = this._observers.indexOf(observer);
  95330. if (index !== -1) {
  95331. this._observers.splice(index, 1);
  95332. return true;
  95333. }
  95334. return false;
  95335. };
  95336. /**
  95337. * Notify all Observers by calling their respective callback with the given data
  95338. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  95339. * @param eventData defines the data to send to all observers
  95340. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  95341. * @param target defines the original target of the state
  95342. * @param currentTarget defines the current target of the state
  95343. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  95344. */
  95345. Observable.prototype.notifyObservers = function (eventData, mask, target, currentTarget) {
  95346. if (mask === void 0) { mask = -1; }
  95347. if (!this._observers.length) {
  95348. return true;
  95349. }
  95350. var state = this._eventState;
  95351. state.mask = mask;
  95352. state.target = target;
  95353. state.currentTarget = currentTarget;
  95354. state.skipNextObservers = false;
  95355. state.lastReturnValue = eventData;
  95356. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  95357. var obs = _a[_i];
  95358. if (obs._willBeUnregistered) {
  95359. continue;
  95360. }
  95361. if (obs.mask & mask) {
  95362. if (obs.scope) {
  95363. state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);
  95364. }
  95365. else {
  95366. state.lastReturnValue = obs.callback(eventData, state);
  95367. }
  95368. if (obs.unregisterOnNextCall) {
  95369. this._deferUnregister(obs);
  95370. }
  95371. }
  95372. if (state.skipNextObservers) {
  95373. return false;
  95374. }
  95375. }
  95376. return true;
  95377. };
  95378. /**
  95379. * Calling this will execute each callback, expecting it to be a promise or return a value.
  95380. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  95381. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  95382. * and it is crucial that all callbacks will be executed.
  95383. * The order of the callbacks is kept, callbacks are not executed parallel.
  95384. *
  95385. * @param eventData The data to be sent to each callback
  95386. * @param mask is used to filter observers defaults to -1
  95387. * @param target defines the callback target (see EventState)
  95388. * @param currentTarget defines he current object in the bubbling phase
  95389. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  95390. */
  95391. Observable.prototype.notifyObserversWithPromise = function (eventData, mask, target, currentTarget) {
  95392. var _this = this;
  95393. if (mask === void 0) { mask = -1; }
  95394. // create an empty promise
  95395. var p = Promise.resolve(eventData);
  95396. // no observers? return this promise.
  95397. if (!this._observers.length) {
  95398. return p;
  95399. }
  95400. var state = this._eventState;
  95401. state.mask = mask;
  95402. state.target = target;
  95403. state.currentTarget = currentTarget;
  95404. state.skipNextObservers = false;
  95405. // execute one callback after another (not using Promise.all, the order is important)
  95406. this._observers.forEach(function (obs) {
  95407. if (state.skipNextObservers) {
  95408. return;
  95409. }
  95410. if (obs._willBeUnregistered) {
  95411. return;
  95412. }
  95413. if (obs.mask & mask) {
  95414. if (obs.scope) {
  95415. p = p.then(function (lastReturnedValue) {
  95416. state.lastReturnValue = lastReturnedValue;
  95417. return obs.callback.apply(obs.scope, [eventData, state]);
  95418. });
  95419. }
  95420. else {
  95421. p = p.then(function (lastReturnedValue) {
  95422. state.lastReturnValue = lastReturnedValue;
  95423. return obs.callback(eventData, state);
  95424. });
  95425. }
  95426. if (obs.unregisterOnNextCall) {
  95427. _this._deferUnregister(obs);
  95428. }
  95429. }
  95430. });
  95431. // return the eventData
  95432. return p.then(function () { return eventData; });
  95433. };
  95434. /**
  95435. * Notify a specific observer
  95436. * @param observer defines the observer to notify
  95437. * @param eventData defines the data to be sent to each callback
  95438. * @param mask is used to filter observers defaults to -1
  95439. */
  95440. Observable.prototype.notifyObserver = function (observer, eventData, mask) {
  95441. if (mask === void 0) { mask = -1; }
  95442. var state = this._eventState;
  95443. state.mask = mask;
  95444. state.skipNextObservers = false;
  95445. observer.callback(eventData, state);
  95446. };
  95447. /**
  95448. * Gets a boolean indicating if the observable has at least one observer
  95449. * @returns true is the Observable has at least one Observer registered
  95450. */
  95451. Observable.prototype.hasObservers = function () {
  95452. return this._observers.length > 0;
  95453. };
  95454. /**
  95455. * Clear the list of observers
  95456. */
  95457. Observable.prototype.clear = function () {
  95458. this._observers = new Array();
  95459. this._onObserverAdded = null;
  95460. };
  95461. /**
  95462. * Clone the current observable
  95463. * @returns a new observable
  95464. */
  95465. Observable.prototype.clone = function () {
  95466. var result = new Observable();
  95467. result._observers = this._observers.slice(0);
  95468. return result;
  95469. };
  95470. /**
  95471. * Does this observable handles observer registered with a given mask
  95472. * @param mask defines the mask to be tested
  95473. * @return whether or not one observer registered with the given mask is handeled
  95474. **/
  95475. Observable.prototype.hasSpecificMask = function (mask) {
  95476. if (mask === void 0) { mask = -1; }
  95477. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  95478. var obs = _a[_i];
  95479. if (obs.mask & mask || obs.mask === mask) {
  95480. return true;
  95481. }
  95482. }
  95483. return false;
  95484. };
  95485. return Observable;
  95486. }());
  95487. /***/ }),
  95488. /***/ "./Misc/performanceMonitor.ts":
  95489. /*!************************************!*\
  95490. !*** ./Misc/performanceMonitor.ts ***!
  95491. \************************************/
  95492. /*! exports provided: PerformanceMonitor, RollingAverage */
  95493. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95494. "use strict";
  95495. __webpack_require__.r(__webpack_exports__);
  95496. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return PerformanceMonitor; });
  95497. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return RollingAverage; });
  95498. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  95499. /**
  95500. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  95501. */
  95502. var PerformanceMonitor = /** @class */ (function () {
  95503. /**
  95504. * constructor
  95505. * @param frameSampleSize The number of samples required to saturate the sliding window
  95506. */
  95507. function PerformanceMonitor(frameSampleSize) {
  95508. if (frameSampleSize === void 0) { frameSampleSize = 30; }
  95509. this._enabled = true;
  95510. this._rollingFrameTime = new RollingAverage(frameSampleSize);
  95511. }
  95512. /**
  95513. * Samples current frame
  95514. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  95515. */
  95516. PerformanceMonitor.prototype.sampleFrame = function (timeMs) {
  95517. if (timeMs === void 0) { timeMs = _precisionDate__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"].Now; }
  95518. if (!this._enabled) {
  95519. return;
  95520. }
  95521. if (this._lastFrameTimeMs != null) {
  95522. var dt = timeMs - this._lastFrameTimeMs;
  95523. this._rollingFrameTime.add(dt);
  95524. }
  95525. this._lastFrameTimeMs = timeMs;
  95526. };
  95527. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTime", {
  95528. /**
  95529. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  95530. */
  95531. get: function () {
  95532. return this._rollingFrameTime.average;
  95533. },
  95534. enumerable: true,
  95535. configurable: true
  95536. });
  95537. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTimeVariance", {
  95538. /**
  95539. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  95540. */
  95541. get: function () {
  95542. return this._rollingFrameTime.variance;
  95543. },
  95544. enumerable: true,
  95545. configurable: true
  95546. });
  95547. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFrameTime", {
  95548. /**
  95549. * Returns the frame time of the most recent frame
  95550. */
  95551. get: function () {
  95552. return this._rollingFrameTime.history(0);
  95553. },
  95554. enumerable: true,
  95555. configurable: true
  95556. });
  95557. Object.defineProperty(PerformanceMonitor.prototype, "averageFPS", {
  95558. /**
  95559. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  95560. */
  95561. get: function () {
  95562. return 1000.0 / this._rollingFrameTime.average;
  95563. },
  95564. enumerable: true,
  95565. configurable: true
  95566. });
  95567. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFPS", {
  95568. /**
  95569. * Returns the average framerate in frames per second using the most recent frame time
  95570. */
  95571. get: function () {
  95572. var history = this._rollingFrameTime.history(0);
  95573. if (history === 0) {
  95574. return 0;
  95575. }
  95576. return 1000.0 / history;
  95577. },
  95578. enumerable: true,
  95579. configurable: true
  95580. });
  95581. Object.defineProperty(PerformanceMonitor.prototype, "isSaturated", {
  95582. /**
  95583. * Returns true if enough samples have been taken to completely fill the sliding window
  95584. */
  95585. get: function () {
  95586. return this._rollingFrameTime.isSaturated();
  95587. },
  95588. enumerable: true,
  95589. configurable: true
  95590. });
  95591. /**
  95592. * Enables contributions to the sliding window sample set
  95593. */
  95594. PerformanceMonitor.prototype.enable = function () {
  95595. this._enabled = true;
  95596. };
  95597. /**
  95598. * Disables contributions to the sliding window sample set
  95599. * Samples will not be interpolated over the disabled period
  95600. */
  95601. PerformanceMonitor.prototype.disable = function () {
  95602. this._enabled = false;
  95603. //clear last sample to avoid interpolating over the disabled period when next enabled
  95604. this._lastFrameTimeMs = null;
  95605. };
  95606. Object.defineProperty(PerformanceMonitor.prototype, "isEnabled", {
  95607. /**
  95608. * Returns true if sampling is enabled
  95609. */
  95610. get: function () {
  95611. return this._enabled;
  95612. },
  95613. enumerable: true,
  95614. configurable: true
  95615. });
  95616. /**
  95617. * Resets performance monitor
  95618. */
  95619. PerformanceMonitor.prototype.reset = function () {
  95620. //clear last sample to avoid interpolating over the disabled period when next enabled
  95621. this._lastFrameTimeMs = null;
  95622. //wipe record
  95623. this._rollingFrameTime.reset();
  95624. };
  95625. return PerformanceMonitor;
  95626. }());
  95627. /**
  95628. * RollingAverage
  95629. *
  95630. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  95631. */
  95632. var RollingAverage = /** @class */ (function () {
  95633. /**
  95634. * constructor
  95635. * @param length The number of samples required to saturate the sliding window
  95636. */
  95637. function RollingAverage(length) {
  95638. this._samples = new Array(length);
  95639. this.reset();
  95640. }
  95641. /**
  95642. * Adds a sample to the sample set
  95643. * @param v The sample value
  95644. */
  95645. RollingAverage.prototype.add = function (v) {
  95646. //http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
  95647. var delta;
  95648. //we need to check if we've already wrapped round
  95649. if (this.isSaturated()) {
  95650. //remove bottom of stack from mean
  95651. var bottomValue = this._samples[this._pos];
  95652. delta = bottomValue - this.average;
  95653. this.average -= delta / (this._sampleCount - 1);
  95654. this._m2 -= delta * (bottomValue - this.average);
  95655. }
  95656. else {
  95657. this._sampleCount++;
  95658. }
  95659. //add new value to mean
  95660. delta = v - this.average;
  95661. this.average += delta / (this._sampleCount);
  95662. this._m2 += delta * (v - this.average);
  95663. //set the new variance
  95664. this.variance = this._m2 / (this._sampleCount - 1);
  95665. this._samples[this._pos] = v;
  95666. this._pos++;
  95667. this._pos %= this._samples.length; //positive wrap around
  95668. };
  95669. /**
  95670. * Returns previously added values or null if outside of history or outside the sliding window domain
  95671. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  95672. * @return Value previously recorded with add() or null if outside of range
  95673. */
  95674. RollingAverage.prototype.history = function (i) {
  95675. if ((i >= this._sampleCount) || (i >= this._samples.length)) {
  95676. return 0;
  95677. }
  95678. var i0 = this._wrapPosition(this._pos - 1.0);
  95679. return this._samples[this._wrapPosition(i0 - i)];
  95680. };
  95681. /**
  95682. * Returns true if enough samples have been taken to completely fill the sliding window
  95683. * @return true if sample-set saturated
  95684. */
  95685. RollingAverage.prototype.isSaturated = function () {
  95686. return this._sampleCount >= this._samples.length;
  95687. };
  95688. /**
  95689. * Resets the rolling average (equivalent to 0 samples taken so far)
  95690. */
  95691. RollingAverage.prototype.reset = function () {
  95692. this.average = 0;
  95693. this.variance = 0;
  95694. this._sampleCount = 0;
  95695. this._pos = 0;
  95696. this._m2 = 0;
  95697. };
  95698. /**
  95699. * Wraps a value around the sample range boundaries
  95700. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  95701. * @return Wrapped position in sample range
  95702. */
  95703. RollingAverage.prototype._wrapPosition = function (i) {
  95704. var max = this._samples.length;
  95705. return ((i % max) + max) % max;
  95706. };
  95707. return RollingAverage;
  95708. }());
  95709. /***/ }),
  95710. /***/ "./Misc/pivotTools.ts":
  95711. /*!****************************!*\
  95712. !*** ./Misc/pivotTools.ts ***!
  95713. \****************************/
  95714. /*! exports provided: PivotTools */
  95715. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95716. "use strict";
  95717. __webpack_require__.r(__webpack_exports__);
  95718. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return PivotTools; });
  95719. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  95720. /**
  95721. * Class containing a set of static utilities functions for managing Pivots
  95722. * @hidden
  95723. */
  95724. var PivotTools = /** @class */ (function () {
  95725. function PivotTools() {
  95726. }
  95727. /** @hidden */
  95728. PivotTools._RemoveAndStorePivotPoint = function (mesh) {
  95729. if (mesh && PivotTools._PivotCached === 0) {
  95730. // Save old pivot and set pivot to 0,0,0
  95731. mesh.getPivotPointToRef(PivotTools._OldPivotPoint);
  95732. if (!PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0)) {
  95733. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityReadOnly);
  95734. PivotTools._OldPivotPoint.subtractToRef(mesh.getPivotPoint(), PivotTools._PivotTranslation);
  95735. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  95736. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  95737. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  95738. mesh.position.addInPlace(PivotTools._PivotTmpVector);
  95739. }
  95740. }
  95741. PivotTools._PivotCached++;
  95742. };
  95743. /** @hidden */
  95744. PivotTools._RestorePivotPoint = function (mesh) {
  95745. if (mesh && !PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0) && PivotTools._PivotCached === 1) {
  95746. mesh.setPivotPoint(PivotTools._OldPivotPoint);
  95747. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  95748. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  95749. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  95750. mesh.position.subtractInPlace(PivotTools._PivotTmpVector);
  95751. }
  95752. this._PivotCached--;
  95753. };
  95754. // Stores the state of the pivot cache (_oldPivotPoint, _pivotTranslation)
  95755. // store/remove pivot point should only be applied during their outermost calls
  95756. PivotTools._PivotCached = 0;
  95757. PivotTools._OldPivotPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  95758. PivotTools._PivotTranslation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  95759. PivotTools._PivotTmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  95760. return PivotTools;
  95761. }());
  95762. /***/ }),
  95763. /***/ "./Misc/precisionDate.ts":
  95764. /*!*******************************!*\
  95765. !*** ./Misc/precisionDate.ts ***!
  95766. \*******************************/
  95767. /*! exports provided: PrecisionDate */
  95768. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95769. "use strict";
  95770. __webpack_require__.r(__webpack_exports__);
  95771. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return PrecisionDate; });
  95772. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  95773. /**
  95774. * Class containing a set of static utilities functions for precision date
  95775. */
  95776. var PrecisionDate = /** @class */ (function () {
  95777. function PrecisionDate() {
  95778. }
  95779. Object.defineProperty(PrecisionDate, "Now", {
  95780. /**
  95781. * Gets either window.performance.now() if supported or Date.now() else
  95782. */
  95783. get: function () {
  95784. if (_domManagement__WEBPACK_IMPORTED_MODULE_0__["DomManagement"].IsWindowObjectExist() && window.performance && window.performance.now) {
  95785. return window.performance.now();
  95786. }
  95787. return Date.now();
  95788. },
  95789. enumerable: true,
  95790. configurable: true
  95791. });
  95792. return PrecisionDate;
  95793. }());
  95794. /***/ }),
  95795. /***/ "./Misc/promise.ts":
  95796. /*!*************************!*\
  95797. !*** ./Misc/promise.ts ***!
  95798. \*************************/
  95799. /*! exports provided: PromisePolyfill */
  95800. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95801. "use strict";
  95802. __webpack_require__.r(__webpack_exports__);
  95803. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return PromisePolyfill; });
  95804. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  95805. var PromiseStates;
  95806. (function (PromiseStates) {
  95807. PromiseStates[PromiseStates["Pending"] = 0] = "Pending";
  95808. PromiseStates[PromiseStates["Fulfilled"] = 1] = "Fulfilled";
  95809. PromiseStates[PromiseStates["Rejected"] = 2] = "Rejected";
  95810. })(PromiseStates || (PromiseStates = {}));
  95811. var FulFillmentAgregator = /** @class */ (function () {
  95812. function FulFillmentAgregator() {
  95813. this.count = 0;
  95814. this.target = 0;
  95815. this.results = [];
  95816. }
  95817. return FulFillmentAgregator;
  95818. }());
  95819. var InternalPromise = /** @class */ (function () {
  95820. function InternalPromise(resolver) {
  95821. var _this = this;
  95822. this._state = PromiseStates.Pending;
  95823. this._children = new Array();
  95824. this._rejectWasConsumed = false;
  95825. if (!resolver) {
  95826. return;
  95827. }
  95828. try {
  95829. resolver(function (value) {
  95830. _this._resolve(value);
  95831. }, function (reason) {
  95832. _this._reject(reason);
  95833. });
  95834. }
  95835. catch (e) {
  95836. this._reject(e);
  95837. }
  95838. }
  95839. Object.defineProperty(InternalPromise.prototype, "_result", {
  95840. get: function () {
  95841. return this._resultValue;
  95842. },
  95843. set: function (value) {
  95844. this._resultValue = value;
  95845. if (this._parent && this._parent._result === undefined) {
  95846. this._parent._result = value;
  95847. }
  95848. },
  95849. enumerable: true,
  95850. configurable: true
  95851. });
  95852. InternalPromise.prototype.catch = function (onRejected) {
  95853. return this.then(undefined, onRejected);
  95854. };
  95855. InternalPromise.prototype.then = function (onFulfilled, onRejected) {
  95856. var _this = this;
  95857. var newPromise = new InternalPromise();
  95858. newPromise._onFulfilled = onFulfilled;
  95859. newPromise._onRejected = onRejected;
  95860. // Composition
  95861. this._children.push(newPromise);
  95862. newPromise._parent = this;
  95863. if (this._state !== PromiseStates.Pending) {
  95864. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  95865. if (_this._state === PromiseStates.Fulfilled || _this._rejectWasConsumed) {
  95866. var returnedValue = newPromise._resolve(_this._result);
  95867. if (returnedValue !== undefined && returnedValue !== null) {
  95868. if (returnedValue._state !== undefined) {
  95869. var returnedPromise = returnedValue;
  95870. newPromise._children.push(returnedPromise);
  95871. returnedPromise._parent = newPromise;
  95872. newPromise = returnedPromise;
  95873. }
  95874. else {
  95875. newPromise._result = returnedValue;
  95876. }
  95877. }
  95878. }
  95879. else {
  95880. newPromise._reject(_this._reason);
  95881. }
  95882. });
  95883. }
  95884. return newPromise;
  95885. };
  95886. InternalPromise.prototype._moveChildren = function (children) {
  95887. var _this = this;
  95888. var _a;
  95889. (_a = this._children).push.apply(_a, children.splice(0, children.length));
  95890. this._children.forEach(function (child) {
  95891. child._parent = _this;
  95892. });
  95893. if (this._state === PromiseStates.Fulfilled) {
  95894. for (var _i = 0, _b = this._children; _i < _b.length; _i++) {
  95895. var child = _b[_i];
  95896. child._resolve(this._result);
  95897. }
  95898. }
  95899. else if (this._state === PromiseStates.Rejected) {
  95900. for (var _c = 0, _d = this._children; _c < _d.length; _c++) {
  95901. var child = _d[_c];
  95902. child._reject(this._reason);
  95903. }
  95904. }
  95905. };
  95906. InternalPromise.prototype._resolve = function (value) {
  95907. try {
  95908. this._state = PromiseStates.Fulfilled;
  95909. var returnedValue = null;
  95910. if (this._onFulfilled) {
  95911. returnedValue = this._onFulfilled(value);
  95912. }
  95913. if (returnedValue !== undefined && returnedValue !== null) {
  95914. if (returnedValue._state !== undefined) {
  95915. // Transmit children
  95916. var returnedPromise = returnedValue;
  95917. returnedPromise._parent = this;
  95918. returnedPromise._moveChildren(this._children);
  95919. value = returnedPromise._result;
  95920. }
  95921. else {
  95922. value = returnedValue;
  95923. }
  95924. }
  95925. this._result = value;
  95926. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  95927. var child = _a[_i];
  95928. child._resolve(value);
  95929. }
  95930. this._children.length = 0;
  95931. delete this._onFulfilled;
  95932. delete this._onRejected;
  95933. }
  95934. catch (e) {
  95935. this._reject(e, true);
  95936. }
  95937. };
  95938. InternalPromise.prototype._reject = function (reason, onLocalThrow) {
  95939. if (onLocalThrow === void 0) { onLocalThrow = false; }
  95940. this._state = PromiseStates.Rejected;
  95941. this._reason = reason;
  95942. if (this._onRejected && !onLocalThrow) {
  95943. try {
  95944. this._onRejected(reason);
  95945. this._rejectWasConsumed = true;
  95946. }
  95947. catch (e) {
  95948. reason = e;
  95949. }
  95950. }
  95951. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  95952. var child = _a[_i];
  95953. if (this._rejectWasConsumed) {
  95954. child._resolve(null);
  95955. }
  95956. else {
  95957. child._reject(reason);
  95958. }
  95959. }
  95960. this._children.length = 0;
  95961. delete this._onFulfilled;
  95962. delete this._onRejected;
  95963. };
  95964. InternalPromise.resolve = function (value) {
  95965. var newPromise = new InternalPromise();
  95966. newPromise._resolve(value);
  95967. return newPromise;
  95968. };
  95969. InternalPromise._RegisterForFulfillment = function (promise, agregator, index) {
  95970. promise.then(function (value) {
  95971. agregator.results[index] = value;
  95972. agregator.count++;
  95973. if (agregator.count === agregator.target) {
  95974. agregator.rootPromise._resolve(agregator.results);
  95975. }
  95976. return null;
  95977. }, function (reason) {
  95978. if (agregator.rootPromise._state !== PromiseStates.Rejected) {
  95979. agregator.rootPromise._reject(reason);
  95980. }
  95981. });
  95982. };
  95983. InternalPromise.all = function (promises) {
  95984. var newPromise = new InternalPromise();
  95985. var agregator = new FulFillmentAgregator();
  95986. agregator.target = promises.length;
  95987. agregator.rootPromise = newPromise;
  95988. if (promises.length) {
  95989. for (var index = 0; index < promises.length; index++) {
  95990. InternalPromise._RegisterForFulfillment(promises[index], agregator, index);
  95991. }
  95992. }
  95993. else {
  95994. newPromise._resolve([]);
  95995. }
  95996. return newPromise;
  95997. };
  95998. InternalPromise.race = function (promises) {
  95999. var newPromise = new InternalPromise();
  96000. if (promises.length) {
  96001. for (var _i = 0, promises_1 = promises; _i < promises_1.length; _i++) {
  96002. var promise = promises_1[_i];
  96003. promise.then(function (value) {
  96004. if (newPromise) {
  96005. newPromise._resolve(value);
  96006. newPromise = null;
  96007. }
  96008. return null;
  96009. }, function (reason) {
  96010. if (newPromise) {
  96011. newPromise._reject(reason);
  96012. newPromise = null;
  96013. }
  96014. });
  96015. }
  96016. }
  96017. return newPromise;
  96018. };
  96019. return InternalPromise;
  96020. }());
  96021. /**
  96022. * Helper class that provides a small promise polyfill
  96023. */
  96024. var PromisePolyfill = /** @class */ (function () {
  96025. function PromisePolyfill() {
  96026. }
  96027. /**
  96028. * Static function used to check if the polyfill is required
  96029. * If this is the case then the function will inject the polyfill to window.Promise
  96030. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  96031. */
  96032. PromisePolyfill.Apply = function (force) {
  96033. if (force === void 0) { force = false; }
  96034. if (force || typeof Promise === 'undefined') {
  96035. var root = window;
  96036. root.Promise = InternalPromise;
  96037. }
  96038. };
  96039. return PromisePolyfill;
  96040. }());
  96041. /***/ }),
  96042. /***/ "./Misc/sceneOptimizer.ts":
  96043. /*!********************************!*\
  96044. !*** ./Misc/sceneOptimizer.ts ***!
  96045. \********************************/
  96046. /*! exports provided: SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer */
  96047. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96048. "use strict";
  96049. __webpack_require__.r(__webpack_exports__);
  96050. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return SceneOptimization; });
  96051. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return TextureOptimization; });
  96052. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return HardwareScalingOptimization; });
  96053. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return ShadowsOptimization; });
  96054. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return PostProcessesOptimization; });
  96055. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return LensFlaresOptimization; });
  96056. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return CustomOptimization; });
  96057. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return ParticlesOptimization; });
  96058. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return RenderTargetsOptimization; });
  96059. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return MergeMeshesOptimization; });
  96060. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return SceneOptimizerOptions; });
  96061. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return SceneOptimizer; });
  96062. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  96063. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  96064. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  96065. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  96066. /**
  96067. * Defines the root class used to create scene optimization to use with SceneOptimizer
  96068. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96069. */
  96070. var SceneOptimization = /** @class */ (function () {
  96071. /**
  96072. * Creates the SceneOptimization object
  96073. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  96074. * @param desc defines the description associated with the optimization
  96075. */
  96076. function SceneOptimization(
  96077. /**
  96078. * Defines the priority of this optimization (0 by default which means first in the list)
  96079. */
  96080. priority) {
  96081. if (priority === void 0) { priority = 0; }
  96082. this.priority = priority;
  96083. }
  96084. /**
  96085. * Gets a string describing the action executed by the current optimization
  96086. * @returns description string
  96087. */
  96088. SceneOptimization.prototype.getDescription = function () {
  96089. return "";
  96090. };
  96091. /**
  96092. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96093. * @param scene defines the current scene where to apply this optimization
  96094. * @param optimizer defines the current optimizer
  96095. * @returns true if everything that can be done was applied
  96096. */
  96097. SceneOptimization.prototype.apply = function (scene, optimizer) {
  96098. return true;
  96099. };
  96100. return SceneOptimization;
  96101. }());
  96102. /**
  96103. * Defines an optimization used to reduce the size of render target textures
  96104. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96105. */
  96106. var TextureOptimization = /** @class */ (function (_super) {
  96107. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureOptimization, _super);
  96108. /**
  96109. * Creates the TextureOptimization object
  96110. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  96111. * @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
  96112. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  96113. */
  96114. function TextureOptimization(
  96115. /**
  96116. * Defines the priority of this optimization (0 by default which means first in the list)
  96117. */
  96118. priority,
  96119. /**
  96120. * 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
  96121. */
  96122. maximumSize,
  96123. /**
  96124. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  96125. */
  96126. step) {
  96127. if (priority === void 0) { priority = 0; }
  96128. if (maximumSize === void 0) { maximumSize = 1024; }
  96129. if (step === void 0) { step = 0.5; }
  96130. var _this = _super.call(this, priority) || this;
  96131. _this.priority = priority;
  96132. _this.maximumSize = maximumSize;
  96133. _this.step = step;
  96134. return _this;
  96135. }
  96136. /**
  96137. * Gets a string describing the action executed by the current optimization
  96138. * @returns description string
  96139. */
  96140. TextureOptimization.prototype.getDescription = function () {
  96141. return "Reducing render target texture size to " + this.maximumSize;
  96142. };
  96143. /**
  96144. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96145. * @param scene defines the current scene where to apply this optimization
  96146. * @param optimizer defines the current optimizer
  96147. * @returns true if everything that can be done was applied
  96148. */
  96149. TextureOptimization.prototype.apply = function (scene, optimizer) {
  96150. var allDone = true;
  96151. for (var index = 0; index < scene.textures.length; index++) {
  96152. var texture = scene.textures[index];
  96153. if (!texture.canRescale || texture.getContext) {
  96154. continue;
  96155. }
  96156. var currentSize = texture.getSize();
  96157. var maxDimension = Math.max(currentSize.width, currentSize.height);
  96158. if (maxDimension > this.maximumSize) {
  96159. texture.scale(this.step);
  96160. allDone = false;
  96161. }
  96162. }
  96163. return allDone;
  96164. };
  96165. return TextureOptimization;
  96166. }(SceneOptimization));
  96167. /**
  96168. * Defines an optimization used to increase or decrease the rendering resolution
  96169. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96170. */
  96171. var HardwareScalingOptimization = /** @class */ (function (_super) {
  96172. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HardwareScalingOptimization, _super);
  96173. /**
  96174. * Creates the HardwareScalingOptimization object
  96175. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  96176. * @param maximumScale defines the maximum scale to use (2 by default)
  96177. * @param step defines the step to use between two passes (0.5 by default)
  96178. */
  96179. function HardwareScalingOptimization(
  96180. /**
  96181. * Defines the priority of this optimization (0 by default which means first in the list)
  96182. */
  96183. priority,
  96184. /**
  96185. * Defines the maximum scale to use (2 by default)
  96186. */
  96187. maximumScale,
  96188. /**
  96189. * Defines the step to use between two passes (0.5 by default)
  96190. */
  96191. step) {
  96192. if (priority === void 0) { priority = 0; }
  96193. if (maximumScale === void 0) { maximumScale = 2; }
  96194. if (step === void 0) { step = 0.25; }
  96195. var _this = _super.call(this, priority) || this;
  96196. _this.priority = priority;
  96197. _this.maximumScale = maximumScale;
  96198. _this.step = step;
  96199. _this._currentScale = -1;
  96200. _this._directionOffset = 1;
  96201. return _this;
  96202. }
  96203. /**
  96204. * Gets a string describing the action executed by the current optimization
  96205. * @return description string
  96206. */
  96207. HardwareScalingOptimization.prototype.getDescription = function () {
  96208. return "Setting hardware scaling level to " + this._currentScale;
  96209. };
  96210. /**
  96211. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96212. * @param scene defines the current scene where to apply this optimization
  96213. * @param optimizer defines the current optimizer
  96214. * @returns true if everything that can be done was applied
  96215. */
  96216. HardwareScalingOptimization.prototype.apply = function (scene, optimizer) {
  96217. if (this._currentScale === -1) {
  96218. this._currentScale = scene.getEngine().getHardwareScalingLevel();
  96219. if (this._currentScale > this.maximumScale) {
  96220. this._directionOffset = -1;
  96221. }
  96222. }
  96223. this._currentScale += this._directionOffset * this.step;
  96224. scene.getEngine().setHardwareScalingLevel(this._currentScale);
  96225. return this._directionOffset === 1 ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale;
  96226. };
  96227. return HardwareScalingOptimization;
  96228. }(SceneOptimization));
  96229. /**
  96230. * Defines an optimization used to remove shadows
  96231. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96232. */
  96233. var ShadowsOptimization = /** @class */ (function (_super) {
  96234. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowsOptimization, _super);
  96235. function ShadowsOptimization() {
  96236. return _super !== null && _super.apply(this, arguments) || this;
  96237. }
  96238. /**
  96239. * Gets a string describing the action executed by the current optimization
  96240. * @return description string
  96241. */
  96242. ShadowsOptimization.prototype.getDescription = function () {
  96243. return "Turning shadows on/off";
  96244. };
  96245. /**
  96246. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96247. * @param scene defines the current scene where to apply this optimization
  96248. * @param optimizer defines the current optimizer
  96249. * @returns true if everything that can be done was applied
  96250. */
  96251. ShadowsOptimization.prototype.apply = function (scene, optimizer) {
  96252. scene.shadowsEnabled = optimizer.isInImprovementMode;
  96253. return true;
  96254. };
  96255. return ShadowsOptimization;
  96256. }(SceneOptimization));
  96257. /**
  96258. * Defines an optimization used to turn post-processes off
  96259. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96260. */
  96261. var PostProcessesOptimization = /** @class */ (function (_super) {
  96262. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PostProcessesOptimization, _super);
  96263. function PostProcessesOptimization() {
  96264. return _super !== null && _super.apply(this, arguments) || this;
  96265. }
  96266. /**
  96267. * Gets a string describing the action executed by the current optimization
  96268. * @return description string
  96269. */
  96270. PostProcessesOptimization.prototype.getDescription = function () {
  96271. return "Turning post-processes on/off";
  96272. };
  96273. /**
  96274. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96275. * @param scene defines the current scene where to apply this optimization
  96276. * @param optimizer defines the current optimizer
  96277. * @returns true if everything that can be done was applied
  96278. */
  96279. PostProcessesOptimization.prototype.apply = function (scene, optimizer) {
  96280. scene.postProcessesEnabled = optimizer.isInImprovementMode;
  96281. return true;
  96282. };
  96283. return PostProcessesOptimization;
  96284. }(SceneOptimization));
  96285. /**
  96286. * Defines an optimization used to turn lens flares off
  96287. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96288. */
  96289. var LensFlaresOptimization = /** @class */ (function (_super) {
  96290. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensFlaresOptimization, _super);
  96291. function LensFlaresOptimization() {
  96292. return _super !== null && _super.apply(this, arguments) || this;
  96293. }
  96294. /**
  96295. * Gets a string describing the action executed by the current optimization
  96296. * @return description string
  96297. */
  96298. LensFlaresOptimization.prototype.getDescription = function () {
  96299. return "Turning lens flares on/off";
  96300. };
  96301. /**
  96302. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96303. * @param scene defines the current scene where to apply this optimization
  96304. * @param optimizer defines the current optimizer
  96305. * @returns true if everything that can be done was applied
  96306. */
  96307. LensFlaresOptimization.prototype.apply = function (scene, optimizer) {
  96308. scene.lensFlaresEnabled = optimizer.isInImprovementMode;
  96309. return true;
  96310. };
  96311. return LensFlaresOptimization;
  96312. }(SceneOptimization));
  96313. /**
  96314. * Defines an optimization based on user defined callback.
  96315. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96316. */
  96317. var CustomOptimization = /** @class */ (function (_super) {
  96318. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomOptimization, _super);
  96319. function CustomOptimization() {
  96320. return _super !== null && _super.apply(this, arguments) || this;
  96321. }
  96322. /**
  96323. * Gets a string describing the action executed by the current optimization
  96324. * @returns description string
  96325. */
  96326. CustomOptimization.prototype.getDescription = function () {
  96327. if (this.onGetDescription) {
  96328. return this.onGetDescription();
  96329. }
  96330. return "Running user defined callback";
  96331. };
  96332. /**
  96333. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96334. * @param scene defines the current scene where to apply this optimization
  96335. * @param optimizer defines the current optimizer
  96336. * @returns true if everything that can be done was applied
  96337. */
  96338. CustomOptimization.prototype.apply = function (scene, optimizer) {
  96339. if (this.onApply) {
  96340. return this.onApply(scene, optimizer);
  96341. }
  96342. return true;
  96343. };
  96344. return CustomOptimization;
  96345. }(SceneOptimization));
  96346. /**
  96347. * Defines an optimization used to turn particles off
  96348. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96349. */
  96350. var ParticlesOptimization = /** @class */ (function (_super) {
  96351. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticlesOptimization, _super);
  96352. function ParticlesOptimization() {
  96353. return _super !== null && _super.apply(this, arguments) || this;
  96354. }
  96355. /**
  96356. * Gets a string describing the action executed by the current optimization
  96357. * @return description string
  96358. */
  96359. ParticlesOptimization.prototype.getDescription = function () {
  96360. return "Turning particles on/off";
  96361. };
  96362. /**
  96363. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96364. * @param scene defines the current scene where to apply this optimization
  96365. * @param optimizer defines the current optimizer
  96366. * @returns true if everything that can be done was applied
  96367. */
  96368. ParticlesOptimization.prototype.apply = function (scene, optimizer) {
  96369. scene.particlesEnabled = optimizer.isInImprovementMode;
  96370. return true;
  96371. };
  96372. return ParticlesOptimization;
  96373. }(SceneOptimization));
  96374. /**
  96375. * Defines an optimization used to turn render targets off
  96376. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96377. */
  96378. var RenderTargetsOptimization = /** @class */ (function (_super) {
  96379. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetsOptimization, _super);
  96380. function RenderTargetsOptimization() {
  96381. return _super !== null && _super.apply(this, arguments) || this;
  96382. }
  96383. /**
  96384. * Gets a string describing the action executed by the current optimization
  96385. * @return description string
  96386. */
  96387. RenderTargetsOptimization.prototype.getDescription = function () {
  96388. return "Turning render targets off";
  96389. };
  96390. /**
  96391. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96392. * @param scene defines the current scene where to apply this optimization
  96393. * @param optimizer defines the current optimizer
  96394. * @returns true if everything that can be done was applied
  96395. */
  96396. RenderTargetsOptimization.prototype.apply = function (scene, optimizer) {
  96397. scene.renderTargetsEnabled = optimizer.isInImprovementMode;
  96398. return true;
  96399. };
  96400. return RenderTargetsOptimization;
  96401. }(SceneOptimization));
  96402. /**
  96403. * Defines an optimization used to merge meshes with compatible materials
  96404. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96405. */
  96406. var MergeMeshesOptimization = /** @class */ (function (_super) {
  96407. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MergeMeshesOptimization, _super);
  96408. function MergeMeshesOptimization() {
  96409. var _this = _super !== null && _super.apply(this, arguments) || this;
  96410. _this._canBeMerged = function (abstractMesh) {
  96411. if (!(abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"])) {
  96412. return false;
  96413. }
  96414. var mesh = abstractMesh;
  96415. if (mesh.isDisposed()) {
  96416. return false;
  96417. }
  96418. if (!mesh.isVisible || !mesh.isEnabled()) {
  96419. return false;
  96420. }
  96421. if (mesh.instances.length > 0) {
  96422. return false;
  96423. }
  96424. if (mesh.skeleton || mesh.hasLODLevels) {
  96425. return false;
  96426. }
  96427. return true;
  96428. };
  96429. return _this;
  96430. }
  96431. Object.defineProperty(MergeMeshesOptimization, "UpdateSelectionTree", {
  96432. /**
  96433. * Gets or sets a boolean which defines if optimization octree has to be updated
  96434. */
  96435. get: function () {
  96436. return MergeMeshesOptimization._UpdateSelectionTree;
  96437. },
  96438. /**
  96439. * Gets or sets a boolean which defines if optimization octree has to be updated
  96440. */
  96441. set: function (value) {
  96442. MergeMeshesOptimization._UpdateSelectionTree = value;
  96443. },
  96444. enumerable: true,
  96445. configurable: true
  96446. });
  96447. /**
  96448. * Gets a string describing the action executed by the current optimization
  96449. * @return description string
  96450. */
  96451. MergeMeshesOptimization.prototype.getDescription = function () {
  96452. return "Merging similar meshes together";
  96453. };
  96454. /**
  96455. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96456. * @param scene defines the current scene where to apply this optimization
  96457. * @param optimizer defines the current optimizer
  96458. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  96459. * @returns true if everything that can be done was applied
  96460. */
  96461. MergeMeshesOptimization.prototype.apply = function (scene, optimizer, updateSelectionTree) {
  96462. var globalPool = scene.meshes.slice(0);
  96463. var globalLength = globalPool.length;
  96464. for (var index = 0; index < globalLength; index++) {
  96465. var currentPool = new Array();
  96466. var current = globalPool[index];
  96467. // Checks
  96468. if (!this._canBeMerged(current)) {
  96469. continue;
  96470. }
  96471. currentPool.push(current);
  96472. // Find compatible meshes
  96473. for (var subIndex = index + 1; subIndex < globalLength; subIndex++) {
  96474. var otherMesh = globalPool[subIndex];
  96475. if (!this._canBeMerged(otherMesh)) {
  96476. continue;
  96477. }
  96478. if (otherMesh.material !== current.material) {
  96479. continue;
  96480. }
  96481. if (otherMesh.checkCollisions !== current.checkCollisions) {
  96482. continue;
  96483. }
  96484. currentPool.push(otherMesh);
  96485. globalLength--;
  96486. globalPool.splice(subIndex, 1);
  96487. subIndex--;
  96488. }
  96489. if (currentPool.length < 2) {
  96490. continue;
  96491. }
  96492. // Merge meshes
  96493. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].MergeMeshes(currentPool, undefined, true);
  96494. }
  96495. // Call the octree system optimization if it is defined.
  96496. var sceneAsAny = scene;
  96497. if (sceneAsAny.createOrUpdateSelectionOctree) {
  96498. if (updateSelectionTree != undefined) {
  96499. if (updateSelectionTree) {
  96500. sceneAsAny.createOrUpdateSelectionOctree();
  96501. }
  96502. }
  96503. else if (MergeMeshesOptimization.UpdateSelectionTree) {
  96504. sceneAsAny.createOrUpdateSelectionOctree();
  96505. }
  96506. }
  96507. return true;
  96508. };
  96509. MergeMeshesOptimization._UpdateSelectionTree = false;
  96510. return MergeMeshesOptimization;
  96511. }(SceneOptimization));
  96512. /**
  96513. * Defines a list of options used by SceneOptimizer
  96514. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96515. */
  96516. var SceneOptimizerOptions = /** @class */ (function () {
  96517. /**
  96518. * Creates a new list of options used by SceneOptimizer
  96519. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  96520. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  96521. */
  96522. function SceneOptimizerOptions(
  96523. /**
  96524. * Defines the target frame rate to reach (60 by default)
  96525. */
  96526. targetFrameRate,
  96527. /**
  96528. * Defines the interval between two checkes (2000ms by default)
  96529. */
  96530. trackerDuration) {
  96531. if (targetFrameRate === void 0) { targetFrameRate = 60; }
  96532. if (trackerDuration === void 0) { trackerDuration = 2000; }
  96533. this.targetFrameRate = targetFrameRate;
  96534. this.trackerDuration = trackerDuration;
  96535. /**
  96536. * Gets the list of optimizations to apply
  96537. */
  96538. this.optimizations = new Array();
  96539. }
  96540. /**
  96541. * Add a new optimization
  96542. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  96543. * @returns the current SceneOptimizerOptions
  96544. */
  96545. SceneOptimizerOptions.prototype.addOptimization = function (optimization) {
  96546. this.optimizations.push(optimization);
  96547. return this;
  96548. };
  96549. /**
  96550. * Add a new custom optimization
  96551. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  96552. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  96553. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  96554. * @returns the current SceneOptimizerOptions
  96555. */
  96556. SceneOptimizerOptions.prototype.addCustomOptimization = function (onApply, onGetDescription, priority) {
  96557. if (priority === void 0) { priority = 0; }
  96558. var optimization = new CustomOptimization(priority);
  96559. optimization.onApply = onApply;
  96560. optimization.onGetDescription = onGetDescription;
  96561. this.optimizations.push(optimization);
  96562. return this;
  96563. };
  96564. /**
  96565. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  96566. * @param targetFrameRate defines the target frame rate (60 by default)
  96567. * @returns a SceneOptimizerOptions object
  96568. */
  96569. SceneOptimizerOptions.LowDegradationAllowed = function (targetFrameRate) {
  96570. var result = new SceneOptimizerOptions(targetFrameRate);
  96571. var priority = 0;
  96572. result.addOptimization(new MergeMeshesOptimization(priority));
  96573. result.addOptimization(new ShadowsOptimization(priority));
  96574. result.addOptimization(new LensFlaresOptimization(priority));
  96575. // Next priority
  96576. priority++;
  96577. result.addOptimization(new PostProcessesOptimization(priority));
  96578. result.addOptimization(new ParticlesOptimization(priority));
  96579. // Next priority
  96580. priority++;
  96581. result.addOptimization(new TextureOptimization(priority, 1024));
  96582. return result;
  96583. };
  96584. /**
  96585. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  96586. * @param targetFrameRate defines the target frame rate (60 by default)
  96587. * @returns a SceneOptimizerOptions object
  96588. */
  96589. SceneOptimizerOptions.ModerateDegradationAllowed = function (targetFrameRate) {
  96590. var result = new SceneOptimizerOptions(targetFrameRate);
  96591. var priority = 0;
  96592. result.addOptimization(new MergeMeshesOptimization(priority));
  96593. result.addOptimization(new ShadowsOptimization(priority));
  96594. result.addOptimization(new LensFlaresOptimization(priority));
  96595. // Next priority
  96596. priority++;
  96597. result.addOptimization(new PostProcessesOptimization(priority));
  96598. result.addOptimization(new ParticlesOptimization(priority));
  96599. // Next priority
  96600. priority++;
  96601. result.addOptimization(new TextureOptimization(priority, 512));
  96602. // Next priority
  96603. priority++;
  96604. result.addOptimization(new RenderTargetsOptimization(priority));
  96605. // Next priority
  96606. priority++;
  96607. result.addOptimization(new HardwareScalingOptimization(priority, 2));
  96608. return result;
  96609. };
  96610. /**
  96611. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  96612. * @param targetFrameRate defines the target frame rate (60 by default)
  96613. * @returns a SceneOptimizerOptions object
  96614. */
  96615. SceneOptimizerOptions.HighDegradationAllowed = function (targetFrameRate) {
  96616. var result = new SceneOptimizerOptions(targetFrameRate);
  96617. var priority = 0;
  96618. result.addOptimization(new MergeMeshesOptimization(priority));
  96619. result.addOptimization(new ShadowsOptimization(priority));
  96620. result.addOptimization(new LensFlaresOptimization(priority));
  96621. // Next priority
  96622. priority++;
  96623. result.addOptimization(new PostProcessesOptimization(priority));
  96624. result.addOptimization(new ParticlesOptimization(priority));
  96625. // Next priority
  96626. priority++;
  96627. result.addOptimization(new TextureOptimization(priority, 256));
  96628. // Next priority
  96629. priority++;
  96630. result.addOptimization(new RenderTargetsOptimization(priority));
  96631. // Next priority
  96632. priority++;
  96633. result.addOptimization(new HardwareScalingOptimization(priority, 4));
  96634. return result;
  96635. };
  96636. return SceneOptimizerOptions;
  96637. }());
  96638. /**
  96639. * Class used to run optimizations in order to reach a target frame rate
  96640. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96641. */
  96642. var SceneOptimizer = /** @class */ (function () {
  96643. /**
  96644. * Creates a new SceneOptimizer
  96645. * @param scene defines the scene to work on
  96646. * @param options defines the options to use with the SceneOptimizer
  96647. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  96648. * @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)
  96649. */
  96650. function SceneOptimizer(scene, options, autoGeneratePriorities, improvementMode) {
  96651. if (autoGeneratePriorities === void 0) { autoGeneratePriorities = true; }
  96652. if (improvementMode === void 0) { improvementMode = false; }
  96653. var _this = this;
  96654. this._isRunning = false;
  96655. this._currentPriorityLevel = 0;
  96656. this._targetFrameRate = 60;
  96657. this._trackerDuration = 2000;
  96658. this._currentFrameRate = 0;
  96659. this._improvementMode = false;
  96660. /**
  96661. * Defines an observable called when the optimizer reaches the target frame rate
  96662. */
  96663. this.onSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  96664. /**
  96665. * Defines an observable called when the optimizer enables an optimization
  96666. */
  96667. this.onNewOptimizationAppliedObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  96668. /**
  96669. * Defines an observable called when the optimizer is not able to reach the target frame rate
  96670. */
  96671. this.onFailureObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  96672. if (!options) {
  96673. this._options = new SceneOptimizerOptions();
  96674. }
  96675. else {
  96676. this._options = options;
  96677. }
  96678. if (this._options.targetFrameRate) {
  96679. this._targetFrameRate = this._options.targetFrameRate;
  96680. }
  96681. if (this._options.trackerDuration) {
  96682. this._trackerDuration = this._options.trackerDuration;
  96683. }
  96684. if (autoGeneratePriorities) {
  96685. var priority = 0;
  96686. for (var _i = 0, _a = this._options.optimizations; _i < _a.length; _i++) {
  96687. var optim = _a[_i];
  96688. optim.priority = priority++;
  96689. }
  96690. }
  96691. this._improvementMode = improvementMode;
  96692. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene;
  96693. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  96694. _this._sceneDisposeObserver = null;
  96695. _this.dispose();
  96696. });
  96697. }
  96698. Object.defineProperty(SceneOptimizer.prototype, "isInImprovementMode", {
  96699. /**
  96700. * Gets a boolean indicating if the optimizer is in improvement mode
  96701. */
  96702. get: function () {
  96703. return this._improvementMode;
  96704. },
  96705. enumerable: true,
  96706. configurable: true
  96707. });
  96708. Object.defineProperty(SceneOptimizer.prototype, "currentPriorityLevel", {
  96709. /**
  96710. * Gets the current priority level (0 at start)
  96711. */
  96712. get: function () {
  96713. return this._currentPriorityLevel;
  96714. },
  96715. enumerable: true,
  96716. configurable: true
  96717. });
  96718. Object.defineProperty(SceneOptimizer.prototype, "currentFrameRate", {
  96719. /**
  96720. * Gets the current frame rate checked by the SceneOptimizer
  96721. */
  96722. get: function () {
  96723. return this._currentFrameRate;
  96724. },
  96725. enumerable: true,
  96726. configurable: true
  96727. });
  96728. Object.defineProperty(SceneOptimizer.prototype, "targetFrameRate", {
  96729. /**
  96730. * Gets or sets the current target frame rate (60 by default)
  96731. */
  96732. get: function () {
  96733. return this._targetFrameRate;
  96734. },
  96735. /**
  96736. * Gets or sets the current target frame rate (60 by default)
  96737. */
  96738. set: function (value) {
  96739. this._targetFrameRate = value;
  96740. },
  96741. enumerable: true,
  96742. configurable: true
  96743. });
  96744. Object.defineProperty(SceneOptimizer.prototype, "trackerDuration", {
  96745. /**
  96746. * Gets or sets the current interval between two checks (every 2000ms by default)
  96747. */
  96748. get: function () {
  96749. return this._trackerDuration;
  96750. },
  96751. /**
  96752. * Gets or sets the current interval between two checks (every 2000ms by default)
  96753. */
  96754. set: function (value) {
  96755. this._trackerDuration = value;
  96756. },
  96757. enumerable: true,
  96758. configurable: true
  96759. });
  96760. Object.defineProperty(SceneOptimizer.prototype, "optimizations", {
  96761. /**
  96762. * Gets the list of active optimizations
  96763. */
  96764. get: function () {
  96765. return this._options.optimizations;
  96766. },
  96767. enumerable: true,
  96768. configurable: true
  96769. });
  96770. /**
  96771. * Stops the current optimizer
  96772. */
  96773. SceneOptimizer.prototype.stop = function () {
  96774. this._isRunning = false;
  96775. };
  96776. /**
  96777. * Reset the optimizer to initial step (current priority level = 0)
  96778. */
  96779. SceneOptimizer.prototype.reset = function () {
  96780. this._currentPriorityLevel = 0;
  96781. };
  96782. /**
  96783. * Start the optimizer. By default it will try to reach a specific framerate
  96784. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  96785. */
  96786. SceneOptimizer.prototype.start = function () {
  96787. var _this = this;
  96788. if (this._isRunning) {
  96789. return;
  96790. }
  96791. this._isRunning = true;
  96792. // Let's wait for the scene to be ready before running our check
  96793. this._scene.executeWhenReady(function () {
  96794. setTimeout(function () {
  96795. _this._checkCurrentState();
  96796. }, _this._trackerDuration);
  96797. });
  96798. };
  96799. SceneOptimizer.prototype._checkCurrentState = function () {
  96800. var _this = this;
  96801. if (!this._isRunning) {
  96802. return;
  96803. }
  96804. var scene = this._scene;
  96805. var options = this._options;
  96806. this._currentFrameRate = Math.round(scene.getEngine().getFps());
  96807. if (this._improvementMode && this._currentFrameRate <= this._targetFrameRate ||
  96808. !this._improvementMode && this._currentFrameRate >= this._targetFrameRate) {
  96809. this._isRunning = false;
  96810. this.onSuccessObservable.notifyObservers(this);
  96811. return;
  96812. }
  96813. // Apply current level of optimizations
  96814. var allDone = true;
  96815. var noOptimizationApplied = true;
  96816. for (var index = 0; index < options.optimizations.length; index++) {
  96817. var optimization = options.optimizations[index];
  96818. if (optimization.priority === this._currentPriorityLevel) {
  96819. noOptimizationApplied = false;
  96820. allDone = allDone && optimization.apply(scene, this);
  96821. this.onNewOptimizationAppliedObservable.notifyObservers(optimization);
  96822. }
  96823. }
  96824. // If no optimization was applied, this is a failure :(
  96825. if (noOptimizationApplied) {
  96826. this._isRunning = false;
  96827. this.onFailureObservable.notifyObservers(this);
  96828. return;
  96829. }
  96830. // If all optimizations were done, move to next level
  96831. if (allDone) {
  96832. this._currentPriorityLevel++;
  96833. }
  96834. // Let's the system running for a specific amount of time before checking FPS
  96835. scene.executeWhenReady(function () {
  96836. setTimeout(function () {
  96837. _this._checkCurrentState();
  96838. }, _this._trackerDuration);
  96839. });
  96840. };
  96841. /**
  96842. * Release all resources
  96843. */
  96844. SceneOptimizer.prototype.dispose = function () {
  96845. this.stop();
  96846. this.onSuccessObservable.clear();
  96847. this.onFailureObservable.clear();
  96848. this.onNewOptimizationAppliedObservable.clear();
  96849. if (this._sceneDisposeObserver) {
  96850. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  96851. }
  96852. };
  96853. /**
  96854. * Helper function to create a SceneOptimizer with one single line of code
  96855. * @param scene defines the scene to work on
  96856. * @param options defines the options to use with the SceneOptimizer
  96857. * @param onSuccess defines a callback to call on success
  96858. * @param onFailure defines a callback to call on failure
  96859. * @returns the new SceneOptimizer object
  96860. */
  96861. SceneOptimizer.OptimizeAsync = function (scene, options, onSuccess, onFailure) {
  96862. var optimizer = new SceneOptimizer(scene, options || SceneOptimizerOptions.ModerateDegradationAllowed(), false);
  96863. if (onSuccess) {
  96864. optimizer.onSuccessObservable.add(function () {
  96865. onSuccess();
  96866. });
  96867. }
  96868. if (onFailure) {
  96869. optimizer.onFailureObservable.add(function () {
  96870. onFailure();
  96871. });
  96872. }
  96873. optimizer.start();
  96874. return optimizer;
  96875. };
  96876. return SceneOptimizer;
  96877. }());
  96878. /***/ }),
  96879. /***/ "./Misc/sceneSerializer.ts":
  96880. /*!*********************************!*\
  96881. !*** ./Misc/sceneSerializer.ts ***!
  96882. \*********************************/
  96883. /*! exports provided: SceneSerializer */
  96884. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96885. "use strict";
  96886. __webpack_require__.r(__webpack_exports__);
  96887. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return SceneSerializer; });
  96888. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  96889. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  96890. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  96891. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  96892. var serializedGeometries = [];
  96893. var serializeGeometry = function (geometry, serializationGeometries) {
  96894. if (serializedGeometries[geometry.id]) {
  96895. return;
  96896. }
  96897. if (geometry.doNotSerialize) {
  96898. return;
  96899. }
  96900. serializationGeometries.vertexData.push(geometry.serializeVerticeData());
  96901. serializedGeometries[geometry.id] = true;
  96902. };
  96903. var serializeMesh = function (mesh, serializationScene) {
  96904. var serializationObject = {};
  96905. // Geometry
  96906. var geometry = mesh._geometry;
  96907. if (geometry) {
  96908. if (!mesh.getScene().getGeometryByID(geometry.id)) {
  96909. // 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
  96910. serializeGeometry(geometry, serializationScene.geometries);
  96911. }
  96912. }
  96913. // Custom
  96914. if (mesh.serialize) {
  96915. mesh.serialize(serializationObject);
  96916. }
  96917. return serializationObject;
  96918. };
  96919. var finalizeSingleMesh = function (mesh, serializationObject) {
  96920. //only works if the mesh is already loaded
  96921. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  96922. //serialize material
  96923. if (mesh.material) {
  96924. if (mesh.material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__["MultiMaterial"]) {
  96925. serializationObject.multiMaterials = serializationObject.multiMaterials || [];
  96926. serializationObject.materials = serializationObject.materials || [];
  96927. if (!serializationObject.multiMaterials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  96928. serializationObject.multiMaterials.push(mesh.material.serialize());
  96929. var _loop_1 = function (submaterial) {
  96930. if (submaterial) {
  96931. if (!serializationObject.materials.some(function (mat) { return (mat.id === submaterial.id); })) {
  96932. serializationObject.materials.push(submaterial.serialize());
  96933. }
  96934. }
  96935. };
  96936. for (var _i = 0, _a = mesh.material.subMaterials; _i < _a.length; _i++) {
  96937. var submaterial = _a[_i];
  96938. _loop_1(submaterial);
  96939. }
  96940. }
  96941. }
  96942. else {
  96943. serializationObject.materials = serializationObject.materials || [];
  96944. if (!serializationObject.materials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  96945. serializationObject.materials.push(mesh.material.serialize());
  96946. }
  96947. }
  96948. }
  96949. //serialize geometry
  96950. var geometry = mesh._geometry;
  96951. if (geometry) {
  96952. if (!serializationObject.geometries) {
  96953. serializationObject.geometries = {};
  96954. serializationObject.geometries.boxes = [];
  96955. serializationObject.geometries.spheres = [];
  96956. serializationObject.geometries.cylinders = [];
  96957. serializationObject.geometries.toruses = [];
  96958. serializationObject.geometries.grounds = [];
  96959. serializationObject.geometries.planes = [];
  96960. serializationObject.geometries.torusKnots = [];
  96961. serializationObject.geometries.vertexData = [];
  96962. }
  96963. serializeGeometry(geometry, serializationObject.geometries);
  96964. }
  96965. // Skeletons
  96966. if (mesh.skeleton) {
  96967. serializationObject.skeletons = serializationObject.skeletons || [];
  96968. serializationObject.skeletons.push(mesh.skeleton.serialize());
  96969. }
  96970. //serialize the actual mesh
  96971. serializationObject.meshes = serializationObject.meshes || [];
  96972. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  96973. }
  96974. };
  96975. /**
  96976. * Class used to serialize a scene into a string
  96977. */
  96978. var SceneSerializer = /** @class */ (function () {
  96979. function SceneSerializer() {
  96980. }
  96981. /**
  96982. * Clear cache used by a previous serialization
  96983. */
  96984. SceneSerializer.ClearCache = function () {
  96985. serializedGeometries = [];
  96986. };
  96987. /**
  96988. * Serialize a scene into a JSON compatible object
  96989. * @param scene defines the scene to serialize
  96990. * @returns a JSON compatible object
  96991. */
  96992. SceneSerializer.Serialize = function (scene) {
  96993. var serializationObject = {};
  96994. SceneSerializer.ClearCache();
  96995. // Scene
  96996. serializationObject.useDelayedTextureLoading = scene.useDelayedTextureLoading;
  96997. serializationObject.autoClear = scene.autoClear;
  96998. serializationObject.clearColor = scene.clearColor.asArray();
  96999. serializationObject.ambientColor = scene.ambientColor.asArray();
  97000. serializationObject.gravity = scene.gravity.asArray();
  97001. serializationObject.collisionsEnabled = scene.collisionsEnabled;
  97002. // Fog
  97003. if (scene.fogMode && scene.fogMode !== 0) {
  97004. serializationObject.fogMode = scene.fogMode;
  97005. serializationObject.fogColor = scene.fogColor.asArray();
  97006. serializationObject.fogStart = scene.fogStart;
  97007. serializationObject.fogEnd = scene.fogEnd;
  97008. serializationObject.fogDensity = scene.fogDensity;
  97009. }
  97010. //Physics
  97011. if (scene.isPhysicsEnabled()) {
  97012. var physicEngine = scene.getPhysicsEngine();
  97013. if (physicEngine) {
  97014. serializationObject.physicsEnabled = true;
  97015. serializationObject.physicsGravity = physicEngine.gravity.asArray();
  97016. serializationObject.physicsEngine = physicEngine.getPhysicsPluginName();
  97017. }
  97018. }
  97019. // Metadata
  97020. if (scene.metadata) {
  97021. serializationObject.metadata = scene.metadata;
  97022. }
  97023. // Morph targets
  97024. serializationObject.morphTargetManagers = [];
  97025. for (var _i = 0, _a = scene.meshes; _i < _a.length; _i++) {
  97026. var abstractMesh = _a[_i];
  97027. var manager = abstractMesh.morphTargetManager;
  97028. if (manager) {
  97029. serializationObject.morphTargetManagers.push(manager.serialize());
  97030. }
  97031. }
  97032. // Lights
  97033. serializationObject.lights = [];
  97034. var index;
  97035. var light;
  97036. for (index = 0; index < scene.lights.length; index++) {
  97037. light = scene.lights[index];
  97038. if (!light.doNotSerialize) {
  97039. serializationObject.lights.push(light.serialize());
  97040. }
  97041. }
  97042. // Cameras
  97043. serializationObject.cameras = [];
  97044. for (index = 0; index < scene.cameras.length; index++) {
  97045. var camera = scene.cameras[index];
  97046. if (!camera.doNotSerialize) {
  97047. serializationObject.cameras.push(camera.serialize());
  97048. }
  97049. }
  97050. if (scene.activeCamera) {
  97051. serializationObject.activeCameraID = scene.activeCamera.id;
  97052. }
  97053. // Animations
  97054. _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"].AppendSerializedAnimations(scene, serializationObject);
  97055. // Reflection probes
  97056. if (scene.reflectionProbes && scene.reflectionProbes.length > 0) {
  97057. serializationObject.reflectionProbes = [];
  97058. for (index = 0; index < scene.reflectionProbes.length; index++) {
  97059. var reflectionProbe = scene.reflectionProbes[index];
  97060. serializationObject.reflectionProbes.push(reflectionProbe.serialize());
  97061. }
  97062. }
  97063. // Materials
  97064. serializationObject.materials = [];
  97065. serializationObject.multiMaterials = [];
  97066. var material;
  97067. for (index = 0; index < scene.materials.length; index++) {
  97068. material = scene.materials[index];
  97069. if (!material.doNotSerialize) {
  97070. serializationObject.materials.push(material.serialize());
  97071. }
  97072. }
  97073. // MultiMaterials
  97074. serializationObject.multiMaterials = [];
  97075. for (index = 0; index < scene.multiMaterials.length; index++) {
  97076. var multiMaterial = scene.multiMaterials[index];
  97077. serializationObject.multiMaterials.push(multiMaterial.serialize());
  97078. }
  97079. // Environment texture
  97080. if (scene.environmentTexture) {
  97081. serializationObject.environmentTexture = scene.environmentTexture.name;
  97082. }
  97083. // Skeletons
  97084. serializationObject.skeletons = [];
  97085. for (index = 0; index < scene.skeletons.length; index++) {
  97086. var skeleton = scene.skeletons[index];
  97087. if (!skeleton.doNotSerialize) {
  97088. serializationObject.skeletons.push(skeleton.serialize());
  97089. }
  97090. }
  97091. // Transform nodes
  97092. serializationObject.transformNodes = [];
  97093. for (index = 0; index < scene.transformNodes.length; index++) {
  97094. serializationObject.transformNodes.push(scene.transformNodes[index].serialize());
  97095. }
  97096. // Geometries
  97097. serializationObject.geometries = {};
  97098. serializationObject.geometries.boxes = [];
  97099. serializationObject.geometries.spheres = [];
  97100. serializationObject.geometries.cylinders = [];
  97101. serializationObject.geometries.toruses = [];
  97102. serializationObject.geometries.grounds = [];
  97103. serializationObject.geometries.planes = [];
  97104. serializationObject.geometries.torusKnots = [];
  97105. serializationObject.geometries.vertexData = [];
  97106. serializedGeometries = [];
  97107. var geometries = scene.getGeometries();
  97108. for (index = 0; index < geometries.length; index++) {
  97109. var geometry = geometries[index];
  97110. if (geometry.isReady()) {
  97111. serializeGeometry(geometry, serializationObject.geometries);
  97112. }
  97113. }
  97114. // Meshes
  97115. serializationObject.meshes = [];
  97116. for (index = 0; index < scene.meshes.length; index++) {
  97117. var abstractMesh = scene.meshes[index];
  97118. if (abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]) {
  97119. var mesh = abstractMesh;
  97120. if (!mesh.doNotSerialize) {
  97121. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  97122. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  97123. }
  97124. }
  97125. }
  97126. }
  97127. // Particles Systems
  97128. serializationObject.particleSystems = [];
  97129. for (index = 0; index < scene.particleSystems.length; index++) {
  97130. serializationObject.particleSystems.push(scene.particleSystems[index].serialize());
  97131. }
  97132. // Action Manager
  97133. if (scene.actionManager) {
  97134. serializationObject.actions = scene.actionManager.serialize("scene");
  97135. }
  97136. // Components
  97137. for (var _b = 0, _c = scene._serializableComponents; _b < _c.length; _b++) {
  97138. var component = _c[_b];
  97139. component.serialize(serializationObject);
  97140. }
  97141. return serializationObject;
  97142. };
  97143. /**
  97144. * Serialize a mesh into a JSON compatible object
  97145. * @param toSerialize defines the mesh to serialize
  97146. * @param withParents defines if parents must be serialized as well
  97147. * @param withChildren defines if children must be serialized as well
  97148. * @returns a JSON compatible object
  97149. */
  97150. SceneSerializer.SerializeMesh = function (toSerialize /* Mesh || Mesh[] */, withParents, withChildren) {
  97151. if (withParents === void 0) { withParents = false; }
  97152. if (withChildren === void 0) { withChildren = false; }
  97153. var serializationObject = {};
  97154. SceneSerializer.ClearCache();
  97155. toSerialize = (toSerialize instanceof Array) ? toSerialize : [toSerialize];
  97156. if (withParents || withChildren) {
  97157. //deliberate for loop! not for each, appended should be processed as well.
  97158. for (var i = 0; i < toSerialize.length; ++i) {
  97159. if (withChildren) {
  97160. toSerialize[i].getDescendants().forEach(function (node) {
  97161. if (node instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"] && (toSerialize.indexOf(node) < 0)) {
  97162. toSerialize.push(node);
  97163. }
  97164. });
  97165. }
  97166. //make sure the array doesn't contain the object already
  97167. if (withParents && toSerialize[i].parent && (toSerialize.indexOf(toSerialize[i].parent) < 0)) {
  97168. toSerialize.push(toSerialize[i].parent);
  97169. }
  97170. }
  97171. }
  97172. toSerialize.forEach(function (mesh) {
  97173. finalizeSingleMesh(mesh, serializationObject);
  97174. });
  97175. return serializationObject;
  97176. };
  97177. return SceneSerializer;
  97178. }());
  97179. /***/ }),
  97180. /***/ "./Misc/screenshotTools.ts":
  97181. /*!*********************************!*\
  97182. !*** ./Misc/screenshotTools.ts ***!
  97183. \*********************************/
  97184. /*! exports provided: ScreenshotTools */
  97185. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97186. "use strict";
  97187. __webpack_require__.r(__webpack_exports__);
  97188. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return ScreenshotTools; });
  97189. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  97190. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  97191. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  97192. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  97193. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  97194. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  97195. // Screenshots
  97196. var screenshotCanvas;
  97197. /**
  97198. * Class containing a set of static utilities functions for screenshots
  97199. */
  97200. var ScreenshotTools = /** @class */ (function () {
  97201. function ScreenshotTools() {
  97202. }
  97203. /**
  97204. * Captures a screenshot of the current rendering
  97205. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97206. * @param engine defines the rendering engine
  97207. * @param camera defines the source camera
  97208. * @param size This parameter can be set to a single number or to an object with the
  97209. * following (optional) properties: precision, width, height. If a single number is passed,
  97210. * it will be used for both width and height. If an object is passed, the screenshot size
  97211. * will be derived from the parameters. The precision property is a multiplier allowing
  97212. * rendering at a higher or lower resolution
  97213. * @param successCallback defines the callback receives a single parameter which contains the
  97214. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97215. * src parameter of an <img> to display it
  97216. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97217. * Check your browser for supported MIME types
  97218. */
  97219. ScreenshotTools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  97220. if (mimeType === void 0) { mimeType = "image/png"; }
  97221. var width;
  97222. var height;
  97223. // If a precision value is specified
  97224. if (size.precision) {
  97225. width = Math.round(engine.getRenderWidth() * size.precision);
  97226. height = Math.round(width / engine.getAspectRatio(camera));
  97227. }
  97228. else if (size.width && size.height) {
  97229. width = size.width;
  97230. height = size.height;
  97231. }
  97232. //If passing only width, computing height to keep display canvas ratio.
  97233. else if (size.width && !size.height) {
  97234. width = size.width;
  97235. height = Math.round(width / engine.getAspectRatio(camera));
  97236. }
  97237. //If passing only height, computing width to keep display canvas ratio.
  97238. else if (size.height && !size.width) {
  97239. height = size.height;
  97240. width = Math.round(height * engine.getAspectRatio(camera));
  97241. }
  97242. //Assuming here that "size" parameter is a number
  97243. else if (!isNaN(size)) {
  97244. height = size;
  97245. width = size;
  97246. }
  97247. else {
  97248. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  97249. return;
  97250. }
  97251. if (!screenshotCanvas) {
  97252. screenshotCanvas = document.createElement('canvas');
  97253. }
  97254. screenshotCanvas.width = width;
  97255. screenshotCanvas.height = height;
  97256. var renderContext = screenshotCanvas.getContext("2d");
  97257. var ratio = engine.getRenderWidth() / engine.getRenderHeight();
  97258. var newWidth = width;
  97259. var newHeight = newWidth / ratio;
  97260. if (newHeight > height) {
  97261. newHeight = height;
  97262. newWidth = newHeight * ratio;
  97263. }
  97264. var offsetX = Math.max(0, width - newWidth) / 2;
  97265. var offsetY = Math.max(0, height - newHeight) / 2;
  97266. var renderingCanvas = engine.getRenderingCanvas();
  97267. if (renderContext && renderingCanvas) {
  97268. renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);
  97269. }
  97270. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].EncodeScreenshotCanvasData(successCallback, mimeType);
  97271. };
  97272. /**
  97273. * Generates an image screenshot from the specified camera.
  97274. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97275. * @param engine The engine to use for rendering
  97276. * @param camera The camera to use for rendering
  97277. * @param size This parameter can be set to a single number or to an object with the
  97278. * following (optional) properties: precision, width, height. If a single number is passed,
  97279. * it will be used for both width and height. If an object is passed, the screenshot size
  97280. * will be derived from the parameters. The precision property is a multiplier allowing
  97281. * rendering at a higher or lower resolution
  97282. * @param successCallback The callback receives a single parameter which contains the
  97283. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97284. * src parameter of an <img> to display it
  97285. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97286. * Check your browser for supported MIME types
  97287. * @param samples Texture samples (default: 1)
  97288. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97289. * @param fileName A name for for the downloaded file.
  97290. */
  97291. ScreenshotTools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  97292. if (mimeType === void 0) { mimeType = "image/png"; }
  97293. if (samples === void 0) { samples = 1; }
  97294. if (antialiasing === void 0) { antialiasing = false; }
  97295. var width;
  97296. var height;
  97297. //If a precision value is specified
  97298. if (size.precision) {
  97299. width = Math.round(engine.getRenderWidth() * size.precision);
  97300. height = Math.round(width / engine.getAspectRatio(camera));
  97301. size = { width: width, height: height };
  97302. }
  97303. else if (size.width && size.height) {
  97304. width = size.width;
  97305. height = size.height;
  97306. }
  97307. //If passing only width, computing height to keep display canvas ratio.
  97308. else if (size.width && !size.height) {
  97309. width = size.width;
  97310. height = Math.round(width / engine.getAspectRatio(camera));
  97311. size = { width: width, height: height };
  97312. }
  97313. //If passing only height, computing width to keep display canvas ratio.
  97314. else if (size.height && !size.width) {
  97315. height = size.height;
  97316. width = Math.round(height * engine.getAspectRatio(camera));
  97317. size = { width: width, height: height };
  97318. }
  97319. //Assuming here that "size" parameter is a number
  97320. else if (!isNaN(size)) {
  97321. height = size;
  97322. width = size;
  97323. }
  97324. else {
  97325. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  97326. return;
  97327. }
  97328. var scene = camera.getScene();
  97329. var previousCamera = null;
  97330. if (scene.activeCamera !== camera) {
  97331. previousCamera = scene.activeCamera;
  97332. scene.activeCamera = camera;
  97333. }
  97334. var renderCanvas = engine.getRenderingCanvas();
  97335. if (!renderCanvas) {
  97336. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("No rendering canvas found !");
  97337. return;
  97338. }
  97339. var originalSize = { width: renderCanvas.width, height: renderCanvas.height };
  97340. engine.setSize(width, height);
  97341. scene.render();
  97342. // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)
  97343. 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);
  97344. texture.renderList = null;
  97345. texture.samples = samples;
  97346. if (antialiasing) {
  97347. texture.addPostProcess(new _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__["FxaaPostProcess"]('antialiasing', 1.0, scene.activeCamera));
  97348. }
  97349. texture.onAfterRenderObservable.add(function () {
  97350. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].DumpFramebuffer(width, height, engine, successCallback, mimeType, fileName);
  97351. });
  97352. scene.incrementRenderId();
  97353. scene.resetCachedMaterial();
  97354. texture.render(true);
  97355. texture.dispose();
  97356. if (previousCamera) {
  97357. scene.activeCamera = previousCamera;
  97358. }
  97359. engine.setSize(originalSize.width, originalSize.height);
  97360. camera.getProjectionMatrix(true); // Force cache refresh;
  97361. };
  97362. return ScreenshotTools;
  97363. }());
  97364. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshot = ScreenshotTools.CreateScreenshot;
  97365. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshotUsingRenderTarget = ScreenshotTools.CreateScreenshotUsingRenderTarget;
  97366. /***/ }),
  97367. /***/ "./Misc/smartArray.ts":
  97368. /*!****************************!*\
  97369. !*** ./Misc/smartArray.ts ***!
  97370. \****************************/
  97371. /*! exports provided: SmartArray, SmartArrayNoDuplicate */
  97372. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97373. "use strict";
  97374. __webpack_require__.r(__webpack_exports__);
  97375. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return SmartArray; });
  97376. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return SmartArrayNoDuplicate; });
  97377. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  97378. /**
  97379. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  97380. */
  97381. var SmartArray = /** @class */ (function () {
  97382. /**
  97383. * Instantiates a Smart Array.
  97384. * @param capacity defines the default capacity of the array.
  97385. */
  97386. function SmartArray(capacity) {
  97387. /**
  97388. * The active length of the array.
  97389. */
  97390. this.length = 0;
  97391. this.data = new Array(capacity);
  97392. this._id = SmartArray._GlobalId++;
  97393. }
  97394. /**
  97395. * Pushes a value at the end of the active data.
  97396. * @param value defines the object to push in the array.
  97397. */
  97398. SmartArray.prototype.push = function (value) {
  97399. this.data[this.length++] = value;
  97400. if (this.length > this.data.length) {
  97401. this.data.length *= 2;
  97402. }
  97403. };
  97404. /**
  97405. * Iterates over the active data and apply the lambda to them.
  97406. * @param func defines the action to apply on each value.
  97407. */
  97408. SmartArray.prototype.forEach = function (func) {
  97409. for (var index = 0; index < this.length; index++) {
  97410. func(this.data[index]);
  97411. }
  97412. };
  97413. /**
  97414. * Sorts the full sets of data.
  97415. * @param compareFn defines the comparison function to apply.
  97416. */
  97417. SmartArray.prototype.sort = function (compareFn) {
  97418. this.data.sort(compareFn);
  97419. };
  97420. /**
  97421. * Resets the active data to an empty array.
  97422. */
  97423. SmartArray.prototype.reset = function () {
  97424. this.length = 0;
  97425. };
  97426. /**
  97427. * Releases all the data from the array as well as the array.
  97428. */
  97429. SmartArray.prototype.dispose = function () {
  97430. this.reset();
  97431. if (this.data) {
  97432. this.data.length = 0;
  97433. this.data = [];
  97434. }
  97435. };
  97436. /**
  97437. * Concats the active data with a given array.
  97438. * @param array defines the data to concatenate with.
  97439. */
  97440. SmartArray.prototype.concat = function (array) {
  97441. if (array.length === 0) {
  97442. return;
  97443. }
  97444. if (this.length + array.length > this.data.length) {
  97445. this.data.length = (this.length + array.length) * 2;
  97446. }
  97447. for (var index = 0; index < array.length; index++) {
  97448. this.data[this.length++] = (array.data || array)[index];
  97449. }
  97450. };
  97451. /**
  97452. * Returns the position of a value in the active data.
  97453. * @param value defines the value to find the index for
  97454. * @returns the index if found in the active data otherwise -1
  97455. */
  97456. SmartArray.prototype.indexOf = function (value) {
  97457. var position = this.data.indexOf(value);
  97458. if (position >= this.length) {
  97459. return -1;
  97460. }
  97461. return position;
  97462. };
  97463. /**
  97464. * Returns whether an element is part of the active data.
  97465. * @param value defines the value to look for
  97466. * @returns true if found in the active data otherwise false
  97467. */
  97468. SmartArray.prototype.contains = function (value) {
  97469. return this.indexOf(value) !== -1;
  97470. };
  97471. // Statics
  97472. SmartArray._GlobalId = 0;
  97473. return SmartArray;
  97474. }());
  97475. /**
  97476. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  97477. * The data in this array can only be present once
  97478. */
  97479. var SmartArrayNoDuplicate = /** @class */ (function (_super) {
  97480. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SmartArrayNoDuplicate, _super);
  97481. function SmartArrayNoDuplicate() {
  97482. var _this = _super !== null && _super.apply(this, arguments) || this;
  97483. _this._duplicateId = 0;
  97484. return _this;
  97485. }
  97486. /**
  97487. * Pushes a value at the end of the active data.
  97488. * THIS DOES NOT PREVENT DUPPLICATE DATA
  97489. * @param value defines the object to push in the array.
  97490. */
  97491. SmartArrayNoDuplicate.prototype.push = function (value) {
  97492. _super.prototype.push.call(this, value);
  97493. if (!value.__smartArrayFlags) {
  97494. value.__smartArrayFlags = {};
  97495. }
  97496. value.__smartArrayFlags[this._id] = this._duplicateId;
  97497. };
  97498. /**
  97499. * Pushes a value at the end of the active data.
  97500. * If the data is already present, it won t be added again
  97501. * @param value defines the object to push in the array.
  97502. * @returns true if added false if it was already present
  97503. */
  97504. SmartArrayNoDuplicate.prototype.pushNoDuplicate = function (value) {
  97505. if (value.__smartArrayFlags && value.__smartArrayFlags[this._id] === this._duplicateId) {
  97506. return false;
  97507. }
  97508. this.push(value);
  97509. return true;
  97510. };
  97511. /**
  97512. * Resets the active data to an empty array.
  97513. */
  97514. SmartArrayNoDuplicate.prototype.reset = function () {
  97515. _super.prototype.reset.call(this);
  97516. this._duplicateId++;
  97517. };
  97518. /**
  97519. * Concats the active data with a given array.
  97520. * This ensures no dupplicate will be present in the result.
  97521. * @param array defines the data to concatenate with.
  97522. */
  97523. SmartArrayNoDuplicate.prototype.concatWithNoDuplicate = function (array) {
  97524. if (array.length === 0) {
  97525. return;
  97526. }
  97527. if (this.length + array.length > this.data.length) {
  97528. this.data.length = (this.length + array.length) * 2;
  97529. }
  97530. for (var index = 0; index < array.length; index++) {
  97531. var item = (array.data || array)[index];
  97532. this.pushNoDuplicate(item);
  97533. }
  97534. };
  97535. return SmartArrayNoDuplicate;
  97536. }(SmartArray));
  97537. /***/ }),
  97538. /***/ "./Misc/stringDictionary.ts":
  97539. /*!**********************************!*\
  97540. !*** ./Misc/stringDictionary.ts ***!
  97541. \**********************************/
  97542. /*! exports provided: StringDictionary */
  97543. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97544. "use strict";
  97545. __webpack_require__.r(__webpack_exports__);
  97546. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return StringDictionary; });
  97547. /**
  97548. * This class implement a typical dictionary using a string as key and the generic type T as value.
  97549. * The underlying implementation relies on an associative array to ensure the best performances.
  97550. * The value can be anything including 'null' but except 'undefined'
  97551. */
  97552. var StringDictionary = /** @class */ (function () {
  97553. function StringDictionary() {
  97554. this._count = 0;
  97555. this._data = {};
  97556. }
  97557. /**
  97558. * This will clear this dictionary and copy the content from the 'source' one.
  97559. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  97560. * @param source the dictionary to take the content from and copy to this dictionary
  97561. */
  97562. StringDictionary.prototype.copyFrom = function (source) {
  97563. var _this = this;
  97564. this.clear();
  97565. source.forEach(function (t, v) { return _this.add(t, v); });
  97566. };
  97567. /**
  97568. * Get a value based from its key
  97569. * @param key the given key to get the matching value from
  97570. * @return the value if found, otherwise undefined is returned
  97571. */
  97572. StringDictionary.prototype.get = function (key) {
  97573. var val = this._data[key];
  97574. if (val !== undefined) {
  97575. return val;
  97576. }
  97577. return undefined;
  97578. };
  97579. /**
  97580. * Get a value from its key or add it if it doesn't exist.
  97581. * This method will ensure you that a given key/data will be present in the dictionary.
  97582. * @param key the given key to get the matching value from
  97583. * @param factory the factory that will create the value if the key is not present in the dictionary.
  97584. * The factory will only be invoked if there's no data for the given key.
  97585. * @return the value corresponding to the key.
  97586. */
  97587. StringDictionary.prototype.getOrAddWithFactory = function (key, factory) {
  97588. var val = this.get(key);
  97589. if (val !== undefined) {
  97590. return val;
  97591. }
  97592. val = factory(key);
  97593. if (val) {
  97594. this.add(key, val);
  97595. }
  97596. return val;
  97597. };
  97598. /**
  97599. * Get a value from its key if present in the dictionary otherwise add it
  97600. * @param key the key to get the value from
  97601. * @param val if there's no such key/value pair in the dictionary add it with this value
  97602. * @return the value corresponding to the key
  97603. */
  97604. StringDictionary.prototype.getOrAdd = function (key, val) {
  97605. var curVal = this.get(key);
  97606. if (curVal !== undefined) {
  97607. return curVal;
  97608. }
  97609. this.add(key, val);
  97610. return val;
  97611. };
  97612. /**
  97613. * Check if there's a given key in the dictionary
  97614. * @param key the key to check for
  97615. * @return true if the key is present, false otherwise
  97616. */
  97617. StringDictionary.prototype.contains = function (key) {
  97618. return this._data[key] !== undefined;
  97619. };
  97620. /**
  97621. * Add a new key and its corresponding value
  97622. * @param key the key to add
  97623. * @param value the value corresponding to the key
  97624. * @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
  97625. */
  97626. StringDictionary.prototype.add = function (key, value) {
  97627. if (this._data[key] !== undefined) {
  97628. return false;
  97629. }
  97630. this._data[key] = value;
  97631. ++this._count;
  97632. return true;
  97633. };
  97634. /**
  97635. * Update a specific value associated to a key
  97636. * @param key defines the key to use
  97637. * @param value defines the value to store
  97638. * @returns true if the value was updated (or false if the key was not found)
  97639. */
  97640. StringDictionary.prototype.set = function (key, value) {
  97641. if (this._data[key] === undefined) {
  97642. return false;
  97643. }
  97644. this._data[key] = value;
  97645. return true;
  97646. };
  97647. /**
  97648. * Get the element of the given key and remove it from the dictionary
  97649. * @param key defines the key to search
  97650. * @returns the value associated with the key or null if not found
  97651. */
  97652. StringDictionary.prototype.getAndRemove = function (key) {
  97653. var val = this.get(key);
  97654. if (val !== undefined) {
  97655. delete this._data[key];
  97656. --this._count;
  97657. return val;
  97658. }
  97659. return null;
  97660. };
  97661. /**
  97662. * Remove a key/value from the dictionary.
  97663. * @param key the key to remove
  97664. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  97665. */
  97666. StringDictionary.prototype.remove = function (key) {
  97667. if (this.contains(key)) {
  97668. delete this._data[key];
  97669. --this._count;
  97670. return true;
  97671. }
  97672. return false;
  97673. };
  97674. /**
  97675. * Clear the whole content of the dictionary
  97676. */
  97677. StringDictionary.prototype.clear = function () {
  97678. this._data = {};
  97679. this._count = 0;
  97680. };
  97681. Object.defineProperty(StringDictionary.prototype, "count", {
  97682. /**
  97683. * Gets the current count
  97684. */
  97685. get: function () {
  97686. return this._count;
  97687. },
  97688. enumerable: true,
  97689. configurable: true
  97690. });
  97691. /**
  97692. * Execute a callback on each key/val of the dictionary.
  97693. * Note that you can remove any element in this dictionary in the callback implementation
  97694. * @param callback the callback to execute on a given key/value pair
  97695. */
  97696. StringDictionary.prototype.forEach = function (callback) {
  97697. for (var cur in this._data) {
  97698. var val = this._data[cur];
  97699. callback(cur, val);
  97700. }
  97701. };
  97702. /**
  97703. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  97704. * If the callback returns null or undefined the method will iterate to the next key/value pair
  97705. * Note that you can remove any element in this dictionary in the callback implementation
  97706. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  97707. * @returns the first item
  97708. */
  97709. StringDictionary.prototype.first = function (callback) {
  97710. for (var cur in this._data) {
  97711. var val = this._data[cur];
  97712. var res = callback(cur, val);
  97713. if (res) {
  97714. return res;
  97715. }
  97716. }
  97717. return null;
  97718. };
  97719. return StringDictionary;
  97720. }());
  97721. /***/ }),
  97722. /***/ "./Misc/tags.ts":
  97723. /*!**********************!*\
  97724. !*** ./Misc/tags.ts ***!
  97725. \**********************/
  97726. /*! exports provided: Tags */
  97727. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97728. "use strict";
  97729. __webpack_require__.r(__webpack_exports__);
  97730. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return Tags; });
  97731. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  97732. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  97733. /**
  97734. * Class used to store custom tags
  97735. */
  97736. var Tags = /** @class */ (function () {
  97737. function Tags() {
  97738. }
  97739. /**
  97740. * Adds support for tags on the given object
  97741. * @param obj defines the object to use
  97742. */
  97743. Tags.EnableFor = function (obj) {
  97744. obj._tags = obj._tags || {};
  97745. obj.hasTags = function () {
  97746. return Tags.HasTags(obj);
  97747. };
  97748. obj.addTags = function (tagsString) {
  97749. return Tags.AddTagsTo(obj, tagsString);
  97750. };
  97751. obj.removeTags = function (tagsString) {
  97752. return Tags.RemoveTagsFrom(obj, tagsString);
  97753. };
  97754. obj.matchesTagsQuery = function (tagsQuery) {
  97755. return Tags.MatchesQuery(obj, tagsQuery);
  97756. };
  97757. };
  97758. /**
  97759. * Removes tags support
  97760. * @param obj defines the object to use
  97761. */
  97762. Tags.DisableFor = function (obj) {
  97763. delete obj._tags;
  97764. delete obj.hasTags;
  97765. delete obj.addTags;
  97766. delete obj.removeTags;
  97767. delete obj.matchesTagsQuery;
  97768. };
  97769. /**
  97770. * Gets a boolean indicating if the given object has tags
  97771. * @param obj defines the object to use
  97772. * @returns a boolean
  97773. */
  97774. Tags.HasTags = function (obj) {
  97775. if (!obj._tags) {
  97776. return false;
  97777. }
  97778. return !_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsEmpty(obj._tags);
  97779. };
  97780. /**
  97781. * Gets the tags available on a given object
  97782. * @param obj defines the object to use
  97783. * @param asString defines if the tags must be returned as a string instead of an array of strings
  97784. * @returns the tags
  97785. */
  97786. Tags.GetTags = function (obj, asString) {
  97787. if (asString === void 0) { asString = true; }
  97788. if (!obj._tags) {
  97789. return null;
  97790. }
  97791. if (asString) {
  97792. var tagsArray = [];
  97793. for (var tag in obj._tags) {
  97794. if (obj._tags.hasOwnProperty(tag) && obj._tags[tag] === true) {
  97795. tagsArray.push(tag);
  97796. }
  97797. }
  97798. return tagsArray.join(" ");
  97799. }
  97800. else {
  97801. return obj._tags;
  97802. }
  97803. };
  97804. /**
  97805. * Adds tags to an object
  97806. * @param obj defines the object to use
  97807. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  97808. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  97809. */
  97810. Tags.AddTagsTo = function (obj, tagsString) {
  97811. if (!tagsString) {
  97812. return;
  97813. }
  97814. if (typeof tagsString !== "string") {
  97815. return;
  97816. }
  97817. var tags = tagsString.split(" ");
  97818. tags.forEach(function (tag, index, array) {
  97819. Tags._AddTagTo(obj, tag);
  97820. });
  97821. };
  97822. /**
  97823. * @hidden
  97824. */
  97825. Tags._AddTagTo = function (obj, tag) {
  97826. tag = tag.trim();
  97827. if (tag === "" || tag === "true" || tag === "false") {
  97828. return;
  97829. }
  97830. if (tag.match(/[\s]/) || tag.match(/^([!]|([|]|[&]){2})/)) {
  97831. return;
  97832. }
  97833. Tags.EnableFor(obj);
  97834. obj._tags[tag] = true;
  97835. };
  97836. /**
  97837. * Removes specific tags from a specific object
  97838. * @param obj defines the object to use
  97839. * @param tagsString defines the tags to remove
  97840. */
  97841. Tags.RemoveTagsFrom = function (obj, tagsString) {
  97842. if (!Tags.HasTags(obj)) {
  97843. return;
  97844. }
  97845. var tags = tagsString.split(" ");
  97846. for (var t in tags) {
  97847. Tags._RemoveTagFrom(obj, tags[t]);
  97848. }
  97849. };
  97850. /**
  97851. * @hidden
  97852. */
  97853. Tags._RemoveTagFrom = function (obj, tag) {
  97854. delete obj._tags[tag];
  97855. };
  97856. /**
  97857. * Defines if tags hosted on an object match a given query
  97858. * @param obj defines the object to use
  97859. * @param tagsQuery defines the tag query
  97860. * @returns a boolean
  97861. */
  97862. Tags.MatchesQuery = function (obj, tagsQuery) {
  97863. if (tagsQuery === undefined) {
  97864. return true;
  97865. }
  97866. if (tagsQuery === "") {
  97867. return Tags.HasTags(obj);
  97868. }
  97869. return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__["AndOrNotEvaluator"].Eval(tagsQuery, function (r) { return Tags.HasTags(obj) && obj._tags[r]; });
  97870. };
  97871. return Tags;
  97872. }());
  97873. /***/ }),
  97874. /***/ "./Misc/textureTools.ts":
  97875. /*!******************************!*\
  97876. !*** ./Misc/textureTools.ts ***!
  97877. \******************************/
  97878. /*! exports provided: TextureTools */
  97879. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97880. "use strict";
  97881. __webpack_require__.r(__webpack_exports__);
  97882. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return TextureTools; });
  97883. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  97884. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  97885. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  97886. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  97887. /**
  97888. * Class used to host texture specific utilities
  97889. */
  97890. var TextureTools = /** @class */ (function () {
  97891. function TextureTools() {
  97892. }
  97893. /**
  97894. * Uses the GPU to create a copy texture rescaled at a given size
  97895. * @param texture Texture to copy from
  97896. * @param width defines the desired width
  97897. * @param height defines the desired height
  97898. * @param useBilinearMode defines if bilinear mode has to be used
  97899. * @return the generated texture
  97900. */
  97901. TextureTools.CreateResizedCopy = function (texture, width, height, useBilinearMode) {
  97902. if (useBilinearMode === void 0) { useBilinearMode = true; }
  97903. var scene = texture.getScene();
  97904. var engine = scene.getEngine();
  97905. 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);
  97906. rtt.wrapU = texture.wrapU;
  97907. rtt.wrapV = texture.wrapV;
  97908. rtt.uOffset = texture.uOffset;
  97909. rtt.vOffset = texture.vOffset;
  97910. rtt.uScale = texture.uScale;
  97911. rtt.vScale = texture.vScale;
  97912. rtt.uAng = texture.uAng;
  97913. rtt.vAng = texture.vAng;
  97914. rtt.wAng = texture.wAng;
  97915. rtt.coordinatesIndex = texture.coordinatesIndex;
  97916. rtt.level = texture.level;
  97917. rtt.anisotropicFilteringLevel = texture.anisotropicFilteringLevel;
  97918. rtt._texture.isReady = false;
  97919. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  97920. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  97921. 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);
  97922. passPostProcess.getEffect().executeWhenCompiled(function () {
  97923. passPostProcess.onApply = function (effect) {
  97924. effect.setTexture("textureSampler", texture);
  97925. };
  97926. var internalTexture = rtt.getInternalTexture();
  97927. if (internalTexture) {
  97928. scene.postProcessManager.directRender([passPostProcess], internalTexture);
  97929. engine.unBindFramebuffer(internalTexture);
  97930. rtt.disposeFramebufferObjects();
  97931. passPostProcess.dispose();
  97932. internalTexture.isReady = true;
  97933. }
  97934. });
  97935. return rtt;
  97936. };
  97937. /**
  97938. * Gets an environment BRDF texture for a given scene
  97939. * @param scene defines the hosting scene
  97940. * @returns the environment BRDF texture
  97941. */
  97942. TextureTools.GetEnvironmentBRDFTexture = function (scene) {
  97943. if (!scene._environmentBRDFTexture) {
  97944. 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);
  97945. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  97946. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  97947. scene._environmentBRDFTexture = texture;
  97948. }
  97949. return scene._environmentBRDFTexture;
  97950. };
  97951. 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=";
  97952. return TextureTools;
  97953. }());
  97954. /***/ }),
  97955. /***/ "./Misc/tga.ts":
  97956. /*!*********************!*\
  97957. !*** ./Misc/tga.ts ***!
  97958. \*********************/
  97959. /*! exports provided: TGATools */
  97960. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97961. "use strict";
  97962. __webpack_require__.r(__webpack_exports__);
  97963. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return TGATools; });
  97964. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  97965. /**
  97966. * Based on jsTGALoader - Javascript loader for TGA file
  97967. * By Vincent Thibault
  97968. * @see http://blog.robrowser.com/javascript-tga-loader.html
  97969. */
  97970. var TGATools = /** @class */ (function () {
  97971. function TGATools() {
  97972. }
  97973. /**
  97974. * Gets the header of a TGA file
  97975. * @param data defines the TGA data
  97976. * @returns the header
  97977. */
  97978. TGATools.GetTGAHeader = function (data) {
  97979. var offset = 0;
  97980. var header = {
  97981. id_length: data[offset++],
  97982. colormap_type: data[offset++],
  97983. image_type: data[offset++],
  97984. colormap_index: data[offset++] | data[offset++] << 8,
  97985. colormap_length: data[offset++] | data[offset++] << 8,
  97986. colormap_size: data[offset++],
  97987. origin: [
  97988. data[offset++] | data[offset++] << 8,
  97989. data[offset++] | data[offset++] << 8
  97990. ],
  97991. width: data[offset++] | data[offset++] << 8,
  97992. height: data[offset++] | data[offset++] << 8,
  97993. pixel_size: data[offset++],
  97994. flags: data[offset++]
  97995. };
  97996. return header;
  97997. };
  97998. /**
  97999. * Uploads TGA content to a Babylon Texture
  98000. * @hidden
  98001. */
  98002. TGATools.UploadContent = function (texture, data) {
  98003. // Not enough data to contain header ?
  98004. if (data.length < 19) {
  98005. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data to contain header");
  98006. return;
  98007. }
  98008. // Read Header
  98009. var offset = 18;
  98010. var header = TGATools.GetTGAHeader(data);
  98011. // Assume it's a valid Targa file.
  98012. if (header.id_length + offset > data.length) {
  98013. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data");
  98014. return;
  98015. }
  98016. // Skip not needed data
  98017. offset += header.id_length;
  98018. var use_rle = false;
  98019. var use_pal = false;
  98020. var use_grey = false;
  98021. // Get some informations.
  98022. switch (header.image_type) {
  98023. case TGATools._TYPE_RLE_INDEXED:
  98024. use_rle = true;
  98025. case TGATools._TYPE_INDEXED:
  98026. use_pal = true;
  98027. break;
  98028. case TGATools._TYPE_RLE_RGB:
  98029. use_rle = true;
  98030. case TGATools._TYPE_RGB:
  98031. // use_rgb = true;
  98032. break;
  98033. case TGATools._TYPE_RLE_GREY:
  98034. use_rle = true;
  98035. case TGATools._TYPE_GREY:
  98036. use_grey = true;
  98037. break;
  98038. }
  98039. var pixel_data;
  98040. // var numAlphaBits = header.flags & 0xf;
  98041. var pixel_size = header.pixel_size >> 3;
  98042. var pixel_total = header.width * header.height * pixel_size;
  98043. // Read palettes
  98044. var palettes;
  98045. if (use_pal) {
  98046. palettes = data.subarray(offset, offset += header.colormap_length * (header.colormap_size >> 3));
  98047. }
  98048. // Read LRE
  98049. if (use_rle) {
  98050. pixel_data = new Uint8Array(pixel_total);
  98051. var c, count, i;
  98052. var localOffset = 0;
  98053. var pixels = new Uint8Array(pixel_size);
  98054. while (offset < pixel_total && localOffset < pixel_total) {
  98055. c = data[offset++];
  98056. count = (c & 0x7f) + 1;
  98057. // RLE pixels
  98058. if (c & 0x80) {
  98059. // Bind pixel tmp array
  98060. for (i = 0; i < pixel_size; ++i) {
  98061. pixels[i] = data[offset++];
  98062. }
  98063. // Copy pixel array
  98064. for (i = 0; i < count; ++i) {
  98065. pixel_data.set(pixels, localOffset + i * pixel_size);
  98066. }
  98067. localOffset += pixel_size * count;
  98068. }
  98069. // Raw pixels
  98070. else {
  98071. count *= pixel_size;
  98072. for (i = 0; i < count; ++i) {
  98073. pixel_data[localOffset + i] = data[offset++];
  98074. }
  98075. localOffset += count;
  98076. }
  98077. }
  98078. }
  98079. // RAW Pixels
  98080. else {
  98081. pixel_data = data.subarray(offset, offset += (use_pal ? header.width * header.height : pixel_total));
  98082. }
  98083. // Load to texture
  98084. var x_start, y_start, x_step, y_step, y_end, x_end;
  98085. switch ((header.flags & TGATools._ORIGIN_MASK) >> TGATools._ORIGIN_SHIFT) {
  98086. default:
  98087. case TGATools._ORIGIN_UL:
  98088. x_start = 0;
  98089. x_step = 1;
  98090. x_end = header.width;
  98091. y_start = 0;
  98092. y_step = 1;
  98093. y_end = header.height;
  98094. break;
  98095. case TGATools._ORIGIN_BL:
  98096. x_start = 0;
  98097. x_step = 1;
  98098. x_end = header.width;
  98099. y_start = header.height - 1;
  98100. y_step = -1;
  98101. y_end = -1;
  98102. break;
  98103. case TGATools._ORIGIN_UR:
  98104. x_start = header.width - 1;
  98105. x_step = -1;
  98106. x_end = -1;
  98107. y_start = 0;
  98108. y_step = 1;
  98109. y_end = header.height;
  98110. break;
  98111. case TGATools._ORIGIN_BR:
  98112. x_start = header.width - 1;
  98113. x_step = -1;
  98114. x_end = -1;
  98115. y_start = header.height - 1;
  98116. y_step = -1;
  98117. y_end = -1;
  98118. break;
  98119. }
  98120. // Load the specify method
  98121. var func = '_getImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits';
  98122. var imageData = TGATools[func](header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end);
  98123. var engine = texture.getEngine();
  98124. engine._uploadDataToTextureDirectly(texture, imageData);
  98125. };
  98126. /** @hidden */
  98127. TGATools._getImageData8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98128. var image = pixel_data, colormap = palettes;
  98129. var width = header.width, height = header.height;
  98130. var color, i = 0, x, y;
  98131. var imageData = new Uint8Array(width * height * 4);
  98132. for (y = y_start; y !== y_end; y += y_step) {
  98133. for (x = x_start; x !== x_end; x += x_step, i++) {
  98134. color = image[i];
  98135. imageData[(x + width * y) * 4 + 3] = 255;
  98136. imageData[(x + width * y) * 4 + 2] = colormap[(color * 3) + 0];
  98137. imageData[(x + width * y) * 4 + 1] = colormap[(color * 3) + 1];
  98138. imageData[(x + width * y) * 4 + 0] = colormap[(color * 3) + 2];
  98139. }
  98140. }
  98141. return imageData;
  98142. };
  98143. /** @hidden */
  98144. TGATools._getImageData16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98145. var image = pixel_data;
  98146. var width = header.width, height = header.height;
  98147. var color, i = 0, x, y;
  98148. var imageData = new Uint8Array(width * height * 4);
  98149. for (y = y_start; y !== y_end; y += y_step) {
  98150. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  98151. color = image[i + 0] + (image[i + 1] << 8); // Inversed ?
  98152. var r = (((color & 0x7C00) >> 10) * 255) / 0x1F | 0;
  98153. var g = (((color & 0x03E0) >> 5) * 255) / 0x1F | 0;
  98154. var b = ((color & 0x001F) * 255) / 0x1F | 0;
  98155. imageData[(x + width * y) * 4 + 0] = r;
  98156. imageData[(x + width * y) * 4 + 1] = g;
  98157. imageData[(x + width * y) * 4 + 2] = b;
  98158. imageData[(x + width * y) * 4 + 3] = (color & 0x8000) ? 0 : 255;
  98159. }
  98160. }
  98161. return imageData;
  98162. };
  98163. /** @hidden */
  98164. TGATools._getImageData24bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98165. var image = pixel_data;
  98166. var width = header.width, height = header.height;
  98167. var i = 0, x, y;
  98168. var imageData = new Uint8Array(width * height * 4);
  98169. for (y = y_start; y !== y_end; y += y_step) {
  98170. for (x = x_start; x !== x_end; x += x_step, i += 3) {
  98171. imageData[(x + width * y) * 4 + 3] = 255;
  98172. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  98173. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  98174. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  98175. }
  98176. }
  98177. return imageData;
  98178. };
  98179. /** @hidden */
  98180. TGATools._getImageData32bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98181. var image = pixel_data;
  98182. var width = header.width, height = header.height;
  98183. var i = 0, x, y;
  98184. var imageData = new Uint8Array(width * height * 4);
  98185. for (y = y_start; y !== y_end; y += y_step) {
  98186. for (x = x_start; x !== x_end; x += x_step, i += 4) {
  98187. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  98188. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  98189. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  98190. imageData[(x + width * y) * 4 + 3] = image[i + 3];
  98191. }
  98192. }
  98193. return imageData;
  98194. };
  98195. /** @hidden */
  98196. TGATools._getImageDataGrey8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98197. var image = pixel_data;
  98198. var width = header.width, height = header.height;
  98199. var color, i = 0, x, y;
  98200. var imageData = new Uint8Array(width * height * 4);
  98201. for (y = y_start; y !== y_end; y += y_step) {
  98202. for (x = x_start; x !== x_end; x += x_step, i++) {
  98203. color = image[i];
  98204. imageData[(x + width * y) * 4 + 0] = color;
  98205. imageData[(x + width * y) * 4 + 1] = color;
  98206. imageData[(x + width * y) * 4 + 2] = color;
  98207. imageData[(x + width * y) * 4 + 3] = 255;
  98208. }
  98209. }
  98210. return imageData;
  98211. };
  98212. /** @hidden */
  98213. TGATools._getImageDataGrey16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98214. var image = pixel_data;
  98215. var width = header.width, height = header.height;
  98216. var i = 0, x, y;
  98217. var imageData = new Uint8Array(width * height * 4);
  98218. for (y = y_start; y !== y_end; y += y_step) {
  98219. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  98220. imageData[(x + width * y) * 4 + 0] = image[i + 0];
  98221. imageData[(x + width * y) * 4 + 1] = image[i + 0];
  98222. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  98223. imageData[(x + width * y) * 4 + 3] = image[i + 1];
  98224. }
  98225. }
  98226. return imageData;
  98227. };
  98228. //private static _TYPE_NO_DATA = 0;
  98229. TGATools._TYPE_INDEXED = 1;
  98230. TGATools._TYPE_RGB = 2;
  98231. TGATools._TYPE_GREY = 3;
  98232. TGATools._TYPE_RLE_INDEXED = 9;
  98233. TGATools._TYPE_RLE_RGB = 10;
  98234. TGATools._TYPE_RLE_GREY = 11;
  98235. TGATools._ORIGIN_MASK = 0x30;
  98236. TGATools._ORIGIN_SHIFT = 0x04;
  98237. TGATools._ORIGIN_BL = 0x00;
  98238. TGATools._ORIGIN_BR = 0x01;
  98239. TGATools._ORIGIN_UL = 0x02;
  98240. TGATools._ORIGIN_UR = 0x03;
  98241. return TGATools;
  98242. }());
  98243. /***/ }),
  98244. /***/ "./Misc/tools.ts":
  98245. /*!***********************!*\
  98246. !*** ./Misc/tools.ts ***!
  98247. \***********************/
  98248. /*! exports provided: ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop */
  98249. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98250. "use strict";
  98251. __webpack_require__.r(__webpack_exports__);
  98252. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return ColorGradient; });
  98253. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return Color3Gradient; });
  98254. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return FactorGradient; });
  98255. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return LoadFileError; });
  98256. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return RetryStrategy; });
  98257. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return Tools; });
  98258. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return PerfCounter; });
  98259. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "className", function() { return className; });
  98260. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return AsyncLoop; });
  98261. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  98262. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  98263. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  98264. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  98265. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  98266. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  98267. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  98268. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  98269. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  98270. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  98271. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  98272. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  98273. /** Class used to store color4 gradient */
  98274. var ColorGradient = /** @class */ (function () {
  98275. function ColorGradient() {
  98276. }
  98277. /**
  98278. * Will get a color picked randomly between color1 and color2.
  98279. * If color2 is undefined then color1 will be used
  98280. * @param result defines the target Color4 to store the result in
  98281. */
  98282. ColorGradient.prototype.getColorToRef = function (result) {
  98283. if (!this.color2) {
  98284. result.copyFrom(this.color1);
  98285. return;
  98286. }
  98287. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].LerpToRef(this.color1, this.color2, Math.random(), result);
  98288. };
  98289. return ColorGradient;
  98290. }());
  98291. /** Class used to store color 3 gradient */
  98292. var Color3Gradient = /** @class */ (function () {
  98293. function Color3Gradient() {
  98294. }
  98295. return Color3Gradient;
  98296. }());
  98297. /** Class used to store factor gradient */
  98298. var FactorGradient = /** @class */ (function () {
  98299. function FactorGradient() {
  98300. }
  98301. /**
  98302. * Will get a number picked randomly between factor1 and factor2.
  98303. * If factor2 is undefined then factor1 will be used
  98304. * @returns the picked number
  98305. */
  98306. FactorGradient.prototype.getFactor = function () {
  98307. if (this.factor2 === undefined) {
  98308. return this.factor1;
  98309. }
  98310. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Lerp(this.factor1, this.factor2, Math.random());
  98311. };
  98312. return FactorGradient;
  98313. }());
  98314. /**
  98315. * @ignore
  98316. * Application error to support additional information when loading a file
  98317. */
  98318. var LoadFileError = /** @class */ (function (_super) {
  98319. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LoadFileError, _super);
  98320. /**
  98321. * Creates a new LoadFileError
  98322. * @param message defines the message of the error
  98323. * @param request defines the optional XHR request
  98324. */
  98325. function LoadFileError(message,
  98326. /** defines the optional XHR request */
  98327. request) {
  98328. var _this = _super.call(this, message) || this;
  98329. _this.request = request;
  98330. _this.name = "LoadFileError";
  98331. LoadFileError._setPrototypeOf(_this, LoadFileError.prototype);
  98332. return _this;
  98333. }
  98334. // See https://stackoverflow.com/questions/12915412/how-do-i-extend-a-host-object-e-g-error-in-typescript
  98335. // and https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  98336. // Polyfill for Object.setPrototypeOf if necessary.
  98337. LoadFileError._setPrototypeOf = Object.setPrototypeOf || (function (o, proto) { o.__proto__ = proto; return o; });
  98338. return LoadFileError;
  98339. }(Error));
  98340. /**
  98341. * Class used to define a retry strategy when error happens while loading assets
  98342. */
  98343. var RetryStrategy = /** @class */ (function () {
  98344. function RetryStrategy() {
  98345. }
  98346. /**
  98347. * Function used to defines an exponential back off strategy
  98348. * @param maxRetries defines the maximum number of retries (3 by default)
  98349. * @param baseInterval defines the interval between retries
  98350. * @returns the strategy function to use
  98351. */
  98352. RetryStrategy.ExponentialBackoff = function (maxRetries, baseInterval) {
  98353. if (maxRetries === void 0) { maxRetries = 3; }
  98354. if (baseInterval === void 0) { baseInterval = 500; }
  98355. return function (url, request, retryIndex) {
  98356. if (request.status !== 0 || retryIndex >= maxRetries || url.indexOf("file:") !== -1) {
  98357. return -1;
  98358. }
  98359. return Math.pow(2, retryIndex) * baseInterval;
  98360. };
  98361. };
  98362. return RetryStrategy;
  98363. }());
  98364. // Screenshots
  98365. var screenshotCanvas;
  98366. /**
  98367. * Class containing a set of static utilities functions
  98368. */
  98369. var Tools = /** @class */ (function () {
  98370. function Tools() {
  98371. }
  98372. /**
  98373. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  98374. * @param u defines the coordinate on X axis
  98375. * @param v defines the coordinate on Y axis
  98376. * @param width defines the width of the source data
  98377. * @param height defines the height of the source data
  98378. * @param pixels defines the source byte array
  98379. * @param color defines the output color
  98380. */
  98381. Tools.FetchToRef = function (u, v, width, height, pixels, color) {
  98382. var wrappedU = ((Math.abs(u) * width) % width) | 0;
  98383. var wrappedV = ((Math.abs(v) * height) % height) | 0;
  98384. var position = (wrappedU + wrappedV * width) * 4;
  98385. color.r = pixels[position] / 255;
  98386. color.g = pixels[position + 1] / 255;
  98387. color.b = pixels[position + 2] / 255;
  98388. color.a = pixels[position + 3] / 255;
  98389. };
  98390. /**
  98391. * Interpolates between a and b via alpha
  98392. * @param a The lower value (returned when alpha = 0)
  98393. * @param b The upper value (returned when alpha = 1)
  98394. * @param alpha The interpolation-factor
  98395. * @return The mixed value
  98396. */
  98397. Tools.Mix = function (a, b, alpha) {
  98398. return a * (1 - alpha) + b * alpha;
  98399. };
  98400. /**
  98401. * Tries to instantiate a new object from a given class name
  98402. * @param className defines the class name to instantiate
  98403. * @returns the new object or null if the system was not able to do the instantiation
  98404. */
  98405. Tools.Instantiate = function (className) {
  98406. if (Tools.RegisteredExternalClasses && Tools.RegisteredExternalClasses[className]) {
  98407. return Tools.RegisteredExternalClasses[className];
  98408. }
  98409. var internalClass = _typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass(className);
  98410. if (internalClass) {
  98411. return internalClass;
  98412. }
  98413. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(className + " not found, you may have missed an import.");
  98414. var arr = className.split(".");
  98415. var fn = (window || this);
  98416. for (var i = 0, len = arr.length; i < len; i++) {
  98417. fn = fn[arr[i]];
  98418. }
  98419. if (typeof fn !== "function") {
  98420. return null;
  98421. }
  98422. return fn;
  98423. };
  98424. /**
  98425. * Provides a slice function that will work even on IE
  98426. * @param data defines the array to slice
  98427. * @param start defines the start of the data (optional)
  98428. * @param end defines the end of the data (optional)
  98429. * @returns the new sliced array
  98430. */
  98431. Tools.Slice = function (data, start, end) {
  98432. if (data.slice) {
  98433. return data.slice(start, end);
  98434. }
  98435. return Array.prototype.slice.call(data, start, end);
  98436. };
  98437. /**
  98438. * Polyfill for setImmediate
  98439. * @param action defines the action to execute after the current execution block
  98440. */
  98441. Tools.SetImmediate = function (action) {
  98442. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && window.setImmediate) {
  98443. window.setImmediate(action);
  98444. }
  98445. else {
  98446. setTimeout(action, 1);
  98447. }
  98448. };
  98449. /**
  98450. * Function indicating if a number is an exponent of 2
  98451. * @param value defines the value to test
  98452. * @returns true if the value is an exponent of 2
  98453. */
  98454. Tools.IsExponentOfTwo = function (value) {
  98455. var count = 1;
  98456. do {
  98457. count *= 2;
  98458. } while (count < value);
  98459. return count === value;
  98460. };
  98461. /**
  98462. * Returns the nearest 32-bit single precision float representation of a Number
  98463. * @param value A Number. If the parameter is of a different type, it will get converted
  98464. * to a number or to NaN if it cannot be converted
  98465. * @returns number
  98466. */
  98467. Tools.FloatRound = function (value) {
  98468. if (Math.fround) {
  98469. return Math.fround(value);
  98470. }
  98471. return (Tools._tmpFloatArray[0] = value);
  98472. };
  98473. /**
  98474. * Find the next highest power of two.
  98475. * @param x Number to start search from.
  98476. * @return Next highest power of two.
  98477. */
  98478. Tools.CeilingPOT = function (x) {
  98479. x--;
  98480. x |= x >> 1;
  98481. x |= x >> 2;
  98482. x |= x >> 4;
  98483. x |= x >> 8;
  98484. x |= x >> 16;
  98485. x++;
  98486. return x;
  98487. };
  98488. /**
  98489. * Find the next lowest power of two.
  98490. * @param x Number to start search from.
  98491. * @return Next lowest power of two.
  98492. */
  98493. Tools.FloorPOT = function (x) {
  98494. x = x | (x >> 1);
  98495. x = x | (x >> 2);
  98496. x = x | (x >> 4);
  98497. x = x | (x >> 8);
  98498. x = x | (x >> 16);
  98499. return x - (x >> 1);
  98500. };
  98501. /**
  98502. * Find the nearest power of two.
  98503. * @param x Number to start search from.
  98504. * @return Next nearest power of two.
  98505. */
  98506. Tools.NearestPOT = function (x) {
  98507. var c = Tools.CeilingPOT(x);
  98508. var f = Tools.FloorPOT(x);
  98509. return (c - x) > (x - f) ? f : c;
  98510. };
  98511. /**
  98512. * Get the closest exponent of two
  98513. * @param value defines the value to approximate
  98514. * @param max defines the maximum value to return
  98515. * @param mode defines how to define the closest value
  98516. * @returns closest exponent of two of the given value
  98517. */
  98518. Tools.GetExponentOfTwo = function (value, max, mode) {
  98519. if (mode === void 0) { mode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST; }
  98520. var pot;
  98521. switch (mode) {
  98522. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_FLOOR:
  98523. pot = Tools.FloorPOT(value);
  98524. break;
  98525. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST:
  98526. pot = Tools.NearestPOT(value);
  98527. break;
  98528. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_CEILING:
  98529. default:
  98530. pot = Tools.CeilingPOT(value);
  98531. break;
  98532. }
  98533. return Math.min(pot, max);
  98534. };
  98535. /**
  98536. * Extracts the filename from a path
  98537. * @param path defines the path to use
  98538. * @returns the filename
  98539. */
  98540. Tools.GetFilename = function (path) {
  98541. var index = path.lastIndexOf("/");
  98542. if (index < 0) {
  98543. return path;
  98544. }
  98545. return path.substring(index + 1);
  98546. };
  98547. /**
  98548. * Extracts the "folder" part of a path (everything before the filename).
  98549. * @param uri The URI to extract the info from
  98550. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  98551. * @returns The "folder" part of the path
  98552. */
  98553. Tools.GetFolderPath = function (uri, returnUnchangedIfNoSlash) {
  98554. if (returnUnchangedIfNoSlash === void 0) { returnUnchangedIfNoSlash = false; }
  98555. var index = uri.lastIndexOf("/");
  98556. if (index < 0) {
  98557. if (returnUnchangedIfNoSlash) {
  98558. return uri;
  98559. }
  98560. return "";
  98561. }
  98562. return uri.substring(0, index + 1);
  98563. };
  98564. /**
  98565. * Convert an angle in radians to degrees
  98566. * @param angle defines the angle to convert
  98567. * @returns the angle in degrees
  98568. */
  98569. Tools.ToDegrees = function (angle) {
  98570. return angle * 180 / Math.PI;
  98571. };
  98572. /**
  98573. * Convert an angle in degrees to radians
  98574. * @param angle defines the angle to convert
  98575. * @returns the angle in radians
  98576. */
  98577. Tools.ToRadians = function (angle) {
  98578. return angle * Math.PI / 180;
  98579. };
  98580. /**
  98581. * Encode a buffer to a base64 string
  98582. * @param buffer defines the buffer to encode
  98583. * @returns the encoded string
  98584. */
  98585. Tools.EncodeArrayBufferTobase64 = function (buffer) {
  98586. var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  98587. var output = "";
  98588. var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
  98589. var i = 0;
  98590. var bytes = new Uint8Array(buffer);
  98591. while (i < bytes.length) {
  98592. chr1 = bytes[i++];
  98593. chr2 = i < bytes.length ? bytes[i++] : Number.NaN; // Not sure if the index
  98594. chr3 = i < bytes.length ? bytes[i++] : Number.NaN; // checks are needed here
  98595. enc1 = chr1 >> 2;
  98596. enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  98597. enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  98598. enc4 = chr3 & 63;
  98599. if (isNaN(chr2)) {
  98600. enc3 = enc4 = 64;
  98601. }
  98602. else if (isNaN(chr3)) {
  98603. enc4 = 64;
  98604. }
  98605. output += keyStr.charAt(enc1) + keyStr.charAt(enc2) +
  98606. keyStr.charAt(enc3) + keyStr.charAt(enc4);
  98607. }
  98608. return "data:image/png;base64," + output;
  98609. };
  98610. /**
  98611. * Extracts minimum and maximum values from a list of indexed positions
  98612. * @param positions defines the positions to use
  98613. * @param indices defines the indices to the positions
  98614. * @param indexStart defines the start index
  98615. * @param indexCount defines the end index
  98616. * @param bias defines bias value to add to the result
  98617. * @return minimum and maximum values
  98618. */
  98619. Tools.ExtractMinAndMaxIndexed = function (positions, indices, indexStart, indexCount, bias) {
  98620. if (bias === void 0) { bias = null; }
  98621. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  98622. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  98623. for (var index = indexStart; index < indexStart + indexCount; index++) {
  98624. var offset = indices[index] * 3;
  98625. var x = positions[offset];
  98626. var y = positions[offset + 1];
  98627. var z = positions[offset + 2];
  98628. minimum.minimizeInPlaceFromFloats(x, y, z);
  98629. maximum.maximizeInPlaceFromFloats(x, y, z);
  98630. }
  98631. if (bias) {
  98632. minimum.x -= minimum.x * bias.x + bias.y;
  98633. minimum.y -= minimum.y * bias.x + bias.y;
  98634. minimum.z -= minimum.z * bias.x + bias.y;
  98635. maximum.x += maximum.x * bias.x + bias.y;
  98636. maximum.y += maximum.y * bias.x + bias.y;
  98637. maximum.z += maximum.z * bias.x + bias.y;
  98638. }
  98639. return {
  98640. minimum: minimum,
  98641. maximum: maximum
  98642. };
  98643. };
  98644. /**
  98645. * Extracts minimum and maximum values from a list of positions
  98646. * @param positions defines the positions to use
  98647. * @param start defines the start index in the positions array
  98648. * @param count defines the number of positions to handle
  98649. * @param bias defines bias value to add to the result
  98650. * @param stride defines the stride size to use (distance between two positions in the positions array)
  98651. * @return minimum and maximum values
  98652. */
  98653. Tools.ExtractMinAndMax = function (positions, start, count, bias, stride) {
  98654. if (bias === void 0) { bias = null; }
  98655. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  98656. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  98657. if (!stride) {
  98658. stride = 3;
  98659. }
  98660. for (var index = start, offset = start * stride; index < start + count; index++, offset += stride) {
  98661. var x = positions[offset];
  98662. var y = positions[offset + 1];
  98663. var z = positions[offset + 2];
  98664. minimum.minimizeInPlaceFromFloats(x, y, z);
  98665. maximum.maximizeInPlaceFromFloats(x, y, z);
  98666. }
  98667. if (bias) {
  98668. minimum.x -= minimum.x * bias.x + bias.y;
  98669. minimum.y -= minimum.y * bias.x + bias.y;
  98670. minimum.z -= minimum.z * bias.x + bias.y;
  98671. maximum.x += maximum.x * bias.x + bias.y;
  98672. maximum.y += maximum.y * bias.x + bias.y;
  98673. maximum.z += maximum.z * bias.x + bias.y;
  98674. }
  98675. return {
  98676. minimum: minimum,
  98677. maximum: maximum
  98678. };
  98679. };
  98680. /**
  98681. * Returns an array if obj is not an array
  98682. * @param obj defines the object to evaluate as an array
  98683. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  98684. * @returns either obj directly if obj is an array or a new array containing obj
  98685. */
  98686. Tools.MakeArray = function (obj, allowsNullUndefined) {
  98687. if (allowsNullUndefined !== true && (obj === undefined || obj == null)) {
  98688. return null;
  98689. }
  98690. return Array.isArray(obj) ? obj : [obj];
  98691. };
  98692. /**
  98693. * Gets the pointer prefix to use
  98694. * @returns "pointer" if touch is enabled. Else returns "mouse"
  98695. */
  98696. Tools.GetPointerPrefix = function () {
  98697. var eventPrefix = "pointer";
  98698. // Check if pointer events are supported
  98699. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && !window.PointerEvent && !navigator.pointerEnabled) {
  98700. eventPrefix = "mouse";
  98701. }
  98702. return eventPrefix;
  98703. };
  98704. /**
  98705. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  98706. * @param func - the function to be called
  98707. * @param requester - the object that will request the next frame. Falls back to window.
  98708. * @returns frame number
  98709. */
  98710. Tools.QueueNewFrame = function (func, requester) {
  98711. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  98712. return setTimeout(func, 16);
  98713. }
  98714. if (!requester) {
  98715. requester = window;
  98716. }
  98717. if (requester.requestAnimationFrame) {
  98718. return requester.requestAnimationFrame(func);
  98719. }
  98720. else if (requester.msRequestAnimationFrame) {
  98721. return requester.msRequestAnimationFrame(func);
  98722. }
  98723. else if (requester.webkitRequestAnimationFrame) {
  98724. return requester.webkitRequestAnimationFrame(func);
  98725. }
  98726. else if (requester.mozRequestAnimationFrame) {
  98727. return requester.mozRequestAnimationFrame(func);
  98728. }
  98729. else if (requester.oRequestAnimationFrame) {
  98730. return requester.oRequestAnimationFrame(func);
  98731. }
  98732. else {
  98733. return window.setTimeout(func, 16);
  98734. }
  98735. };
  98736. /**
  98737. * Ask the browser to promote the current element to fullscreen rendering mode
  98738. * @param element defines the DOM element to promote
  98739. */
  98740. Tools.RequestFullscreen = function (element) {
  98741. var requestFunction = element.requestFullscreen || element.msRequestFullscreen || element.webkitRequestFullscreen || element.mozRequestFullScreen;
  98742. if (!requestFunction) {
  98743. return;
  98744. }
  98745. requestFunction.call(element);
  98746. };
  98747. /**
  98748. * Asks the browser to exit fullscreen mode
  98749. */
  98750. Tools.ExitFullscreen = function () {
  98751. if (document.exitFullscreen) {
  98752. document.exitFullscreen();
  98753. }
  98754. else if (document.mozCancelFullScreen) {
  98755. document.mozCancelFullScreen();
  98756. }
  98757. else if (document.webkitCancelFullScreen) {
  98758. document.webkitCancelFullScreen();
  98759. }
  98760. else if (document.msCancelFullScreen) {
  98761. document.msCancelFullScreen();
  98762. }
  98763. };
  98764. /**
  98765. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  98766. * @param url define the url we are trying
  98767. * @param element define the dom element where to configure the cors policy
  98768. */
  98769. Tools.SetCorsBehavior = function (url, element) {
  98770. if (url && url.indexOf("data:") === 0) {
  98771. return;
  98772. }
  98773. if (Tools.CorsBehavior) {
  98774. if (typeof (Tools.CorsBehavior) === 'string' || Tools.CorsBehavior instanceof String) {
  98775. element.crossOrigin = Tools.CorsBehavior;
  98776. }
  98777. else {
  98778. var result = Tools.CorsBehavior(url);
  98779. if (result) {
  98780. element.crossOrigin = result;
  98781. }
  98782. }
  98783. }
  98784. };
  98785. // External files
  98786. /**
  98787. * Removes unwanted characters from an url
  98788. * @param url defines the url to clean
  98789. * @returns the cleaned url
  98790. */
  98791. Tools.CleanUrl = function (url) {
  98792. url = url.replace(/#/mg, "%23");
  98793. return url;
  98794. };
  98795. /**
  98796. * Loads an image as an HTMLImageElement.
  98797. * @param input url string, ArrayBuffer, or Blob to load
  98798. * @param onLoad callback called when the image successfully loads
  98799. * @param onError callback called when the image fails to load
  98800. * @param offlineProvider offline provider for caching
  98801. * @returns the HTMLImageElement of the loaded image
  98802. */
  98803. Tools.LoadImage = function (input, onLoad, onError, offlineProvider) {
  98804. var url;
  98805. var usingObjectURL = false;
  98806. if (input instanceof ArrayBuffer) {
  98807. url = URL.createObjectURL(new Blob([input]));
  98808. usingObjectURL = true;
  98809. }
  98810. else if (input instanceof Blob) {
  98811. url = URL.createObjectURL(input);
  98812. usingObjectURL = true;
  98813. }
  98814. else {
  98815. url = Tools.CleanUrl(input);
  98816. url = Tools.PreprocessUrl(input);
  98817. }
  98818. var img = new Image();
  98819. Tools.SetCorsBehavior(url, img);
  98820. var loadHandler = function () {
  98821. if (usingObjectURL && img.src) {
  98822. URL.revokeObjectURL(img.src);
  98823. }
  98824. img.removeEventListener("load", loadHandler);
  98825. img.removeEventListener("error", errorHandler);
  98826. onLoad(img);
  98827. };
  98828. var errorHandler = function (err) {
  98829. if (usingObjectURL && img.src) {
  98830. URL.revokeObjectURL(img.src);
  98831. }
  98832. img.removeEventListener("load", loadHandler);
  98833. img.removeEventListener("error", errorHandler);
  98834. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error while trying to load image: " + input);
  98835. if (onError) {
  98836. onError("Error while trying to load image: " + input, err);
  98837. }
  98838. };
  98839. img.addEventListener("load", loadHandler);
  98840. img.addEventListener("error", errorHandler);
  98841. var noOfflineSupport = function () {
  98842. img.src = url;
  98843. };
  98844. var loadFromOfflineSupport = function () {
  98845. if (offlineProvider) {
  98846. offlineProvider.loadImage(url, img);
  98847. }
  98848. };
  98849. if (url.substr(0, 5) !== "data:" && offlineProvider && offlineProvider.enableTexturesOffline) {
  98850. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport);
  98851. }
  98852. else {
  98853. if (url.indexOf("file:") !== -1) {
  98854. var textureName = decodeURIComponent(url.substring(5).toLowerCase());
  98855. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]) {
  98856. try {
  98857. var blobURL;
  98858. try {
  98859. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  98860. }
  98861. catch (ex) {
  98862. // Chrome doesn't support oneTimeOnly parameter
  98863. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  98864. }
  98865. img.src = blobURL;
  98866. usingObjectURL = true;
  98867. }
  98868. catch (e) {
  98869. img.src = "";
  98870. }
  98871. return img;
  98872. }
  98873. }
  98874. noOfflineSupport();
  98875. }
  98876. return img;
  98877. };
  98878. /**
  98879. * Loads a file
  98880. * @param url url string, ArrayBuffer, or Blob to load
  98881. * @param onSuccess callback called when the file successfully loads
  98882. * @param onProgress callback called while file is loading (if the server supports this mode)
  98883. * @param offlineProvider defines the offline provider for caching
  98884. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  98885. * @param onError callback called when the file fails to load
  98886. * @returns a file request object
  98887. */
  98888. Tools.LoadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  98889. url = Tools.CleanUrl(url);
  98890. url = Tools.PreprocessUrl(url);
  98891. // If file and file input are set
  98892. if (url.indexOf("file:") !== -1) {
  98893. var fileName = decodeURIComponent(url.substring(5).toLowerCase());
  98894. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName]) {
  98895. return Tools.ReadFile(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName], onSuccess, onProgress, useArrayBuffer);
  98896. }
  98897. }
  98898. var loadUrl = Tools.BaseUrl + url;
  98899. var aborted = false;
  98900. var fileRequest = {
  98901. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  98902. abort: function () { return aborted = true; },
  98903. };
  98904. var requestFile = function () {
  98905. var request = new XMLHttpRequest();
  98906. var retryHandle = null;
  98907. fileRequest.abort = function () {
  98908. aborted = true;
  98909. if (request.readyState !== (XMLHttpRequest.DONE || 4)) {
  98910. request.abort();
  98911. }
  98912. if (retryHandle !== null) {
  98913. clearTimeout(retryHandle);
  98914. retryHandle = null;
  98915. }
  98916. };
  98917. var retryLoop = function (retryIndex) {
  98918. request.open('GET', loadUrl, true);
  98919. if (useArrayBuffer) {
  98920. request.responseType = "arraybuffer";
  98921. }
  98922. if (onProgress) {
  98923. request.addEventListener("progress", onProgress);
  98924. }
  98925. var onLoadEnd = function () {
  98926. request.removeEventListener("loadend", onLoadEnd);
  98927. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  98928. fileRequest.onCompleteObservable.clear();
  98929. };
  98930. request.addEventListener("loadend", onLoadEnd);
  98931. var onReadyStateChange = function () {
  98932. if (aborted) {
  98933. return;
  98934. }
  98935. // In case of undefined state in some browsers.
  98936. if (request.readyState === (XMLHttpRequest.DONE || 4)) {
  98937. // Some browsers have issues where onreadystatechange can be called multiple times with the same value.
  98938. request.removeEventListener("readystatechange", onReadyStateChange);
  98939. if ((request.status >= 200 && request.status < 300) || (request.status === 0 && (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() || Tools.IsFileURL()))) {
  98940. onSuccess(!useArrayBuffer ? request.responseText : request.response, request.responseURL);
  98941. return;
  98942. }
  98943. var retryStrategy = Tools.DefaultRetryStrategy;
  98944. if (retryStrategy) {
  98945. var waitTime = retryStrategy(loadUrl, request, retryIndex);
  98946. if (waitTime !== -1) {
  98947. // Prevent the request from completing for retry.
  98948. request.removeEventListener("loadend", onLoadEnd);
  98949. request = new XMLHttpRequest();
  98950. retryHandle = setTimeout(function () { return retryLoop(retryIndex + 1); }, waitTime);
  98951. return;
  98952. }
  98953. }
  98954. var e = new LoadFileError("Error status: " + request.status + " " + request.statusText + " - Unable to load " + loadUrl, request);
  98955. if (onError) {
  98956. onError(request, e);
  98957. }
  98958. else {
  98959. throw e;
  98960. }
  98961. }
  98962. };
  98963. request.addEventListener("readystatechange", onReadyStateChange);
  98964. if (Tools.UseCustomRequestHeaders) {
  98965. Tools.InjectCustomRequestHeaders(request);
  98966. }
  98967. request.send();
  98968. };
  98969. retryLoop(0);
  98970. };
  98971. // Caching all files
  98972. if (offlineProvider && offlineProvider.enableSceneOffline) {
  98973. var noOfflineSupport_1 = function (request) {
  98974. if (request && request.status > 400) {
  98975. if (onError) {
  98976. onError(request);
  98977. }
  98978. }
  98979. else {
  98980. if (!aborted) {
  98981. requestFile();
  98982. }
  98983. }
  98984. };
  98985. var loadFromOfflineSupport = function () {
  98986. // TODO: database needs to support aborting and should return a IFileRequest
  98987. if (aborted) {
  98988. return;
  98989. }
  98990. if (offlineProvider) {
  98991. offlineProvider.loadFile(url, function (data) {
  98992. if (!aborted) {
  98993. onSuccess(data);
  98994. }
  98995. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  98996. }, onProgress ? function (event) {
  98997. if (!aborted) {
  98998. onProgress(event);
  98999. }
  99000. } : undefined, noOfflineSupport_1, useArrayBuffer);
  99001. }
  99002. };
  99003. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport_1);
  99004. }
  99005. else {
  99006. requestFile();
  99007. }
  99008. return fileRequest;
  99009. };
  99010. /**
  99011. * Load a script (identified by an url). When the url returns, the
  99012. * content of this file is added into a new script element, attached to the DOM (body element)
  99013. * @param scriptUrl defines the url of the script to laod
  99014. * @param onSuccess defines the callback called when the script is loaded
  99015. * @param onError defines the callback to call if an error occurs
  99016. */
  99017. Tools.LoadScript = function (scriptUrl, onSuccess, onError) {
  99018. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  99019. return;
  99020. }
  99021. var head = document.getElementsByTagName('head')[0];
  99022. var script = document.createElement('script');
  99023. script.type = 'text/javascript';
  99024. script.src = scriptUrl;
  99025. script.onload = function () {
  99026. if (onSuccess) {
  99027. onSuccess();
  99028. }
  99029. };
  99030. script.onerror = function (e) {
  99031. if (onError) {
  99032. onError("Unable to load script '" + scriptUrl + "'", e);
  99033. }
  99034. };
  99035. head.appendChild(script);
  99036. };
  99037. /**
  99038. * Loads a file from a blob
  99039. * @param fileToLoad defines the blob to use
  99040. * @param callback defines the callback to call when data is loaded
  99041. * @param progressCallback defines the callback to call during loading process
  99042. * @returns a file request object
  99043. */
  99044. Tools.ReadFileAsDataURL = function (fileToLoad, callback, progressCallback) {
  99045. var reader = new FileReader();
  99046. var request = {
  99047. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  99048. abort: function () { return reader.abort(); },
  99049. };
  99050. reader.onloadend = function (e) {
  99051. request.onCompleteObservable.notifyObservers(request);
  99052. };
  99053. reader.onload = function (e) {
  99054. //target doesn't have result from ts 1.3
  99055. callback(e.target['result']);
  99056. };
  99057. reader.onprogress = progressCallback;
  99058. reader.readAsDataURL(fileToLoad);
  99059. return request;
  99060. };
  99061. /**
  99062. * Loads a file
  99063. * @param fileToLoad defines the file to load
  99064. * @param callback defines the callback to call when data is loaded
  99065. * @param progressCallBack defines the callback to call during loading process
  99066. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  99067. * @returns a file request object
  99068. */
  99069. Tools.ReadFile = function (fileToLoad, callback, progressCallBack, useArrayBuffer) {
  99070. var reader = new FileReader();
  99071. var request = {
  99072. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  99073. abort: function () { return reader.abort(); },
  99074. };
  99075. reader.onloadend = function (e) { return request.onCompleteObservable.notifyObservers(request); };
  99076. reader.onerror = function (e) {
  99077. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log("Error while reading file: " + fileToLoad.name);
  99078. callback(JSON.stringify({ autoClear: true, clearColor: [1, 0, 0], ambientColor: [0, 0, 0], gravity: [0, -9.807, 0], meshes: [], cameras: [], lights: [] }));
  99079. };
  99080. reader.onload = function (e) {
  99081. //target doesn't have result from ts 1.3
  99082. callback(e.target['result']);
  99083. };
  99084. if (progressCallBack) {
  99085. reader.onprogress = progressCallBack;
  99086. }
  99087. if (!useArrayBuffer) {
  99088. // Asynchronous read
  99089. reader.readAsText(fileToLoad);
  99090. }
  99091. else {
  99092. reader.readAsArrayBuffer(fileToLoad);
  99093. }
  99094. return request;
  99095. };
  99096. /**
  99097. * Creates a data url from a given string content
  99098. * @param content defines the content to convert
  99099. * @returns the new data url link
  99100. */
  99101. Tools.FileAsURL = function (content) {
  99102. var fileBlob = new Blob([content]);
  99103. var url = window.URL || window.webkitURL;
  99104. var link = url.createObjectURL(fileBlob);
  99105. return link;
  99106. };
  99107. /**
  99108. * Format the given number to a specific decimal format
  99109. * @param value defines the number to format
  99110. * @param decimals defines the number of decimals to use
  99111. * @returns the formatted string
  99112. */
  99113. Tools.Format = function (value, decimals) {
  99114. if (decimals === void 0) { decimals = 2; }
  99115. return value.toFixed(decimals);
  99116. };
  99117. /**
  99118. * Checks if a given vector is inside a specific range
  99119. * @param v defines the vector to test
  99120. * @param min defines the minimum range
  99121. * @param max defines the maximum range
  99122. */
  99123. Tools.CheckExtends = function (v, min, max) {
  99124. min.minimizeInPlace(v);
  99125. max.maximizeInPlace(v);
  99126. };
  99127. /**
  99128. * Tries to copy an object by duplicating every property
  99129. * @param source defines the source object
  99130. * @param destination defines the target object
  99131. * @param doNotCopyList defines a list of properties to avoid
  99132. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  99133. */
  99134. Tools.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  99135. _deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source, destination, doNotCopyList, mustCopyList);
  99136. };
  99137. /**
  99138. * Gets a boolean indicating if the given object has no own property
  99139. * @param obj defines the object to test
  99140. * @returns true if object has no own property
  99141. */
  99142. Tools.IsEmpty = function (obj) {
  99143. for (var i in obj) {
  99144. if (obj.hasOwnProperty(i)) {
  99145. return false;
  99146. }
  99147. }
  99148. return true;
  99149. };
  99150. /**
  99151. * Function used to register events at window level
  99152. * @param events defines the events to register
  99153. */
  99154. Tools.RegisterTopRootEvents = function (events) {
  99155. for (var index = 0; index < events.length; index++) {
  99156. var event = events[index];
  99157. window.addEventListener(event.name, event.handler, false);
  99158. try {
  99159. if (window.parent) {
  99160. window.parent.addEventListener(event.name, event.handler, false);
  99161. }
  99162. }
  99163. catch (e) {
  99164. // Silently fails...
  99165. }
  99166. }
  99167. };
  99168. /**
  99169. * Function used to unregister events from window level
  99170. * @param events defines the events to unregister
  99171. */
  99172. Tools.UnregisterTopRootEvents = function (events) {
  99173. for (var index = 0; index < events.length; index++) {
  99174. var event = events[index];
  99175. window.removeEventListener(event.name, event.handler);
  99176. try {
  99177. if (window.parent) {
  99178. window.parent.removeEventListener(event.name, event.handler);
  99179. }
  99180. }
  99181. catch (e) {
  99182. // Silently fails...
  99183. }
  99184. }
  99185. };
  99186. /**
  99187. * Dumps the current bound framebuffer
  99188. * @param width defines the rendering width
  99189. * @param height defines the rendering height
  99190. * @param engine defines the hosting engine
  99191. * @param successCallback defines the callback triggered once the data are available
  99192. * @param mimeType defines the mime type of the result
  99193. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  99194. */
  99195. Tools.DumpFramebuffer = function (width, height, engine, successCallback, mimeType, fileName) {
  99196. if (mimeType === void 0) { mimeType = "image/png"; }
  99197. // Read the contents of the framebuffer
  99198. var numberOfChannelsByLine = width * 4;
  99199. var halfHeight = height / 2;
  99200. //Reading datas from WebGL
  99201. var data = engine.readPixels(0, 0, width, height);
  99202. //To flip image on Y axis.
  99203. for (var i = 0; i < halfHeight; i++) {
  99204. for (var j = 0; j < numberOfChannelsByLine; j++) {
  99205. var currentCell = j + i * numberOfChannelsByLine;
  99206. var targetLine = height - i - 1;
  99207. var targetCell = j + targetLine * numberOfChannelsByLine;
  99208. var temp = data[currentCell];
  99209. data[currentCell] = data[targetCell];
  99210. data[targetCell] = temp;
  99211. }
  99212. }
  99213. // Create a 2D canvas to store the result
  99214. if (!screenshotCanvas) {
  99215. screenshotCanvas = document.createElement('canvas');
  99216. }
  99217. screenshotCanvas.width = width;
  99218. screenshotCanvas.height = height;
  99219. var context = screenshotCanvas.getContext('2d');
  99220. if (context) {
  99221. // Copy the pixels to a 2D canvas
  99222. var imageData = context.createImageData(width, height);
  99223. var castData = (imageData.data);
  99224. castData.set(data);
  99225. context.putImageData(imageData, 0, 0);
  99226. Tools.EncodeScreenshotCanvasData(successCallback, mimeType, fileName);
  99227. }
  99228. };
  99229. /**
  99230. * Converts the canvas data to blob.
  99231. * This acts as a polyfill for browsers not supporting the to blob function.
  99232. * @param canvas Defines the canvas to extract the data from
  99233. * @param successCallback Defines the callback triggered once the data are available
  99234. * @param mimeType Defines the mime type of the result
  99235. */
  99236. Tools.ToBlob = function (canvas, successCallback, mimeType) {
  99237. if (mimeType === void 0) { mimeType = "image/png"; }
  99238. // We need HTMLCanvasElement.toBlob for HD screenshots
  99239. if (!canvas.toBlob) {
  99240. // low performance polyfill based on toDataURL (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)
  99241. canvas.toBlob = function (callback, type, quality) {
  99242. var _this = this;
  99243. setTimeout(function () {
  99244. var binStr = atob(_this.toDataURL(type, quality).split(',')[1]), len = binStr.length, arr = new Uint8Array(len);
  99245. for (var i = 0; i < len; i++) {
  99246. arr[i] = binStr.charCodeAt(i);
  99247. }
  99248. callback(new Blob([arr]));
  99249. });
  99250. };
  99251. }
  99252. canvas.toBlob(function (blob) {
  99253. successCallback(blob);
  99254. }, mimeType);
  99255. };
  99256. /**
  99257. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  99258. * @param successCallback defines the callback triggered once the data are available
  99259. * @param mimeType defines the mime type of the result
  99260. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  99261. */
  99262. Tools.EncodeScreenshotCanvasData = function (successCallback, mimeType, fileName) {
  99263. if (mimeType === void 0) { mimeType = "image/png"; }
  99264. if (successCallback) {
  99265. var base64Image = screenshotCanvas.toDataURL(mimeType);
  99266. successCallback(base64Image);
  99267. }
  99268. else {
  99269. this.ToBlob(screenshotCanvas, function (blob) {
  99270. //Creating a link if the browser have the download attribute on the a tag, to automatically start download generated image.
  99271. if (("download" in document.createElement("a"))) {
  99272. if (!fileName) {
  99273. var date = new Date();
  99274. var stringDate = (date.getFullYear() + "-" + (date.getMonth() + 1)).slice(2) + "-" + date.getDate() + "_" + date.getHours() + "-" + ('0' + date.getMinutes()).slice(-2);
  99275. fileName = "screenshot_" + stringDate + ".png";
  99276. }
  99277. Tools.Download(blob, fileName);
  99278. }
  99279. else {
  99280. var url = URL.createObjectURL(blob);
  99281. var newWindow = window.open("");
  99282. if (!newWindow) {
  99283. return;
  99284. }
  99285. var img = newWindow.document.createElement("img");
  99286. img.onload = function () {
  99287. // no longer need to read the blob so it's revoked
  99288. URL.revokeObjectURL(url);
  99289. };
  99290. img.src = url;
  99291. newWindow.document.body.appendChild(img);
  99292. }
  99293. }, mimeType);
  99294. }
  99295. };
  99296. /**
  99297. * Downloads a blob in the browser
  99298. * @param blob defines the blob to download
  99299. * @param fileName defines the name of the downloaded file
  99300. */
  99301. Tools.Download = function (blob, fileName) {
  99302. if (navigator && navigator.msSaveBlob) {
  99303. navigator.msSaveBlob(blob, fileName);
  99304. return;
  99305. }
  99306. var url = window.URL.createObjectURL(blob);
  99307. var a = document.createElement("a");
  99308. document.body.appendChild(a);
  99309. a.style.display = "none";
  99310. a.href = url;
  99311. a.download = fileName;
  99312. a.addEventListener("click", function () {
  99313. if (a.parentElement) {
  99314. a.parentElement.removeChild(a);
  99315. }
  99316. });
  99317. a.click();
  99318. window.URL.revokeObjectURL(url);
  99319. };
  99320. /**
  99321. * Captures a screenshot of the current rendering
  99322. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99323. * @param engine defines the rendering engine
  99324. * @param camera defines the source camera
  99325. * @param size This parameter can be set to a single number or to an object with the
  99326. * following (optional) properties: precision, width, height. If a single number is passed,
  99327. * it will be used for both width and height. If an object is passed, the screenshot size
  99328. * will be derived from the parameters. The precision property is a multiplier allowing
  99329. * rendering at a higher or lower resolution
  99330. * @param successCallback defines the callback receives a single parameter which contains the
  99331. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99332. * src parameter of an <img> to display it
  99333. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99334. * Check your browser for supported MIME types
  99335. */
  99336. Tools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  99337. if (mimeType === void 0) { mimeType = "image/png"; }
  99338. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  99339. };
  99340. /**
  99341. * Generates an image screenshot from the specified camera.
  99342. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99343. * @param engine The engine to use for rendering
  99344. * @param camera The camera to use for rendering
  99345. * @param size This parameter can be set to a single number or to an object with the
  99346. * following (optional) properties: precision, width, height. If a single number is passed,
  99347. * it will be used for both width and height. If an object is passed, the screenshot size
  99348. * will be derived from the parameters. The precision property is a multiplier allowing
  99349. * rendering at a higher or lower resolution
  99350. * @param successCallback The callback receives a single parameter which contains the
  99351. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99352. * src parameter of an <img> to display it
  99353. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99354. * Check your browser for supported MIME types
  99355. * @param samples Texture samples (default: 1)
  99356. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99357. * @param fileName A name for for the downloaded file.
  99358. */
  99359. Tools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  99360. if (mimeType === void 0) { mimeType = "image/png"; }
  99361. if (samples === void 0) { samples = 1; }
  99362. if (antialiasing === void 0) { antialiasing = false; }
  99363. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  99364. };
  99365. /**
  99366. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99367. * Be aware Math.random() could cause collisions, but:
  99368. * "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"
  99369. * @returns a pseudo random id
  99370. */
  99371. Tools.RandomId = function () {
  99372. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  99373. var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
  99374. return v.toString(16);
  99375. });
  99376. };
  99377. /**
  99378. * Test if the given uri is a base64 string
  99379. * @param uri The uri to test
  99380. * @return True if the uri is a base64 string or false otherwise
  99381. */
  99382. Tools.IsBase64 = function (uri) {
  99383. return uri.length < 5 ? false : uri.substr(0, 5) === "data:";
  99384. };
  99385. /**
  99386. * Decode the given base64 uri.
  99387. * @param uri The uri to decode
  99388. * @return The decoded base64 data.
  99389. */
  99390. Tools.DecodeBase64 = function (uri) {
  99391. var decodedString = atob(uri.split(",")[1]);
  99392. var bufferLength = decodedString.length;
  99393. var bufferView = new Uint8Array(new ArrayBuffer(bufferLength));
  99394. for (var i = 0; i < bufferLength; i++) {
  99395. bufferView[i] = decodedString.charCodeAt(i);
  99396. }
  99397. return bufferView.buffer;
  99398. };
  99399. Object.defineProperty(Tools, "errorsCount", {
  99400. /**
  99401. * Gets a value indicating the number of loading errors
  99402. * @ignorenaming
  99403. */
  99404. get: function () {
  99405. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].errorsCount;
  99406. },
  99407. enumerable: true,
  99408. configurable: true
  99409. });
  99410. /**
  99411. * Log a message to the console
  99412. * @param message defines the message to log
  99413. */
  99414. Tools.Log = function (message) {
  99415. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log(message);
  99416. };
  99417. /**
  99418. * Write a warning message to the console
  99419. * @param message defines the message to log
  99420. */
  99421. Tools.Warn = function (message) {
  99422. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(message);
  99423. };
  99424. /**
  99425. * Write an error message to the console
  99426. * @param message defines the message to log
  99427. */
  99428. Tools.Error = function (message) {
  99429. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error(message);
  99430. };
  99431. Object.defineProperty(Tools, "LogCache", {
  99432. /**
  99433. * Gets current log cache (list of logs)
  99434. */
  99435. get: function () {
  99436. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogCache;
  99437. },
  99438. enumerable: true,
  99439. configurable: true
  99440. });
  99441. /**
  99442. * Clears the log cache
  99443. */
  99444. Tools.ClearLogCache = function () {
  99445. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ClearLogCache();
  99446. };
  99447. Object.defineProperty(Tools, "LogLevels", {
  99448. /**
  99449. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99450. */
  99451. set: function (level) {
  99452. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogLevels = level;
  99453. },
  99454. enumerable: true,
  99455. configurable: true
  99456. });
  99457. /**
  99458. * Checks if the loaded document was accessed via `file:`-Protocol.
  99459. * @returns boolean
  99460. */
  99461. Tools.IsFileURL = function () {
  99462. return location.protocol === "file:";
  99463. };
  99464. Object.defineProperty(Tools, "PerformanceLogLevel", {
  99465. /**
  99466. * Sets the current performance log level
  99467. */
  99468. set: function (level) {
  99469. if ((level & Tools.PerformanceUserMarkLogLevel) === Tools.PerformanceUserMarkLogLevel) {
  99470. Tools.StartPerformanceCounter = Tools._StartUserMark;
  99471. Tools.EndPerformanceCounter = Tools._EndUserMark;
  99472. return;
  99473. }
  99474. if ((level & Tools.PerformanceConsoleLogLevel) === Tools.PerformanceConsoleLogLevel) {
  99475. Tools.StartPerformanceCounter = Tools._StartPerformanceConsole;
  99476. Tools.EndPerformanceCounter = Tools._EndPerformanceConsole;
  99477. return;
  99478. }
  99479. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  99480. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  99481. },
  99482. enumerable: true,
  99483. configurable: true
  99484. });
  99485. Tools._StartPerformanceCounterDisabled = function (counterName, condition) {
  99486. };
  99487. Tools._EndPerformanceCounterDisabled = function (counterName, condition) {
  99488. };
  99489. Tools._StartUserMark = function (counterName, condition) {
  99490. if (condition === void 0) { condition = true; }
  99491. if (!Tools._performance) {
  99492. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  99493. return;
  99494. }
  99495. Tools._performance = window.performance;
  99496. }
  99497. if (!condition || !Tools._performance.mark) {
  99498. return;
  99499. }
  99500. Tools._performance.mark(counterName + "-Begin");
  99501. };
  99502. Tools._EndUserMark = function (counterName, condition) {
  99503. if (condition === void 0) { condition = true; }
  99504. if (!condition || !Tools._performance.mark) {
  99505. return;
  99506. }
  99507. Tools._performance.mark(counterName + "-End");
  99508. Tools._performance.measure(counterName, counterName + "-Begin", counterName + "-End");
  99509. };
  99510. Tools._StartPerformanceConsole = function (counterName, condition) {
  99511. if (condition === void 0) { condition = true; }
  99512. if (!condition) {
  99513. return;
  99514. }
  99515. Tools._StartUserMark(counterName, condition);
  99516. if (console.time) {
  99517. console.time(counterName);
  99518. }
  99519. };
  99520. Tools._EndPerformanceConsole = function (counterName, condition) {
  99521. if (condition === void 0) { condition = true; }
  99522. if (!condition) {
  99523. return;
  99524. }
  99525. Tools._EndUserMark(counterName, condition);
  99526. if (console.time) {
  99527. console.timeEnd(counterName);
  99528. }
  99529. };
  99530. /**
  99531. * Injects the @see CustomRequestHeaders into the given request
  99532. * @param request the request that should be used for injection
  99533. */
  99534. Tools.InjectCustomRequestHeaders = function (request) {
  99535. for (var key in Tools.CustomRequestHeaders) {
  99536. var val = Tools.CustomRequestHeaders[key];
  99537. if (val) {
  99538. request.setRequestHeader(key, val);
  99539. }
  99540. }
  99541. };
  99542. Object.defineProperty(Tools, "Now", {
  99543. /**
  99544. * Gets either window.performance.now() if supported or Date.now() else
  99545. */
  99546. get: function () {
  99547. return _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  99548. },
  99549. enumerable: true,
  99550. configurable: true
  99551. });
  99552. /**
  99553. * This method will return the name of the class used to create the instance of the given object.
  99554. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  99555. * @param object the object to get the class name from
  99556. * @param isType defines if the object is actually a type
  99557. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  99558. */
  99559. Tools.GetClassName = function (object, isType) {
  99560. if (isType === void 0) { isType = false; }
  99561. var name = null;
  99562. if (!isType && object.getClassName) {
  99563. name = object.getClassName();
  99564. }
  99565. else {
  99566. if (object instanceof Object) {
  99567. var classObj = isType ? object : Object.getPrototypeOf(object);
  99568. name = classObj.constructor["__bjsclassName__"];
  99569. }
  99570. if (!name) {
  99571. name = typeof object;
  99572. }
  99573. }
  99574. return name;
  99575. };
  99576. /**
  99577. * Gets the first element of an array satisfying a given predicate
  99578. * @param array defines the array to browse
  99579. * @param predicate defines the predicate to use
  99580. * @returns null if not found or the element
  99581. */
  99582. Tools.First = function (array, predicate) {
  99583. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  99584. var el = array_1[_i];
  99585. if (predicate(el)) {
  99586. return el;
  99587. }
  99588. }
  99589. return null;
  99590. };
  99591. /**
  99592. * This method will return the name of the full name of the class, including its owning module (if any).
  99593. * 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).
  99594. * @param object the object to get the class name from
  99595. * @param isType defines if the object is actually a type
  99596. * @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.
  99597. * @ignorenaming
  99598. */
  99599. Tools.getFullClassName = function (object, isType) {
  99600. if (isType === void 0) { isType = false; }
  99601. var className = null;
  99602. var moduleName = null;
  99603. if (!isType && object.getClassName) {
  99604. className = object.getClassName();
  99605. }
  99606. else {
  99607. if (object instanceof Object) {
  99608. var classObj = isType ? object : Object.getPrototypeOf(object);
  99609. className = classObj.constructor["__bjsclassName__"];
  99610. moduleName = classObj.constructor["__bjsmoduleName__"];
  99611. }
  99612. if (!className) {
  99613. className = typeof object;
  99614. }
  99615. }
  99616. if (!className) {
  99617. return null;
  99618. }
  99619. return ((moduleName != null) ? (moduleName + ".") : "") + className;
  99620. };
  99621. /**
  99622. * Returns a promise that resolves after the given amount of time.
  99623. * @param delay Number of milliseconds to delay
  99624. * @returns Promise that resolves after the given amount of time
  99625. */
  99626. Tools.DelayAsync = function (delay) {
  99627. return new Promise(function (resolve) {
  99628. setTimeout(function () {
  99629. resolve();
  99630. }, delay);
  99631. });
  99632. };
  99633. /**
  99634. * Gets the current gradient from an array of IValueGradient
  99635. * @param ratio defines the current ratio to get
  99636. * @param gradients defines the array of IValueGradient
  99637. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  99638. */
  99639. Tools.GetCurrentGradient = function (ratio, gradients, updateFunc) {
  99640. for (var gradientIndex = 0; gradientIndex < gradients.length - 1; gradientIndex++) {
  99641. var currentGradient = gradients[gradientIndex];
  99642. var nextGradient = gradients[gradientIndex + 1];
  99643. if (ratio >= currentGradient.gradient && ratio <= nextGradient.gradient) {
  99644. var scale = (ratio - currentGradient.gradient) / (nextGradient.gradient - currentGradient.gradient);
  99645. updateFunc(currentGradient, nextGradient, scale);
  99646. return;
  99647. }
  99648. }
  99649. // Use last index if over
  99650. var lastIndex = gradients.length - 1;
  99651. updateFunc(gradients[lastIndex], gradients[lastIndex], 1.0);
  99652. };
  99653. /**
  99654. * Gets or sets the base URL to use to load assets
  99655. */
  99656. Tools.BaseUrl = "";
  99657. /**
  99658. * Enable/Disable Custom HTTP Request Headers globally.
  99659. * default = false
  99660. * @see CustomRequestHeaders
  99661. */
  99662. Tools.UseCustomRequestHeaders = false;
  99663. /**
  99664. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  99665. * i.e. when loading files, where the server/service expects an Authorization header.
  99666. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  99667. */
  99668. Tools.CustomRequestHeaders = {};
  99669. /**
  99670. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  99671. */
  99672. Tools.DefaultRetryStrategy = RetryStrategy.ExponentialBackoff();
  99673. /**
  99674. * Default behaviour for cors in the application.
  99675. * It can be a string if the expected behavior is identical in the entire app.
  99676. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  99677. */
  99678. Tools.CorsBehavior = "anonymous";
  99679. /**
  99680. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  99681. * @ignorenaming
  99682. */
  99683. Tools.UseFallbackTexture = true;
  99684. /**
  99685. * Use this object to register external classes like custom textures or material
  99686. * to allow the laoders to instantiate them
  99687. */
  99688. Tools.RegisteredExternalClasses = {};
  99689. /**
  99690. * Texture content used if a texture cannot loaded
  99691. * @ignorenaming
  99692. */
  99693. 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";
  99694. Tools._tmpFloatArray = new Float32Array(1);
  99695. /**
  99696. * Extracts text content from a DOM element hierarchy
  99697. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  99698. */
  99699. Tools.GetDOMTextContent = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].GetDOMTextContent;
  99700. /**
  99701. * Gets or sets a function used to pre-process url before using them to load assets
  99702. */
  99703. Tools.PreprocessUrl = function (url) {
  99704. return url;
  99705. };
  99706. // Logs
  99707. /**
  99708. * No log
  99709. */
  99710. Tools.NoneLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].NoneLogLevel;
  99711. /**
  99712. * Only message logs
  99713. */
  99714. Tools.MessageLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].MessageLogLevel;
  99715. /**
  99716. * Only warning logs
  99717. */
  99718. Tools.WarningLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].WarningLogLevel;
  99719. /**
  99720. * Only error logs
  99721. */
  99722. Tools.ErrorLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ErrorLogLevel;
  99723. /**
  99724. * All logs
  99725. */
  99726. Tools.AllLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].AllLogLevel;
  99727. /**
  99728. * Checks if the window object exists
  99729. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  99730. */
  99731. Tools.IsWindowObjectExist = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist;
  99732. // Performances
  99733. /**
  99734. * No performance log
  99735. */
  99736. Tools.PerformanceNoneLogLevel = 0;
  99737. /**
  99738. * Use user marks to log performance
  99739. */
  99740. Tools.PerformanceUserMarkLogLevel = 1;
  99741. /**
  99742. * Log performance to the console
  99743. */
  99744. Tools.PerformanceConsoleLogLevel = 2;
  99745. /**
  99746. * Starts a performance counter
  99747. */
  99748. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  99749. /**
  99750. * Ends a specific performance coutner
  99751. */
  99752. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  99753. return Tools;
  99754. }());
  99755. /**
  99756. * This class is used to track a performance counter which is number based.
  99757. * The user has access to many properties which give statistics of different nature.
  99758. *
  99759. * The implementer can track two kinds of Performance Counter: time and count.
  99760. * 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.
  99761. * 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.
  99762. */
  99763. var PerfCounter = /** @class */ (function () {
  99764. /**
  99765. * Creates a new counter
  99766. */
  99767. function PerfCounter() {
  99768. this._startMonitoringTime = 0;
  99769. this._min = 0;
  99770. this._max = 0;
  99771. this._average = 0;
  99772. this._lastSecAverage = 0;
  99773. this._current = 0;
  99774. this._totalValueCount = 0;
  99775. this._totalAccumulated = 0;
  99776. this._lastSecAccumulated = 0;
  99777. this._lastSecTime = 0;
  99778. this._lastSecValueCount = 0;
  99779. }
  99780. Object.defineProperty(PerfCounter.prototype, "min", {
  99781. /**
  99782. * Returns the smallest value ever
  99783. */
  99784. get: function () {
  99785. return this._min;
  99786. },
  99787. enumerable: true,
  99788. configurable: true
  99789. });
  99790. Object.defineProperty(PerfCounter.prototype, "max", {
  99791. /**
  99792. * Returns the biggest value ever
  99793. */
  99794. get: function () {
  99795. return this._max;
  99796. },
  99797. enumerable: true,
  99798. configurable: true
  99799. });
  99800. Object.defineProperty(PerfCounter.prototype, "average", {
  99801. /**
  99802. * Returns the average value since the performance counter is running
  99803. */
  99804. get: function () {
  99805. return this._average;
  99806. },
  99807. enumerable: true,
  99808. configurable: true
  99809. });
  99810. Object.defineProperty(PerfCounter.prototype, "lastSecAverage", {
  99811. /**
  99812. * Returns the average value of the last second the counter was monitored
  99813. */
  99814. get: function () {
  99815. return this._lastSecAverage;
  99816. },
  99817. enumerable: true,
  99818. configurable: true
  99819. });
  99820. Object.defineProperty(PerfCounter.prototype, "current", {
  99821. /**
  99822. * Returns the current value
  99823. */
  99824. get: function () {
  99825. return this._current;
  99826. },
  99827. enumerable: true,
  99828. configurable: true
  99829. });
  99830. Object.defineProperty(PerfCounter.prototype, "total", {
  99831. /**
  99832. * Gets the accumulated total
  99833. */
  99834. get: function () {
  99835. return this._totalAccumulated;
  99836. },
  99837. enumerable: true,
  99838. configurable: true
  99839. });
  99840. Object.defineProperty(PerfCounter.prototype, "count", {
  99841. /**
  99842. * Gets the total value count
  99843. */
  99844. get: function () {
  99845. return this._totalValueCount;
  99846. },
  99847. enumerable: true,
  99848. configurable: true
  99849. });
  99850. /**
  99851. * Call this method to start monitoring a new frame.
  99852. * 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.
  99853. */
  99854. PerfCounter.prototype.fetchNewFrame = function () {
  99855. this._totalValueCount++;
  99856. this._current = 0;
  99857. this._lastSecValueCount++;
  99858. };
  99859. /**
  99860. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  99861. * @param newCount the count value to add to the monitored count
  99862. * @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.
  99863. */
  99864. PerfCounter.prototype.addCount = function (newCount, fetchResult) {
  99865. if (!PerfCounter.Enabled) {
  99866. return;
  99867. }
  99868. this._current += newCount;
  99869. if (fetchResult) {
  99870. this._fetchResult();
  99871. }
  99872. };
  99873. /**
  99874. * Start monitoring this performance counter
  99875. */
  99876. PerfCounter.prototype.beginMonitoring = function () {
  99877. if (!PerfCounter.Enabled) {
  99878. return;
  99879. }
  99880. this._startMonitoringTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  99881. };
  99882. /**
  99883. * Compute the time lapsed since the previous beginMonitoring() call.
  99884. * @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
  99885. */
  99886. PerfCounter.prototype.endMonitoring = function (newFrame) {
  99887. if (newFrame === void 0) { newFrame = true; }
  99888. if (!PerfCounter.Enabled) {
  99889. return;
  99890. }
  99891. if (newFrame) {
  99892. this.fetchNewFrame();
  99893. }
  99894. var currentTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  99895. this._current = currentTime - this._startMonitoringTime;
  99896. if (newFrame) {
  99897. this._fetchResult();
  99898. }
  99899. };
  99900. PerfCounter.prototype._fetchResult = function () {
  99901. this._totalAccumulated += this._current;
  99902. this._lastSecAccumulated += this._current;
  99903. // Min/Max update
  99904. this._min = Math.min(this._min, this._current);
  99905. this._max = Math.max(this._max, this._current);
  99906. this._average = this._totalAccumulated / this._totalValueCount;
  99907. // Reset last sec?
  99908. var now = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  99909. if ((now - this._lastSecTime) > 1000) {
  99910. this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount;
  99911. this._lastSecTime = now;
  99912. this._lastSecAccumulated = 0;
  99913. this._lastSecValueCount = 0;
  99914. }
  99915. };
  99916. /**
  99917. * Gets or sets a global boolean to turn on and off all the counters
  99918. */
  99919. PerfCounter.Enabled = true;
  99920. return PerfCounter;
  99921. }());
  99922. /**
  99923. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  99924. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  99925. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  99926. * @param name The name of the class, case should be preserved
  99927. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  99928. */
  99929. function className(name, module) {
  99930. return function (target) {
  99931. target["__bjsclassName__"] = name;
  99932. target["__bjsmoduleName__"] = (module != null) ? module : null;
  99933. };
  99934. }
  99935. /**
  99936. * An implementation of a loop for asynchronous functions.
  99937. */
  99938. var AsyncLoop = /** @class */ (function () {
  99939. /**
  99940. * Constructor.
  99941. * @param iterations the number of iterations.
  99942. * @param func the function to run each iteration
  99943. * @param successCallback the callback that will be called upon succesful execution
  99944. * @param offset starting offset.
  99945. */
  99946. function AsyncLoop(
  99947. /**
  99948. * Defines the number of iterations for the loop
  99949. */
  99950. iterations, func, successCallback, offset) {
  99951. if (offset === void 0) { offset = 0; }
  99952. this.iterations = iterations;
  99953. this.index = offset - 1;
  99954. this._done = false;
  99955. this._fn = func;
  99956. this._successCallback = successCallback;
  99957. }
  99958. /**
  99959. * Execute the next iteration. Must be called after the last iteration was finished.
  99960. */
  99961. AsyncLoop.prototype.executeNext = function () {
  99962. if (!this._done) {
  99963. if (this.index + 1 < this.iterations) {
  99964. ++this.index;
  99965. this._fn(this);
  99966. }
  99967. else {
  99968. this.breakLoop();
  99969. }
  99970. }
  99971. };
  99972. /**
  99973. * Break the loop and run the success callback.
  99974. */
  99975. AsyncLoop.prototype.breakLoop = function () {
  99976. this._done = true;
  99977. this._successCallback();
  99978. };
  99979. /**
  99980. * Create and run an async loop.
  99981. * @param iterations the number of iterations.
  99982. * @param fn the function to run each iteration
  99983. * @param successCallback the callback that will be called upon succesful execution
  99984. * @param offset starting offset.
  99985. * @returns the created async loop object
  99986. */
  99987. AsyncLoop.Run = function (iterations, fn, successCallback, offset) {
  99988. if (offset === void 0) { offset = 0; }
  99989. var loop = new AsyncLoop(iterations, fn, successCallback, offset);
  99990. loop.executeNext();
  99991. return loop;
  99992. };
  99993. /**
  99994. * A for-loop that will run a given number of iterations synchronous and the rest async.
  99995. * @param iterations total number of iterations
  99996. * @param syncedIterations number of synchronous iterations in each async iteration.
  99997. * @param fn the function to call each iteration.
  99998. * @param callback a success call back that will be called when iterating stops.
  99999. * @param breakFunction a break condition (optional)
  100000. * @param timeout timeout settings for the setTimeout function. default - 0.
  100001. * @returns the created async loop object
  100002. */
  100003. AsyncLoop.SyncAsyncForLoop = function (iterations, syncedIterations, fn, callback, breakFunction, timeout) {
  100004. if (timeout === void 0) { timeout = 0; }
  100005. return AsyncLoop.Run(Math.ceil(iterations / syncedIterations), function (loop) {
  100006. if (breakFunction && breakFunction()) {
  100007. loop.breakLoop();
  100008. }
  100009. else {
  100010. setTimeout(function () {
  100011. for (var i = 0; i < syncedIterations; ++i) {
  100012. var iteration = (loop.index * syncedIterations) + i;
  100013. if (iteration >= iterations) {
  100014. break;
  100015. }
  100016. fn(iteration);
  100017. if (breakFunction && breakFunction()) {
  100018. loop.breakLoop();
  100019. break;
  100020. }
  100021. }
  100022. loop.executeNext();
  100023. }, timeout);
  100024. }
  100025. }, callback);
  100026. };
  100027. return AsyncLoop;
  100028. }());
  100029. /***/ }),
  100030. /***/ "./Misc/typeStore.ts":
  100031. /*!***************************!*\
  100032. !*** ./Misc/typeStore.ts ***!
  100033. \***************************/
  100034. /*! exports provided: _TypeStore */
  100035. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100036. "use strict";
  100037. __webpack_require__.r(__webpack_exports__);
  100038. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _TypeStore; });
  100039. /** @hidden */
  100040. var _TypeStore = /** @class */ (function () {
  100041. function _TypeStore() {
  100042. }
  100043. /** @hidden */
  100044. _TypeStore.GetClass = function (fqdn) {
  100045. if (this.RegisteredTypes && this.RegisteredTypes[fqdn]) {
  100046. return this.RegisteredTypes[fqdn];
  100047. }
  100048. return null;
  100049. };
  100050. /** @hidden */
  100051. _TypeStore.RegisteredTypes = {};
  100052. return _TypeStore;
  100053. }());
  100054. /***/ }),
  100055. /***/ "./Misc/videoRecorder.ts":
  100056. /*!*******************************!*\
  100057. !*** ./Misc/videoRecorder.ts ***!
  100058. \*******************************/
  100059. /*! exports provided: VideoRecorder */
  100060. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100061. "use strict";
  100062. __webpack_require__.r(__webpack_exports__);
  100063. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return VideoRecorder; });
  100064. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  100065. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  100066. /**
  100067. * This can helps recording videos from BabylonJS.
  100068. * This is based on the available WebRTC functionalities of the browser.
  100069. *
  100070. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  100071. */
  100072. var VideoRecorder = /** @class */ (function () {
  100073. /**
  100074. * Create a new VideoCapture object which can help converting what you see in Babylon to
  100075. * a video file.
  100076. * @param engine Defines the BabylonJS Engine you wish to record
  100077. * @param options Defines options that can be used to customized the capture
  100078. */
  100079. function VideoRecorder(engine, options) {
  100080. if (options === void 0) { options = null; }
  100081. if (!VideoRecorder.IsSupported(engine)) {
  100082. throw "Your browser does not support recording so far.";
  100083. }
  100084. var canvas = engine.getRenderingCanvas();
  100085. if (!canvas) {
  100086. throw "The babylon engine must have a canvas to be recorded";
  100087. }
  100088. this._canvas = canvas;
  100089. this._canvas.isRecording = false;
  100090. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, VideoRecorder._defaultOptions, options);
  100091. var stream = this._canvas.captureStream(this._options.fps);
  100092. this._mediaRecorder = new MediaRecorder(stream, { mimeType: this._options.mimeType });
  100093. this._mediaRecorder.ondataavailable = this._handleDataAvailable.bind(this);
  100094. this._mediaRecorder.onerror = this._handleError.bind(this);
  100095. this._mediaRecorder.onstop = this._handleStop.bind(this);
  100096. }
  100097. /**
  100098. * Returns wehther or not the VideoRecorder is available in your browser.
  100099. * @param engine Defines the Babylon Engine to check the support for
  100100. * @returns true if supported otherwise false
  100101. */
  100102. VideoRecorder.IsSupported = function (engine) {
  100103. var canvas = engine.getRenderingCanvas();
  100104. return (!!canvas && typeof canvas.captureStream === "function");
  100105. };
  100106. Object.defineProperty(VideoRecorder.prototype, "isRecording", {
  100107. /**
  100108. * True wether a recording is already in progress.
  100109. */
  100110. get: function () {
  100111. return !!this._canvas && this._canvas.isRecording;
  100112. },
  100113. enumerable: true,
  100114. configurable: true
  100115. });
  100116. /**
  100117. * Stops the current recording before the default capture timeout passed in the startRecording
  100118. * functions.
  100119. */
  100120. VideoRecorder.prototype.stopRecording = function () {
  100121. if (!this._canvas || !this._mediaRecorder) {
  100122. return;
  100123. }
  100124. if (!this.isRecording) {
  100125. return;
  100126. }
  100127. this._canvas.isRecording = false;
  100128. this._mediaRecorder.stop();
  100129. };
  100130. /**
  100131. * Starts recording the canvas for a max duration specified in parameters.
  100132. * @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.
  100133. * @param maxDuration Defines the maximum recording time in seconds.
  100134. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  100135. * @return a promise callback at the end of the recording with the video data in Blob.
  100136. */
  100137. VideoRecorder.prototype.startRecording = function (fileName, maxDuration) {
  100138. var _this = this;
  100139. if (fileName === void 0) { fileName = "babylonjs.webm"; }
  100140. if (maxDuration === void 0) { maxDuration = 7; }
  100141. if (!this._canvas || !this._mediaRecorder) {
  100142. throw "Recorder has already been disposed";
  100143. }
  100144. if (this.isRecording) {
  100145. throw "Recording already in progress";
  100146. }
  100147. if (maxDuration > 0) {
  100148. setTimeout(function () {
  100149. _this.stopRecording();
  100150. }, maxDuration * 1000);
  100151. }
  100152. this._fileName = fileName;
  100153. this._recordedChunks = [];
  100154. this._resolve = null;
  100155. this._reject = null;
  100156. this._canvas.isRecording = true;
  100157. this._mediaRecorder.start(this._options.recordChunckSize);
  100158. return new Promise(function (resolve, reject) {
  100159. _this._resolve = resolve;
  100160. _this._reject = reject;
  100161. });
  100162. };
  100163. /**
  100164. * Releases internal resources used during the recording.
  100165. */
  100166. VideoRecorder.prototype.dispose = function () {
  100167. this._canvas = null;
  100168. this._mediaRecorder = null;
  100169. this._recordedChunks = [];
  100170. this._fileName = null;
  100171. this._resolve = null;
  100172. this._reject = null;
  100173. };
  100174. VideoRecorder.prototype._handleDataAvailable = function (event) {
  100175. if (event.data.size > 0) {
  100176. this._recordedChunks.push(event.data);
  100177. }
  100178. };
  100179. VideoRecorder.prototype._handleError = function (event) {
  100180. this.stopRecording();
  100181. if (this._reject) {
  100182. this._reject(event.error);
  100183. }
  100184. else {
  100185. throw new event.error();
  100186. }
  100187. };
  100188. VideoRecorder.prototype._handleStop = function () {
  100189. this.stopRecording();
  100190. var superBuffer = new Blob(this._recordedChunks);
  100191. if (this._resolve) {
  100192. this._resolve(superBuffer);
  100193. }
  100194. window.URL.createObjectURL(superBuffer);
  100195. if (this._fileName) {
  100196. _tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Download(superBuffer, this._fileName);
  100197. }
  100198. };
  100199. VideoRecorder._defaultOptions = {
  100200. mimeType: "video/webm",
  100201. fps: 25,
  100202. recordChunckSize: 3000
  100203. };
  100204. return VideoRecorder;
  100205. }());
  100206. /***/ }),
  100207. /***/ "./Misc/virtualJoystick.ts":
  100208. /*!*********************************!*\
  100209. !*** ./Misc/virtualJoystick.ts ***!
  100210. \*********************************/
  100211. /*! exports provided: JoystickAxis, VirtualJoystick */
  100212. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100213. "use strict";
  100214. __webpack_require__.r(__webpack_exports__);
  100215. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return JoystickAxis; });
  100216. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return VirtualJoystick; });
  100217. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  100218. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  100219. // Mainly based on these 2 articles :
  100220. // 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
  100221. // & on Seb Lee-Delisle original work: http://seb.ly/2011/04/multi-touch-game-controller-in-javascripthtml5-for-ipad/
  100222. /**
  100223. * Defines the potential axis of a Joystick
  100224. */
  100225. var JoystickAxis;
  100226. (function (JoystickAxis) {
  100227. /** X axis */
  100228. JoystickAxis[JoystickAxis["X"] = 0] = "X";
  100229. /** Y axis */
  100230. JoystickAxis[JoystickAxis["Y"] = 1] = "Y";
  100231. /** Z axis */
  100232. JoystickAxis[JoystickAxis["Z"] = 2] = "Z";
  100233. })(JoystickAxis || (JoystickAxis = {}));
  100234. /**
  100235. * Class used to define virtual joystick (used in touch mode)
  100236. */
  100237. var VirtualJoystick = /** @class */ (function () {
  100238. /**
  100239. * Creates a new virtual joystick
  100240. * @param leftJoystick defines that the joystick is for left hand (false by default)
  100241. */
  100242. function VirtualJoystick(leftJoystick) {
  100243. var _this = this;
  100244. if (leftJoystick) {
  100245. this._leftJoystick = true;
  100246. }
  100247. else {
  100248. this._leftJoystick = false;
  100249. }
  100250. VirtualJoystick._globalJoystickIndex++;
  100251. // By default left & right arrow keys are moving the X
  100252. // and up & down keys are moving the Y
  100253. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  100254. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  100255. this.reverseLeftRight = false;
  100256. this.reverseUpDown = false;
  100257. // collections of pointers
  100258. this._touches = new _stringDictionary__WEBPACK_IMPORTED_MODULE_1__["StringDictionary"]();
  100259. this.deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  100260. this._joystickSensibility = 25;
  100261. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  100262. this._onResize = function (evt) {
  100263. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  100264. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  100265. if (VirtualJoystick.Canvas) {
  100266. VirtualJoystick.Canvas.width = VirtualJoystick.vjCanvasWidth;
  100267. VirtualJoystick.Canvas.height = VirtualJoystick.vjCanvasHeight;
  100268. }
  100269. VirtualJoystick.halfWidth = VirtualJoystick.vjCanvasWidth / 2;
  100270. };
  100271. // injecting a canvas element on top of the canvas 3D game
  100272. if (!VirtualJoystick.Canvas) {
  100273. window.addEventListener("resize", this._onResize, false);
  100274. VirtualJoystick.Canvas = document.createElement("canvas");
  100275. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  100276. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  100277. VirtualJoystick.Canvas.width = window.innerWidth;
  100278. VirtualJoystick.Canvas.height = window.innerHeight;
  100279. VirtualJoystick.Canvas.style.width = "100%";
  100280. VirtualJoystick.Canvas.style.height = "100%";
  100281. VirtualJoystick.Canvas.style.position = "absolute";
  100282. VirtualJoystick.Canvas.style.backgroundColor = "transparent";
  100283. VirtualJoystick.Canvas.style.top = "0px";
  100284. VirtualJoystick.Canvas.style.left = "0px";
  100285. VirtualJoystick.Canvas.style.zIndex = "5";
  100286. VirtualJoystick.Canvas.style.msTouchAction = "none";
  100287. // Support for jQuery PEP polyfill
  100288. VirtualJoystick.Canvas.setAttribute("touch-action", "none");
  100289. var context = VirtualJoystick.Canvas.getContext('2d');
  100290. if (!context) {
  100291. throw new Error("Unable to create canvas for virtual joystick");
  100292. }
  100293. VirtualJoystick.vjCanvasContext = context;
  100294. VirtualJoystick.vjCanvasContext.strokeStyle = "#ffffff";
  100295. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  100296. document.body.appendChild(VirtualJoystick.Canvas);
  100297. }
  100298. VirtualJoystick.halfWidth = VirtualJoystick.Canvas.width / 2;
  100299. this.pressed = false;
  100300. // default joystick color
  100301. this._joystickColor = "cyan";
  100302. this._joystickPointerID = -1;
  100303. // current joystick position
  100304. this._joystickPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  100305. this._joystickPreviousPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  100306. // origin joystick position
  100307. this._joystickPointerStartPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  100308. this._deltaJoystickVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  100309. this._onPointerDownHandlerRef = function (evt) {
  100310. _this._onPointerDown(evt);
  100311. };
  100312. this._onPointerMoveHandlerRef = function (evt) {
  100313. _this._onPointerMove(evt);
  100314. };
  100315. this._onPointerUpHandlerRef = function (evt) {
  100316. _this._onPointerUp(evt);
  100317. };
  100318. VirtualJoystick.Canvas.addEventListener('pointerdown', this._onPointerDownHandlerRef, false);
  100319. VirtualJoystick.Canvas.addEventListener('pointermove', this._onPointerMoveHandlerRef, false);
  100320. VirtualJoystick.Canvas.addEventListener('pointerup', this._onPointerUpHandlerRef, false);
  100321. VirtualJoystick.Canvas.addEventListener('pointerout', this._onPointerUpHandlerRef, false);
  100322. VirtualJoystick.Canvas.addEventListener("contextmenu", function (evt) {
  100323. evt.preventDefault(); // Disables system menu
  100324. }, false);
  100325. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  100326. }
  100327. /**
  100328. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  100329. * @param newJoystickSensibility defines the new sensibility
  100330. */
  100331. VirtualJoystick.prototype.setJoystickSensibility = function (newJoystickSensibility) {
  100332. this._joystickSensibility = newJoystickSensibility;
  100333. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  100334. };
  100335. VirtualJoystick.prototype._onPointerDown = function (e) {
  100336. var positionOnScreenCondition;
  100337. e.preventDefault();
  100338. if (this._leftJoystick === true) {
  100339. positionOnScreenCondition = (e.clientX < VirtualJoystick.halfWidth);
  100340. }
  100341. else {
  100342. positionOnScreenCondition = (e.clientX > VirtualJoystick.halfWidth);
  100343. }
  100344. if (positionOnScreenCondition && this._joystickPointerID < 0) {
  100345. // First contact will be dedicated to the virtual joystick
  100346. this._joystickPointerID = e.pointerId;
  100347. this._joystickPointerStartPos.x = e.clientX;
  100348. this._joystickPointerStartPos.y = e.clientY;
  100349. this._joystickPointerPos = this._joystickPointerStartPos.clone();
  100350. this._joystickPreviousPointerPos = this._joystickPointerStartPos.clone();
  100351. this._deltaJoystickVector.x = 0;
  100352. this._deltaJoystickVector.y = 0;
  100353. this.pressed = true;
  100354. this._touches.add(e.pointerId.toString(), e);
  100355. }
  100356. else {
  100357. // You can only trigger the action buttons with a joystick declared
  100358. if (VirtualJoystick._globalJoystickIndex < 2 && this._action) {
  100359. this._action();
  100360. this._touches.add(e.pointerId.toString(), { x: e.clientX, y: e.clientY, prevX: e.clientX, prevY: e.clientY });
  100361. }
  100362. }
  100363. };
  100364. VirtualJoystick.prototype._onPointerMove = function (e) {
  100365. // If the current pointer is the one associated to the joystick (first touch contact)
  100366. if (this._joystickPointerID == e.pointerId) {
  100367. this._joystickPointerPos.x = e.clientX;
  100368. this._joystickPointerPos.y = e.clientY;
  100369. this._deltaJoystickVector = this._joystickPointerPos.clone();
  100370. this._deltaJoystickVector = this._deltaJoystickVector.subtract(this._joystickPointerStartPos);
  100371. var directionLeftRight = this.reverseLeftRight ? -1 : 1;
  100372. var deltaJoystickX = directionLeftRight * this._deltaJoystickVector.x / this._inversedSensibility;
  100373. switch (this._axisTargetedByLeftAndRight) {
  100374. case JoystickAxis.X:
  100375. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickX));
  100376. break;
  100377. case JoystickAxis.Y:
  100378. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickX));
  100379. break;
  100380. case JoystickAxis.Z:
  100381. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickX));
  100382. break;
  100383. }
  100384. var directionUpDown = this.reverseUpDown ? 1 : -1;
  100385. var deltaJoystickY = directionUpDown * this._deltaJoystickVector.y / this._inversedSensibility;
  100386. switch (this._axisTargetedByUpAndDown) {
  100387. case JoystickAxis.X:
  100388. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickY));
  100389. break;
  100390. case JoystickAxis.Y:
  100391. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickY));
  100392. break;
  100393. case JoystickAxis.Z:
  100394. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickY));
  100395. break;
  100396. }
  100397. }
  100398. else {
  100399. var data = this._touches.get(e.pointerId.toString());
  100400. if (data) {
  100401. data.x = e.clientX;
  100402. data.y = e.clientY;
  100403. }
  100404. }
  100405. };
  100406. VirtualJoystick.prototype._onPointerUp = function (e) {
  100407. if (this._joystickPointerID == e.pointerId) {
  100408. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPointerStartPos.x - 64, this._joystickPointerStartPos.y - 64, 128, 128);
  100409. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x - 42, this._joystickPreviousPointerPos.y - 42, 84, 84);
  100410. this._joystickPointerID = -1;
  100411. this.pressed = false;
  100412. }
  100413. else {
  100414. var touch = this._touches.get(e.pointerId.toString());
  100415. if (touch) {
  100416. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  100417. }
  100418. }
  100419. this._deltaJoystickVector.x = 0;
  100420. this._deltaJoystickVector.y = 0;
  100421. this._touches.remove(e.pointerId.toString());
  100422. };
  100423. /**
  100424. * Change the color of the virtual joystick
  100425. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  100426. */
  100427. VirtualJoystick.prototype.setJoystickColor = function (newColor) {
  100428. this._joystickColor = newColor;
  100429. };
  100430. /**
  100431. * Defines a callback to call when the joystick is touched
  100432. * @param action defines the callback
  100433. */
  100434. VirtualJoystick.prototype.setActionOnTouch = function (action) {
  100435. this._action = action;
  100436. };
  100437. /**
  100438. * Defines which axis you'd like to control for left & right
  100439. * @param axis defines the axis to use
  100440. */
  100441. VirtualJoystick.prototype.setAxisForLeftRight = function (axis) {
  100442. switch (axis) {
  100443. case JoystickAxis.X:
  100444. case JoystickAxis.Y:
  100445. case JoystickAxis.Z:
  100446. this._axisTargetedByLeftAndRight = axis;
  100447. break;
  100448. default:
  100449. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  100450. break;
  100451. }
  100452. };
  100453. /**
  100454. * Defines which axis you'd like to control for up & down
  100455. * @param axis defines the axis to use
  100456. */
  100457. VirtualJoystick.prototype.setAxisForUpDown = function (axis) {
  100458. switch (axis) {
  100459. case JoystickAxis.X:
  100460. case JoystickAxis.Y:
  100461. case JoystickAxis.Z:
  100462. this._axisTargetedByUpAndDown = axis;
  100463. break;
  100464. default:
  100465. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  100466. break;
  100467. }
  100468. };
  100469. VirtualJoystick.prototype._drawVirtualJoystick = function () {
  100470. var _this = this;
  100471. if (this.pressed) {
  100472. this._touches.forEach(function (key, touch) {
  100473. if (touch.pointerId === _this._joystickPointerID) {
  100474. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPointerStartPos.x - 64, _this._joystickPointerStartPos.y - 64, 128, 128);
  100475. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPreviousPointerPos.x - 42, _this._joystickPreviousPointerPos.y - 42, 84, 84);
  100476. VirtualJoystick.vjCanvasContext.beginPath();
  100477. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  100478. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  100479. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 40, 0, Math.PI * 2, true);
  100480. VirtualJoystick.vjCanvasContext.stroke();
  100481. VirtualJoystick.vjCanvasContext.closePath();
  100482. VirtualJoystick.vjCanvasContext.beginPath();
  100483. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  100484. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  100485. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 60, 0, Math.PI * 2, true);
  100486. VirtualJoystick.vjCanvasContext.stroke();
  100487. VirtualJoystick.vjCanvasContext.closePath();
  100488. VirtualJoystick.vjCanvasContext.beginPath();
  100489. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  100490. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerPos.x, _this._joystickPointerPos.y, 40, 0, Math.PI * 2, true);
  100491. VirtualJoystick.vjCanvasContext.stroke();
  100492. VirtualJoystick.vjCanvasContext.closePath();
  100493. _this._joystickPreviousPointerPos = _this._joystickPointerPos.clone();
  100494. }
  100495. else {
  100496. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  100497. VirtualJoystick.vjCanvasContext.beginPath();
  100498. VirtualJoystick.vjCanvasContext.fillStyle = "white";
  100499. VirtualJoystick.vjCanvasContext.beginPath();
  100500. VirtualJoystick.vjCanvasContext.strokeStyle = "red";
  100501. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  100502. VirtualJoystick.vjCanvasContext.arc(touch.x, touch.y, 40, 0, Math.PI * 2, true);
  100503. VirtualJoystick.vjCanvasContext.stroke();
  100504. VirtualJoystick.vjCanvasContext.closePath();
  100505. touch.prevX = touch.x;
  100506. touch.prevY = touch.y;
  100507. }
  100508. });
  100509. }
  100510. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  100511. };
  100512. /**
  100513. * Release internal HTML canvas
  100514. */
  100515. VirtualJoystick.prototype.releaseCanvas = function () {
  100516. if (VirtualJoystick.Canvas) {
  100517. VirtualJoystick.Canvas.removeEventListener('pointerdown', this._onPointerDownHandlerRef);
  100518. VirtualJoystick.Canvas.removeEventListener('pointermove', this._onPointerMoveHandlerRef);
  100519. VirtualJoystick.Canvas.removeEventListener('pointerup', this._onPointerUpHandlerRef);
  100520. VirtualJoystick.Canvas.removeEventListener('pointerout', this._onPointerUpHandlerRef);
  100521. window.removeEventListener("resize", this._onResize);
  100522. document.body.removeChild(VirtualJoystick.Canvas);
  100523. VirtualJoystick.Canvas = null;
  100524. }
  100525. };
  100526. // Used to draw the virtual joystick inside a 2D canvas on top of the WebGL rendering canvas
  100527. VirtualJoystick._globalJoystickIndex = 0;
  100528. return VirtualJoystick;
  100529. }());
  100530. /***/ }),
  100531. /***/ "./Misc/workerPool.ts":
  100532. /*!****************************!*\
  100533. !*** ./Misc/workerPool.ts ***!
  100534. \****************************/
  100535. /*! exports provided: WorkerPool */
  100536. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100537. "use strict";
  100538. __webpack_require__.r(__webpack_exports__);
  100539. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return WorkerPool; });
  100540. /**
  100541. * Helper class to push actions to a pool of workers.
  100542. */
  100543. var WorkerPool = /** @class */ (function () {
  100544. /**
  100545. * Constructor
  100546. * @param workers Array of workers to use for actions
  100547. */
  100548. function WorkerPool(workers) {
  100549. this._pendingActions = new Array();
  100550. this._workerInfos = workers.map(function (worker) { return ({
  100551. worker: worker,
  100552. active: false
  100553. }); });
  100554. }
  100555. /**
  100556. * Terminates all workers and clears any pending actions.
  100557. */
  100558. WorkerPool.prototype.dispose = function () {
  100559. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  100560. var workerInfo = _a[_i];
  100561. workerInfo.worker.terminate();
  100562. }
  100563. delete this._workerInfos;
  100564. delete this._pendingActions;
  100565. };
  100566. /**
  100567. * Pushes an action to the worker pool. If all the workers are active, the action will be
  100568. * pended until a worker has completed its action.
  100569. * @param action The action to perform. Call onComplete when the action is complete.
  100570. */
  100571. WorkerPool.prototype.push = function (action) {
  100572. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  100573. var workerInfo = _a[_i];
  100574. if (!workerInfo.active) {
  100575. this._execute(workerInfo, action);
  100576. return;
  100577. }
  100578. }
  100579. this._pendingActions.push(action);
  100580. };
  100581. WorkerPool.prototype._execute = function (workerInfo, action) {
  100582. var _this = this;
  100583. workerInfo.active = true;
  100584. action(workerInfo.worker, function () {
  100585. workerInfo.active = false;
  100586. var nextAction = _this._pendingActions.shift();
  100587. if (nextAction) {
  100588. _this._execute(workerInfo, nextAction);
  100589. }
  100590. });
  100591. };
  100592. return WorkerPool;
  100593. }());
  100594. /***/ }),
  100595. /***/ "./Morph/index.ts":
  100596. /*!************************!*\
  100597. !*** ./Morph/index.ts ***!
  100598. \************************/
  100599. /*! exports provided: MorphTarget, MorphTargetManager */
  100600. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100601. "use strict";
  100602. __webpack_require__.r(__webpack_exports__);
  100603. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  100604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _morphTarget__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  100605. /* harmony import */ var _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./morphTargetManager */ "./Morph/morphTargetManager.ts");
  100606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__["MorphTargetManager"]; });
  100607. /***/ }),
  100608. /***/ "./Morph/morphTarget.ts":
  100609. /*!******************************!*\
  100610. !*** ./Morph/morphTarget.ts ***!
  100611. \******************************/
  100612. /*! exports provided: MorphTarget */
  100613. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100614. "use strict";
  100615. __webpack_require__.r(__webpack_exports__);
  100616. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return MorphTarget; });
  100617. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  100618. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  100619. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  100620. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  100621. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  100622. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  100623. /**
  100624. * Defines a target to use with MorphTargetManager
  100625. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  100626. */
  100627. var MorphTarget = /** @class */ (function () {
  100628. /**
  100629. * Creates a new MorphTarget
  100630. * @param name defines the name of the target
  100631. * @param influence defines the influence to use
  100632. * @param scene defines the scene the morphtarget belongs to
  100633. */
  100634. function MorphTarget(
  100635. /** defines the name of the target */
  100636. name, influence, scene) {
  100637. if (influence === void 0) { influence = 0; }
  100638. if (scene === void 0) { scene = null; }
  100639. this.name = name;
  100640. /**
  100641. * Gets or sets the list of animations
  100642. */
  100643. this.animations = new Array();
  100644. this._positions = null;
  100645. this._normals = null;
  100646. this._tangents = null;
  100647. /**
  100648. * Observable raised when the influence changes
  100649. */
  100650. this.onInfluenceChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  100651. /** @hidden */
  100652. this._onDataLayoutChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  100653. this._animationPropertiesOverride = null;
  100654. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  100655. this.influence = influence;
  100656. }
  100657. Object.defineProperty(MorphTarget.prototype, "influence", {
  100658. /**
  100659. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  100660. */
  100661. get: function () {
  100662. return this._influence;
  100663. },
  100664. set: function (influence) {
  100665. if (this._influence === influence) {
  100666. return;
  100667. }
  100668. var previous = this._influence;
  100669. this._influence = influence;
  100670. if (this.onInfluenceChanged.hasObservers) {
  100671. this.onInfluenceChanged.notifyObservers(previous === 0 || influence === 0);
  100672. }
  100673. },
  100674. enumerable: true,
  100675. configurable: true
  100676. });
  100677. Object.defineProperty(MorphTarget.prototype, "animationPropertiesOverride", {
  100678. /**
  100679. * Gets or sets the animation properties override
  100680. */
  100681. get: function () {
  100682. if (!this._animationPropertiesOverride && this._scene) {
  100683. return this._scene.animationPropertiesOverride;
  100684. }
  100685. return this._animationPropertiesOverride;
  100686. },
  100687. set: function (value) {
  100688. this._animationPropertiesOverride = value;
  100689. },
  100690. enumerable: true,
  100691. configurable: true
  100692. });
  100693. Object.defineProperty(MorphTarget.prototype, "hasPositions", {
  100694. /**
  100695. * Gets a boolean defining if the target contains position data
  100696. */
  100697. get: function () {
  100698. return !!this._positions;
  100699. },
  100700. enumerable: true,
  100701. configurable: true
  100702. });
  100703. Object.defineProperty(MorphTarget.prototype, "hasNormals", {
  100704. /**
  100705. * Gets a boolean defining if the target contains normal data
  100706. */
  100707. get: function () {
  100708. return !!this._normals;
  100709. },
  100710. enumerable: true,
  100711. configurable: true
  100712. });
  100713. Object.defineProperty(MorphTarget.prototype, "hasTangents", {
  100714. /**
  100715. * Gets a boolean defining if the target contains tangent data
  100716. */
  100717. get: function () {
  100718. return !!this._tangents;
  100719. },
  100720. enumerable: true,
  100721. configurable: true
  100722. });
  100723. /**
  100724. * Affects position data to this target
  100725. * @param data defines the position data to use
  100726. */
  100727. MorphTarget.prototype.setPositions = function (data) {
  100728. var hadPositions = this.hasPositions;
  100729. this._positions = data;
  100730. if (hadPositions !== this.hasPositions) {
  100731. this._onDataLayoutChanged.notifyObservers(undefined);
  100732. }
  100733. };
  100734. /**
  100735. * Gets the position data stored in this target
  100736. * @returns a FloatArray containing the position data (or null if not present)
  100737. */
  100738. MorphTarget.prototype.getPositions = function () {
  100739. return this._positions;
  100740. };
  100741. /**
  100742. * Affects normal data to this target
  100743. * @param data defines the normal data to use
  100744. */
  100745. MorphTarget.prototype.setNormals = function (data) {
  100746. var hadNormals = this.hasNormals;
  100747. this._normals = data;
  100748. if (hadNormals !== this.hasNormals) {
  100749. this._onDataLayoutChanged.notifyObservers(undefined);
  100750. }
  100751. };
  100752. /**
  100753. * Gets the normal data stored in this target
  100754. * @returns a FloatArray containing the normal data (or null if not present)
  100755. */
  100756. MorphTarget.prototype.getNormals = function () {
  100757. return this._normals;
  100758. };
  100759. /**
  100760. * Affects tangent data to this target
  100761. * @param data defines the tangent data to use
  100762. */
  100763. MorphTarget.prototype.setTangents = function (data) {
  100764. var hadTangents = this.hasTangents;
  100765. this._tangents = data;
  100766. if (hadTangents !== this.hasTangents) {
  100767. this._onDataLayoutChanged.notifyObservers(undefined);
  100768. }
  100769. };
  100770. /**
  100771. * Gets the tangent data stored in this target
  100772. * @returns a FloatArray containing the tangent data (or null if not present)
  100773. */
  100774. MorphTarget.prototype.getTangents = function () {
  100775. return this._tangents;
  100776. };
  100777. /**
  100778. * Serializes the current target into a Serialization object
  100779. * @returns the serialized object
  100780. */
  100781. MorphTarget.prototype.serialize = function () {
  100782. var serializationObject = {};
  100783. serializationObject.name = this.name;
  100784. serializationObject.influence = this.influence;
  100785. serializationObject.positions = Array.prototype.slice.call(this.getPositions());
  100786. if (this.id != null) {
  100787. serializationObject.id = this.id;
  100788. }
  100789. if (this.hasNormals) {
  100790. serializationObject.normals = Array.prototype.slice.call(this.getNormals());
  100791. }
  100792. if (this.hasTangents) {
  100793. serializationObject.tangents = Array.prototype.slice.call(this.getTangents());
  100794. }
  100795. // Animations
  100796. _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  100797. return serializationObject;
  100798. };
  100799. /**
  100800. * Returns the string "MorphTarget"
  100801. * @returns "MorphTarget"
  100802. */
  100803. MorphTarget.prototype.getClassName = function () {
  100804. return "MorphTarget";
  100805. };
  100806. // Statics
  100807. /**
  100808. * Creates a new target from serialized data
  100809. * @param serializationObject defines the serialized data to use
  100810. * @returns a new MorphTarget
  100811. */
  100812. MorphTarget.Parse = function (serializationObject) {
  100813. var result = new MorphTarget(serializationObject.name, serializationObject.influence);
  100814. result.setPositions(serializationObject.positions);
  100815. if (serializationObject.id != null) {
  100816. result.id = serializationObject.id;
  100817. }
  100818. if (serializationObject.normals) {
  100819. result.setNormals(serializationObject.normals);
  100820. }
  100821. if (serializationObject.tangents) {
  100822. result.setTangents(serializationObject.tangents);
  100823. }
  100824. // Animations
  100825. if (serializationObject.animations) {
  100826. for (var animationIndex = 0; animationIndex < serializationObject.animations.length; animationIndex++) {
  100827. var parsedAnimation = serializationObject.animations[animationIndex];
  100828. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  100829. if (internalClass) {
  100830. result.animations.push(internalClass.Parse(parsedAnimation));
  100831. }
  100832. }
  100833. }
  100834. return result;
  100835. };
  100836. /**
  100837. * Creates a MorphTarget from mesh data
  100838. * @param mesh defines the source mesh
  100839. * @param name defines the name to use for the new target
  100840. * @param influence defines the influence to attach to the target
  100841. * @returns a new MorphTarget
  100842. */
  100843. MorphTarget.FromMesh = function (mesh, name, influence) {
  100844. if (!name) {
  100845. name = mesh.name;
  100846. }
  100847. var result = new MorphTarget(name, influence, mesh.getScene());
  100848. result.setPositions(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind));
  100849. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  100850. result.setNormals(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind));
  100851. }
  100852. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  100853. result.setTangents(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind));
  100854. }
  100855. return result;
  100856. };
  100857. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  100858. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["serialize"])()
  100859. ], MorphTarget.prototype, "id", void 0);
  100860. return MorphTarget;
  100861. }());
  100862. /***/ }),
  100863. /***/ "./Morph/morphTargetManager.ts":
  100864. /*!*************************************!*\
  100865. !*** ./Morph/morphTargetManager.ts ***!
  100866. \*************************************/
  100867. /*! exports provided: MorphTargetManager */
  100868. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100869. "use strict";
  100870. __webpack_require__.r(__webpack_exports__);
  100871. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return MorphTargetManager; });
  100872. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  100873. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  100874. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  100875. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  100876. /**
  100877. * This class is used to deform meshes using morphing between different targets
  100878. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  100879. */
  100880. var MorphTargetManager = /** @class */ (function () {
  100881. /**
  100882. * Creates a new MorphTargetManager
  100883. * @param scene defines the current scene
  100884. */
  100885. function MorphTargetManager(scene) {
  100886. if (scene === void 0) { scene = null; }
  100887. this._targets = new Array();
  100888. this._targetInfluenceChangedObservers = new Array();
  100889. this._targetDataLayoutChangedObservers = new Array();
  100890. this._activeTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  100891. this._supportsNormals = false;
  100892. this._supportsTangents = false;
  100893. this._vertexCount = 0;
  100894. this._uniqueId = 0;
  100895. this._tempInfluences = new Array();
  100896. if (!scene) {
  100897. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  100898. }
  100899. this._scene = scene;
  100900. if (this._scene) {
  100901. this._scene.morphTargetManagers.push(this);
  100902. this._uniqueId = this._scene.getUniqueId();
  100903. }
  100904. }
  100905. Object.defineProperty(MorphTargetManager.prototype, "uniqueId", {
  100906. /**
  100907. * Gets the unique ID of this manager
  100908. */
  100909. get: function () {
  100910. return this._uniqueId;
  100911. },
  100912. enumerable: true,
  100913. configurable: true
  100914. });
  100915. Object.defineProperty(MorphTargetManager.prototype, "vertexCount", {
  100916. /**
  100917. * Gets the number of vertices handled by this manager
  100918. */
  100919. get: function () {
  100920. return this._vertexCount;
  100921. },
  100922. enumerable: true,
  100923. configurable: true
  100924. });
  100925. Object.defineProperty(MorphTargetManager.prototype, "supportsNormals", {
  100926. /**
  100927. * Gets a boolean indicating if this manager supports morphing of normals
  100928. */
  100929. get: function () {
  100930. return this._supportsNormals;
  100931. },
  100932. enumerable: true,
  100933. configurable: true
  100934. });
  100935. Object.defineProperty(MorphTargetManager.prototype, "supportsTangents", {
  100936. /**
  100937. * Gets a boolean indicating if this manager supports morphing of tangents
  100938. */
  100939. get: function () {
  100940. return this._supportsTangents;
  100941. },
  100942. enumerable: true,
  100943. configurable: true
  100944. });
  100945. Object.defineProperty(MorphTargetManager.prototype, "numTargets", {
  100946. /**
  100947. * Gets the number of targets stored in this manager
  100948. */
  100949. get: function () {
  100950. return this._targets.length;
  100951. },
  100952. enumerable: true,
  100953. configurable: true
  100954. });
  100955. Object.defineProperty(MorphTargetManager.prototype, "numInfluencers", {
  100956. /**
  100957. * Gets the number of influencers (ie. the number of targets with influences > 0)
  100958. */
  100959. get: function () {
  100960. return this._activeTargets.length;
  100961. },
  100962. enumerable: true,
  100963. configurable: true
  100964. });
  100965. Object.defineProperty(MorphTargetManager.prototype, "influences", {
  100966. /**
  100967. * Gets the list of influences (one per target)
  100968. */
  100969. get: function () {
  100970. return this._influences;
  100971. },
  100972. enumerable: true,
  100973. configurable: true
  100974. });
  100975. /**
  100976. * Gets the active target at specified index. An active target is a target with an influence > 0
  100977. * @param index defines the index to check
  100978. * @returns the requested target
  100979. */
  100980. MorphTargetManager.prototype.getActiveTarget = function (index) {
  100981. return this._activeTargets.data[index];
  100982. };
  100983. /**
  100984. * Gets the target at specified index
  100985. * @param index defines the index to check
  100986. * @returns the requested target
  100987. */
  100988. MorphTargetManager.prototype.getTarget = function (index) {
  100989. return this._targets[index];
  100990. };
  100991. /**
  100992. * Add a new target to this manager
  100993. * @param target defines the target to add
  100994. */
  100995. MorphTargetManager.prototype.addTarget = function (target) {
  100996. var _this = this;
  100997. this._targets.push(target);
  100998. this._targetInfluenceChangedObservers.push(target.onInfluenceChanged.add(function (needUpdate) {
  100999. _this._syncActiveTargets(needUpdate);
  101000. }));
  101001. this._targetDataLayoutChangedObservers.push(target._onDataLayoutChanged.add(function () {
  101002. _this._syncActiveTargets(true);
  101003. }));
  101004. this._syncActiveTargets(true);
  101005. };
  101006. /**
  101007. * Removes a target from the manager
  101008. * @param target defines the target to remove
  101009. */
  101010. MorphTargetManager.prototype.removeTarget = function (target) {
  101011. var index = this._targets.indexOf(target);
  101012. if (index >= 0) {
  101013. this._targets.splice(index, 1);
  101014. target.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(index, 1)[0]);
  101015. target._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(index, 1)[0]);
  101016. this._syncActiveTargets(true);
  101017. }
  101018. };
  101019. /**
  101020. * Serializes the current manager into a Serialization object
  101021. * @returns the serialized object
  101022. */
  101023. MorphTargetManager.prototype.serialize = function () {
  101024. var serializationObject = {};
  101025. serializationObject.id = this.uniqueId;
  101026. serializationObject.targets = [];
  101027. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  101028. var target = _a[_i];
  101029. serializationObject.targets.push(target.serialize());
  101030. }
  101031. return serializationObject;
  101032. };
  101033. MorphTargetManager.prototype._syncActiveTargets = function (needUpdate) {
  101034. var influenceCount = 0;
  101035. this._activeTargets.reset();
  101036. this._supportsNormals = true;
  101037. this._supportsTangents = true;
  101038. this._vertexCount = 0;
  101039. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  101040. var target = _a[_i];
  101041. if (target.influence === 0) {
  101042. continue;
  101043. }
  101044. this._activeTargets.push(target);
  101045. this._tempInfluences[influenceCount++] = target.influence;
  101046. this._supportsNormals = this._supportsNormals && target.hasNormals;
  101047. this._supportsTangents = this._supportsTangents && target.hasTangents;
  101048. var positions = target.getPositions();
  101049. if (positions) {
  101050. var vertexCount = positions.length / 3;
  101051. if (this._vertexCount === 0) {
  101052. this._vertexCount = vertexCount;
  101053. }
  101054. else if (this._vertexCount !== vertexCount) {
  101055. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Incompatible target. Targets must all have the same vertices count.");
  101056. return;
  101057. }
  101058. }
  101059. }
  101060. if (!this._influences || this._influences.length !== influenceCount) {
  101061. this._influences = new Float32Array(influenceCount);
  101062. }
  101063. for (var index = 0; index < influenceCount; index++) {
  101064. this._influences[index] = this._tempInfluences[index];
  101065. }
  101066. if (needUpdate) {
  101067. this.synchronize();
  101068. }
  101069. };
  101070. /**
  101071. * Syncrhonize the targets with all the meshes using this morph target manager
  101072. */
  101073. MorphTargetManager.prototype.synchronize = function () {
  101074. if (!this._scene) {
  101075. return;
  101076. }
  101077. // Flag meshes as dirty to resync with the active targets
  101078. for (var _i = 0, _a = this._scene.meshes; _i < _a.length; _i++) {
  101079. var mesh = _a[_i];
  101080. if (mesh.morphTargetManager === this) {
  101081. mesh._syncGeometryWithMorphTargetManager();
  101082. }
  101083. }
  101084. };
  101085. // Statics
  101086. /**
  101087. * Creates a new MorphTargetManager from serialized data
  101088. * @param serializationObject defines the serialized data
  101089. * @param scene defines the hosting scene
  101090. * @returns the new MorphTargetManager
  101091. */
  101092. MorphTargetManager.Parse = function (serializationObject, scene) {
  101093. var result = new MorphTargetManager(scene);
  101094. result._uniqueId = serializationObject.id;
  101095. for (var _i = 0, _a = serializationObject.targets; _i < _a.length; _i++) {
  101096. var targetData = _a[_i];
  101097. result.addTarget(_morphTarget__WEBPACK_IMPORTED_MODULE_3__["MorphTarget"].Parse(targetData));
  101098. }
  101099. return result;
  101100. };
  101101. return MorphTargetManager;
  101102. }());
  101103. /***/ }),
  101104. /***/ "./Offline/database.ts":
  101105. /*!*****************************!*\
  101106. !*** ./Offline/database.ts ***!
  101107. \*****************************/
  101108. /*! exports provided: Database */
  101109. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101110. "use strict";
  101111. __webpack_require__.r(__webpack_exports__);
  101112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return Database; });
  101113. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  101114. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  101115. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tga */ "./Misc/tga.ts");
  101116. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  101117. // Sets the default offline provider to Babylon.js
  101118. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].OfflineProviderFactory = function (urlToScene, callbackManifestChecked, disableManifestCheck) {
  101119. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  101120. return new Database(urlToScene, callbackManifestChecked, disableManifestCheck);
  101121. };
  101122. /**
  101123. * Class used to enable access to IndexedDB
  101124. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  101125. */
  101126. var Database = /** @class */ (function () {
  101127. /**
  101128. * Creates a new Database
  101129. * @param urlToScene defines the url to load the scene
  101130. * @param callbackManifestChecked defines the callback to use when manifest is checked
  101131. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  101132. */
  101133. function Database(urlToScene, callbackManifestChecked, disableManifestCheck) {
  101134. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  101135. var _this = this;
  101136. // Handling various flavors of prefixed version of IndexedDB
  101137. this._idbFactory = (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB);
  101138. this._callbackManifestChecked = callbackManifestChecked;
  101139. this._currentSceneUrl = Database._ReturnFullUrlLocation(urlToScene);
  101140. this._db = null;
  101141. this._enableSceneOffline = false;
  101142. this._enableTexturesOffline = false;
  101143. this._manifestVersionFound = 0;
  101144. this._mustUpdateRessources = false;
  101145. this._hasReachedQuota = false;
  101146. if (!Database.IDBStorageEnabled) {
  101147. this._callbackManifestChecked(true);
  101148. }
  101149. else {
  101150. if (disableManifestCheck) {
  101151. this._enableSceneOffline = true;
  101152. this._enableTexturesOffline = true;
  101153. this._manifestVersionFound = 1;
  101154. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  101155. _this._callbackManifestChecked(true);
  101156. });
  101157. }
  101158. else {
  101159. this._checkManifestFile();
  101160. }
  101161. }
  101162. }
  101163. Object.defineProperty(Database.prototype, "enableSceneOffline", {
  101164. /**
  101165. * Gets a boolean indicating if scene must be saved in the database
  101166. */
  101167. get: function () {
  101168. return this._enableSceneOffline;
  101169. },
  101170. enumerable: true,
  101171. configurable: true
  101172. });
  101173. Object.defineProperty(Database.prototype, "enableTexturesOffline", {
  101174. /**
  101175. * Gets a boolean indicating if textures must be saved in the database
  101176. */
  101177. get: function () {
  101178. return this._enableTexturesOffline;
  101179. },
  101180. enumerable: true,
  101181. configurable: true
  101182. });
  101183. Database.prototype._checkManifestFile = function () {
  101184. var _this = this;
  101185. var noManifestFile = function () {
  101186. _this._enableSceneOffline = false;
  101187. _this._enableTexturesOffline = false;
  101188. _this._callbackManifestChecked(false);
  101189. };
  101190. var timeStampUsed = false;
  101191. var manifestURL = this._currentSceneUrl + ".manifest";
  101192. var xhr = new XMLHttpRequest();
  101193. if (navigator.onLine) {
  101194. // Adding a timestamp to by-pass browsers' cache
  101195. timeStampUsed = true;
  101196. manifestURL = manifestURL + (manifestURL.match(/\?/) == null ? "?" : "&") + Date.now();
  101197. }
  101198. xhr.open("GET", manifestURL, true);
  101199. xhr.addEventListener("load", function () {
  101200. if (xhr.status === 200 || Database._ValidateXHRData(xhr, 1)) {
  101201. try {
  101202. var manifestFile = JSON.parse(xhr.response);
  101203. _this._enableSceneOffline = manifestFile.enableSceneOffline;
  101204. _this._enableTexturesOffline = manifestFile.enableTexturesOffline && Database.IsUASupportingBlobStorage;
  101205. if (manifestFile.version && !isNaN(parseInt(manifestFile.version))) {
  101206. _this._manifestVersionFound = manifestFile.version;
  101207. }
  101208. if (_this._callbackManifestChecked) {
  101209. _this._callbackManifestChecked(true);
  101210. }
  101211. }
  101212. catch (ex) {
  101213. noManifestFile();
  101214. }
  101215. }
  101216. else {
  101217. noManifestFile();
  101218. }
  101219. }, false);
  101220. xhr.addEventListener("error", function () {
  101221. if (timeStampUsed) {
  101222. timeStampUsed = false;
  101223. // Let's retry without the timeStamp
  101224. // It could fail when coupled with HTML5 Offline API
  101225. var retryManifestURL = _this._currentSceneUrl + ".manifest";
  101226. xhr.open("GET", retryManifestURL, true);
  101227. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  101228. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  101229. }
  101230. xhr.send();
  101231. }
  101232. else {
  101233. noManifestFile();
  101234. }
  101235. }, false);
  101236. try {
  101237. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  101238. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  101239. }
  101240. xhr.send();
  101241. }
  101242. catch (ex) {
  101243. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error on XHR send request.");
  101244. this._callbackManifestChecked(false);
  101245. }
  101246. };
  101247. /**
  101248. * Open the database and make it available
  101249. * @param successCallback defines the callback to call on success
  101250. * @param errorCallback defines the callback to call on error
  101251. */
  101252. Database.prototype.open = function (successCallback, errorCallback) {
  101253. var _this = this;
  101254. var handleError = function () {
  101255. _this._isSupported = false;
  101256. if (errorCallback) {
  101257. errorCallback();
  101258. }
  101259. };
  101260. if (!this._idbFactory || !(this._enableSceneOffline || this._enableTexturesOffline)) {
  101261. // Your browser doesn't support IndexedDB
  101262. this._isSupported = false;
  101263. if (errorCallback) {
  101264. errorCallback();
  101265. }
  101266. }
  101267. else {
  101268. // If the DB hasn't been opened or created yet
  101269. if (!this._db) {
  101270. this._hasReachedQuota = false;
  101271. this._isSupported = true;
  101272. var request = this._idbFactory.open("babylonjs", 1);
  101273. // Could occur if user is blocking the quota for the DB and/or doesn't grant access to IndexedDB
  101274. request.onerror = function () {
  101275. handleError();
  101276. };
  101277. // executes when a version change transaction cannot complete due to other active transactions
  101278. request.onblocked = function () {
  101279. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("IDB request blocked. Please reload the page.");
  101280. handleError();
  101281. };
  101282. // DB has been opened successfully
  101283. request.onsuccess = function () {
  101284. _this._db = request.result;
  101285. successCallback();
  101286. };
  101287. // Initialization of the DB. Creating Scenes & Textures stores
  101288. request.onupgradeneeded = function (event) {
  101289. _this._db = (event.target).result;
  101290. if (_this._db) {
  101291. try {
  101292. _this._db.createObjectStore("scenes", { keyPath: "sceneUrl" });
  101293. _this._db.createObjectStore("versions", { keyPath: "sceneUrl" });
  101294. _this._db.createObjectStore("textures", { keyPath: "textureUrl" });
  101295. }
  101296. catch (ex) {
  101297. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while creating object stores. Exception: " + ex.message);
  101298. handleError();
  101299. }
  101300. }
  101301. };
  101302. }
  101303. // DB has already been created and opened
  101304. else {
  101305. if (successCallback) {
  101306. successCallback();
  101307. }
  101308. }
  101309. }
  101310. };
  101311. /**
  101312. * Loads an image from the database
  101313. * @param url defines the url to load from
  101314. * @param image defines the target DOM image
  101315. */
  101316. Database.prototype.loadImage = function (url, image) {
  101317. var _this = this;
  101318. var completeURL = Database._ReturnFullUrlLocation(url);
  101319. var saveAndLoadImage = function () {
  101320. if (!_this._hasReachedQuota && _this._db !== null) {
  101321. // the texture is not yet in the DB, let's try to save it
  101322. _this._saveImageIntoDBAsync(completeURL, image);
  101323. }
  101324. // If the texture is not in the DB and we've reached the DB quota limit
  101325. // let's load it directly from the web
  101326. else {
  101327. image.src = url;
  101328. }
  101329. };
  101330. if (!this._mustUpdateRessources) {
  101331. this._loadImageFromDBAsync(completeURL, image, saveAndLoadImage);
  101332. }
  101333. // First time we're download the images or update requested in the manifest file by a version change
  101334. else {
  101335. saveAndLoadImage();
  101336. }
  101337. };
  101338. Database.prototype._loadImageFromDBAsync = function (url, image, notInDBCallback) {
  101339. if (this._isSupported && this._db !== null) {
  101340. var texture;
  101341. var transaction = this._db.transaction(["textures"]);
  101342. transaction.onabort = function () {
  101343. image.src = url;
  101344. };
  101345. transaction.oncomplete = function () {
  101346. var blobTextureURL;
  101347. if (texture) {
  101348. var URL = window.URL || window.webkitURL;
  101349. blobTextureURL = URL.createObjectURL(texture.data);
  101350. image.onerror = function () {
  101351. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading image from blob URL: " + blobTextureURL + " switching back to web url: " + url);
  101352. image.src = url;
  101353. };
  101354. image.src = blobTextureURL;
  101355. }
  101356. else {
  101357. notInDBCallback();
  101358. }
  101359. };
  101360. var getRequest = transaction.objectStore("textures").get(url);
  101361. getRequest.onsuccess = function (event) {
  101362. texture = (event.target).result;
  101363. };
  101364. getRequest.onerror = function () {
  101365. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading texture " + url + " from DB.");
  101366. image.src = url;
  101367. };
  101368. }
  101369. else {
  101370. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  101371. image.src = url;
  101372. }
  101373. };
  101374. Database.prototype._saveImageIntoDBAsync = function (url, image) {
  101375. var _this = this;
  101376. if (this._isSupported) {
  101377. // In case of error (type not supported or quota exceeded), we're at least sending back XHR data to allow texture loading later on
  101378. var generateBlobUrl = function () {
  101379. var blobTextureURL;
  101380. if (blob) {
  101381. var URL = window.URL || window.webkitURL;
  101382. try {
  101383. blobTextureURL = URL.createObjectURL(blob);
  101384. }
  101385. // Chrome is raising a type error if we're setting the oneTimeOnly parameter
  101386. catch (ex) {
  101387. blobTextureURL = URL.createObjectURL(blob);
  101388. }
  101389. }
  101390. if (blobTextureURL) {
  101391. image.src = blobTextureURL;
  101392. }
  101393. };
  101394. if (Database.IsUASupportingBlobStorage) { // Create XHR
  101395. var xhr = new XMLHttpRequest(), blob;
  101396. xhr.open("GET", url, true);
  101397. xhr.responseType = "blob";
  101398. xhr.addEventListener("load", function () {
  101399. if (xhr.status === 200 && _this._db) {
  101400. // Blob as response (XHR2)
  101401. blob = xhr.response;
  101402. var transaction = _this._db.transaction(["textures"], "readwrite");
  101403. // the transaction could abort because of a QuotaExceededError error
  101404. transaction.onabort = function (event) {
  101405. try {
  101406. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  101407. var srcElement = (event.srcElement || event.target);
  101408. var error = srcElement.error;
  101409. if (error && error.name === "QuotaExceededError") {
  101410. _this._hasReachedQuota = true;
  101411. }
  101412. }
  101413. catch (ex) { }
  101414. generateBlobUrl();
  101415. };
  101416. transaction.oncomplete = function () {
  101417. generateBlobUrl();
  101418. };
  101419. var newTexture = { textureUrl: url, data: blob };
  101420. try {
  101421. // Put the blob into the dabase
  101422. var addRequest = transaction.objectStore("textures").put(newTexture);
  101423. addRequest.onsuccess = function () {
  101424. };
  101425. addRequest.onerror = function () {
  101426. generateBlobUrl();
  101427. };
  101428. }
  101429. catch (ex) {
  101430. // "DataCloneError" generated by Chrome when you try to inject blob into IndexedDB
  101431. if (ex.code === 25) {
  101432. Database.IsUASupportingBlobStorage = false;
  101433. _this._enableTexturesOffline = false;
  101434. }
  101435. image.src = url;
  101436. }
  101437. }
  101438. else {
  101439. image.src = url;
  101440. }
  101441. }, false);
  101442. xhr.addEventListener("error", function () {
  101443. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in XHR request in BABYLON.Database.");
  101444. image.src = url;
  101445. }, false);
  101446. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].CustomRequestHeaders) {
  101447. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  101448. }
  101449. xhr.send();
  101450. }
  101451. else {
  101452. image.src = url;
  101453. }
  101454. }
  101455. else {
  101456. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  101457. image.src = url;
  101458. }
  101459. };
  101460. Database.prototype._checkVersionFromDB = function (url, versionLoaded) {
  101461. var _this = this;
  101462. var updateVersion = function () {
  101463. // the version is not yet in the DB or we need to update it
  101464. _this._saveVersionIntoDBAsync(url, versionLoaded);
  101465. };
  101466. this._loadVersionFromDBAsync(url, versionLoaded, updateVersion);
  101467. };
  101468. Database.prototype._loadVersionFromDBAsync = function (url, callback, updateInDBCallback) {
  101469. var _this = this;
  101470. if (this._isSupported && this._db) {
  101471. var version;
  101472. try {
  101473. var transaction = this._db.transaction(["versions"]);
  101474. transaction.oncomplete = function () {
  101475. if (version) {
  101476. // If the version in the JSON file is different from the version in DB
  101477. if (_this._manifestVersionFound !== version.data) {
  101478. _this._mustUpdateRessources = true;
  101479. updateInDBCallback();
  101480. }
  101481. else {
  101482. callback(version.data);
  101483. }
  101484. }
  101485. // version was not found in DB
  101486. else {
  101487. _this._mustUpdateRessources = true;
  101488. updateInDBCallback();
  101489. }
  101490. };
  101491. transaction.onabort = function () {
  101492. callback(-1);
  101493. };
  101494. var getRequest = transaction.objectStore("versions").get(url);
  101495. getRequest.onsuccess = function (event) {
  101496. version = (event.target).result;
  101497. };
  101498. getRequest.onerror = function () {
  101499. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading version for scene " + url + " from DB.");
  101500. callback(-1);
  101501. };
  101502. }
  101503. catch (ex) {
  101504. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (READ OP). Exception: " + ex.message);
  101505. callback(-1);
  101506. }
  101507. }
  101508. else {
  101509. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  101510. callback(-1);
  101511. }
  101512. };
  101513. Database.prototype._saveVersionIntoDBAsync = function (url, callback) {
  101514. var _this = this;
  101515. if (this._isSupported && !this._hasReachedQuota && this._db) {
  101516. try {
  101517. // Open a transaction to the database
  101518. var transaction = this._db.transaction(["versions"], "readwrite");
  101519. // the transaction could abort because of a QuotaExceededError error
  101520. transaction.onabort = function (event) {
  101521. try { //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  101522. var error = event.srcElement['error'];
  101523. if (error && error.name === "QuotaExceededError") {
  101524. _this._hasReachedQuota = true;
  101525. }
  101526. }
  101527. catch (ex) { }
  101528. callback(-1);
  101529. };
  101530. transaction.oncomplete = function () {
  101531. callback(_this._manifestVersionFound);
  101532. };
  101533. var newVersion = { sceneUrl: url, data: this._manifestVersionFound };
  101534. // Put the scene into the database
  101535. var addRequest = transaction.objectStore("versions").put(newVersion);
  101536. addRequest.onsuccess = function () {
  101537. };
  101538. addRequest.onerror = function () {
  101539. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add version request in BABYLON.Database.");
  101540. };
  101541. }
  101542. catch (ex) {
  101543. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + ex.message);
  101544. callback(-1);
  101545. }
  101546. }
  101547. else {
  101548. callback(-1);
  101549. }
  101550. };
  101551. /**
  101552. * Loads a file from database
  101553. * @param url defines the URL to load from
  101554. * @param sceneLoaded defines a callback to call on success
  101555. * @param progressCallBack defines a callback to call when progress changed
  101556. * @param errorCallback defines a callback to call on error
  101557. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  101558. */
  101559. Database.prototype.loadFile = function (url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer) {
  101560. var _this = this;
  101561. var completeUrl = Database._ReturnFullUrlLocation(url);
  101562. var saveAndLoadFile = function () {
  101563. // the scene is not yet in the DB, let's try to save it
  101564. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  101565. };
  101566. this._checkVersionFromDB(completeUrl, function (version) {
  101567. if (version !== -1) {
  101568. if (!_this._mustUpdateRessources) {
  101569. _this._loadFileAsync(completeUrl, sceneLoaded, saveAndLoadFile);
  101570. }
  101571. else {
  101572. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  101573. }
  101574. }
  101575. else {
  101576. if (errorCallback) {
  101577. errorCallback();
  101578. }
  101579. }
  101580. });
  101581. };
  101582. Database.prototype._loadFileAsync = function (url, callback, notInDBCallback) {
  101583. if (this._isSupported && this._db) {
  101584. var targetStore;
  101585. if (url.indexOf(".babylon") !== -1) {
  101586. targetStore = "scenes";
  101587. }
  101588. else {
  101589. targetStore = "textures";
  101590. }
  101591. var file;
  101592. var transaction = this._db.transaction([targetStore]);
  101593. transaction.oncomplete = function () {
  101594. if (file) {
  101595. callback(file.data);
  101596. }
  101597. // file was not found in DB
  101598. else {
  101599. notInDBCallback();
  101600. }
  101601. };
  101602. transaction.onabort = function () {
  101603. notInDBCallback();
  101604. };
  101605. var getRequest = transaction.objectStore(targetStore).get(url);
  101606. getRequest.onsuccess = function (event) {
  101607. file = (event.target).result;
  101608. };
  101609. getRequest.onerror = function () {
  101610. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading file " + url + " from DB.");
  101611. notInDBCallback();
  101612. };
  101613. }
  101614. else {
  101615. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  101616. callback();
  101617. }
  101618. };
  101619. Database.prototype._saveFileAsync = function (url, callback, progressCallback, useArrayBuffer, errorCallback) {
  101620. var _this = this;
  101621. if (this._isSupported) {
  101622. var targetStore;
  101623. if (url.indexOf(".babylon") !== -1) {
  101624. targetStore = "scenes";
  101625. }
  101626. else {
  101627. targetStore = "textures";
  101628. }
  101629. // Create XHR
  101630. var xhr = new XMLHttpRequest();
  101631. var fileData;
  101632. xhr.open("GET", url + "?" + Date.now(), true);
  101633. if (useArrayBuffer) {
  101634. xhr.responseType = "arraybuffer";
  101635. }
  101636. if (progressCallback) {
  101637. xhr.onprogress = progressCallback;
  101638. }
  101639. xhr.addEventListener("load", function () {
  101640. if (xhr.status === 200 || (xhr.status < 400 && Database._ValidateXHRData(xhr, !useArrayBuffer ? 1 : 6))) {
  101641. // Blob as response (XHR2)
  101642. fileData = !useArrayBuffer ? xhr.responseText : xhr.response;
  101643. if (!_this._hasReachedQuota && _this._db) {
  101644. // Open a transaction to the database
  101645. var transaction = _this._db.transaction([targetStore], "readwrite");
  101646. // the transaction could abort because of a QuotaExceededError error
  101647. transaction.onabort = function (event) {
  101648. try {
  101649. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  101650. var error = event.srcElement['error'];
  101651. if (error && error.name === "QuotaExceededError") {
  101652. _this._hasReachedQuota = true;
  101653. }
  101654. }
  101655. catch (ex) { }
  101656. callback(fileData);
  101657. };
  101658. transaction.oncomplete = function () {
  101659. callback(fileData);
  101660. };
  101661. var newFile;
  101662. if (targetStore === "scenes") {
  101663. newFile = { sceneUrl: url, data: fileData, version: _this._manifestVersionFound };
  101664. }
  101665. else {
  101666. newFile = { textureUrl: url, data: fileData };
  101667. }
  101668. try {
  101669. // Put the scene into the database
  101670. var addRequest = transaction.objectStore(targetStore).put(newFile);
  101671. addRequest.onsuccess = function () {
  101672. };
  101673. addRequest.onerror = function () {
  101674. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add file request in BABYLON.Database.");
  101675. };
  101676. }
  101677. catch (ex) {
  101678. callback(fileData);
  101679. }
  101680. }
  101681. else {
  101682. callback(fileData);
  101683. }
  101684. }
  101685. else {
  101686. if (xhr.status >= 400 && errorCallback) {
  101687. errorCallback(xhr);
  101688. }
  101689. else {
  101690. callback();
  101691. }
  101692. }
  101693. }, false);
  101694. xhr.addEventListener("error", function () {
  101695. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("error on XHR request.");
  101696. callback();
  101697. }, false);
  101698. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  101699. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  101700. }
  101701. xhr.send();
  101702. }
  101703. else {
  101704. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or Babylon.js Database is not open.");
  101705. callback();
  101706. }
  101707. };
  101708. /**
  101709. * Validates if xhr data is correct
  101710. * @param xhr defines the request to validate
  101711. * @param dataType defines the expected data type
  101712. * @returns true if data is correct
  101713. */
  101714. Database._ValidateXHRData = function (xhr, dataType) {
  101715. // 1 for text (.babylon, manifest and shaders), 2 for TGA, 4 for DDS, 7 for all
  101716. if (dataType === void 0) { dataType = 7; }
  101717. try {
  101718. if (dataType & 1) {
  101719. if (xhr.responseText && xhr.responseText.length > 0) {
  101720. return true;
  101721. }
  101722. else if (dataType === 1) {
  101723. return false;
  101724. }
  101725. }
  101726. if (dataType & 2) {
  101727. // Check header width and height since there is no "TGA" magic number
  101728. var tgaHeader = _Misc_tga__WEBPACK_IMPORTED_MODULE_2__["TGATools"].GetTGAHeader(xhr.response);
  101729. if (tgaHeader.width && tgaHeader.height && tgaHeader.width > 0 && tgaHeader.height > 0) {
  101730. return true;
  101731. }
  101732. else if (dataType === 2) {
  101733. return false;
  101734. }
  101735. }
  101736. if (dataType & 4) {
  101737. // Check for the "DDS" magic number
  101738. var ddsHeader = new Uint8Array(xhr.response, 0, 3);
  101739. if (ddsHeader[0] === 68 && ddsHeader[1] === 68 && ddsHeader[2] === 83) {
  101740. return true;
  101741. }
  101742. else {
  101743. return false;
  101744. }
  101745. }
  101746. }
  101747. catch (e) {
  101748. // Global protection
  101749. }
  101750. return false;
  101751. };
  101752. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  101753. Database.IsUASupportingBlobStorage = true;
  101754. /**
  101755. * Gets a boolean indicating if Database storate is enabled (off by default)
  101756. */
  101757. Database.IDBStorageEnabled = false;
  101758. Database._ParseURL = function (url) {
  101759. var a = document.createElement('a');
  101760. a.href = url;
  101761. var urlWithoutHash = url.substring(0, url.lastIndexOf("#"));
  101762. var fileName = url.substring(urlWithoutHash.lastIndexOf("/") + 1, url.length);
  101763. var absLocation = url.substring(0, url.indexOf(fileName, 0));
  101764. return absLocation;
  101765. };
  101766. Database._ReturnFullUrlLocation = function (url) {
  101767. if (url.indexOf("http:/") === -1 && url.indexOf("https:/") === -1) {
  101768. return (Database._ParseURL(window.location.href) + url);
  101769. }
  101770. else {
  101771. return url;
  101772. }
  101773. };
  101774. return Database;
  101775. }());
  101776. /***/ }),
  101777. /***/ "./Offline/index.ts":
  101778. /*!**************************!*\
  101779. !*** ./Offline/index.ts ***!
  101780. \**************************/
  101781. /*! exports provided: Database */
  101782. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101783. "use strict";
  101784. __webpack_require__.r(__webpack_exports__);
  101785. /* harmony import */ var _database__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database */ "./Offline/database.ts");
  101786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _database__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  101787. /***/ }),
  101788. /***/ "./Particles/EmitterTypes/boxParticleEmitter.ts":
  101789. /*!******************************************************!*\
  101790. !*** ./Particles/EmitterTypes/boxParticleEmitter.ts ***!
  101791. \******************************************************/
  101792. /*! exports provided: BoxParticleEmitter */
  101793. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101794. "use strict";
  101795. __webpack_require__.r(__webpack_exports__);
  101796. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return BoxParticleEmitter; });
  101797. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  101798. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  101799. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101800. /**
  101801. * Particle emitter emitting particles from the inside of a box.
  101802. * It emits the particles randomly between 2 given directions.
  101803. */
  101804. var BoxParticleEmitter = /** @class */ (function () {
  101805. /**
  101806. * Creates a new instance BoxParticleEmitter
  101807. */
  101808. function BoxParticleEmitter() {
  101809. /**
  101810. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101811. */
  101812. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  101813. /**
  101814. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101815. */
  101816. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  101817. /**
  101818. * 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.
  101819. */
  101820. this.minEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-0.5, -0.5, -0.5);
  101821. /**
  101822. * 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.
  101823. */
  101824. this.maxEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.5, 0.5, 0.5);
  101825. }
  101826. /**
  101827. * Called by the particle System when the direction is computed for the created particle.
  101828. * @param worldMatrix is the world matrix of the particle system
  101829. * @param directionToUpdate is the direction vector to update with the result
  101830. * @param particle is the particle we are computed the direction for
  101831. */
  101832. BoxParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101833. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  101834. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  101835. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  101836. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  101837. };
  101838. /**
  101839. * Called by the particle System when the position is computed for the created particle.
  101840. * @param worldMatrix is the world matrix of the particle system
  101841. * @param positionToUpdate is the position vector to update with the result
  101842. * @param particle is the particle we are computed the position for
  101843. */
  101844. BoxParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  101845. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.x, this.maxEmitBox.x);
  101846. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.y, this.maxEmitBox.y);
  101847. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
  101848. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  101849. };
  101850. /**
  101851. * Clones the current emitter and returns a copy of it
  101852. * @returns the new emitter
  101853. */
  101854. BoxParticleEmitter.prototype.clone = function () {
  101855. var newOne = new BoxParticleEmitter();
  101856. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  101857. return newOne;
  101858. };
  101859. /**
  101860. * Called by the GPUParticleSystem to setup the update shader
  101861. * @param effect defines the update shader
  101862. */
  101863. BoxParticleEmitter.prototype.applyToShader = function (effect) {
  101864. effect.setVector3("direction1", this.direction1);
  101865. effect.setVector3("direction2", this.direction2);
  101866. effect.setVector3("minEmitBox", this.minEmitBox);
  101867. effect.setVector3("maxEmitBox", this.maxEmitBox);
  101868. };
  101869. /**
  101870. * Returns a string to use to update the GPU particles update shader
  101871. * @returns a string containng the defines string
  101872. */
  101873. BoxParticleEmitter.prototype.getEffectDefines = function () {
  101874. return "#define BOXEMITTER";
  101875. };
  101876. /**
  101877. * Returns the string "BoxParticleEmitter"
  101878. * @returns a string containing the class name
  101879. */
  101880. BoxParticleEmitter.prototype.getClassName = function () {
  101881. return "BoxParticleEmitter";
  101882. };
  101883. /**
  101884. * Serializes the particle system to a JSON object.
  101885. * @returns the JSON object
  101886. */
  101887. BoxParticleEmitter.prototype.serialize = function () {
  101888. var serializationObject = {};
  101889. serializationObject.type = this.getClassName();
  101890. serializationObject.direction1 = this.direction1.asArray();
  101891. serializationObject.direction2 = this.direction2.asArray();
  101892. serializationObject.minEmitBox = this.minEmitBox.asArray();
  101893. serializationObject.maxEmitBox = this.maxEmitBox.asArray();
  101894. return serializationObject;
  101895. };
  101896. /**
  101897. * Parse properties from a JSON object
  101898. * @param serializationObject defines the JSON object
  101899. */
  101900. BoxParticleEmitter.prototype.parse = function (serializationObject) {
  101901. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  101902. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  101903. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.minEmitBox, 0, this.minEmitBox);
  101904. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.maxEmitBox, 0, this.maxEmitBox);
  101905. };
  101906. return BoxParticleEmitter;
  101907. }());
  101908. /***/ }),
  101909. /***/ "./Particles/EmitterTypes/coneParticleEmitter.ts":
  101910. /*!*******************************************************!*\
  101911. !*** ./Particles/EmitterTypes/coneParticleEmitter.ts ***!
  101912. \*******************************************************/
  101913. /*! exports provided: ConeParticleEmitter */
  101914. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101915. "use strict";
  101916. __webpack_require__.r(__webpack_exports__);
  101917. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return ConeParticleEmitter; });
  101918. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  101919. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  101920. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101921. /**
  101922. * Particle emitter emitting particles from the inside of a cone.
  101923. * It emits the particles alongside the cone volume from the base to the particle.
  101924. * The emission direction might be randomized.
  101925. */
  101926. var ConeParticleEmitter = /** @class */ (function () {
  101927. /**
  101928. * Creates a new instance ConeParticleEmitter
  101929. * @param radius the radius of the emission cone (1 by default)
  101930. * @param angle the cone base angle (PI by default)
  101931. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  101932. */
  101933. function ConeParticleEmitter(radius, angle,
  101934. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  101935. directionRandomizer) {
  101936. if (radius === void 0) { radius = 1; }
  101937. if (angle === void 0) { angle = Math.PI; }
  101938. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  101939. this.directionRandomizer = directionRandomizer;
  101940. /**
  101941. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  101942. */
  101943. this.radiusRange = 1;
  101944. /**
  101945. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  101946. */
  101947. this.heightRange = 1;
  101948. /**
  101949. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  101950. */
  101951. this.emitFromSpawnPointOnly = false;
  101952. this.angle = angle;
  101953. this.radius = radius;
  101954. }
  101955. Object.defineProperty(ConeParticleEmitter.prototype, "radius", {
  101956. /**
  101957. * Gets or sets the radius of the emission cone
  101958. */
  101959. get: function () {
  101960. return this._radius;
  101961. },
  101962. set: function (value) {
  101963. this._radius = value;
  101964. this._buildHeight();
  101965. },
  101966. enumerable: true,
  101967. configurable: true
  101968. });
  101969. Object.defineProperty(ConeParticleEmitter.prototype, "angle", {
  101970. /**
  101971. * Gets or sets the angle of the emission cone
  101972. */
  101973. get: function () {
  101974. return this._angle;
  101975. },
  101976. set: function (value) {
  101977. this._angle = value;
  101978. this._buildHeight();
  101979. },
  101980. enumerable: true,
  101981. configurable: true
  101982. });
  101983. ConeParticleEmitter.prototype._buildHeight = function () {
  101984. if (this._angle !== 0) {
  101985. this._height = this._radius / Math.tan(this._angle / 2);
  101986. }
  101987. else {
  101988. this._height = 1;
  101989. }
  101990. };
  101991. /**
  101992. * Called by the particle System when the direction is computed for the created particle.
  101993. * @param worldMatrix is the world matrix of the particle system
  101994. * @param directionToUpdate is the direction vector to update with the result
  101995. * @param particle is the particle we are computed the direction for
  101996. */
  101997. ConeParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101998. if (Math.abs(Math.cos(this._angle)) === 1.0) {
  101999. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(0, 1.0, 0, worldMatrix, directionToUpdate);
  102000. }
  102001. else {
  102002. // measure the direction Vector from the emitter to the particle.
  102003. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  102004. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102005. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102006. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102007. direction.x += randX;
  102008. direction.y += randY;
  102009. direction.z += randZ;
  102010. direction.normalize();
  102011. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  102012. }
  102013. };
  102014. /**
  102015. * Called by the particle System when the position is computed for the created particle.
  102016. * @param worldMatrix is the world matrix of the particle system
  102017. * @param positionToUpdate is the position vector to update with the result
  102018. * @param particle is the particle we are computed the position for
  102019. */
  102020. ConeParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  102021. var s = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, Math.PI * 2);
  102022. var h;
  102023. if (!this.emitFromSpawnPointOnly) {
  102024. h = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.heightRange);
  102025. // Better distribution in a cone at normal angles.
  102026. h = 1 - h * h;
  102027. }
  102028. else {
  102029. h = 0.0001;
  102030. }
  102031. var radius = this._radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this._radius * this.radiusRange);
  102032. radius = radius * h;
  102033. var randX = radius * Math.sin(s);
  102034. var randZ = radius * Math.cos(s);
  102035. var randY = h * this._height;
  102036. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  102037. };
  102038. /**
  102039. * Clones the current emitter and returns a copy of it
  102040. * @returns the new emitter
  102041. */
  102042. ConeParticleEmitter.prototype.clone = function () {
  102043. var newOne = new ConeParticleEmitter(this._radius, this._angle, this.directionRandomizer);
  102044. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  102045. return newOne;
  102046. };
  102047. /**
  102048. * Called by the GPUParticleSystem to setup the update shader
  102049. * @param effect defines the update shader
  102050. */
  102051. ConeParticleEmitter.prototype.applyToShader = function (effect) {
  102052. effect.setFloat2("radius", this._radius, this.radiusRange);
  102053. effect.setFloat("coneAngle", this._angle);
  102054. effect.setFloat2("height", this._height, this.heightRange);
  102055. effect.setFloat("directionRandomizer", this.directionRandomizer);
  102056. };
  102057. /**
  102058. * Returns a string to use to update the GPU particles update shader
  102059. * @returns a string containng the defines string
  102060. */
  102061. ConeParticleEmitter.prototype.getEffectDefines = function () {
  102062. var defines = "#define CONEEMITTER";
  102063. if (this.emitFromSpawnPointOnly) {
  102064. defines += "\n#define CONEEMITTERSPAWNPOINT";
  102065. }
  102066. return defines;
  102067. };
  102068. /**
  102069. * Returns the string "ConeParticleEmitter"
  102070. * @returns a string containing the class name
  102071. */
  102072. ConeParticleEmitter.prototype.getClassName = function () {
  102073. return "ConeParticleEmitter";
  102074. };
  102075. /**
  102076. * Serializes the particle system to a JSON object.
  102077. * @returns the JSON object
  102078. */
  102079. ConeParticleEmitter.prototype.serialize = function () {
  102080. var serializationObject = {};
  102081. serializationObject.type = this.getClassName();
  102082. serializationObject.radius = this._radius;
  102083. serializationObject.angle = this._angle;
  102084. serializationObject.directionRandomizer = this.directionRandomizer;
  102085. return serializationObject;
  102086. };
  102087. /**
  102088. * Parse properties from a JSON object
  102089. * @param serializationObject defines the JSON object
  102090. */
  102091. ConeParticleEmitter.prototype.parse = function (serializationObject) {
  102092. this.radius = serializationObject.radius;
  102093. this.angle = serializationObject.angle;
  102094. this.directionRandomizer = serializationObject.directionRandomizer;
  102095. };
  102096. return ConeParticleEmitter;
  102097. }());
  102098. /***/ }),
  102099. /***/ "./Particles/EmitterTypes/cylinderParticleEmitter.ts":
  102100. /*!***********************************************************!*\
  102101. !*** ./Particles/EmitterTypes/cylinderParticleEmitter.ts ***!
  102102. \***********************************************************/
  102103. /*! exports provided: CylinderParticleEmitter, CylinderDirectedParticleEmitter */
  102104. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102105. "use strict";
  102106. __webpack_require__.r(__webpack_exports__);
  102107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return CylinderParticleEmitter; });
  102108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return CylinderDirectedParticleEmitter; });
  102109. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  102110. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  102111. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  102112. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  102113. /**
  102114. * Particle emitter emitting particles from the inside of a cylinder.
  102115. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  102116. */
  102117. var CylinderParticleEmitter = /** @class */ (function () {
  102118. /**
  102119. * Creates a new instance CylinderParticleEmitter
  102120. * @param radius the radius of the emission cylinder (1 by default)
  102121. * @param height the height of the emission cylinder (1 by default)
  102122. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102123. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  102124. */
  102125. function CylinderParticleEmitter(
  102126. /**
  102127. * The radius of the emission cylinder.
  102128. */
  102129. radius,
  102130. /**
  102131. * The height of the emission cylinder.
  102132. */
  102133. height,
  102134. /**
  102135. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  102136. */
  102137. radiusRange,
  102138. /**
  102139. * How much to randomize the particle direction [0-1].
  102140. */
  102141. directionRandomizer) {
  102142. if (radius === void 0) { radius = 1; }
  102143. if (height === void 0) { height = 1; }
  102144. if (radiusRange === void 0) { radiusRange = 1; }
  102145. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  102146. this.radius = radius;
  102147. this.height = height;
  102148. this.radiusRange = radiusRange;
  102149. this.directionRandomizer = directionRandomizer;
  102150. }
  102151. /**
  102152. * Called by the particle System when the direction is computed for the created particle.
  102153. * @param worldMatrix is the world matrix of the particle system
  102154. * @param directionToUpdate is the direction vector to update with the result
  102155. * @param particle is the particle we are computed the direction for
  102156. */
  102157. CylinderParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102158. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  102159. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2);
  102160. var angle = Math.atan2(direction.x, direction.z);
  102161. angle += _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer;
  102162. direction.y = randY; // set direction y to rand y to mirror normal of cylinder surface
  102163. direction.x = Math.sin(angle);
  102164. direction.z = Math.cos(angle);
  102165. direction.normalize();
  102166. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  102167. };
  102168. /**
  102169. * Called by the particle System when the position is computed for the created particle.
  102170. * @param worldMatrix is the world matrix of the particle system
  102171. * @param positionToUpdate is the position vector to update with the result
  102172. * @param particle is the particle we are computed the position for
  102173. */
  102174. CylinderParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  102175. var yPos = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.height / 2, this.height / 2);
  102176. var angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  102177. // Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html
  102178. var radiusDistribution = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1);
  102179. var positionRadius = Math.sqrt(radiusDistribution) * this.radius;
  102180. var xPos = positionRadius * Math.cos(angle);
  102181. var zPos = positionRadius * Math.sin(angle);
  102182. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, worldMatrix, positionToUpdate);
  102183. };
  102184. /**
  102185. * Clones the current emitter and returns a copy of it
  102186. * @returns the new emitter
  102187. */
  102188. CylinderParticleEmitter.prototype.clone = function () {
  102189. var newOne = new CylinderParticleEmitter(this.radius, this.directionRandomizer);
  102190. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  102191. return newOne;
  102192. };
  102193. /**
  102194. * Called by the GPUParticleSystem to setup the update shader
  102195. * @param effect defines the update shader
  102196. */
  102197. CylinderParticleEmitter.prototype.applyToShader = function (effect) {
  102198. effect.setFloat("radius", this.radius);
  102199. effect.setFloat("height", this.height);
  102200. effect.setFloat("radiusRange", this.radiusRange);
  102201. effect.setFloat("directionRandomizer", this.directionRandomizer);
  102202. };
  102203. /**
  102204. * Returns a string to use to update the GPU particles update shader
  102205. * @returns a string containng the defines string
  102206. */
  102207. CylinderParticleEmitter.prototype.getEffectDefines = function () {
  102208. return "#define CYLINDEREMITTER";
  102209. };
  102210. /**
  102211. * Returns the string "CylinderParticleEmitter"
  102212. * @returns a string containing the class name
  102213. */
  102214. CylinderParticleEmitter.prototype.getClassName = function () {
  102215. return "CylinderParticleEmitter";
  102216. };
  102217. /**
  102218. * Serializes the particle system to a JSON object.
  102219. * @returns the JSON object
  102220. */
  102221. CylinderParticleEmitter.prototype.serialize = function () {
  102222. var serializationObject = {};
  102223. serializationObject.type = this.getClassName();
  102224. serializationObject.radius = this.radius;
  102225. serializationObject.height = this.height;
  102226. serializationObject.radiusRange = this.radiusRange;
  102227. serializationObject.directionRandomizer = this.directionRandomizer;
  102228. return serializationObject;
  102229. };
  102230. /**
  102231. * Parse properties from a JSON object
  102232. * @param serializationObject defines the JSON object
  102233. */
  102234. CylinderParticleEmitter.prototype.parse = function (serializationObject) {
  102235. this.radius = serializationObject.radius;
  102236. this.height = serializationObject.height;
  102237. this.radiusRange = serializationObject.radiusRange;
  102238. this.directionRandomizer = serializationObject.directionRandomizer;
  102239. };
  102240. return CylinderParticleEmitter;
  102241. }());
  102242. /**
  102243. * Particle emitter emitting particles from the inside of a cylinder.
  102244. * It emits the particles randomly between two vectors.
  102245. */
  102246. var CylinderDirectedParticleEmitter = /** @class */ (function (_super) {
  102247. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderDirectedParticleEmitter, _super);
  102248. /**
  102249. * Creates a new instance CylinderDirectedParticleEmitter
  102250. * @param radius the radius of the emission cylinder (1 by default)
  102251. * @param height the height of the emission cylinder (1 by default)
  102252. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102253. * @param direction1 the min limit of the emission direction (up vector by default)
  102254. * @param direction2 the max limit of the emission direction (up vector by default)
  102255. */
  102256. function CylinderDirectedParticleEmitter(radius, height, radiusRange,
  102257. /**
  102258. * The min limit of the emission direction.
  102259. */
  102260. direction1,
  102261. /**
  102262. * The max limit of the emission direction.
  102263. */
  102264. direction2) {
  102265. if (radius === void 0) { radius = 1; }
  102266. if (height === void 0) { height = 1; }
  102267. if (radiusRange === void 0) { radiusRange = 1; }
  102268. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  102269. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  102270. var _this = _super.call(this, radius, height, radiusRange) || this;
  102271. _this.direction1 = direction1;
  102272. _this.direction2 = direction2;
  102273. return _this;
  102274. }
  102275. /**
  102276. * Called by the particle System when the direction is computed for the created particle.
  102277. * @param worldMatrix is the world matrix of the particle system
  102278. * @param directionToUpdate is the direction vector to update with the result
  102279. * @param particle is the particle we are computed the direction for
  102280. */
  102281. CylinderDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102282. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  102283. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  102284. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  102285. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  102286. };
  102287. /**
  102288. * Clones the current emitter and returns a copy of it
  102289. * @returns the new emitter
  102290. */
  102291. CylinderDirectedParticleEmitter.prototype.clone = function () {
  102292. var newOne = new CylinderDirectedParticleEmitter(this.radius, this.height, this.radiusRange, this.direction1, this.direction2);
  102293. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  102294. return newOne;
  102295. };
  102296. /**
  102297. * Called by the GPUParticleSystem to setup the update shader
  102298. * @param effect defines the update shader
  102299. */
  102300. CylinderDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  102301. effect.setFloat("radius", this.radius);
  102302. effect.setFloat("height", this.height);
  102303. effect.setFloat("radiusRange", this.radiusRange);
  102304. effect.setVector3("direction1", this.direction1);
  102305. effect.setVector3("direction2", this.direction2);
  102306. };
  102307. /**
  102308. * Returns a string to use to update the GPU particles update shader
  102309. * @returns a string containng the defines string
  102310. */
  102311. CylinderDirectedParticleEmitter.prototype.getEffectDefines = function () {
  102312. return "#define CYLINDEREMITTER\n#define DIRECTEDCYLINDEREMITTER";
  102313. };
  102314. /**
  102315. * Returns the string "CylinderDirectedParticleEmitter"
  102316. * @returns a string containing the class name
  102317. */
  102318. CylinderDirectedParticleEmitter.prototype.getClassName = function () {
  102319. return "CylinderDirectedParticleEmitter";
  102320. };
  102321. /**
  102322. * Serializes the particle system to a JSON object.
  102323. * @returns the JSON object
  102324. */
  102325. CylinderDirectedParticleEmitter.prototype.serialize = function () {
  102326. var serializationObject = _super.prototype.serialize.call(this);
  102327. serializationObject.direction1 = this.direction1.asArray();
  102328. serializationObject.direction2 = this.direction2.asArray();
  102329. return serializationObject;
  102330. };
  102331. /**
  102332. * Parse properties from a JSON object
  102333. * @param serializationObject defines the JSON object
  102334. */
  102335. CylinderDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  102336. _super.prototype.parse.call(this, serializationObject);
  102337. this.direction1.copyFrom(serializationObject.direction1);
  102338. this.direction2.copyFrom(serializationObject.direction2);
  102339. };
  102340. return CylinderDirectedParticleEmitter;
  102341. }(CylinderParticleEmitter));
  102342. /***/ }),
  102343. /***/ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts":
  102344. /*!**************************************************************!*\
  102345. !*** ./Particles/EmitterTypes/hemisphericParticleEmitter.ts ***!
  102346. \**************************************************************/
  102347. /*! exports provided: HemisphericParticleEmitter */
  102348. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102349. "use strict";
  102350. __webpack_require__.r(__webpack_exports__);
  102351. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return HemisphericParticleEmitter; });
  102352. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  102353. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  102354. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  102355. /**
  102356. * Particle emitter emitting particles from the inside of a hemisphere.
  102357. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  102358. */
  102359. var HemisphericParticleEmitter = /** @class */ (function () {
  102360. /**
  102361. * Creates a new instance HemisphericParticleEmitter
  102362. * @param radius the radius of the emission hemisphere (1 by default)
  102363. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102364. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  102365. */
  102366. function HemisphericParticleEmitter(
  102367. /**
  102368. * The radius of the emission hemisphere.
  102369. */
  102370. radius,
  102371. /**
  102372. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  102373. */
  102374. radiusRange,
  102375. /**
  102376. * How much to randomize the particle direction [0-1].
  102377. */
  102378. directionRandomizer) {
  102379. if (radius === void 0) { radius = 1; }
  102380. if (radiusRange === void 0) { radiusRange = 1; }
  102381. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  102382. this.radius = radius;
  102383. this.radiusRange = radiusRange;
  102384. this.directionRandomizer = directionRandomizer;
  102385. }
  102386. /**
  102387. * Called by the particle System when the direction is computed for the created particle.
  102388. * @param worldMatrix is the world matrix of the particle system
  102389. * @param directionToUpdate is the direction vector to update with the result
  102390. * @param particle is the particle we are computed the direction for
  102391. */
  102392. HemisphericParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102393. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  102394. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102395. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102396. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102397. direction.x += randX;
  102398. direction.y += randY;
  102399. direction.z += randZ;
  102400. direction.normalize();
  102401. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  102402. };
  102403. /**
  102404. * Called by the particle System when the position is computed for the created particle.
  102405. * @param worldMatrix is the world matrix of the particle system
  102406. * @param positionToUpdate is the position vector to update with the result
  102407. * @param particle is the particle we are computed the position for
  102408. */
  102409. HemisphericParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  102410. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  102411. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  102412. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  102413. var theta = Math.acos(2 * v - 1);
  102414. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  102415. var randY = randRadius * Math.cos(theta);
  102416. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  102417. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, Math.abs(randY), randZ, worldMatrix, positionToUpdate);
  102418. };
  102419. /**
  102420. * Clones the current emitter and returns a copy of it
  102421. * @returns the new emitter
  102422. */
  102423. HemisphericParticleEmitter.prototype.clone = function () {
  102424. var newOne = new HemisphericParticleEmitter(this.radius, this.directionRandomizer);
  102425. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  102426. return newOne;
  102427. };
  102428. /**
  102429. * Called by the GPUParticleSystem to setup the update shader
  102430. * @param effect defines the update shader
  102431. */
  102432. HemisphericParticleEmitter.prototype.applyToShader = function (effect) {
  102433. effect.setFloat("radius", this.radius);
  102434. effect.setFloat("radiusRange", this.radiusRange);
  102435. effect.setFloat("directionRandomizer", this.directionRandomizer);
  102436. };
  102437. /**
  102438. * Returns a string to use to update the GPU particles update shader
  102439. * @returns a string containng the defines string
  102440. */
  102441. HemisphericParticleEmitter.prototype.getEffectDefines = function () {
  102442. return "#define HEMISPHERICEMITTER";
  102443. };
  102444. /**
  102445. * Returns the string "HemisphericParticleEmitter"
  102446. * @returns a string containing the class name
  102447. */
  102448. HemisphericParticleEmitter.prototype.getClassName = function () {
  102449. return "HemisphericParticleEmitter";
  102450. };
  102451. /**
  102452. * Serializes the particle system to a JSON object.
  102453. * @returns the JSON object
  102454. */
  102455. HemisphericParticleEmitter.prototype.serialize = function () {
  102456. var serializationObject = {};
  102457. serializationObject.type = this.getClassName();
  102458. serializationObject.radius = this.radius;
  102459. serializationObject.radiusRange = this.radiusRange;
  102460. serializationObject.directionRandomizer = this.directionRandomizer;
  102461. return serializationObject;
  102462. };
  102463. /**
  102464. * Parse properties from a JSON object
  102465. * @param serializationObject defines the JSON object
  102466. */
  102467. HemisphericParticleEmitter.prototype.parse = function (serializationObject) {
  102468. this.radius = serializationObject.radius;
  102469. this.radiusRange = serializationObject.radiusRange;
  102470. this.directionRandomizer = serializationObject.directionRandomizer;
  102471. };
  102472. return HemisphericParticleEmitter;
  102473. }());
  102474. /***/ }),
  102475. /***/ "./Particles/EmitterTypes/index.ts":
  102476. /*!*****************************************!*\
  102477. !*** ./Particles/EmitterTypes/index.ts ***!
  102478. \*****************************************/
  102479. /*! exports provided: BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  102480. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102481. "use strict";
  102482. __webpack_require__.r(__webpack_exports__);
  102483. /* harmony import */ var _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  102484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  102485. /* harmony import */ var _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./coneParticleEmitter */ "./Particles/EmitterTypes/coneParticleEmitter.ts");
  102486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  102487. /* harmony import */ var _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cylinderParticleEmitter */ "./Particles/EmitterTypes/cylinderParticleEmitter.ts");
  102488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"]; });
  102489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"]; });
  102490. /* harmony import */ var _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hemisphericParticleEmitter */ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts");
  102491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__["HemisphericParticleEmitter"]; });
  102492. /* harmony import */ var _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pointParticleEmitter */ "./Particles/EmitterTypes/pointParticleEmitter.ts");
  102493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__["PointParticleEmitter"]; });
  102494. /* harmony import */ var _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./sphereParticleEmitter */ "./Particles/EmitterTypes/sphereParticleEmitter.ts");
  102495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereParticleEmitter"]; });
  102496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereDirectedParticleEmitter"]; });
  102497. /***/ }),
  102498. /***/ "./Particles/EmitterTypes/pointParticleEmitter.ts":
  102499. /*!********************************************************!*\
  102500. !*** ./Particles/EmitterTypes/pointParticleEmitter.ts ***!
  102501. \********************************************************/
  102502. /*! exports provided: PointParticleEmitter */
  102503. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102504. "use strict";
  102505. __webpack_require__.r(__webpack_exports__);
  102506. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return PointParticleEmitter; });
  102507. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  102508. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  102509. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  102510. /**
  102511. * Particle emitter emitting particles from a point.
  102512. * It emits the particles randomly between 2 given directions.
  102513. */
  102514. var PointParticleEmitter = /** @class */ (function () {
  102515. /**
  102516. * Creates a new instance PointParticleEmitter
  102517. */
  102518. function PointParticleEmitter() {
  102519. /**
  102520. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  102521. */
  102522. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  102523. /**
  102524. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  102525. */
  102526. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  102527. }
  102528. /**
  102529. * Called by the particle System when the direction is computed for the created particle.
  102530. * @param worldMatrix is the world matrix of the particle system
  102531. * @param directionToUpdate is the direction vector to update with the result
  102532. * @param particle is the particle we are computed the direction for
  102533. */
  102534. PointParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102535. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  102536. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  102537. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  102538. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  102539. };
  102540. /**
  102541. * Called by the particle System when the position is computed for the created particle.
  102542. * @param worldMatrix is the world matrix of the particle system
  102543. * @param positionToUpdate is the position vector to update with the result
  102544. * @param particle is the particle we are computed the position for
  102545. */
  102546. PointParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  102547. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0, 0, 0, worldMatrix, positionToUpdate);
  102548. };
  102549. /**
  102550. * Clones the current emitter and returns a copy of it
  102551. * @returns the new emitter
  102552. */
  102553. PointParticleEmitter.prototype.clone = function () {
  102554. var newOne = new PointParticleEmitter();
  102555. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  102556. return newOne;
  102557. };
  102558. /**
  102559. * Called by the GPUParticleSystem to setup the update shader
  102560. * @param effect defines the update shader
  102561. */
  102562. PointParticleEmitter.prototype.applyToShader = function (effect) {
  102563. effect.setVector3("direction1", this.direction1);
  102564. effect.setVector3("direction2", this.direction2);
  102565. };
  102566. /**
  102567. * Returns a string to use to update the GPU particles update shader
  102568. * @returns a string containng the defines string
  102569. */
  102570. PointParticleEmitter.prototype.getEffectDefines = function () {
  102571. return "#define POINTEMITTER";
  102572. };
  102573. /**
  102574. * Returns the string "PointParticleEmitter"
  102575. * @returns a string containing the class name
  102576. */
  102577. PointParticleEmitter.prototype.getClassName = function () {
  102578. return "PointParticleEmitter";
  102579. };
  102580. /**
  102581. * Serializes the particle system to a JSON object.
  102582. * @returns the JSON object
  102583. */
  102584. PointParticleEmitter.prototype.serialize = function () {
  102585. var serializationObject = {};
  102586. serializationObject.type = this.getClassName();
  102587. serializationObject.direction1 = this.direction1.asArray();
  102588. serializationObject.direction2 = this.direction2.asArray();
  102589. return serializationObject;
  102590. };
  102591. /**
  102592. * Parse properties from a JSON object
  102593. * @param serializationObject defines the JSON object
  102594. */
  102595. PointParticleEmitter.prototype.parse = function (serializationObject) {
  102596. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  102597. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  102598. };
  102599. return PointParticleEmitter;
  102600. }());
  102601. /***/ }),
  102602. /***/ "./Particles/EmitterTypes/sphereParticleEmitter.ts":
  102603. /*!*********************************************************!*\
  102604. !*** ./Particles/EmitterTypes/sphereParticleEmitter.ts ***!
  102605. \*********************************************************/
  102606. /*! exports provided: SphereParticleEmitter, SphereDirectedParticleEmitter */
  102607. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102608. "use strict";
  102609. __webpack_require__.r(__webpack_exports__);
  102610. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return SphereParticleEmitter; });
  102611. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return SphereDirectedParticleEmitter; });
  102612. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  102613. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  102614. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  102615. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  102616. /**
  102617. * Particle emitter emitting particles from the inside of a sphere.
  102618. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  102619. */
  102620. var SphereParticleEmitter = /** @class */ (function () {
  102621. /**
  102622. * Creates a new instance SphereParticleEmitter
  102623. * @param radius the radius of the emission sphere (1 by default)
  102624. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102625. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  102626. */
  102627. function SphereParticleEmitter(
  102628. /**
  102629. * The radius of the emission sphere.
  102630. */
  102631. radius,
  102632. /**
  102633. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  102634. */
  102635. radiusRange,
  102636. /**
  102637. * How much to randomize the particle direction [0-1].
  102638. */
  102639. directionRandomizer) {
  102640. if (radius === void 0) { radius = 1; }
  102641. if (radiusRange === void 0) { radiusRange = 1; }
  102642. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  102643. this.radius = radius;
  102644. this.radiusRange = radiusRange;
  102645. this.directionRandomizer = directionRandomizer;
  102646. }
  102647. /**
  102648. * Called by the particle System when the direction is computed for the created particle.
  102649. * @param worldMatrix is the world matrix of the particle system
  102650. * @param directionToUpdate is the direction vector to update with the result
  102651. * @param particle is the particle we are computed the direction for
  102652. */
  102653. SphereParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102654. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  102655. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102656. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102657. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102658. direction.x += randX;
  102659. direction.y += randY;
  102660. direction.z += randZ;
  102661. direction.normalize();
  102662. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  102663. };
  102664. /**
  102665. * Called by the particle System when the position is computed for the created particle.
  102666. * @param worldMatrix is the world matrix of the particle system
  102667. * @param positionToUpdate is the position vector to update with the result
  102668. * @param particle is the particle we are computed the position for
  102669. */
  102670. SphereParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  102671. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  102672. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  102673. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  102674. var theta = Math.acos(2 * v - 1);
  102675. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  102676. var randY = randRadius * Math.cos(theta);
  102677. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  102678. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  102679. };
  102680. /**
  102681. * Clones the current emitter and returns a copy of it
  102682. * @returns the new emitter
  102683. */
  102684. SphereParticleEmitter.prototype.clone = function () {
  102685. var newOne = new SphereParticleEmitter(this.radius, this.directionRandomizer);
  102686. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  102687. return newOne;
  102688. };
  102689. /**
  102690. * Called by the GPUParticleSystem to setup the update shader
  102691. * @param effect defines the update shader
  102692. */
  102693. SphereParticleEmitter.prototype.applyToShader = function (effect) {
  102694. effect.setFloat("radius", this.radius);
  102695. effect.setFloat("radiusRange", this.radiusRange);
  102696. effect.setFloat("directionRandomizer", this.directionRandomizer);
  102697. };
  102698. /**
  102699. * Returns a string to use to update the GPU particles update shader
  102700. * @returns a string containng the defines string
  102701. */
  102702. SphereParticleEmitter.prototype.getEffectDefines = function () {
  102703. return "#define SPHEREEMITTER";
  102704. };
  102705. /**
  102706. * Returns the string "SphereParticleEmitter"
  102707. * @returns a string containing the class name
  102708. */
  102709. SphereParticleEmitter.prototype.getClassName = function () {
  102710. return "SphereParticleEmitter";
  102711. };
  102712. /**
  102713. * Serializes the particle system to a JSON object.
  102714. * @returns the JSON object
  102715. */
  102716. SphereParticleEmitter.prototype.serialize = function () {
  102717. var serializationObject = {};
  102718. serializationObject.type = this.getClassName();
  102719. serializationObject.radius = this.radius;
  102720. serializationObject.radiusRange = this.radiusRange;
  102721. serializationObject.directionRandomizer = this.directionRandomizer;
  102722. return serializationObject;
  102723. };
  102724. /**
  102725. * Parse properties from a JSON object
  102726. * @param serializationObject defines the JSON object
  102727. */
  102728. SphereParticleEmitter.prototype.parse = function (serializationObject) {
  102729. this.radius = serializationObject.radius;
  102730. this.radiusRange = serializationObject.radiusRange;
  102731. this.directionRandomizer = serializationObject.directionRandomizer;
  102732. };
  102733. return SphereParticleEmitter;
  102734. }());
  102735. /**
  102736. * Particle emitter emitting particles from the inside of a sphere.
  102737. * It emits the particles randomly between two vectors.
  102738. */
  102739. var SphereDirectedParticleEmitter = /** @class */ (function (_super) {
  102740. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SphereDirectedParticleEmitter, _super);
  102741. /**
  102742. * Creates a new instance SphereDirectedParticleEmitter
  102743. * @param radius the radius of the emission sphere (1 by default)
  102744. * @param direction1 the min limit of the emission direction (up vector by default)
  102745. * @param direction2 the max limit of the emission direction (up vector by default)
  102746. */
  102747. function SphereDirectedParticleEmitter(radius,
  102748. /**
  102749. * The min limit of the emission direction.
  102750. */
  102751. direction1,
  102752. /**
  102753. * The max limit of the emission direction.
  102754. */
  102755. direction2) {
  102756. if (radius === void 0) { radius = 1; }
  102757. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  102758. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  102759. var _this = _super.call(this, radius) || this;
  102760. _this.direction1 = direction1;
  102761. _this.direction2 = direction2;
  102762. return _this;
  102763. }
  102764. /**
  102765. * Called by the particle System when the direction is computed for the created particle.
  102766. * @param worldMatrix is the world matrix of the particle system
  102767. * @param directionToUpdate is the direction vector to update with the result
  102768. * @param particle is the particle we are computed the direction for
  102769. */
  102770. SphereDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102771. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  102772. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  102773. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  102774. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  102775. };
  102776. /**
  102777. * Clones the current emitter and returns a copy of it
  102778. * @returns the new emitter
  102779. */
  102780. SphereDirectedParticleEmitter.prototype.clone = function () {
  102781. var newOne = new SphereDirectedParticleEmitter(this.radius, this.direction1, this.direction2);
  102782. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  102783. return newOne;
  102784. };
  102785. /**
  102786. * Called by the GPUParticleSystem to setup the update shader
  102787. * @param effect defines the update shader
  102788. */
  102789. SphereDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  102790. effect.setFloat("radius", this.radius);
  102791. effect.setFloat("radiusRange", this.radiusRange);
  102792. effect.setVector3("direction1", this.direction1);
  102793. effect.setVector3("direction2", this.direction2);
  102794. };
  102795. /**
  102796. * Returns a string to use to update the GPU particles update shader
  102797. * @returns a string containng the defines string
  102798. */
  102799. SphereDirectedParticleEmitter.prototype.getEffectDefines = function () {
  102800. return "#define SPHEREEMITTER\n#define DIRECTEDSPHEREEMITTER";
  102801. };
  102802. /**
  102803. * Returns the string "SphereDirectedParticleEmitter"
  102804. * @returns a string containing the class name
  102805. */
  102806. SphereDirectedParticleEmitter.prototype.getClassName = function () {
  102807. return "SphereDirectedParticleEmitter";
  102808. };
  102809. /**
  102810. * Serializes the particle system to a JSON object.
  102811. * @returns the JSON object
  102812. */
  102813. SphereDirectedParticleEmitter.prototype.serialize = function () {
  102814. var serializationObject = _super.prototype.serialize.call(this);
  102815. serializationObject.direction1 = this.direction1.asArray();
  102816. serializationObject.direction2 = this.direction2.asArray();
  102817. return serializationObject;
  102818. };
  102819. /**
  102820. * Parse properties from a JSON object
  102821. * @param serializationObject defines the JSON object
  102822. */
  102823. SphereDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  102824. _super.prototype.parse.call(this, serializationObject);
  102825. this.direction1.copyFrom(serializationObject.direction1);
  102826. this.direction2.copyFrom(serializationObject.direction2);
  102827. };
  102828. return SphereDirectedParticleEmitter;
  102829. }(SphereParticleEmitter));
  102830. /***/ }),
  102831. /***/ "./Particles/baseParticleSystem.ts":
  102832. /*!*****************************************!*\
  102833. !*** ./Particles/baseParticleSystem.ts ***!
  102834. \*****************************************/
  102835. /*! exports provided: BaseParticleSystem */
  102836. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102837. "use strict";
  102838. __webpack_require__.r(__webpack_exports__);
  102839. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return BaseParticleSystem; });
  102840. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  102841. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  102842. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  102843. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  102844. /**
  102845. * This represents the base class for particle system in Babylon.
  102846. * 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.
  102847. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  102848. * @example https://doc.babylonjs.com/babylon101/particles
  102849. */
  102850. var BaseParticleSystem = /** @class */ (function () {
  102851. /**
  102852. * Instantiates a particle system.
  102853. * 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.
  102854. * @param name The name of the particle system
  102855. */
  102856. function BaseParticleSystem(name) {
  102857. /**
  102858. * List of animations used by the particle system.
  102859. */
  102860. this.animations = [];
  102861. /**
  102862. * The rendering group used by the Particle system to chose when to render.
  102863. */
  102864. this.renderingGroupId = 0;
  102865. /**
  102866. * The emitter represents the Mesh or position we are attaching the particle system to.
  102867. */
  102868. this.emitter = null;
  102869. /**
  102870. * The maximum number of particles to emit per frame
  102871. */
  102872. this.emitRate = 10;
  102873. /**
  102874. * If you want to launch only a few particles at once, that can be done, as well.
  102875. */
  102876. this.manualEmitCount = -1;
  102877. /**
  102878. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  102879. */
  102880. this.updateSpeed = 0.01;
  102881. /**
  102882. * The amount of time the particle system is running (depends of the overall update speed).
  102883. */
  102884. this.targetStopDuration = 0;
  102885. /**
  102886. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  102887. */
  102888. this.disposeOnStop = false;
  102889. /**
  102890. * Minimum power of emitting particles.
  102891. */
  102892. this.minEmitPower = 1;
  102893. /**
  102894. * Maximum power of emitting particles.
  102895. */
  102896. this.maxEmitPower = 1;
  102897. /**
  102898. * Minimum life time of emitting particles.
  102899. */
  102900. this.minLifeTime = 1;
  102901. /**
  102902. * Maximum life time of emitting particles.
  102903. */
  102904. this.maxLifeTime = 1;
  102905. /**
  102906. * Minimum Size of emitting particles.
  102907. */
  102908. this.minSize = 1;
  102909. /**
  102910. * Maximum Size of emitting particles.
  102911. */
  102912. this.maxSize = 1;
  102913. /**
  102914. * Minimum scale of emitting particles on X axis.
  102915. */
  102916. this.minScaleX = 1;
  102917. /**
  102918. * Maximum scale of emitting particles on X axis.
  102919. */
  102920. this.maxScaleX = 1;
  102921. /**
  102922. * Minimum scale of emitting particles on Y axis.
  102923. */
  102924. this.minScaleY = 1;
  102925. /**
  102926. * Maximum scale of emitting particles on Y axis.
  102927. */
  102928. this.maxScaleY = 1;
  102929. /**
  102930. * Gets or sets the minimal initial rotation in radians.
  102931. */
  102932. this.minInitialRotation = 0;
  102933. /**
  102934. * Gets or sets the maximal initial rotation in radians.
  102935. */
  102936. this.maxInitialRotation = 0;
  102937. /**
  102938. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  102939. */
  102940. this.minAngularSpeed = 0;
  102941. /**
  102942. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  102943. */
  102944. this.maxAngularSpeed = 0;
  102945. /**
  102946. * The layer mask we are rendering the particles through.
  102947. */
  102948. this.layerMask = 0x0FFFFFFF;
  102949. /**
  102950. * This can help using your own shader to render the particle system.
  102951. * The according effect will be created
  102952. */
  102953. this.customShader = null;
  102954. /**
  102955. * By default particle system starts as soon as they are created. This prevents the
  102956. * automatic start to happen and let you decide when to start emitting particles.
  102957. */
  102958. this.preventAutoStart = false;
  102959. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  102960. this.noiseStrength = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](10, 10, 10);
  102961. /**
  102962. * Callback triggered when the particle animation is ending.
  102963. */
  102964. this.onAnimationEnd = null;
  102965. /**
  102966. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  102967. */
  102968. this.blendMode = BaseParticleSystem.BLENDMODE_ONEONE;
  102969. /**
  102970. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  102971. * to override the particles.
  102972. */
  102973. this.forceDepthWrite = false;
  102974. /** 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 */
  102975. this.preWarmCycles = 0;
  102976. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  102977. this.preWarmStepOffset = 1;
  102978. /**
  102979. * 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)
  102980. */
  102981. this.spriteCellChangeSpeed = 1;
  102982. /**
  102983. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  102984. */
  102985. this.startSpriteCellID = 0;
  102986. /**
  102987. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  102988. */
  102989. this.endSpriteCellID = 0;
  102990. /**
  102991. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  102992. */
  102993. this.spriteCellWidth = 0;
  102994. /**
  102995. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  102996. */
  102997. this.spriteCellHeight = 0;
  102998. /**
  102999. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  103000. */
  103001. this.spriteRandomStartCell = false;
  103002. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  103003. this.translationPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  103004. /**
  103005. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  103006. */
  103007. this.beginAnimationOnStart = false;
  103008. /**
  103009. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  103010. */
  103011. this.beginAnimationFrom = 0;
  103012. /**
  103013. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  103014. */
  103015. this.beginAnimationTo = 60;
  103016. /**
  103017. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  103018. */
  103019. this.beginAnimationLoop = false;
  103020. /**
  103021. * You can use gravity if you want to give an orientation to your particles.
  103022. */
  103023. this.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103024. this._colorGradients = null;
  103025. this._sizeGradients = null;
  103026. this._lifeTimeGradients = null;
  103027. this._angularSpeedGradients = null;
  103028. this._velocityGradients = null;
  103029. this._limitVelocityGradients = null;
  103030. this._dragGradients = null;
  103031. this._emitRateGradients = null;
  103032. this._startSizeGradients = null;
  103033. this._rampGradients = null;
  103034. this._colorRemapGradients = null;
  103035. this._alphaRemapGradients = null;
  103036. /**
  103037. * Defines the delay in milliseconds before starting the system (0 by default)
  103038. */
  103039. this.startDelay = 0;
  103040. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  103041. this.limitVelocityDamping = 0.4;
  103042. /**
  103043. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  103044. */
  103045. this.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  103046. /**
  103047. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  103048. */
  103049. this.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  103050. /**
  103051. * Color the particle will have at the end of its lifetime
  103052. */
  103053. this.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 1.0);
  103054. /**
  103055. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  103056. */
  103057. this.textureMask = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  103058. /** @hidden */
  103059. this._isSubEmitter = false;
  103060. /**
  103061. * Gets or sets the billboard mode to use when isBillboardBased = true.
  103062. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  103063. */
  103064. this.billboardMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  103065. this._isBillboardBased = true;
  103066. /**
  103067. * Local cache of defines for image processing.
  103068. */
  103069. this._imageProcessingConfigurationDefines = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__["ImageProcessingConfigurationDefines"]();
  103070. this.id = name;
  103071. this.name = name;
  103072. }
  103073. Object.defineProperty(BaseParticleSystem.prototype, "noiseTexture", {
  103074. /**
  103075. * Gets or sets a texture used to add random noise to particle positions
  103076. */
  103077. get: function () {
  103078. return this._noiseTexture;
  103079. },
  103080. set: function (value) {
  103081. if (this._noiseTexture === value) {
  103082. return;
  103083. }
  103084. this._noiseTexture = value;
  103085. this._reset();
  103086. },
  103087. enumerable: true,
  103088. configurable: true
  103089. });
  103090. Object.defineProperty(BaseParticleSystem.prototype, "isAnimationSheetEnabled", {
  103091. /**
  103092. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  103093. */
  103094. get: function () {
  103095. return this._isAnimationSheetEnabled;
  103096. },
  103097. set: function (value) {
  103098. if (this._isAnimationSheetEnabled == value) {
  103099. return;
  103100. }
  103101. this._isAnimationSheetEnabled = value;
  103102. this._reset();
  103103. },
  103104. enumerable: true,
  103105. configurable: true
  103106. });
  103107. /**
  103108. * Get hosting scene
  103109. * @returns the scene
  103110. */
  103111. BaseParticleSystem.prototype.getScene = function () {
  103112. return this._scene;
  103113. };
  103114. BaseParticleSystem.prototype._hasTargetStopDurationDependantGradient = function () {
  103115. return (this._startSizeGradients && this._startSizeGradients.length > 0)
  103116. || (this._emitRateGradients && this._emitRateGradients.length > 0)
  103117. || (this._lifeTimeGradients && this._lifeTimeGradients.length > 0);
  103118. };
  103119. /**
  103120. * Gets the current list of drag gradients.
  103121. * You must use addDragGradient and removeDragGradient to udpate this list
  103122. * @returns the list of drag gradients
  103123. */
  103124. BaseParticleSystem.prototype.getDragGradients = function () {
  103125. return this._dragGradients;
  103126. };
  103127. /**
  103128. * Gets the current list of limit velocity gradients.
  103129. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  103130. * @returns the list of limit velocity gradients
  103131. */
  103132. BaseParticleSystem.prototype.getLimitVelocityGradients = function () {
  103133. return this._limitVelocityGradients;
  103134. };
  103135. /**
  103136. * Gets the current list of color gradients.
  103137. * You must use addColorGradient and removeColorGradient to udpate this list
  103138. * @returns the list of color gradients
  103139. */
  103140. BaseParticleSystem.prototype.getColorGradients = function () {
  103141. return this._colorGradients;
  103142. };
  103143. /**
  103144. * Gets the current list of size gradients.
  103145. * You must use addSizeGradient and removeSizeGradient to udpate this list
  103146. * @returns the list of size gradients
  103147. */
  103148. BaseParticleSystem.prototype.getSizeGradients = function () {
  103149. return this._sizeGradients;
  103150. };
  103151. /**
  103152. * Gets the current list of color remap gradients.
  103153. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  103154. * @returns the list of color remap gradients
  103155. */
  103156. BaseParticleSystem.prototype.getColorRemapGradients = function () {
  103157. return this._colorRemapGradients;
  103158. };
  103159. /**
  103160. * Gets the current list of alpha remap gradients.
  103161. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  103162. * @returns the list of alpha remap gradients
  103163. */
  103164. BaseParticleSystem.prototype.getAlphaRemapGradients = function () {
  103165. return this._alphaRemapGradients;
  103166. };
  103167. /**
  103168. * Gets the current list of life time gradients.
  103169. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  103170. * @returns the list of life time gradients
  103171. */
  103172. BaseParticleSystem.prototype.getLifeTimeGradients = function () {
  103173. return this._lifeTimeGradients;
  103174. };
  103175. /**
  103176. * Gets the current list of angular speed gradients.
  103177. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  103178. * @returns the list of angular speed gradients
  103179. */
  103180. BaseParticleSystem.prototype.getAngularSpeedGradients = function () {
  103181. return this._angularSpeedGradients;
  103182. };
  103183. /**
  103184. * Gets the current list of velocity gradients.
  103185. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  103186. * @returns the list of velocity gradients
  103187. */
  103188. BaseParticleSystem.prototype.getVelocityGradients = function () {
  103189. return this._velocityGradients;
  103190. };
  103191. /**
  103192. * Gets the current list of start size gradients.
  103193. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  103194. * @returns the list of start size gradients
  103195. */
  103196. BaseParticleSystem.prototype.getStartSizeGradients = function () {
  103197. return this._startSizeGradients;
  103198. };
  103199. /**
  103200. * Gets the current list of emit rate gradients.
  103201. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  103202. * @returns the list of emit rate gradients
  103203. */
  103204. BaseParticleSystem.prototype.getEmitRateGradients = function () {
  103205. return this._emitRateGradients;
  103206. };
  103207. Object.defineProperty(BaseParticleSystem.prototype, "direction1", {
  103208. /**
  103209. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  103210. * This only works when particleEmitterTyps is a BoxParticleEmitter
  103211. */
  103212. get: function () {
  103213. if (this.particleEmitterType.direction1) {
  103214. return this.particleEmitterType.direction1;
  103215. }
  103216. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103217. },
  103218. set: function (value) {
  103219. if (this.particleEmitterType.direction1) {
  103220. this.particleEmitterType.direction1 = value;
  103221. }
  103222. },
  103223. enumerable: true,
  103224. configurable: true
  103225. });
  103226. Object.defineProperty(BaseParticleSystem.prototype, "direction2", {
  103227. /**
  103228. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  103229. * This only works when particleEmitterTyps is a BoxParticleEmitter
  103230. */
  103231. get: function () {
  103232. if (this.particleEmitterType.direction2) {
  103233. return this.particleEmitterType.direction2;
  103234. }
  103235. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103236. },
  103237. set: function (value) {
  103238. if (this.particleEmitterType.direction2) {
  103239. this.particleEmitterType.direction2 = value;
  103240. }
  103241. },
  103242. enumerable: true,
  103243. configurable: true
  103244. });
  103245. Object.defineProperty(BaseParticleSystem.prototype, "minEmitBox", {
  103246. /**
  103247. * 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.
  103248. * This only works when particleEmitterTyps is a BoxParticleEmitter
  103249. */
  103250. get: function () {
  103251. if (this.particleEmitterType.minEmitBox) {
  103252. return this.particleEmitterType.minEmitBox;
  103253. }
  103254. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103255. },
  103256. set: function (value) {
  103257. if (this.particleEmitterType.minEmitBox) {
  103258. this.particleEmitterType.minEmitBox = value;
  103259. }
  103260. },
  103261. enumerable: true,
  103262. configurable: true
  103263. });
  103264. Object.defineProperty(BaseParticleSystem.prototype, "maxEmitBox", {
  103265. /**
  103266. * 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.
  103267. * This only works when particleEmitterTyps is a BoxParticleEmitter
  103268. */
  103269. get: function () {
  103270. if (this.particleEmitterType.maxEmitBox) {
  103271. return this.particleEmitterType.maxEmitBox;
  103272. }
  103273. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103274. },
  103275. set: function (value) {
  103276. if (this.particleEmitterType.maxEmitBox) {
  103277. this.particleEmitterType.maxEmitBox = value;
  103278. }
  103279. },
  103280. enumerable: true,
  103281. configurable: true
  103282. });
  103283. Object.defineProperty(BaseParticleSystem.prototype, "isBillboardBased", {
  103284. /**
  103285. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  103286. */
  103287. get: function () {
  103288. return this._isBillboardBased;
  103289. },
  103290. set: function (value) {
  103291. if (this._isBillboardBased === value) {
  103292. return;
  103293. }
  103294. this._isBillboardBased = value;
  103295. this._reset();
  103296. },
  103297. enumerable: true,
  103298. configurable: true
  103299. });
  103300. Object.defineProperty(BaseParticleSystem.prototype, "imageProcessingConfiguration", {
  103301. /**
  103302. * Gets the image processing configuration used either in this material.
  103303. */
  103304. get: function () {
  103305. return this._imageProcessingConfiguration;
  103306. },
  103307. /**
  103308. * Sets the Default image processing configuration used either in the this material.
  103309. *
  103310. * If sets to null, the scene one is in use.
  103311. */
  103312. set: function (value) {
  103313. this._attachImageProcessingConfiguration(value);
  103314. },
  103315. enumerable: true,
  103316. configurable: true
  103317. });
  103318. /**
  103319. * Attaches a new image processing configuration to the Standard Material.
  103320. * @param configuration
  103321. */
  103322. BaseParticleSystem.prototype._attachImageProcessingConfiguration = function (configuration) {
  103323. if (configuration === this._imageProcessingConfiguration) {
  103324. return;
  103325. }
  103326. // Pick the scene configuration if needed.
  103327. if (!configuration) {
  103328. this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration;
  103329. }
  103330. else {
  103331. this._imageProcessingConfiguration = configuration;
  103332. }
  103333. };
  103334. /** @hidden */
  103335. BaseParticleSystem.prototype._reset = function () {
  103336. };
  103337. /** @hidden */
  103338. BaseParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  103339. if (!gradients) {
  103340. return this;
  103341. }
  103342. var index = 0;
  103343. for (var _i = 0, gradients_1 = gradients; _i < gradients_1.length; _i++) {
  103344. var valueGradient = gradients_1[_i];
  103345. if (valueGradient.gradient === gradient) {
  103346. gradients.splice(index, 1);
  103347. break;
  103348. }
  103349. index++;
  103350. }
  103351. if (texture) {
  103352. texture.dispose();
  103353. }
  103354. return this;
  103355. };
  103356. /**
  103357. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  103358. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  103359. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  103360. * @returns the emitter
  103361. */
  103362. BaseParticleSystem.prototype.createPointEmitter = function (direction1, direction2) {
  103363. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["PointParticleEmitter"]();
  103364. particleEmitter.direction1 = direction1;
  103365. particleEmitter.direction2 = direction2;
  103366. this.particleEmitterType = particleEmitter;
  103367. return particleEmitter;
  103368. };
  103369. /**
  103370. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  103371. * @param radius The radius of the hemisphere to emit from
  103372. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  103373. * @returns the emitter
  103374. */
  103375. BaseParticleSystem.prototype.createHemisphericEmitter = function (radius, radiusRange) {
  103376. if (radius === void 0) { radius = 1; }
  103377. if (radiusRange === void 0) { radiusRange = 1; }
  103378. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["HemisphericParticleEmitter"](radius, radiusRange);
  103379. this.particleEmitterType = particleEmitter;
  103380. return particleEmitter;
  103381. };
  103382. /**
  103383. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  103384. * @param radius The radius of the sphere to emit from
  103385. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  103386. * @returns the emitter
  103387. */
  103388. BaseParticleSystem.prototype.createSphereEmitter = function (radius, radiusRange) {
  103389. if (radius === void 0) { radius = 1; }
  103390. if (radiusRange === void 0) { radiusRange = 1; }
  103391. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereParticleEmitter"](radius, radiusRange);
  103392. this.particleEmitterType = particleEmitter;
  103393. return particleEmitter;
  103394. };
  103395. /**
  103396. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  103397. * @param radius The radius of the sphere to emit from
  103398. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  103399. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  103400. * @returns the emitter
  103401. */
  103402. BaseParticleSystem.prototype.createDirectedSphereEmitter = function (radius, direction1, direction2) {
  103403. if (radius === void 0) { radius = 1; }
  103404. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  103405. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  103406. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereDirectedParticleEmitter"](radius, direction1, direction2);
  103407. this.particleEmitterType = particleEmitter;
  103408. return particleEmitter;
  103409. };
  103410. /**
  103411. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  103412. * @param radius The radius of the emission cylinder
  103413. * @param height The height of the emission cylinder
  103414. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  103415. * @param directionRandomizer How much to randomize the particle direction [0-1]
  103416. * @returns the emitter
  103417. */
  103418. BaseParticleSystem.prototype.createCylinderEmitter = function (radius, height, radiusRange, directionRandomizer) {
  103419. if (radius === void 0) { radius = 1; }
  103420. if (height === void 0) { height = 1; }
  103421. if (radiusRange === void 0) { radiusRange = 1; }
  103422. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  103423. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"](radius, height, radiusRange, directionRandomizer);
  103424. this.particleEmitterType = particleEmitter;
  103425. return particleEmitter;
  103426. };
  103427. /**
  103428. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  103429. * @param radius The radius of the cylinder to emit from
  103430. * @param height The height of the emission cylinder
  103431. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  103432. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  103433. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  103434. * @returns the emitter
  103435. */
  103436. BaseParticleSystem.prototype.createDirectedCylinderEmitter = function (radius, height, radiusRange, direction1, direction2) {
  103437. if (radius === void 0) { radius = 1; }
  103438. if (height === void 0) { height = 1; }
  103439. if (radiusRange === void 0) { radiusRange = 1; }
  103440. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  103441. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  103442. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"](radius, height, radiusRange, direction1, direction2);
  103443. this.particleEmitterType = particleEmitter;
  103444. return particleEmitter;
  103445. };
  103446. /**
  103447. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  103448. * @param radius The radius of the cone to emit from
  103449. * @param angle The base angle of the cone
  103450. * @returns the emitter
  103451. */
  103452. BaseParticleSystem.prototype.createConeEmitter = function (radius, angle) {
  103453. if (radius === void 0) { radius = 1; }
  103454. if (angle === void 0) { angle = Math.PI / 4; }
  103455. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["ConeParticleEmitter"](radius, angle);
  103456. this.particleEmitterType = particleEmitter;
  103457. return particleEmitter;
  103458. };
  103459. /**
  103460. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  103461. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  103462. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  103463. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  103464. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  103465. * @returns the emitter
  103466. */
  103467. BaseParticleSystem.prototype.createBoxEmitter = function (direction1, direction2, minEmitBox, maxEmitBox) {
  103468. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["BoxParticleEmitter"]();
  103469. this.particleEmitterType = particleEmitter;
  103470. this.direction1 = direction1;
  103471. this.direction2 = direction2;
  103472. this.minEmitBox = minEmitBox;
  103473. this.maxEmitBox = maxEmitBox;
  103474. return particleEmitter;
  103475. };
  103476. /**
  103477. * Source color is added to the destination color without alpha affecting the result
  103478. */
  103479. BaseParticleSystem.BLENDMODE_ONEONE = 0;
  103480. /**
  103481. * Blend current color and particle color using particle’s alpha
  103482. */
  103483. BaseParticleSystem.BLENDMODE_STANDARD = 1;
  103484. /**
  103485. * Add current color and particle color multiplied by particle’s alpha
  103486. */
  103487. BaseParticleSystem.BLENDMODE_ADD = 2;
  103488. /**
  103489. * Multiply current color with particle color
  103490. */
  103491. BaseParticleSystem.BLENDMODE_MULTIPLY = 3;
  103492. /**
  103493. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  103494. */
  103495. BaseParticleSystem.BLENDMODE_MULTIPLYADD = 4;
  103496. return BaseParticleSystem;
  103497. }());
  103498. /***/ }),
  103499. /***/ "./Particles/gpuParticleSystem.ts":
  103500. /*!****************************************!*\
  103501. !*** ./Particles/gpuParticleSystem.ts ***!
  103502. \****************************************/
  103503. /*! exports provided: GPUParticleSystem */
  103504. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103505. "use strict";
  103506. __webpack_require__.r(__webpack_exports__);
  103507. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return GPUParticleSystem; });
  103508. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  103509. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  103510. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  103511. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  103512. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  103513. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  103514. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  103515. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  103516. /* harmony import */ var _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Particles/EmitterTypes/boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  103517. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  103518. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  103519. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  103520. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  103521. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  103522. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  103523. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  103524. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  103525. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  103526. /* harmony import */ var _Shaders_gpuUpdateParticles_fragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.fragment */ "./Shaders/gpuUpdateParticles.fragment.ts");
  103527. /* harmony import */ var _Shaders_gpuUpdateParticles_vertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.vertex */ "./Shaders/gpuUpdateParticles.vertex.ts");
  103528. /* harmony import */ var _Shaders_gpuRenderParticles_fragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.fragment */ "./Shaders/gpuRenderParticles.fragment.ts");
  103529. /* harmony import */ var _Shaders_gpuRenderParticles_vertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.vertex */ "./Shaders/gpuRenderParticles.vertex.ts");
  103530. /**
  103531. * This represents a GPU particle system in Babylon
  103532. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  103533. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  103534. */
  103535. var GPUParticleSystem = /** @class */ (function (_super) {
  103536. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GPUParticleSystem, _super);
  103537. /**
  103538. * Instantiates a GPU particle system.
  103539. * 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.
  103540. * @param name The name of the particle system
  103541. * @param options The options used to create the system
  103542. * @param scene The scene the particle system belongs to
  103543. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  103544. */
  103545. function GPUParticleSystem(name, options, scene, isAnimationSheetEnabled) {
  103546. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  103547. var _this = _super.call(this, name) || this;
  103548. /**
  103549. * The layer mask we are rendering the particles through.
  103550. */
  103551. _this.layerMask = 0x0FFFFFFF;
  103552. _this._accumulatedCount = 0;
  103553. _this._targetIndex = 0;
  103554. _this._currentRenderId = -1;
  103555. _this._started = false;
  103556. _this._stopped = false;
  103557. _this._timeDelta = 0;
  103558. _this._actualFrame = 0;
  103559. _this._rawTextureWidth = 256;
  103560. /**
  103561. * An event triggered when the system is disposed.
  103562. */
  103563. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  103564. /**
  103565. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  103566. * to override the particles.
  103567. */
  103568. _this.forceDepthWrite = false;
  103569. _this._preWarmDone = false;
  103570. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  103571. // Setup the default processing configuration to the scene.
  103572. _this._attachImageProcessingConfiguration(null);
  103573. _this._engine = _this._scene.getEngine();
  103574. if (!options.randomTextureSize) {
  103575. delete options.randomTextureSize;
  103576. }
  103577. var fullOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ capacity: 50000, randomTextureSize: _this._engine.getCaps().maxTextureSize }, options);
  103578. var optionsAsNumber = options;
  103579. if (isFinite(optionsAsNumber)) {
  103580. fullOptions.capacity = optionsAsNumber;
  103581. }
  103582. _this._capacity = fullOptions.capacity;
  103583. _this._activeCount = fullOptions.capacity;
  103584. _this._currentActiveCount = 0;
  103585. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  103586. _this._scene.particleSystems.push(_this);
  103587. _this._updateEffectOptions = {
  103588. attributes: ["position", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset", "noiseCoordinates1", "noiseCoordinates2"],
  103589. uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange", "gravity", "emitPower",
  103590. "direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor",
  103591. "angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"],
  103592. uniformBuffersNames: [],
  103593. samplers: ["randomSampler", "randomSampler2", "sizeGradientSampler", "angularSpeedGradientSampler", "velocityGradientSampler", "limitVelocityGradientSampler", "noiseSampler", "dragGradientSampler"],
  103594. defines: "",
  103595. fallbacks: null,
  103596. onCompiled: null,
  103597. onError: null,
  103598. indexParameters: null,
  103599. maxSimultaneousLights: 0,
  103600. transformFeedbackVaryings: []
  103601. };
  103602. _this.particleEmitterType = new _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__["BoxParticleEmitter"]();
  103603. // Random data
  103604. var maxTextureSize = Math.min(_this._engine.getCaps().maxTextureSize, fullOptions.randomTextureSize);
  103605. var d = [];
  103606. for (var i = 0; i < maxTextureSize; ++i) {
  103607. d.push(Math.random());
  103608. d.push(Math.random());
  103609. d.push(Math.random());
  103610. d.push(Math.random());
  103611. }
  103612. _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);
  103613. _this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  103614. _this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  103615. d = [];
  103616. for (var i = 0; i < maxTextureSize; ++i) {
  103617. d.push(Math.random());
  103618. d.push(Math.random());
  103619. d.push(Math.random());
  103620. d.push(Math.random());
  103621. }
  103622. _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);
  103623. _this._randomTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  103624. _this._randomTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  103625. _this._randomTextureSize = maxTextureSize;
  103626. return _this;
  103627. }
  103628. Object.defineProperty(GPUParticleSystem, "IsSupported", {
  103629. /**
  103630. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  103631. */
  103632. get: function () {
  103633. if (!_Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine) {
  103634. return false;
  103635. }
  103636. return _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine.webGLVersion > 1;
  103637. },
  103638. enumerable: true,
  103639. configurable: true
  103640. });
  103641. /**
  103642. * Gets the maximum number of particles active at the same time.
  103643. * @returns The max number of active particles.
  103644. */
  103645. GPUParticleSystem.prototype.getCapacity = function () {
  103646. return this._capacity;
  103647. };
  103648. Object.defineProperty(GPUParticleSystem.prototype, "activeParticleCount", {
  103649. /**
  103650. * Gets or set the number of active particles
  103651. */
  103652. get: function () {
  103653. return this._activeCount;
  103654. },
  103655. set: function (value) {
  103656. this._activeCount = Math.min(value, this._capacity);
  103657. },
  103658. enumerable: true,
  103659. configurable: true
  103660. });
  103661. /**
  103662. * Is this system ready to be used/rendered
  103663. * @return true if the system is ready
  103664. */
  103665. GPUParticleSystem.prototype.isReady = function () {
  103666. if (!this._updateEffect) {
  103667. this._recreateUpdateEffect();
  103668. this._recreateRenderEffect();
  103669. return false;
  103670. }
  103671. if (!this.emitter || !this._updateEffect.isReady() || !this._imageProcessingConfiguration.isReady() || !this._renderEffect.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  103672. return false;
  103673. }
  103674. return true;
  103675. };
  103676. /**
  103677. * Gets if the system has been started. (Note: this will still be true after stop is called)
  103678. * @returns True if it has been started, otherwise false.
  103679. */
  103680. GPUParticleSystem.prototype.isStarted = function () {
  103681. return this._started;
  103682. };
  103683. /**
  103684. * Starts the particle system and begins to emit
  103685. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  103686. */
  103687. GPUParticleSystem.prototype.start = function (delay) {
  103688. var _this = this;
  103689. if (delay === void 0) { delay = this.startDelay; }
  103690. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  103691. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  103692. }
  103693. if (delay) {
  103694. setTimeout(function () {
  103695. _this.start(0);
  103696. }, delay);
  103697. return;
  103698. }
  103699. this._started = true;
  103700. this._stopped = false;
  103701. this._preWarmDone = false;
  103702. // Animations
  103703. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  103704. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  103705. }
  103706. };
  103707. /**
  103708. * Stops the particle system.
  103709. */
  103710. GPUParticleSystem.prototype.stop = function () {
  103711. this._stopped = true;
  103712. };
  103713. /**
  103714. * Remove all active particles
  103715. */
  103716. GPUParticleSystem.prototype.reset = function () {
  103717. this._releaseBuffers();
  103718. this._releaseVAOs();
  103719. this._currentActiveCount = 0;
  103720. this._targetIndex = 0;
  103721. };
  103722. /**
  103723. * Returns the string "GPUParticleSystem"
  103724. * @returns a string containing the class name
  103725. */
  103726. GPUParticleSystem.prototype.getClassName = function () {
  103727. return "GPUParticleSystem";
  103728. };
  103729. GPUParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  103730. _super.prototype._removeGradientAndTexture.call(this, gradient, gradients, texture);
  103731. this._releaseBuffers();
  103732. return this;
  103733. };
  103734. /**
  103735. * Adds a new color gradient
  103736. * @param gradient defines the gradient to use (between 0 and 1)
  103737. * @param color1 defines the color to affect to the specified gradient
  103738. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  103739. * @returns the current particle system
  103740. */
  103741. GPUParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  103742. if (!this._colorGradients) {
  103743. this._colorGradients = [];
  103744. }
  103745. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  103746. colorGradient.gradient = gradient;
  103747. colorGradient.color1 = color1;
  103748. this._colorGradients.push(colorGradient);
  103749. this._colorGradients.sort(function (a, b) {
  103750. if (a.gradient < b.gradient) {
  103751. return -1;
  103752. }
  103753. else if (a.gradient > b.gradient) {
  103754. return 1;
  103755. }
  103756. return 0;
  103757. });
  103758. if (this._colorGradientsTexture) {
  103759. this._colorGradientsTexture.dispose();
  103760. this._colorGradientsTexture = null;
  103761. }
  103762. this._releaseBuffers();
  103763. return this;
  103764. };
  103765. /**
  103766. * Remove a specific color gradient
  103767. * @param gradient defines the gradient to remove
  103768. * @returns the current particle system
  103769. */
  103770. GPUParticleSystem.prototype.removeColorGradient = function (gradient) {
  103771. this._removeGradientAndTexture(gradient, this._colorGradients, this._colorGradientsTexture);
  103772. this._colorGradientsTexture = null;
  103773. return this;
  103774. };
  103775. GPUParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor) {
  103776. var valueGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  103777. valueGradient.gradient = gradient;
  103778. valueGradient.factor1 = factor;
  103779. factorGradients.push(valueGradient);
  103780. factorGradients.sort(function (a, b) {
  103781. if (a.gradient < b.gradient) {
  103782. return -1;
  103783. }
  103784. else if (a.gradient > b.gradient) {
  103785. return 1;
  103786. }
  103787. return 0;
  103788. });
  103789. this._releaseBuffers();
  103790. };
  103791. /**
  103792. * Adds a new size gradient
  103793. * @param gradient defines the gradient to use (between 0 and 1)
  103794. * @param factor defines the size factor to affect to the specified gradient
  103795. * @returns the current particle system
  103796. */
  103797. GPUParticleSystem.prototype.addSizeGradient = function (gradient, factor) {
  103798. if (!this._sizeGradients) {
  103799. this._sizeGradients = [];
  103800. }
  103801. this._addFactorGradient(this._sizeGradients, gradient, factor);
  103802. if (this._sizeGradientsTexture) {
  103803. this._sizeGradientsTexture.dispose();
  103804. this._sizeGradientsTexture = null;
  103805. }
  103806. this._releaseBuffers();
  103807. return this;
  103808. };
  103809. /**
  103810. * Remove a specific size gradient
  103811. * @param gradient defines the gradient to remove
  103812. * @returns the current particle system
  103813. */
  103814. GPUParticleSystem.prototype.removeSizeGradient = function (gradient) {
  103815. this._removeGradientAndTexture(gradient, this._sizeGradients, this._sizeGradientsTexture);
  103816. this._sizeGradientsTexture = null;
  103817. return this;
  103818. };
  103819. /**
  103820. * Adds a new angular speed gradient
  103821. * @param gradient defines the gradient to use (between 0 and 1)
  103822. * @param factor defines the angular speed to affect to the specified gradient
  103823. * @returns the current particle system
  103824. */
  103825. GPUParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor) {
  103826. if (!this._angularSpeedGradients) {
  103827. this._angularSpeedGradients = [];
  103828. }
  103829. this._addFactorGradient(this._angularSpeedGradients, gradient, factor);
  103830. if (this._angularSpeedGradientsTexture) {
  103831. this._angularSpeedGradientsTexture.dispose();
  103832. this._angularSpeedGradientsTexture = null;
  103833. }
  103834. this._releaseBuffers();
  103835. return this;
  103836. };
  103837. /**
  103838. * Remove a specific angular speed gradient
  103839. * @param gradient defines the gradient to remove
  103840. * @returns the current particle system
  103841. */
  103842. GPUParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  103843. this._removeGradientAndTexture(gradient, this._angularSpeedGradients, this._angularSpeedGradientsTexture);
  103844. this._angularSpeedGradientsTexture = null;
  103845. return this;
  103846. };
  103847. /**
  103848. * Adds a new velocity gradient
  103849. * @param gradient defines the gradient to use (between 0 and 1)
  103850. * @param factor defines the velocity to affect to the specified gradient
  103851. * @returns the current particle system
  103852. */
  103853. GPUParticleSystem.prototype.addVelocityGradient = function (gradient, factor) {
  103854. if (!this._velocityGradients) {
  103855. this._velocityGradients = [];
  103856. }
  103857. this._addFactorGradient(this._velocityGradients, gradient, factor);
  103858. if (this._velocityGradientsTexture) {
  103859. this._velocityGradientsTexture.dispose();
  103860. this._velocityGradientsTexture = null;
  103861. }
  103862. this._releaseBuffers();
  103863. return this;
  103864. };
  103865. /**
  103866. * Remove a specific velocity gradient
  103867. * @param gradient defines the gradient to remove
  103868. * @returns the current particle system
  103869. */
  103870. GPUParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  103871. this._removeGradientAndTexture(gradient, this._velocityGradients, this._velocityGradientsTexture);
  103872. this._velocityGradientsTexture = null;
  103873. return this;
  103874. };
  103875. /**
  103876. * Adds a new limit velocity gradient
  103877. * @param gradient defines the gradient to use (between 0 and 1)
  103878. * @param factor defines the limit velocity value to affect to the specified gradient
  103879. * @returns the current particle system
  103880. */
  103881. GPUParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor) {
  103882. if (!this._limitVelocityGradients) {
  103883. this._limitVelocityGradients = [];
  103884. }
  103885. this._addFactorGradient(this._limitVelocityGradients, gradient, factor);
  103886. if (this._limitVelocityGradientsTexture) {
  103887. this._limitVelocityGradientsTexture.dispose();
  103888. this._limitVelocityGradientsTexture = null;
  103889. }
  103890. this._releaseBuffers();
  103891. return this;
  103892. };
  103893. /**
  103894. * Remove a specific limit velocity gradient
  103895. * @param gradient defines the gradient to remove
  103896. * @returns the current particle system
  103897. */
  103898. GPUParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  103899. this._removeGradientAndTexture(gradient, this._limitVelocityGradients, this._limitVelocityGradientsTexture);
  103900. this._limitVelocityGradientsTexture = null;
  103901. return this;
  103902. };
  103903. /**
  103904. * Adds a new drag gradient
  103905. * @param gradient defines the gradient to use (between 0 and 1)
  103906. * @param factor defines the drag value to affect to the specified gradient
  103907. * @returns the current particle system
  103908. */
  103909. GPUParticleSystem.prototype.addDragGradient = function (gradient, factor) {
  103910. if (!this._dragGradients) {
  103911. this._dragGradients = [];
  103912. }
  103913. this._addFactorGradient(this._dragGradients, gradient, factor);
  103914. if (this._dragGradientsTexture) {
  103915. this._dragGradientsTexture.dispose();
  103916. this._dragGradientsTexture = null;
  103917. }
  103918. this._releaseBuffers();
  103919. return this;
  103920. };
  103921. /**
  103922. * Remove a specific drag gradient
  103923. * @param gradient defines the gradient to remove
  103924. * @returns the current particle system
  103925. */
  103926. GPUParticleSystem.prototype.removeDragGradient = function (gradient) {
  103927. this._removeGradientAndTexture(gradient, this._dragGradients, this._dragGradientsTexture);
  103928. this._dragGradientsTexture = null;
  103929. return this;
  103930. };
  103931. /**
  103932. * Not supported by GPUParticleSystem
  103933. * @param gradient defines the gradient to use (between 0 and 1)
  103934. * @param factor defines the emit rate value to affect to the specified gradient
  103935. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  103936. * @returns the current particle system
  103937. */
  103938. GPUParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  103939. // Do nothing as emit rate is not supported by GPUParticleSystem
  103940. return this;
  103941. };
  103942. /**
  103943. * Not supported by GPUParticleSystem
  103944. * @param gradient defines the gradient to remove
  103945. * @returns the current particle system
  103946. */
  103947. GPUParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  103948. // Do nothing as emit rate is not supported by GPUParticleSystem
  103949. return this;
  103950. };
  103951. /**
  103952. * Not supported by GPUParticleSystem
  103953. * @param gradient defines the gradient to use (between 0 and 1)
  103954. * @param factor defines the start size value to affect to the specified gradient
  103955. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  103956. * @returns the current particle system
  103957. */
  103958. GPUParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  103959. // Do nothing as start size is not supported by GPUParticleSystem
  103960. return this;
  103961. };
  103962. /**
  103963. * Not supported by GPUParticleSystem
  103964. * @param gradient defines the gradient to remove
  103965. * @returns the current particle system
  103966. */
  103967. GPUParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  103968. // Do nothing as start size is not supported by GPUParticleSystem
  103969. return this;
  103970. };
  103971. /**
  103972. * Not supported by GPUParticleSystem
  103973. * @param gradient defines the gradient to use (between 0 and 1)
  103974. * @param min defines the color remap minimal range
  103975. * @param max defines the color remap maximal range
  103976. * @returns the current particle system
  103977. */
  103978. GPUParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  103979. // Do nothing as start size is not supported by GPUParticleSystem
  103980. return this;
  103981. };
  103982. /**
  103983. * Not supported by GPUParticleSystem
  103984. * @param gradient defines the gradient to remove
  103985. * @returns the current particle system
  103986. */
  103987. GPUParticleSystem.prototype.removeColorRemapGradient = function () {
  103988. // Do nothing as start size is not supported by GPUParticleSystem
  103989. return this;
  103990. };
  103991. /**
  103992. * Not supported by GPUParticleSystem
  103993. * @param gradient defines the gradient to use (between 0 and 1)
  103994. * @param min defines the alpha remap minimal range
  103995. * @param max defines the alpha remap maximal range
  103996. * @returns the current particle system
  103997. */
  103998. GPUParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  103999. // Do nothing as start size is not supported by GPUParticleSystem
  104000. return this;
  104001. };
  104002. /**
  104003. * Not supported by GPUParticleSystem
  104004. * @param gradient defines the gradient to remove
  104005. * @returns the current particle system
  104006. */
  104007. GPUParticleSystem.prototype.removeAlphaRemapGradient = function () {
  104008. // Do nothing as start size is not supported by GPUParticleSystem
  104009. return this;
  104010. };
  104011. /**
  104012. * Not supported by GPUParticleSystem
  104013. * @param gradient defines the gradient to use (between 0 and 1)
  104014. * @param color defines the color to affect to the specified gradient
  104015. * @returns the current particle system
  104016. */
  104017. GPUParticleSystem.prototype.addRampGradient = function (gradient, color) {
  104018. //Not supported by GPUParticleSystem
  104019. return this;
  104020. };
  104021. /**
  104022. * Not supported by GPUParticleSystem
  104023. * @param gradient defines the gradient to remove
  104024. * @returns the current particle system
  104025. */
  104026. GPUParticleSystem.prototype.removeRampGradient = function () {
  104027. //Not supported by GPUParticleSystem
  104028. return this;
  104029. };
  104030. /**
  104031. * Not supported by GPUParticleSystem
  104032. * @returns the list of ramp gradients
  104033. */
  104034. GPUParticleSystem.prototype.getRampGradients = function () {
  104035. return null;
  104036. };
  104037. Object.defineProperty(GPUParticleSystem.prototype, "useRampGradients", {
  104038. /**
  104039. * Not supported by GPUParticleSystem
  104040. * Gets or sets a boolean indicating that ramp gradients must be used
  104041. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  104042. */
  104043. get: function () {
  104044. //Not supported by GPUParticleSystem
  104045. return false;
  104046. },
  104047. set: function (value) {
  104048. //Not supported by GPUParticleSystem
  104049. },
  104050. enumerable: true,
  104051. configurable: true
  104052. });
  104053. /**
  104054. * Not supported by GPUParticleSystem
  104055. * @param gradient defines the gradient to use (between 0 and 1)
  104056. * @param factor defines the life time factor to affect to the specified gradient
  104057. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104058. * @returns the current particle system
  104059. */
  104060. GPUParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  104061. //Not supported by GPUParticleSystem
  104062. return this;
  104063. };
  104064. /**
  104065. * Not supported by GPUParticleSystem
  104066. * @param gradient defines the gradient to remove
  104067. * @returns the current particle system
  104068. */
  104069. GPUParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  104070. //Not supported by GPUParticleSystem
  104071. return this;
  104072. };
  104073. GPUParticleSystem.prototype._reset = function () {
  104074. this._releaseBuffers();
  104075. };
  104076. GPUParticleSystem.prototype._createUpdateVAO = function (source) {
  104077. var updateVertexBuffers = {};
  104078. updateVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3);
  104079. updateVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1);
  104080. updateVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1);
  104081. updateVertexBuffers["seed"] = source.createVertexBuffer("seed", 5, 4);
  104082. updateVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3);
  104083. var offset = 12;
  104084. if (!this._colorGradientsTexture) {
  104085. updateVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4);
  104086. offset += 4;
  104087. }
  104088. updateVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3);
  104089. offset += 3;
  104090. if (!this._isBillboardBased) {
  104091. updateVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3);
  104092. offset += 3;
  104093. }
  104094. if (this._angularSpeedGradientsTexture) {
  104095. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1);
  104096. offset += 1;
  104097. }
  104098. else {
  104099. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 2);
  104100. offset += 2;
  104101. }
  104102. if (this._isAnimationSheetEnabled) {
  104103. updateVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1);
  104104. offset += 1;
  104105. if (this.spriteRandomStartCell) {
  104106. updateVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1);
  104107. offset += 1;
  104108. }
  104109. }
  104110. if (this.noiseTexture) {
  104111. updateVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3);
  104112. offset += 3;
  104113. updateVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3);
  104114. offset += 3;
  104115. }
  104116. var vao = this._engine.recordVertexArrayObject(updateVertexBuffers, null, this._updateEffect);
  104117. this._engine.bindArrayBuffer(null);
  104118. return vao;
  104119. };
  104120. GPUParticleSystem.prototype._createRenderVAO = function (source, spriteSource) {
  104121. var renderVertexBuffers = {};
  104122. renderVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3, this._attributesStrideSize, true);
  104123. renderVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1, this._attributesStrideSize, true);
  104124. renderVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1, this._attributesStrideSize, true);
  104125. renderVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3, this._attributesStrideSize, true);
  104126. var offset = 12;
  104127. if (!this._colorGradientsTexture) {
  104128. renderVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4, this._attributesStrideSize, true);
  104129. offset += 4;
  104130. }
  104131. if (this.billboardMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED) {
  104132. renderVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3, this._attributesStrideSize, true);
  104133. }
  104134. offset += 3; // Direction
  104135. if (!this._isBillboardBased) {
  104136. renderVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3, this._attributesStrideSize, true);
  104137. offset += 3;
  104138. }
  104139. renderVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1, this._attributesStrideSize, true);
  104140. if (this._angularSpeedGradientsTexture) {
  104141. offset++;
  104142. }
  104143. else {
  104144. offset += 2;
  104145. }
  104146. if (this._isAnimationSheetEnabled) {
  104147. renderVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1, this._attributesStrideSize, true);
  104148. offset += 1;
  104149. if (this.spriteRandomStartCell) {
  104150. renderVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1, this._attributesStrideSize, true);
  104151. offset += 1;
  104152. }
  104153. }
  104154. if (this.noiseTexture) {
  104155. renderVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3, this._attributesStrideSize, true);
  104156. offset += 3;
  104157. renderVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3, this._attributesStrideSize, true);
  104158. offset += 3;
  104159. }
  104160. renderVertexBuffers["offset"] = spriteSource.createVertexBuffer("offset", 0, 2);
  104161. renderVertexBuffers["uv"] = spriteSource.createVertexBuffer("uv", 2, 2);
  104162. var vao = this._engine.recordVertexArrayObject(renderVertexBuffers, null, this._renderEffect);
  104163. this._engine.bindArrayBuffer(null);
  104164. return vao;
  104165. };
  104166. GPUParticleSystem.prototype._initialize = function (force) {
  104167. if (force === void 0) { force = false; }
  104168. if (this._buffer0 && !force) {
  104169. return;
  104170. }
  104171. var engine = this._scene.getEngine();
  104172. var data = new Array();
  104173. this._attributesStrideSize = 21;
  104174. this._targetIndex = 0;
  104175. if (!this.isBillboardBased) {
  104176. this._attributesStrideSize += 3;
  104177. }
  104178. if (this._colorGradientsTexture) {
  104179. this._attributesStrideSize -= 4;
  104180. }
  104181. if (this._angularSpeedGradientsTexture) {
  104182. this._attributesStrideSize -= 1;
  104183. }
  104184. if (this._isAnimationSheetEnabled) {
  104185. this._attributesStrideSize += 1;
  104186. if (this.spriteRandomStartCell) {
  104187. this._attributesStrideSize += 1;
  104188. }
  104189. }
  104190. if (this.noiseTexture) {
  104191. this._attributesStrideSize += 6;
  104192. }
  104193. for (var particleIndex = 0; particleIndex < this._capacity; particleIndex++) {
  104194. // position
  104195. data.push(0.0);
  104196. data.push(0.0);
  104197. data.push(0.0);
  104198. // Age and life
  104199. data.push(0.0); // create the particle as a dead one to create a new one at start
  104200. data.push(0.0);
  104201. // Seed
  104202. data.push(Math.random());
  104203. data.push(Math.random());
  104204. data.push(Math.random());
  104205. data.push(Math.random());
  104206. // Size
  104207. data.push(0.0);
  104208. data.push(0.0);
  104209. data.push(0.0);
  104210. if (!this._colorGradientsTexture) {
  104211. // color
  104212. data.push(0.0);
  104213. data.push(0.0);
  104214. data.push(0.0);
  104215. data.push(0.0);
  104216. }
  104217. // direction
  104218. data.push(0.0);
  104219. data.push(0.0);
  104220. data.push(0.0);
  104221. if (!this.isBillboardBased) {
  104222. // initialDirection
  104223. data.push(0.0);
  104224. data.push(0.0);
  104225. data.push(0.0);
  104226. }
  104227. // angle
  104228. data.push(0.0);
  104229. if (!this._angularSpeedGradientsTexture) {
  104230. data.push(0.0);
  104231. }
  104232. if (this._isAnimationSheetEnabled) {
  104233. data.push(0.0);
  104234. if (this.spriteRandomStartCell) {
  104235. data.push(0.0);
  104236. }
  104237. }
  104238. if (this.noiseTexture) { // Random coordinates for reading into noise texture
  104239. data.push(Math.random());
  104240. data.push(Math.random());
  104241. data.push(Math.random());
  104242. data.push(Math.random());
  104243. data.push(Math.random());
  104244. data.push(Math.random());
  104245. }
  104246. }
  104247. // Sprite data
  104248. var spriteData = new Float32Array([0.5, 0.5, 1, 1,
  104249. -0.5, 0.5, 0, 1,
  104250. -0.5, -0.5, 0, 0,
  104251. 0.5, -0.5, 1, 0]);
  104252. // Buffers
  104253. this._buffer0 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  104254. this._buffer1 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  104255. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 4);
  104256. // Update VAO
  104257. this._updateVAO = [];
  104258. this._updateVAO.push(this._createUpdateVAO(this._buffer0));
  104259. this._updateVAO.push(this._createUpdateVAO(this._buffer1));
  104260. // Render VAO
  104261. this._renderVAO = [];
  104262. this._renderVAO.push(this._createRenderVAO(this._buffer1, this._spriteBuffer));
  104263. this._renderVAO.push(this._createRenderVAO(this._buffer0, this._spriteBuffer));
  104264. // Links
  104265. this._sourceBuffer = this._buffer0;
  104266. this._targetBuffer = this._buffer1;
  104267. };
  104268. /** @hidden */
  104269. GPUParticleSystem.prototype._recreateUpdateEffect = function () {
  104270. var defines = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
  104271. if (this._isBillboardBased) {
  104272. defines += "\n#define BILLBOARD";
  104273. }
  104274. if (this._colorGradientsTexture) {
  104275. defines += "\n#define COLORGRADIENTS";
  104276. }
  104277. if (this._sizeGradientsTexture) {
  104278. defines += "\n#define SIZEGRADIENTS";
  104279. }
  104280. if (this._angularSpeedGradientsTexture) {
  104281. defines += "\n#define ANGULARSPEEDGRADIENTS";
  104282. }
  104283. if (this._velocityGradientsTexture) {
  104284. defines += "\n#define VELOCITYGRADIENTS";
  104285. }
  104286. if (this._limitVelocityGradientsTexture) {
  104287. defines += "\n#define LIMITVELOCITYGRADIENTS";
  104288. }
  104289. if (this._dragGradientsTexture) {
  104290. defines += "\n#define DRAGGRADIENTS";
  104291. }
  104292. if (this.isAnimationSheetEnabled) {
  104293. defines += "\n#define ANIMATESHEET";
  104294. if (this.spriteRandomStartCell) {
  104295. defines += "\n#define ANIMATESHEETRANDOMSTART";
  104296. }
  104297. }
  104298. if (this.noiseTexture) {
  104299. defines += "\n#define NOISE";
  104300. }
  104301. if (this._updateEffect && this._updateEffectOptions.defines === defines) {
  104302. return;
  104303. }
  104304. this._updateEffectOptions.transformFeedbackVaryings = ["outPosition", "outAge", "outLife", "outSeed", "outSize"];
  104305. if (!this._colorGradientsTexture) {
  104306. this._updateEffectOptions.transformFeedbackVaryings.push("outColor");
  104307. }
  104308. this._updateEffectOptions.transformFeedbackVaryings.push("outDirection");
  104309. if (!this._isBillboardBased) {
  104310. this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection");
  104311. }
  104312. this._updateEffectOptions.transformFeedbackVaryings.push("outAngle");
  104313. if (this.isAnimationSheetEnabled) {
  104314. this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex");
  104315. if (this.spriteRandomStartCell) {
  104316. this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset");
  104317. }
  104318. }
  104319. if (this.noiseTexture) {
  104320. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1");
  104321. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2");
  104322. }
  104323. this._updateEffectOptions.defines = defines;
  104324. this._updateEffect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["Effect"]("gpuUpdateParticles", this._updateEffectOptions, this._scene.getEngine());
  104325. };
  104326. /** @hidden */
  104327. GPUParticleSystem.prototype._recreateRenderEffect = function () {
  104328. var defines = "";
  104329. if (this._scene.clipPlane) {
  104330. defines = "\n#define CLIPPLANE";
  104331. }
  104332. if (this._scene.clipPlane2) {
  104333. defines = "\n#define CLIPPLANE2";
  104334. }
  104335. if (this._scene.clipPlane3) {
  104336. defines = "\n#define CLIPPLANE3";
  104337. }
  104338. if (this._scene.clipPlane4) {
  104339. defines = "\n#define CLIPPLANE4";
  104340. }
  104341. if (this.blendMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY) {
  104342. defines = "\n#define BLENDMULTIPLYMODE";
  104343. }
  104344. if (this._isBillboardBased) {
  104345. defines += "\n#define BILLBOARD";
  104346. switch (this.billboardMode) {
  104347. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_Y:
  104348. defines += "\n#define BILLBOARDY";
  104349. break;
  104350. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED:
  104351. defines += "\n#define BILLBOARDSTRETCHED";
  104352. break;
  104353. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_ALL:
  104354. default:
  104355. break;
  104356. }
  104357. }
  104358. if (this._colorGradientsTexture) {
  104359. defines += "\n#define COLORGRADIENTS";
  104360. }
  104361. if (this.isAnimationSheetEnabled) {
  104362. defines += "\n#define ANIMATESHEET";
  104363. }
  104364. if (this._imageProcessingConfiguration) {
  104365. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  104366. defines += "\n" + this._imageProcessingConfigurationDefines.toString();
  104367. }
  104368. if (this._renderEffect && this._renderEffect.defines === defines) {
  104369. return;
  104370. }
  104371. var uniforms = ["view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "sheetInfos", "translationPivot", "eyePosition"];
  104372. var samplers = ["textureSampler", "colorGradientSampler"];
  104373. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  104374. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._imageProcessingConfigurationDefines);
  104375. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  104376. }
  104377. 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);
  104378. };
  104379. /**
  104380. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  104381. * @param preWarm defines if we are in the pre-warmimg phase
  104382. */
  104383. GPUParticleSystem.prototype.animate = function (preWarm) {
  104384. if (preWarm === void 0) { preWarm = false; }
  104385. this._timeDelta = this.updateSpeed * (preWarm ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  104386. this._actualFrame += this._timeDelta;
  104387. if (!this._stopped) {
  104388. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  104389. this.stop();
  104390. }
  104391. }
  104392. };
  104393. GPUParticleSystem.prototype._createFactorGradientTexture = function (factorGradients, textureName) {
  104394. var texture = this[textureName];
  104395. if (!factorGradients || !factorGradients.length || texture) {
  104396. return;
  104397. }
  104398. var data = new Float32Array(this._rawTextureWidth);
  104399. for (var x = 0; x < this._rawTextureWidth; x++) {
  104400. var ratio = x / this._rawTextureWidth;
  104401. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, factorGradients, function (currentGradient, nextGradient, scale) {
  104402. data[x] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  104403. });
  104404. }
  104405. 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);
  104406. };
  104407. GPUParticleSystem.prototype._createSizeGradientTexture = function () {
  104408. this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture");
  104409. };
  104410. GPUParticleSystem.prototype._createAngularSpeedGradientTexture = function () {
  104411. this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture");
  104412. };
  104413. GPUParticleSystem.prototype._createVelocityGradientTexture = function () {
  104414. this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture");
  104415. };
  104416. GPUParticleSystem.prototype._createLimitVelocityGradientTexture = function () {
  104417. this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture");
  104418. };
  104419. GPUParticleSystem.prototype._createDragGradientTexture = function () {
  104420. this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture");
  104421. };
  104422. GPUParticleSystem.prototype._createColorGradientTexture = function () {
  104423. if (!this._colorGradients || !this._colorGradients.length || this._colorGradientsTexture) {
  104424. return;
  104425. }
  104426. var data = new Uint8Array(this._rawTextureWidth * 4);
  104427. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color4[0];
  104428. for (var x = 0; x < this._rawTextureWidth; x++) {
  104429. var ratio = x / this._rawTextureWidth;
  104430. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._colorGradients, function (currentGradient, nextGradient, scale) {
  104431. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(currentGradient.color1, nextGradient.color1, scale, tmpColor);
  104432. data[x * 4] = tmpColor.r * 255;
  104433. data[x * 4 + 1] = tmpColor.g * 255;
  104434. data[x * 4 + 2] = tmpColor.b * 255;
  104435. data[x * 4 + 3] = tmpColor.a * 255;
  104436. });
  104437. }
  104438. 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);
  104439. };
  104440. /**
  104441. * Renders the particle system in its current state
  104442. * @param preWarm defines if the system should only update the particles but not render them
  104443. * @returns the current number of particles
  104444. */
  104445. GPUParticleSystem.prototype.render = function (preWarm) {
  104446. if (preWarm === void 0) { preWarm = false; }
  104447. if (!this._started) {
  104448. return 0;
  104449. }
  104450. this._createColorGradientTexture();
  104451. this._createSizeGradientTexture();
  104452. this._createAngularSpeedGradientTexture();
  104453. this._createVelocityGradientTexture();
  104454. this._createLimitVelocityGradientTexture();
  104455. this._createDragGradientTexture();
  104456. this._recreateUpdateEffect();
  104457. this._recreateRenderEffect();
  104458. if (!this.isReady()) {
  104459. return 0;
  104460. }
  104461. if (!preWarm) {
  104462. if (!this._preWarmDone && this.preWarmCycles) {
  104463. for (var index = 0; index < this.preWarmCycles; index++) {
  104464. this.animate(true);
  104465. this.render(true);
  104466. }
  104467. this._preWarmDone = true;
  104468. }
  104469. if (this._currentRenderId === this._scene.getFrameId()) {
  104470. return 0;
  104471. }
  104472. this._currentRenderId = this._scene.getFrameId();
  104473. }
  104474. // Get everything ready to render
  104475. this._initialize();
  104476. this._accumulatedCount += this.emitRate * this._timeDelta;
  104477. if (this._accumulatedCount > 1) {
  104478. var intPart = this._accumulatedCount | 0;
  104479. this._accumulatedCount -= intPart;
  104480. this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + intPart);
  104481. }
  104482. if (!this._currentActiveCount) {
  104483. return 0;
  104484. }
  104485. // Enable update effect
  104486. this._engine.enableEffect(this._updateEffect);
  104487. this._engine.setState(false);
  104488. this._updateEffect.setFloat("currentCount", this._currentActiveCount);
  104489. this._updateEffect.setFloat("timeDelta", this._timeDelta);
  104490. this._updateEffect.setFloat("stopFactor", this._stopped ? 0 : 1);
  104491. this._updateEffect.setTexture("randomSampler", this._randomTexture);
  104492. this._updateEffect.setTexture("randomSampler2", this._randomTexture2);
  104493. this._updateEffect.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
  104494. this._updateEffect.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower);
  104495. if (!this._colorGradientsTexture) {
  104496. this._updateEffect.setDirectColor4("color1", this.color1);
  104497. this._updateEffect.setDirectColor4("color2", this.color2);
  104498. }
  104499. this._updateEffect.setFloat2("sizeRange", this.minSize, this.maxSize);
  104500. this._updateEffect.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY);
  104501. this._updateEffect.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation);
  104502. this._updateEffect.setVector3("gravity", this.gravity);
  104503. if (this._sizeGradientsTexture) {
  104504. this._updateEffect.setTexture("sizeGradientSampler", this._sizeGradientsTexture);
  104505. }
  104506. if (this._angularSpeedGradientsTexture) {
  104507. this._updateEffect.setTexture("angularSpeedGradientSampler", this._angularSpeedGradientsTexture);
  104508. }
  104509. if (this._velocityGradientsTexture) {
  104510. this._updateEffect.setTexture("velocityGradientSampler", this._velocityGradientsTexture);
  104511. }
  104512. if (this._limitVelocityGradientsTexture) {
  104513. this._updateEffect.setTexture("limitVelocityGradientSampler", this._limitVelocityGradientsTexture);
  104514. this._updateEffect.setFloat("limitVelocityDamping", this.limitVelocityDamping);
  104515. }
  104516. if (this._dragGradientsTexture) {
  104517. this._updateEffect.setTexture("dragGradientSampler", this._dragGradientsTexture);
  104518. }
  104519. if (this.particleEmitterType) {
  104520. this.particleEmitterType.applyToShader(this._updateEffect);
  104521. }
  104522. if (this._isAnimationSheetEnabled) {
  104523. this._updateEffect.setFloat3("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed);
  104524. }
  104525. if (this.noiseTexture) {
  104526. this._updateEffect.setTexture("noiseSampler", this.noiseTexture);
  104527. this._updateEffect.setVector3("noiseStrength", this.noiseStrength);
  104528. }
  104529. var emitterWM;
  104530. if (this.emitter.position) {
  104531. var emitterMesh = this.emitter;
  104532. emitterWM = emitterMesh.getWorldMatrix();
  104533. }
  104534. else {
  104535. var emitterPosition = this.emitter;
  104536. emitterWM = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  104537. }
  104538. this._updateEffect.setMatrix("emitterWM", emitterWM);
  104539. // Bind source VAO
  104540. this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex], null);
  104541. // Update
  104542. this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer());
  104543. this._engine.setRasterizerState(false);
  104544. this._engine.beginTransformFeedback(true);
  104545. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].PointListDrawMode, 0, this._currentActiveCount);
  104546. this._engine.endTransformFeedback();
  104547. this._engine.setRasterizerState(true);
  104548. this._engine.bindTransformFeedbackBuffer(null);
  104549. if (!preWarm) {
  104550. // Enable render effect
  104551. this._engine.enableEffect(this._renderEffect);
  104552. var viewMatrix = this._scene.getViewMatrix();
  104553. this._renderEffect.setMatrix("view", viewMatrix);
  104554. this._renderEffect.setMatrix("projection", this._scene.getProjectionMatrix());
  104555. this._renderEffect.setTexture("textureSampler", this.particleTexture);
  104556. this._renderEffect.setVector2("translationPivot", this.translationPivot);
  104557. if (this._colorGradientsTexture) {
  104558. this._renderEffect.setTexture("colorGradientSampler", this._colorGradientsTexture);
  104559. }
  104560. else {
  104561. this._renderEffect.setDirectColor4("colorDead", this.colorDead);
  104562. }
  104563. if (this._isAnimationSheetEnabled && this.particleTexture) {
  104564. var baseSize = this.particleTexture.getBaseSize();
  104565. this._renderEffect.setFloat3("sheetInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  104566. }
  104567. if (this._isBillboardBased) {
  104568. var camera = this._scene.activeCamera;
  104569. this._renderEffect.setVector3("eyePosition", camera.globalPosition);
  104570. }
  104571. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  104572. var invView = viewMatrix.clone();
  104573. invView.invert();
  104574. this._renderEffect.setMatrix("invView", invView);
  104575. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindClipPlane(this._renderEffect, this._scene);
  104576. }
  104577. // image processing
  104578. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  104579. this._imageProcessingConfiguration.bind(this._renderEffect);
  104580. }
  104581. // Draw order
  104582. switch (this.blendMode) {
  104583. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ADD:
  104584. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ADD);
  104585. break;
  104586. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ONEONE:
  104587. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ONEONE);
  104588. break;
  104589. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_STANDARD:
  104590. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_COMBINE);
  104591. break;
  104592. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY:
  104593. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_MULTIPLY);
  104594. break;
  104595. }
  104596. if (this.forceDepthWrite) {
  104597. this._engine.setDepthWrite(true);
  104598. }
  104599. // Bind source VAO
  104600. this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex], null);
  104601. // Render
  104602. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].TriangleFanDrawMode, 0, 4, this._currentActiveCount);
  104603. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_DISABLE);
  104604. }
  104605. // Switch VAOs
  104606. this._targetIndex++;
  104607. if (this._targetIndex === 2) {
  104608. this._targetIndex = 0;
  104609. }
  104610. // Switch buffers
  104611. var tmpBuffer = this._sourceBuffer;
  104612. this._sourceBuffer = this._targetBuffer;
  104613. this._targetBuffer = tmpBuffer;
  104614. return this._currentActiveCount;
  104615. };
  104616. /**
  104617. * Rebuilds the particle system
  104618. */
  104619. GPUParticleSystem.prototype.rebuild = function () {
  104620. this._initialize(true);
  104621. };
  104622. GPUParticleSystem.prototype._releaseBuffers = function () {
  104623. if (this._buffer0) {
  104624. this._buffer0.dispose();
  104625. this._buffer0 = null;
  104626. }
  104627. if (this._buffer1) {
  104628. this._buffer1.dispose();
  104629. this._buffer1 = null;
  104630. }
  104631. if (this._spriteBuffer) {
  104632. this._spriteBuffer.dispose();
  104633. this._spriteBuffer = null;
  104634. }
  104635. };
  104636. GPUParticleSystem.prototype._releaseVAOs = function () {
  104637. if (!this._updateVAO) {
  104638. return;
  104639. }
  104640. for (var index = 0; index < this._updateVAO.length; index++) {
  104641. this._engine.releaseVertexArrayObject(this._updateVAO[index]);
  104642. }
  104643. this._updateVAO = [];
  104644. for (var index = 0; index < this._renderVAO.length; index++) {
  104645. this._engine.releaseVertexArrayObject(this._renderVAO[index]);
  104646. }
  104647. this._renderVAO = [];
  104648. };
  104649. /**
  104650. * Disposes the particle system and free the associated resources
  104651. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  104652. */
  104653. GPUParticleSystem.prototype.dispose = function (disposeTexture) {
  104654. if (disposeTexture === void 0) { disposeTexture = true; }
  104655. var index = this._scene.particleSystems.indexOf(this);
  104656. if (index > -1) {
  104657. this._scene.particleSystems.splice(index, 1);
  104658. }
  104659. this._releaseBuffers();
  104660. this._releaseVAOs();
  104661. if (this._colorGradientsTexture) {
  104662. this._colorGradientsTexture.dispose();
  104663. this._colorGradientsTexture = null;
  104664. }
  104665. if (this._sizeGradientsTexture) {
  104666. this._sizeGradientsTexture.dispose();
  104667. this._sizeGradientsTexture = null;
  104668. }
  104669. if (this._angularSpeedGradientsTexture) {
  104670. this._angularSpeedGradientsTexture.dispose();
  104671. this._angularSpeedGradientsTexture = null;
  104672. }
  104673. if (this._velocityGradientsTexture) {
  104674. this._velocityGradientsTexture.dispose();
  104675. this._velocityGradientsTexture = null;
  104676. }
  104677. if (this._limitVelocityGradientsTexture) {
  104678. this._limitVelocityGradientsTexture.dispose();
  104679. this._limitVelocityGradientsTexture = null;
  104680. }
  104681. if (this._dragGradientsTexture) {
  104682. this._dragGradientsTexture.dispose();
  104683. this._dragGradientsTexture = null;
  104684. }
  104685. if (this._randomTexture) {
  104686. this._randomTexture.dispose();
  104687. this._randomTexture = null;
  104688. }
  104689. if (this._randomTexture2) {
  104690. this._randomTexture2.dispose();
  104691. this._randomTexture2 = null;
  104692. }
  104693. if (disposeTexture && this.particleTexture) {
  104694. this.particleTexture.dispose();
  104695. this.particleTexture = null;
  104696. }
  104697. if (disposeTexture && this.noiseTexture) {
  104698. this.noiseTexture.dispose();
  104699. this.noiseTexture = null;
  104700. }
  104701. // Callback
  104702. this.onDisposeObservable.notifyObservers(this);
  104703. this.onDisposeObservable.clear();
  104704. };
  104705. /**
  104706. * Clones the particle system.
  104707. * @param name The name of the cloned object
  104708. * @param newEmitter The new emitter to use
  104709. * @returns the cloned particle system
  104710. */
  104711. GPUParticleSystem.prototype.clone = function (name, newEmitter) {
  104712. var result = new GPUParticleSystem(name, { capacity: this._capacity, randomTextureSize: this._randomTextureSize }, this._scene);
  104713. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__["DeepCopier"].DeepCopy(this, result);
  104714. if (newEmitter === undefined) {
  104715. newEmitter = this.emitter;
  104716. }
  104717. result.emitter = newEmitter;
  104718. if (this.particleTexture) {
  104719. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"](this.particleTexture.url, this._scene);
  104720. }
  104721. return result;
  104722. };
  104723. /**
  104724. * Serializes the particle system to a JSON object.
  104725. * @returns the JSON object
  104726. */
  104727. GPUParticleSystem.prototype.serialize = function () {
  104728. var serializationObject = {};
  104729. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Serialize(serializationObject, this);
  104730. serializationObject.activeParticleCount = this.activeParticleCount;
  104731. return serializationObject;
  104732. };
  104733. /**
  104734. * Parses a JSON object to create a GPU particle system.
  104735. * @param parsedParticleSystem The JSON object to parse
  104736. * @param scene The scene to create the particle system in
  104737. * @param rootUrl The root url to use to load external dependencies like texture
  104738. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  104739. * @returns the parsed GPU particle system
  104740. */
  104741. GPUParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  104742. if (doNotStart === void 0) { doNotStart = false; }
  104743. var name = parsedParticleSystem.name;
  104744. var particleSystem = new GPUParticleSystem(name, { capacity: parsedParticleSystem.capacity, randomTextureSize: parsedParticleSystem.randomTextureSize }, scene);
  104745. if (parsedParticleSystem.activeParticleCount) {
  104746. particleSystem.activeParticleCount = parsedParticleSystem.activeParticleCount;
  104747. }
  104748. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  104749. // Auto start
  104750. if (parsedParticleSystem.preventAutoStart) {
  104751. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  104752. }
  104753. if (!doNotStart && !particleSystem.preventAutoStart) {
  104754. particleSystem.start();
  104755. }
  104756. return particleSystem;
  104757. };
  104758. return GPUParticleSystem;
  104759. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__["BaseParticleSystem"]));
  104760. /***/ }),
  104761. /***/ "./Particles/index.ts":
  104762. /*!****************************!*\
  104763. !*** ./Particles/index.ts ***!
  104764. \****************************/
  104765. /*! exports provided: BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  104766. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104767. "use strict";
  104768. __webpack_require__.r(__webpack_exports__);
  104769. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  104770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  104771. /* harmony import */ var _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  104772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["BoxParticleEmitter"]; });
  104773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  104774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderParticleEmitter"]; });
  104775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderDirectedParticleEmitter"]; });
  104776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["HemisphericParticleEmitter"]; });
  104777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["PointParticleEmitter"]; });
  104778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereParticleEmitter"]; });
  104779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereDirectedParticleEmitter"]; });
  104780. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  104781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__["GPUParticleSystem"]; });
  104782. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  104783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _particle__WEBPACK_IMPORTED_MODULE_3__["Particle"]; });
  104784. /* harmony import */ var _particleHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleHelper */ "./Particles/particleHelper.ts");
  104785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _particleHelper__WEBPACK_IMPORTED_MODULE_4__["ParticleHelper"]; });
  104786. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  104787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _particleSystem__WEBPACK_IMPORTED_MODULE_5__["ParticleSystem"]; });
  104788. /* harmony import */ var _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystemComponent */ "./Particles/particleSystemComponent.ts");
  104789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__["_IDoNeedToBeInTheBuild"]; });
  104790. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  104791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__["ParticleSystemSet"]; });
  104792. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  104793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["SolidParticle"]; });
  104794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["ModelShape"]; });
  104795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["DepthSortedParticle"]; });
  104796. /* harmony import */ var _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./solidParticleSystem */ "./Particles/solidParticleSystem.ts");
  104797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__["SolidParticleSystem"]; });
  104798. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  104799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitterType"]; });
  104800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitter"]; });
  104801. /***/ }),
  104802. /***/ "./Particles/particle.ts":
  104803. /*!*******************************!*\
  104804. !*** ./Particles/particle.ts ***!
  104805. \*******************************/
  104806. /*! exports provided: Particle */
  104807. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104808. "use strict";
  104809. __webpack_require__.r(__webpack_exports__);
  104810. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return Particle; });
  104811. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  104812. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  104813. /**
  104814. * A particle represents one of the element emitted by a particle system.
  104815. * This is mainly define by its coordinates, direction, velocity and age.
  104816. */
  104817. var Particle = /** @class */ (function () {
  104818. /**
  104819. * Creates a new instance Particle
  104820. * @param particleSystem the particle system the particle belongs to
  104821. */
  104822. function Particle(
  104823. /**
  104824. * The particle system the particle belongs to.
  104825. */
  104826. particleSystem) {
  104827. this.particleSystem = particleSystem;
  104828. /**
  104829. * The world position of the particle in the scene.
  104830. */
  104831. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  104832. /**
  104833. * The world direction of the particle in the scene.
  104834. */
  104835. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  104836. /**
  104837. * The color of the particle.
  104838. */
  104839. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  104840. /**
  104841. * The color change of the particle per step.
  104842. */
  104843. this.colorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  104844. /**
  104845. * Defines how long will the life of the particle be.
  104846. */
  104847. this.lifeTime = 1.0;
  104848. /**
  104849. * The current age of the particle.
  104850. */
  104851. this.age = 0;
  104852. /**
  104853. * The current size of the particle.
  104854. */
  104855. this.size = 0;
  104856. /**
  104857. * The current scale of the particle.
  104858. */
  104859. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](1, 1);
  104860. /**
  104861. * The current angle of the particle.
  104862. */
  104863. this.angle = 0;
  104864. /**
  104865. * Defines how fast is the angle changing.
  104866. */
  104867. this.angularSpeed = 0;
  104868. /**
  104869. * Defines the cell index used by the particle to be rendered from a sprite.
  104870. */
  104871. this.cellIndex = 0;
  104872. /** @hidden */
  104873. this._attachedSubEmitters = null;
  104874. /** @hidden */
  104875. this._currentColor1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  104876. /** @hidden */
  104877. this._currentColor2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  104878. /** @hidden */
  104879. this._currentSize1 = 0;
  104880. /** @hidden */
  104881. this._currentSize2 = 0;
  104882. /** @hidden */
  104883. this._currentAngularSpeed1 = 0;
  104884. /** @hidden */
  104885. this._currentAngularSpeed2 = 0;
  104886. /** @hidden */
  104887. this._currentVelocity1 = 0;
  104888. /** @hidden */
  104889. this._currentVelocity2 = 0;
  104890. /** @hidden */
  104891. this._currentLimitVelocity1 = 0;
  104892. /** @hidden */
  104893. this._currentLimitVelocity2 = 0;
  104894. /** @hidden */
  104895. this._currentDrag1 = 0;
  104896. /** @hidden */
  104897. this._currentDrag2 = 0;
  104898. this.id = Particle._Count++;
  104899. if (!this.particleSystem.isAnimationSheetEnabled) {
  104900. return;
  104901. }
  104902. this.updateCellInfoFromSystem();
  104903. }
  104904. Particle.prototype.updateCellInfoFromSystem = function () {
  104905. this.cellIndex = this.particleSystem.startSpriteCellID;
  104906. };
  104907. /**
  104908. * Defines how the sprite cell index is updated for the particle
  104909. */
  104910. Particle.prototype.updateCellIndex = function () {
  104911. var offsetAge = this.age;
  104912. var changeSpeed = this.particleSystem.spriteCellChangeSpeed;
  104913. if (this.particleSystem.spriteRandomStartCell) {
  104914. if (this._randomCellOffset === undefined) {
  104915. this._randomCellOffset = Math.random() * this.lifeTime;
  104916. }
  104917. if (changeSpeed === 0) { // Special case when speed = 0 meaning we want to stay on initial cell
  104918. changeSpeed = 1;
  104919. offsetAge = this._randomCellOffset;
  104920. }
  104921. else {
  104922. offsetAge += this._randomCellOffset;
  104923. }
  104924. }
  104925. var dist = (this._initialEndSpriteCellID - this._initialStartSpriteCellID);
  104926. var ratio = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(((offsetAge * changeSpeed) % this.lifeTime) / this.lifeTime);
  104927. this.cellIndex = this._initialStartSpriteCellID + (ratio * dist) | 0;
  104928. };
  104929. /** @hidden */
  104930. Particle.prototype._inheritParticleInfoToSubEmitter = function (subEmitter) {
  104931. if (subEmitter.particleSystem.emitter.position) {
  104932. var emitterMesh = subEmitter.particleSystem.emitter;
  104933. emitterMesh.position.copyFrom(this.position);
  104934. if (subEmitter.inheritDirection) {
  104935. emitterMesh.position.subtractToRef(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  104936. // Look at using Y as forward
  104937. emitterMesh.lookAt(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0], 0, Math.PI / 2);
  104938. }
  104939. }
  104940. else {
  104941. var emitterPosition = subEmitter.particleSystem.emitter;
  104942. emitterPosition.copyFrom(this.position);
  104943. }
  104944. // Set inheritedVelocityOffset to be used when new particles are created
  104945. this.direction.scaleToRef(subEmitter.inheritedVelocityAmount / 2, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  104946. subEmitter.particleSystem._inheritedVelocityOffset.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  104947. };
  104948. /** @hidden */
  104949. Particle.prototype._inheritParticleInfoToSubEmitters = function () {
  104950. var _this = this;
  104951. if (this._attachedSubEmitters && this._attachedSubEmitters.length > 0) {
  104952. this._attachedSubEmitters.forEach(function (subEmitter) {
  104953. _this._inheritParticleInfoToSubEmitter(subEmitter);
  104954. });
  104955. }
  104956. };
  104957. /** @hidden */
  104958. Particle.prototype._reset = function () {
  104959. this.age = 0;
  104960. this._currentColorGradient = null;
  104961. this._currentSizeGradient = null;
  104962. this._currentAngularSpeedGradient = null;
  104963. this._currentVelocityGradient = null;
  104964. this._currentLimitVelocityGradient = null;
  104965. this._currentDragGradient = null;
  104966. this.cellIndex = this.particleSystem.startSpriteCellID;
  104967. this._randomCellOffset = undefined;
  104968. };
  104969. /**
  104970. * Copy the properties of particle to another one.
  104971. * @param other the particle to copy the information to.
  104972. */
  104973. Particle.prototype.copyTo = function (other) {
  104974. other.position.copyFrom(this.position);
  104975. if (this._initialDirection) {
  104976. if (other._initialDirection) {
  104977. other._initialDirection.copyFrom(this._initialDirection);
  104978. }
  104979. else {
  104980. other._initialDirection = this._initialDirection.clone();
  104981. }
  104982. }
  104983. else {
  104984. other._initialDirection = null;
  104985. }
  104986. other.direction.copyFrom(this.direction);
  104987. other.color.copyFrom(this.color);
  104988. other.colorStep.copyFrom(this.colorStep);
  104989. other.lifeTime = this.lifeTime;
  104990. other.age = this.age;
  104991. other._randomCellOffset = this._randomCellOffset;
  104992. other.size = this.size;
  104993. other.scale.copyFrom(this.scale);
  104994. other.angle = this.angle;
  104995. other.angularSpeed = this.angularSpeed;
  104996. other.particleSystem = this.particleSystem;
  104997. other.cellIndex = this.cellIndex;
  104998. other.id = this.id;
  104999. other._attachedSubEmitters = this._attachedSubEmitters;
  105000. if (this._currentColorGradient) {
  105001. other._currentColorGradient = this._currentColorGradient;
  105002. other._currentColor1.copyFrom(this._currentColor1);
  105003. other._currentColor2.copyFrom(this._currentColor2);
  105004. }
  105005. if (this._currentSizeGradient) {
  105006. other._currentSizeGradient = this._currentSizeGradient;
  105007. other._currentSize1 = this._currentSize1;
  105008. other._currentSize2 = this._currentSize2;
  105009. }
  105010. if (this._currentAngularSpeedGradient) {
  105011. other._currentAngularSpeedGradient = this._currentAngularSpeedGradient;
  105012. other._currentAngularSpeed1 = this._currentAngularSpeed1;
  105013. other._currentAngularSpeed2 = this._currentAngularSpeed2;
  105014. }
  105015. if (this._currentVelocityGradient) {
  105016. other._currentVelocityGradient = this._currentVelocityGradient;
  105017. other._currentVelocity1 = this._currentVelocity1;
  105018. other._currentVelocity2 = this._currentVelocity2;
  105019. }
  105020. if (this._currentLimitVelocityGradient) {
  105021. other._currentLimitVelocityGradient = this._currentLimitVelocityGradient;
  105022. other._currentLimitVelocity1 = this._currentLimitVelocity1;
  105023. other._currentLimitVelocity2 = this._currentLimitVelocity2;
  105024. }
  105025. if (this._currentDragGradient) {
  105026. other._currentDragGradient = this._currentDragGradient;
  105027. other._currentDrag1 = this._currentDrag1;
  105028. other._currentDrag2 = this._currentDrag2;
  105029. }
  105030. if (this.particleSystem.isAnimationSheetEnabled) {
  105031. other._initialStartSpriteCellID = this._initialStartSpriteCellID;
  105032. other._initialEndSpriteCellID = this._initialEndSpriteCellID;
  105033. }
  105034. if (this.particleSystem.useRampGradients) {
  105035. other.remapData.copyFrom(this.remapData);
  105036. }
  105037. if (this._randomNoiseCoordinates1) {
  105038. if (other._randomNoiseCoordinates1) {
  105039. other._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1);
  105040. other._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2);
  105041. }
  105042. else {
  105043. other._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone();
  105044. other._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone();
  105045. }
  105046. }
  105047. };
  105048. Particle._Count = 0;
  105049. return Particle;
  105050. }());
  105051. /***/ }),
  105052. /***/ "./Particles/particleHelper.ts":
  105053. /*!*************************************!*\
  105054. !*** ./Particles/particleHelper.ts ***!
  105055. \*************************************/
  105056. /*! exports provided: ParticleHelper */
  105057. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105058. "use strict";
  105059. __webpack_require__.r(__webpack_exports__);
  105060. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return ParticleHelper; });
  105061. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  105062. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  105063. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  105064. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  105065. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  105066. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  105067. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  105068. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  105069. /**
  105070. * This class is made for on one-liner static method to help creating particle system set.
  105071. */
  105072. var ParticleHelper = /** @class */ (function () {
  105073. function ParticleHelper() {
  105074. }
  105075. /**
  105076. * Create a default particle system that you can tweak
  105077. * @param emitter defines the emitter to use
  105078. * @param capacity defines the system capacity (default is 500 particles)
  105079. * @param scene defines the hosting scene
  105080. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  105081. * @returns the new Particle system
  105082. */
  105083. ParticleHelper.CreateDefault = function (emitter, capacity, scene, useGPU) {
  105084. if (capacity === void 0) { capacity = 500; }
  105085. if (useGPU === void 0) { useGPU = false; }
  105086. var system;
  105087. if (useGPU) {
  105088. system = new _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"]("default system", { capacity: capacity }, scene);
  105089. }
  105090. else {
  105091. system = new _particleSystem__WEBPACK_IMPORTED_MODULE_6__["ParticleSystem"]("default system", capacity, scene);
  105092. }
  105093. system.emitter = emitter;
  105094. system.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]("https://www.babylonjs.com/assets/Flare.png", system.getScene());
  105095. system.createConeEmitter(0.1, Math.PI / 4);
  105096. // Particle color
  105097. system.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  105098. system.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  105099. system.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 0.0);
  105100. // Particle Size
  105101. system.minSize = 0.1;
  105102. system.maxSize = 0.1;
  105103. // Emission speed
  105104. system.minEmitPower = 2;
  105105. system.maxEmitPower = 2;
  105106. // Update speed
  105107. system.updateSpeed = 1 / 60;
  105108. system.emitRate = 30;
  105109. return system;
  105110. };
  105111. /**
  105112. * This is the main static method (one-liner) of this helper to create different particle systems
  105113. * @param type This string represents the type to the particle system to create
  105114. * @param scene The scene where the particle system should live
  105115. * @param gpu If the system will use gpu
  105116. * @returns the ParticleSystemSet created
  105117. */
  105118. ParticleHelper.CreateAsync = function (type, scene, gpu) {
  105119. if (gpu === void 0) { gpu = false; }
  105120. if (!scene) {
  105121. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  105122. }
  105123. var token = {};
  105124. scene._addPendingData(token);
  105125. return new Promise(function (resolve, reject) {
  105126. if (gpu && !_gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"].IsSupported) {
  105127. scene._removePendingData(token);
  105128. return reject("Particle system with GPU is not supported.");
  105129. }
  105130. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(ParticleHelper.BaseAssetsUrl + "/systems/" + type + ".json", function (data) {
  105131. scene._removePendingData(token);
  105132. var newData = JSON.parse(data.toString());
  105133. return resolve(_particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"].Parse(newData, scene, gpu));
  105134. }, undefined, undefined, undefined, function () {
  105135. scene._removePendingData(token);
  105136. return reject("An error occured while the creation of your particle system. Check if your type '" + type + "' exists.");
  105137. });
  105138. });
  105139. };
  105140. /**
  105141. * Static function used to export a particle system to a ParticleSystemSet variable.
  105142. * Please note that the emitter shape is not exported
  105143. * @param systems defines the particle systems to export
  105144. * @returns the created particle system set
  105145. */
  105146. ParticleHelper.ExportSet = function (systems) {
  105147. var set = new _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"]();
  105148. for (var _i = 0, systems_1 = systems; _i < systems_1.length; _i++) {
  105149. var system = systems_1[_i];
  105150. set.systems.push(system);
  105151. }
  105152. return set;
  105153. };
  105154. /**
  105155. * Gets or sets base Assets URL
  105156. */
  105157. ParticleHelper.BaseAssetsUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].PARTICLES_BaseAssetsUrl;
  105158. return ParticleHelper;
  105159. }());
  105160. /***/ }),
  105161. /***/ "./Particles/particleSystem.ts":
  105162. /*!*************************************!*\
  105163. !*** ./Particles/particleSystem.ts ***!
  105164. \*************************************/
  105165. /*! exports provided: ParticleSystem */
  105166. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105167. "use strict";
  105168. __webpack_require__.r(__webpack_exports__);
  105169. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return ParticleSystem; });
  105170. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  105171. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  105172. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  105173. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  105174. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  105175. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  105176. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  105177. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  105178. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  105179. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  105180. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  105181. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  105182. /* harmony import */ var _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/Textures/Procedurals/proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  105183. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  105184. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  105185. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  105186. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  105187. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  105188. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  105189. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  105190. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  105191. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  105192. /* harmony import */ var _Shaders_particles_fragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Shaders/particles.fragment */ "./Shaders/particles.fragment.ts");
  105193. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  105194. /**
  105195. * This represents a particle system in Babylon.
  105196. * 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.
  105197. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  105198. * @example https://doc.babylonjs.com/babylon101/particles
  105199. */
  105200. var ParticleSystem = /** @class */ (function (_super) {
  105201. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticleSystem, _super);
  105202. /**
  105203. * Instantiates a particle system.
  105204. * 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.
  105205. * @param name The name of the particle system
  105206. * @param capacity The max number of particles alive at the same time
  105207. * @param scene The scene the particle system belongs to
  105208. * @param customEffect a custom effect used to change the way particles are rendered by default
  105209. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  105210. * @param epsilon Offset used to render the particles
  105211. */
  105212. function ParticleSystem(name, capacity, scene, customEffect, isAnimationSheetEnabled, epsilon) {
  105213. if (customEffect === void 0) { customEffect = null; }
  105214. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  105215. if (epsilon === void 0) { epsilon = 0.01; }
  105216. var _this = _super.call(this, name) || this;
  105217. /**
  105218. * @hidden
  105219. */
  105220. _this._inheritedVelocityOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  105221. /**
  105222. * An event triggered when the system is disposed
  105223. */
  105224. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  105225. _this._particles = new Array();
  105226. _this._stockParticles = new Array();
  105227. _this._newPartsExcess = 0;
  105228. _this._vertexBuffers = {};
  105229. _this._scaledColorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  105230. _this._colorDiff = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  105231. _this._scaledDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  105232. _this._scaledGravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  105233. _this._currentRenderId = -1;
  105234. _this._useInstancing = false;
  105235. _this._started = false;
  105236. _this._stopped = false;
  105237. _this._actualFrame = 0;
  105238. /** @hidden */
  105239. _this._currentEmitRate1 = 0;
  105240. /** @hidden */
  105241. _this._currentEmitRate2 = 0;
  105242. /** @hidden */
  105243. _this._currentStartSize1 = 0;
  105244. /** @hidden */
  105245. _this._currentStartSize2 = 0;
  105246. _this._rawTextureWidth = 256;
  105247. _this._useRampGradients = false;
  105248. /**
  105249. * @hidden
  105250. * If the particle systems emitter should be disposed when the particle system is disposed
  105251. */
  105252. _this._disposeEmitterOnDispose = false;
  105253. // start of sub system methods
  105254. /**
  105255. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  105256. * Its lifetime will start back at 0.
  105257. */
  105258. _this.recycleParticle = function (particle) {
  105259. // move particle from activeParticle list to stock particles
  105260. var lastParticle = _this._particles.pop();
  105261. if (lastParticle !== particle) {
  105262. lastParticle.copyTo(particle);
  105263. }
  105264. _this._stockParticles.push(lastParticle);
  105265. };
  105266. _this._createParticle = function () {
  105267. var particle;
  105268. if (_this._stockParticles.length !== 0) {
  105269. particle = _this._stockParticles.pop();
  105270. particle._reset();
  105271. }
  105272. else {
  105273. particle = new _particle__WEBPACK_IMPORTED_MODULE_16__["Particle"](_this);
  105274. }
  105275. // Attach emitters
  105276. if (_this._subEmitters && _this._subEmitters.length > 0) {
  105277. var subEmitters = _this._subEmitters[Math.floor(Math.random() * _this._subEmitters.length)];
  105278. particle._attachedSubEmitters = [];
  105279. subEmitters.forEach(function (subEmitter) {
  105280. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].ATTACHED) {
  105281. var newEmitter = subEmitter.clone();
  105282. particle._attachedSubEmitters.push(newEmitter);
  105283. newEmitter.particleSystem.start();
  105284. }
  105285. });
  105286. }
  105287. return particle;
  105288. };
  105289. _this._emitFromParticle = function (particle) {
  105290. if (!_this._subEmitters || _this._subEmitters.length === 0) {
  105291. return;
  105292. }
  105293. var templateIndex = Math.floor(Math.random() * _this._subEmitters.length);
  105294. _this._subEmitters[templateIndex].forEach(function (subEmitter) {
  105295. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].END) {
  105296. var subSystem = subEmitter.clone();
  105297. particle._inheritParticleInfoToSubEmitter(subSystem);
  105298. subSystem.particleSystem._rootParticleSystem = _this;
  105299. _this.activeSubSystems.push(subSystem.particleSystem);
  105300. subSystem.particleSystem.start();
  105301. }
  105302. });
  105303. };
  105304. _this._capacity = capacity;
  105305. _this._epsilon = epsilon;
  105306. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  105307. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__["EngineStore"].LastCreatedScene;
  105308. // Setup the default processing configuration to the scene.
  105309. _this._attachImageProcessingConfiguration(null);
  105310. _this._customEffect = customEffect;
  105311. _this._scene.particleSystems.push(_this);
  105312. _this._useInstancing = _this._scene.getEngine().getCaps().instancedArrays;
  105313. _this._createIndexBuffer();
  105314. _this._createVertexBuffers();
  105315. // Default emitter type
  105316. _this.particleEmitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  105317. // Update
  105318. _this.updateFunction = function (particles) {
  105319. var noiseTextureSize = null;
  105320. var noiseTextureData = null;
  105321. if (_this.noiseTexture) { // We need to get texture data back to CPU
  105322. noiseTextureSize = _this.noiseTexture.getSize();
  105323. noiseTextureData = (_this.noiseTexture.getContent());
  105324. }
  105325. var _loop_1 = function () {
  105326. particle = particles[index];
  105327. var scaledUpdateSpeed = _this._scaledUpdateSpeed;
  105328. var previousAge = particle.age;
  105329. particle.age += scaledUpdateSpeed;
  105330. // Evaluate step to death
  105331. if (particle.age > particle.lifeTime) {
  105332. var diff = particle.age - previousAge;
  105333. var oldDiff = particle.lifeTime - previousAge;
  105334. scaledUpdateSpeed = (oldDiff * scaledUpdateSpeed) / diff;
  105335. particle.age = particle.lifeTime;
  105336. }
  105337. var ratio = particle.age / particle.lifeTime;
  105338. // Color
  105339. if (_this._colorGradients && _this._colorGradients.length > 0) {
  105340. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorGradients, function (currentGradient, nextGradient, scale) {
  105341. if (currentGradient !== particle._currentColorGradient) {
  105342. particle._currentColor1.copyFrom(particle._currentColor2);
  105343. nextGradient.getColorToRef(particle._currentColor2);
  105344. particle._currentColorGradient = currentGradient;
  105345. }
  105346. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(particle._currentColor1, particle._currentColor2, scale, particle.color);
  105347. });
  105348. }
  105349. else {
  105350. particle.colorStep.scaleToRef(scaledUpdateSpeed, _this._scaledColorStep);
  105351. particle.color.addInPlace(_this._scaledColorStep);
  105352. if (particle.color.a < 0) {
  105353. particle.color.a = 0;
  105354. }
  105355. }
  105356. // Angular speed
  105357. if (_this._angularSpeedGradients && _this._angularSpeedGradients.length > 0) {
  105358. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._angularSpeedGradients, function (currentGradient, nextGradient, scale) {
  105359. if (currentGradient !== particle._currentAngularSpeedGradient) {
  105360. particle._currentAngularSpeed1 = particle._currentAngularSpeed2;
  105361. particle._currentAngularSpeed2 = nextGradient.getFactor();
  105362. particle._currentAngularSpeedGradient = currentGradient;
  105363. }
  105364. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentAngularSpeed1, particle._currentAngularSpeed2, scale);
  105365. });
  105366. }
  105367. particle.angle += particle.angularSpeed * scaledUpdateSpeed;
  105368. // Direction
  105369. var directionScale = scaledUpdateSpeed;
  105370. /// Velocity
  105371. if (_this._velocityGradients && _this._velocityGradients.length > 0) {
  105372. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._velocityGradients, function (currentGradient, nextGradient, scale) {
  105373. if (currentGradient !== particle._currentVelocityGradient) {
  105374. particle._currentVelocity1 = particle._currentVelocity2;
  105375. particle._currentVelocity2 = nextGradient.getFactor();
  105376. particle._currentVelocityGradient = currentGradient;
  105377. }
  105378. directionScale *= _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
  105379. });
  105380. }
  105381. particle.direction.scaleToRef(directionScale, _this._scaledDirection);
  105382. /// Limit velocity
  105383. if (_this._limitVelocityGradients && _this._limitVelocityGradients.length > 0) {
  105384. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._limitVelocityGradients, function (currentGradient, nextGradient, scale) {
  105385. if (currentGradient !== particle._currentLimitVelocityGradient) {
  105386. particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
  105387. particle._currentLimitVelocity2 = nextGradient.getFactor();
  105388. particle._currentLimitVelocityGradient = currentGradient;
  105389. }
  105390. var limitVelocity = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
  105391. var currentVelocity = particle.direction.length();
  105392. if (currentVelocity > limitVelocity) {
  105393. particle.direction.scaleInPlace(_this.limitVelocityDamping);
  105394. }
  105395. });
  105396. }
  105397. /// Drag
  105398. if (_this._dragGradients && _this._dragGradients.length > 0) {
  105399. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._dragGradients, function (currentGradient, nextGradient, scale) {
  105400. if (currentGradient !== particle._currentDragGradient) {
  105401. particle._currentDrag1 = particle._currentDrag2;
  105402. particle._currentDrag2 = nextGradient.getFactor();
  105403. particle._currentDragGradient = currentGradient;
  105404. }
  105405. var drag = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentDrag1, particle._currentDrag2, scale);
  105406. _this._scaledDirection.scaleInPlace(1.0 - drag);
  105407. });
  105408. }
  105409. particle.position.addInPlace(_this._scaledDirection);
  105410. // Noise
  105411. if (noiseTextureData && noiseTextureSize && particle._randomNoiseCoordinates1) {
  105412. var fetchedColorR = _this._fetchR(particle._randomNoiseCoordinates1.x, particle._randomNoiseCoordinates1.y, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  105413. var fetchedColorG = _this._fetchR(particle._randomNoiseCoordinates1.z, particle._randomNoiseCoordinates2.x, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  105414. var fetchedColorB = _this._fetchR(particle._randomNoiseCoordinates2.y, particle._randomNoiseCoordinates2.z, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  105415. var force = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  105416. var scaledForce = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  105417. force.copyFromFloats((2 * fetchedColorR - 1) * _this.noiseStrength.x, (2 * fetchedColorG - 1) * _this.noiseStrength.y, (2 * fetchedColorB - 1) * _this.noiseStrength.z);
  105418. force.scaleToRef(scaledUpdateSpeed, scaledForce);
  105419. particle.direction.addInPlace(scaledForce);
  105420. }
  105421. // Gravity
  105422. _this.gravity.scaleToRef(scaledUpdateSpeed, _this._scaledGravity);
  105423. particle.direction.addInPlace(_this._scaledGravity);
  105424. // Size
  105425. if (_this._sizeGradients && _this._sizeGradients.length > 0) {
  105426. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._sizeGradients, function (currentGradient, nextGradient, scale) {
  105427. if (currentGradient !== particle._currentSizeGradient) {
  105428. particle._currentSize1 = particle._currentSize2;
  105429. particle._currentSize2 = nextGradient.getFactor();
  105430. particle._currentSizeGradient = currentGradient;
  105431. }
  105432. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentSize1, particle._currentSize2, scale);
  105433. });
  105434. }
  105435. // Remap data
  105436. if (_this._useRampGradients) {
  105437. if (_this._colorRemapGradients && _this._colorRemapGradients.length > 0) {
  105438. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorRemapGradients, function (currentGradient, nextGradient, scale) {
  105439. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  105440. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  105441. particle.remapData.x = min;
  105442. particle.remapData.y = max - min;
  105443. });
  105444. }
  105445. if (_this._alphaRemapGradients && _this._alphaRemapGradients.length > 0) {
  105446. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._alphaRemapGradients, function (currentGradient, nextGradient, scale) {
  105447. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  105448. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  105449. particle.remapData.z = min;
  105450. particle.remapData.w = max - min;
  105451. });
  105452. }
  105453. }
  105454. if (_this._isAnimationSheetEnabled) {
  105455. particle.updateCellIndex();
  105456. }
  105457. // Update the position of the attached sub-emitters to match their attached particle
  105458. particle._inheritParticleInfoToSubEmitters();
  105459. if (particle.age >= particle.lifeTime) { // Recycle by swapping with last particle
  105460. _this._emitFromParticle(particle);
  105461. if (particle._attachedSubEmitters) {
  105462. particle._attachedSubEmitters.forEach(function (subEmitter) {
  105463. subEmitter.particleSystem.disposeOnStop = true;
  105464. subEmitter.particleSystem.stop();
  105465. });
  105466. particle._attachedSubEmitters = null;
  105467. }
  105468. _this.recycleParticle(particle);
  105469. index--;
  105470. return "continue";
  105471. }
  105472. };
  105473. var particle;
  105474. for (var index = 0; index < particles.length; index++) {
  105475. _loop_1();
  105476. }
  105477. };
  105478. return _this;
  105479. }
  105480. Object.defineProperty(ParticleSystem.prototype, "onDispose", {
  105481. /**
  105482. * Sets a callback that will be triggered when the system is disposed
  105483. */
  105484. set: function (callback) {
  105485. if (this._onDisposeObserver) {
  105486. this.onDisposeObservable.remove(this._onDisposeObserver);
  105487. }
  105488. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  105489. },
  105490. enumerable: true,
  105491. configurable: true
  105492. });
  105493. Object.defineProperty(ParticleSystem.prototype, "useRampGradients", {
  105494. /** Gets or sets a boolean indicating that ramp gradients must be used
  105495. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  105496. */
  105497. get: function () {
  105498. return this._useRampGradients;
  105499. },
  105500. set: function (value) {
  105501. if (this._useRampGradients === value) {
  105502. return;
  105503. }
  105504. this._useRampGradients = value;
  105505. this._resetEffect();
  105506. },
  105507. enumerable: true,
  105508. configurable: true
  105509. });
  105510. Object.defineProperty(ParticleSystem.prototype, "particles", {
  105511. //end of Sub-emitter
  105512. /**
  105513. * Gets the current list of active particles
  105514. */
  105515. get: function () {
  105516. return this._particles;
  105517. },
  105518. enumerable: true,
  105519. configurable: true
  105520. });
  105521. /**
  105522. * Returns the string "ParticleSystem"
  105523. * @returns a string containing the class name
  105524. */
  105525. ParticleSystem.prototype.getClassName = function () {
  105526. return "ParticleSystem";
  105527. };
  105528. ParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor, factor2) {
  105529. var newGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  105530. newGradient.gradient = gradient;
  105531. newGradient.factor1 = factor;
  105532. newGradient.factor2 = factor2;
  105533. factorGradients.push(newGradient);
  105534. factorGradients.sort(function (a, b) {
  105535. if (a.gradient < b.gradient) {
  105536. return -1;
  105537. }
  105538. else if (a.gradient > b.gradient) {
  105539. return 1;
  105540. }
  105541. return 0;
  105542. });
  105543. };
  105544. ParticleSystem.prototype._removeFactorGradient = function (factorGradients, gradient) {
  105545. if (!factorGradients) {
  105546. return;
  105547. }
  105548. var index = 0;
  105549. for (var _i = 0, factorGradients_1 = factorGradients; _i < factorGradients_1.length; _i++) {
  105550. var factorGradient = factorGradients_1[_i];
  105551. if (factorGradient.gradient === gradient) {
  105552. factorGradients.splice(index, 1);
  105553. break;
  105554. }
  105555. index++;
  105556. }
  105557. };
  105558. /**
  105559. * Adds a new life time gradient
  105560. * @param gradient defines the gradient to use (between 0 and 1)
  105561. * @param factor defines the life time factor to affect to the specified gradient
  105562. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105563. * @returns the current particle system
  105564. */
  105565. ParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  105566. if (!this._lifeTimeGradients) {
  105567. this._lifeTimeGradients = [];
  105568. }
  105569. this._addFactorGradient(this._lifeTimeGradients, gradient, factor, factor2);
  105570. return this;
  105571. };
  105572. /**
  105573. * Remove a specific life time gradient
  105574. * @param gradient defines the gradient to remove
  105575. * @returns the current particle system
  105576. */
  105577. ParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  105578. this._removeFactorGradient(this._lifeTimeGradients, gradient);
  105579. return this;
  105580. };
  105581. /**
  105582. * Adds a new size gradient
  105583. * @param gradient defines the gradient to use (between 0 and 1)
  105584. * @param factor defines the size factor to affect to the specified gradient
  105585. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105586. * @returns the current particle system
  105587. */
  105588. ParticleSystem.prototype.addSizeGradient = function (gradient, factor, factor2) {
  105589. if (!this._sizeGradients) {
  105590. this._sizeGradients = [];
  105591. }
  105592. this._addFactorGradient(this._sizeGradients, gradient, factor, factor2);
  105593. return this;
  105594. };
  105595. /**
  105596. * Remove a specific size gradient
  105597. * @param gradient defines the gradient to remove
  105598. * @returns the current particle system
  105599. */
  105600. ParticleSystem.prototype.removeSizeGradient = function (gradient) {
  105601. this._removeFactorGradient(this._sizeGradients, gradient);
  105602. return this;
  105603. };
  105604. /**
  105605. * Adds a new color remap gradient
  105606. * @param gradient defines the gradient to use (between 0 and 1)
  105607. * @param min defines the color remap minimal range
  105608. * @param max defines the color remap maximal range
  105609. * @returns the current particle system
  105610. */
  105611. ParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  105612. if (!this._colorRemapGradients) {
  105613. this._colorRemapGradients = [];
  105614. }
  105615. this._addFactorGradient(this._colorRemapGradients, gradient, min, max);
  105616. return this;
  105617. };
  105618. /**
  105619. * Remove a specific color remap gradient
  105620. * @param gradient defines the gradient to remove
  105621. * @returns the current particle system
  105622. */
  105623. ParticleSystem.prototype.removeColorRemapGradient = function (gradient) {
  105624. this._removeFactorGradient(this._colorRemapGradients, gradient);
  105625. return this;
  105626. };
  105627. /**
  105628. * Adds a new alpha remap gradient
  105629. * @param gradient defines the gradient to use (between 0 and 1)
  105630. * @param min defines the alpha remap minimal range
  105631. * @param max defines the alpha remap maximal range
  105632. * @returns the current particle system
  105633. */
  105634. ParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  105635. if (!this._alphaRemapGradients) {
  105636. this._alphaRemapGradients = [];
  105637. }
  105638. this._addFactorGradient(this._alphaRemapGradients, gradient, min, max);
  105639. return this;
  105640. };
  105641. /**
  105642. * Remove a specific alpha remap gradient
  105643. * @param gradient defines the gradient to remove
  105644. * @returns the current particle system
  105645. */
  105646. ParticleSystem.prototype.removeAlphaRemapGradient = function (gradient) {
  105647. this._removeFactorGradient(this._alphaRemapGradients, gradient);
  105648. return this;
  105649. };
  105650. /**
  105651. * Adds a new angular speed gradient
  105652. * @param gradient defines the gradient to use (between 0 and 1)
  105653. * @param factor defines the angular speed to affect to the specified gradient
  105654. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105655. * @returns the current particle system
  105656. */
  105657. ParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor, factor2) {
  105658. if (!this._angularSpeedGradients) {
  105659. this._angularSpeedGradients = [];
  105660. }
  105661. this._addFactorGradient(this._angularSpeedGradients, gradient, factor, factor2);
  105662. return this;
  105663. };
  105664. /**
  105665. * Remove a specific angular speed gradient
  105666. * @param gradient defines the gradient to remove
  105667. * @returns the current particle system
  105668. */
  105669. ParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  105670. this._removeFactorGradient(this._angularSpeedGradients, gradient);
  105671. return this;
  105672. };
  105673. /**
  105674. * Adds a new velocity gradient
  105675. * @param gradient defines the gradient to use (between 0 and 1)
  105676. * @param factor defines the velocity to affect to the specified gradient
  105677. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105678. * @returns the current particle system
  105679. */
  105680. ParticleSystem.prototype.addVelocityGradient = function (gradient, factor, factor2) {
  105681. if (!this._velocityGradients) {
  105682. this._velocityGradients = [];
  105683. }
  105684. this._addFactorGradient(this._velocityGradients, gradient, factor, factor2);
  105685. return this;
  105686. };
  105687. /**
  105688. * Remove a specific velocity gradient
  105689. * @param gradient defines the gradient to remove
  105690. * @returns the current particle system
  105691. */
  105692. ParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  105693. this._removeFactorGradient(this._velocityGradients, gradient);
  105694. return this;
  105695. };
  105696. /**
  105697. * Adds a new limit velocity gradient
  105698. * @param gradient defines the gradient to use (between 0 and 1)
  105699. * @param factor defines the limit velocity value to affect to the specified gradient
  105700. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105701. * @returns the current particle system
  105702. */
  105703. ParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor, factor2) {
  105704. if (!this._limitVelocityGradients) {
  105705. this._limitVelocityGradients = [];
  105706. }
  105707. this._addFactorGradient(this._limitVelocityGradients, gradient, factor, factor2);
  105708. return this;
  105709. };
  105710. /**
  105711. * Remove a specific limit velocity gradient
  105712. * @param gradient defines the gradient to remove
  105713. * @returns the current particle system
  105714. */
  105715. ParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  105716. this._removeFactorGradient(this._limitVelocityGradients, gradient);
  105717. return this;
  105718. };
  105719. /**
  105720. * Adds a new drag gradient
  105721. * @param gradient defines the gradient to use (between 0 and 1)
  105722. * @param factor defines the drag value to affect to the specified gradient
  105723. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105724. * @returns the current particle system
  105725. */
  105726. ParticleSystem.prototype.addDragGradient = function (gradient, factor, factor2) {
  105727. if (!this._dragGradients) {
  105728. this._dragGradients = [];
  105729. }
  105730. this._addFactorGradient(this._dragGradients, gradient, factor, factor2);
  105731. return this;
  105732. };
  105733. /**
  105734. * Remove a specific drag gradient
  105735. * @param gradient defines the gradient to remove
  105736. * @returns the current particle system
  105737. */
  105738. ParticleSystem.prototype.removeDragGradient = function (gradient) {
  105739. this._removeFactorGradient(this._dragGradients, gradient);
  105740. return this;
  105741. };
  105742. /**
  105743. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  105744. * @param gradient defines the gradient to use (between 0 and 1)
  105745. * @param factor defines the emit rate value to affect to the specified gradient
  105746. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105747. * @returns the current particle system
  105748. */
  105749. ParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  105750. if (!this._emitRateGradients) {
  105751. this._emitRateGradients = [];
  105752. }
  105753. this._addFactorGradient(this._emitRateGradients, gradient, factor, factor2);
  105754. return this;
  105755. };
  105756. /**
  105757. * Remove a specific emit rate gradient
  105758. * @param gradient defines the gradient to remove
  105759. * @returns the current particle system
  105760. */
  105761. ParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  105762. this._removeFactorGradient(this._emitRateGradients, gradient);
  105763. return this;
  105764. };
  105765. /**
  105766. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  105767. * @param gradient defines the gradient to use (between 0 and 1)
  105768. * @param factor defines the start size value to affect to the specified gradient
  105769. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105770. * @returns the current particle system
  105771. */
  105772. ParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  105773. if (!this._startSizeGradients) {
  105774. this._startSizeGradients = [];
  105775. }
  105776. this._addFactorGradient(this._startSizeGradients, gradient, factor, factor2);
  105777. return this;
  105778. };
  105779. /**
  105780. * Remove a specific start size gradient
  105781. * @param gradient defines the gradient to remove
  105782. * @returns the current particle system
  105783. */
  105784. ParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  105785. this._removeFactorGradient(this._emitRateGradients, gradient);
  105786. return this;
  105787. };
  105788. ParticleSystem.prototype._createRampGradientTexture = function () {
  105789. if (!this._rampGradients || !this._rampGradients.length || this._rampGradientsTexture) {
  105790. return;
  105791. }
  105792. var data = new Uint8Array(this._rawTextureWidth * 4);
  105793. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color3[0];
  105794. for (var x = 0; x < this._rawTextureWidth; x++) {
  105795. var ratio = x / this._rawTextureWidth;
  105796. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._rampGradients, function (currentGradient, nextGradient, scale) {
  105797. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].LerpToRef(currentGradient.color, nextGradient.color, scale, tmpColor);
  105798. data[x * 4] = tmpColor.r * 255;
  105799. data[x * 4 + 1] = tmpColor.g * 255;
  105800. data[x * 4 + 2] = tmpColor.b * 255;
  105801. data[x * 4 + 3] = 255;
  105802. });
  105803. }
  105804. 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);
  105805. };
  105806. /**
  105807. * Gets the current list of ramp gradients.
  105808. * You must use addRampGradient and removeRampGradient to udpate this list
  105809. * @returns the list of ramp gradients
  105810. */
  105811. ParticleSystem.prototype.getRampGradients = function () {
  105812. return this._rampGradients;
  105813. };
  105814. /**
  105815. * Adds a new ramp gradient used to remap particle colors
  105816. * @param gradient defines the gradient to use (between 0 and 1)
  105817. * @param color defines the color to affect to the specified gradient
  105818. * @returns the current particle system
  105819. */
  105820. ParticleSystem.prototype.addRampGradient = function (gradient, color) {
  105821. if (!this._rampGradients) {
  105822. this._rampGradients = [];
  105823. }
  105824. var rampGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Color3Gradient"]();
  105825. rampGradient.gradient = gradient;
  105826. rampGradient.color = color;
  105827. this._rampGradients.push(rampGradient);
  105828. this._rampGradients.sort(function (a, b) {
  105829. if (a.gradient < b.gradient) {
  105830. return -1;
  105831. }
  105832. else if (a.gradient > b.gradient) {
  105833. return 1;
  105834. }
  105835. return 0;
  105836. });
  105837. if (this._rampGradientsTexture) {
  105838. this._rampGradientsTexture.dispose();
  105839. this._rampGradientsTexture = null;
  105840. }
  105841. this._createRampGradientTexture();
  105842. return this;
  105843. };
  105844. /**
  105845. * Remove a specific ramp gradient
  105846. * @param gradient defines the gradient to remove
  105847. * @returns the current particle system
  105848. */
  105849. ParticleSystem.prototype.removeRampGradient = function (gradient) {
  105850. this._removeGradientAndTexture(gradient, this._rampGradients, this._rampGradientsTexture);
  105851. this._rampGradientsTexture = null;
  105852. if (this._rampGradients && this._rampGradients.length > 0) {
  105853. this._createRampGradientTexture();
  105854. }
  105855. return this;
  105856. };
  105857. /**
  105858. * Adds a new color gradient
  105859. * @param gradient defines the gradient to use (between 0 and 1)
  105860. * @param color1 defines the color to affect to the specified gradient
  105861. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  105862. * @returns this particle system
  105863. */
  105864. ParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  105865. if (!this._colorGradients) {
  105866. this._colorGradients = [];
  105867. }
  105868. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  105869. colorGradient.gradient = gradient;
  105870. colorGradient.color1 = color1;
  105871. colorGradient.color2 = color2;
  105872. this._colorGradients.push(colorGradient);
  105873. this._colorGradients.sort(function (a, b) {
  105874. if (a.gradient < b.gradient) {
  105875. return -1;
  105876. }
  105877. else if (a.gradient > b.gradient) {
  105878. return 1;
  105879. }
  105880. return 0;
  105881. });
  105882. return this;
  105883. };
  105884. /**
  105885. * Remove a specific color gradient
  105886. * @param gradient defines the gradient to remove
  105887. * @returns this particle system
  105888. */
  105889. ParticleSystem.prototype.removeColorGradient = function (gradient) {
  105890. if (!this._colorGradients) {
  105891. return this;
  105892. }
  105893. var index = 0;
  105894. for (var _i = 0, _a = this._colorGradients; _i < _a.length; _i++) {
  105895. var colorGradient = _a[_i];
  105896. if (colorGradient.gradient === gradient) {
  105897. this._colorGradients.splice(index, 1);
  105898. break;
  105899. }
  105900. index++;
  105901. }
  105902. return this;
  105903. };
  105904. ParticleSystem.prototype._fetchR = function (u, v, width, height, pixels) {
  105905. u = Math.abs(u) * 0.5 + 0.5;
  105906. v = Math.abs(v) * 0.5 + 0.5;
  105907. var wrappedU = ((u * width) % width) | 0;
  105908. var wrappedV = ((v * height) % height) | 0;
  105909. var position = (wrappedU + wrappedV * width) * 4;
  105910. return pixels[position] / 255;
  105911. };
  105912. ParticleSystem.prototype._reset = function () {
  105913. this._resetEffect();
  105914. };
  105915. ParticleSystem.prototype._resetEffect = function () {
  105916. if (this._vertexBuffer) {
  105917. this._vertexBuffer.dispose();
  105918. this._vertexBuffer = null;
  105919. }
  105920. if (this._spriteBuffer) {
  105921. this._spriteBuffer.dispose();
  105922. this._spriteBuffer = null;
  105923. }
  105924. this._createVertexBuffers();
  105925. };
  105926. ParticleSystem.prototype._createVertexBuffers = function () {
  105927. this._vertexBufferSize = this._useInstancing ? 10 : 12;
  105928. if (this._isAnimationSheetEnabled) {
  105929. this._vertexBufferSize += 1;
  105930. }
  105931. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  105932. this._vertexBufferSize += 3;
  105933. }
  105934. if (this._useRampGradients) {
  105935. this._vertexBufferSize += 4;
  105936. }
  105937. var engine = this._scene.getEngine();
  105938. this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4));
  105939. this._vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, this._vertexData, true, this._vertexBufferSize);
  105940. var dataOffset = 0;
  105941. var positions = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  105942. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind] = positions;
  105943. dataOffset += 3;
  105944. var colors = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  105945. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind] = colors;
  105946. dataOffset += 4;
  105947. var options = this._vertexBuffer.createVertexBuffer("angle", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  105948. this._vertexBuffers["angle"] = options;
  105949. dataOffset += 1;
  105950. var size = this._vertexBuffer.createVertexBuffer("size", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  105951. this._vertexBuffers["size"] = size;
  105952. dataOffset += 2;
  105953. if (this._isAnimationSheetEnabled) {
  105954. var cellIndexBuffer = this._vertexBuffer.createVertexBuffer("cellIndex", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  105955. this._vertexBuffers["cellIndex"] = cellIndexBuffer;
  105956. dataOffset += 1;
  105957. }
  105958. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  105959. var directionBuffer = this._vertexBuffer.createVertexBuffer("direction", dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  105960. this._vertexBuffers["direction"] = directionBuffer;
  105961. dataOffset += 3;
  105962. }
  105963. if (this._useRampGradients) {
  105964. var rampDataBuffer = this._vertexBuffer.createVertexBuffer("remapData", dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  105965. this._vertexBuffers["remapData"] = rampDataBuffer;
  105966. dataOffset += 4;
  105967. }
  105968. var offsets;
  105969. if (this._useInstancing) {
  105970. var spriteData = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
  105971. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 2);
  105972. offsets = this._spriteBuffer.createVertexBuffer("offset", 0, 2);
  105973. }
  105974. else {
  105975. offsets = this._vertexBuffer.createVertexBuffer("offset", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  105976. dataOffset += 2;
  105977. }
  105978. this._vertexBuffers["offset"] = offsets;
  105979. };
  105980. ParticleSystem.prototype._createIndexBuffer = function () {
  105981. if (this._useInstancing) {
  105982. return;
  105983. }
  105984. var indices = [];
  105985. var index = 0;
  105986. for (var count = 0; count < this._capacity; count++) {
  105987. indices.push(index);
  105988. indices.push(index + 1);
  105989. indices.push(index + 2);
  105990. indices.push(index);
  105991. indices.push(index + 2);
  105992. indices.push(index + 3);
  105993. index += 4;
  105994. }
  105995. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  105996. };
  105997. /**
  105998. * Gets the maximum number of particles active at the same time.
  105999. * @returns The max number of active particles.
  106000. */
  106001. ParticleSystem.prototype.getCapacity = function () {
  106002. return this._capacity;
  106003. };
  106004. /**
  106005. * Gets whether there are still active particles in the system.
  106006. * @returns True if it is alive, otherwise false.
  106007. */
  106008. ParticleSystem.prototype.isAlive = function () {
  106009. return this._alive;
  106010. };
  106011. /**
  106012. * Gets if the system has been started. (Note: this will still be true after stop is called)
  106013. * @returns True if it has been started, otherwise false.
  106014. */
  106015. ParticleSystem.prototype.isStarted = function () {
  106016. return this._started;
  106017. };
  106018. ParticleSystem.prototype._prepareSubEmitterInternalArray = function () {
  106019. var _this = this;
  106020. this._subEmitters = new Array();
  106021. if (this.subEmitters) {
  106022. this.subEmitters.forEach(function (subEmitter) {
  106023. if (subEmitter instanceof ParticleSystem) {
  106024. _this._subEmitters.push([new _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"](subEmitter)]);
  106025. }
  106026. else if (subEmitter instanceof _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]) {
  106027. _this._subEmitters.push([subEmitter]);
  106028. }
  106029. else if (subEmitter instanceof Array) {
  106030. _this._subEmitters.push(subEmitter);
  106031. }
  106032. });
  106033. }
  106034. };
  106035. /**
  106036. * Starts the particle system and begins to emit
  106037. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  106038. */
  106039. ParticleSystem.prototype.start = function (delay) {
  106040. var _this = this;
  106041. if (delay === void 0) { delay = this.startDelay; }
  106042. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  106043. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  106044. }
  106045. if (delay) {
  106046. setTimeout(function () {
  106047. _this.start(0);
  106048. }, delay);
  106049. return;
  106050. }
  106051. // Convert the subEmitters field to the constant type field _subEmitters
  106052. this._prepareSubEmitterInternalArray();
  106053. this._started = true;
  106054. this._stopped = false;
  106055. this._actualFrame = 0;
  106056. if (this._subEmitters && this._subEmitters.length != 0) {
  106057. this.activeSubSystems = new Array();
  106058. }
  106059. // Reset emit gradient so it acts the same on every start
  106060. if (this._emitRateGradients) {
  106061. if (this._emitRateGradients.length > 0) {
  106062. this._currentEmitRateGradient = this._emitRateGradients[0];
  106063. this._currentEmitRate1 = this._currentEmitRateGradient.getFactor();
  106064. this._currentEmitRate2 = this._currentEmitRate1;
  106065. }
  106066. if (this._emitRateGradients.length > 1) {
  106067. this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
  106068. }
  106069. }
  106070. // Reset start size gradient so it acts the same on every start
  106071. if (this._startSizeGradients) {
  106072. if (this._startSizeGradients.length > 0) {
  106073. this._currentStartSizeGradient = this._startSizeGradients[0];
  106074. this._currentStartSize1 = this._currentStartSizeGradient.getFactor();
  106075. this._currentStartSize2 = this._currentStartSize1;
  106076. }
  106077. if (this._startSizeGradients.length > 1) {
  106078. this._currentStartSize2 = this._startSizeGradients[1].getFactor();
  106079. }
  106080. }
  106081. if (this.preWarmCycles) {
  106082. if (this.emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__["AbstractMesh"]) {
  106083. this.emitter.computeWorldMatrix(true);
  106084. }
  106085. var noiseTextureAsProcedural_1 = this.noiseTexture;
  106086. if (noiseTextureAsProcedural_1 && noiseTextureAsProcedural_1.onGeneratedObservable) {
  106087. noiseTextureAsProcedural_1.onGeneratedObservable.addOnce(function () {
  106088. setTimeout(function () {
  106089. for (var index = 0; index < _this.preWarmCycles; index++) {
  106090. _this.animate(true);
  106091. noiseTextureAsProcedural_1.render();
  106092. }
  106093. });
  106094. });
  106095. }
  106096. else {
  106097. for (var index = 0; index < this.preWarmCycles; index++) {
  106098. this.animate(true);
  106099. }
  106100. }
  106101. }
  106102. // Animations
  106103. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  106104. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  106105. }
  106106. };
  106107. /**
  106108. * Stops the particle system.
  106109. * @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.
  106110. */
  106111. ParticleSystem.prototype.stop = function (stopSubEmitters) {
  106112. if (stopSubEmitters === void 0) { stopSubEmitters = true; }
  106113. this._stopped = true;
  106114. if (stopSubEmitters) {
  106115. this._stopSubEmitters();
  106116. }
  106117. };
  106118. // animation sheet
  106119. /**
  106120. * Remove all active particles
  106121. */
  106122. ParticleSystem.prototype.reset = function () {
  106123. this._stockParticles = [];
  106124. this._particles = [];
  106125. };
  106126. /**
  106127. * @hidden (for internal use only)
  106128. */
  106129. ParticleSystem.prototype._appendParticleVertex = function (index, particle, offsetX, offsetY) {
  106130. var offset = index * this._vertexBufferSize;
  106131. this._vertexData[offset++] = particle.position.x;
  106132. this._vertexData[offset++] = particle.position.y;
  106133. this._vertexData[offset++] = particle.position.z;
  106134. this._vertexData[offset++] = particle.color.r;
  106135. this._vertexData[offset++] = particle.color.g;
  106136. this._vertexData[offset++] = particle.color.b;
  106137. this._vertexData[offset++] = particle.color.a;
  106138. this._vertexData[offset++] = particle.angle;
  106139. this._vertexData[offset++] = particle.scale.x * particle.size;
  106140. this._vertexData[offset++] = particle.scale.y * particle.size;
  106141. if (this._isAnimationSheetEnabled) {
  106142. this._vertexData[offset++] = particle.cellIndex;
  106143. }
  106144. if (!this._isBillboardBased) {
  106145. if (particle._initialDirection) {
  106146. this._vertexData[offset++] = particle._initialDirection.x;
  106147. this._vertexData[offset++] = particle._initialDirection.y;
  106148. this._vertexData[offset++] = particle._initialDirection.z;
  106149. }
  106150. else {
  106151. this._vertexData[offset++] = particle.direction.x;
  106152. this._vertexData[offset++] = particle.direction.y;
  106153. this._vertexData[offset++] = particle.direction.z;
  106154. }
  106155. }
  106156. else if (this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  106157. this._vertexData[offset++] = particle.direction.x;
  106158. this._vertexData[offset++] = particle.direction.y;
  106159. this._vertexData[offset++] = particle.direction.z;
  106160. }
  106161. if (this._useRampGradients) {
  106162. this._vertexData[offset++] = particle.remapData.x;
  106163. this._vertexData[offset++] = particle.remapData.y;
  106164. this._vertexData[offset++] = particle.remapData.z;
  106165. this._vertexData[offset++] = particle.remapData.w;
  106166. }
  106167. if (!this._useInstancing) {
  106168. if (this._isAnimationSheetEnabled) {
  106169. if (offsetX === 0) {
  106170. offsetX = this._epsilon;
  106171. }
  106172. else if (offsetX === 1) {
  106173. offsetX = 1 - this._epsilon;
  106174. }
  106175. if (offsetY === 0) {
  106176. offsetY = this._epsilon;
  106177. }
  106178. else if (offsetY === 1) {
  106179. offsetY = 1 - this._epsilon;
  106180. }
  106181. }
  106182. this._vertexData[offset++] = offsetX;
  106183. this._vertexData[offset++] = offsetY;
  106184. }
  106185. };
  106186. ParticleSystem.prototype._stopSubEmitters = function () {
  106187. if (!this.activeSubSystems) {
  106188. return;
  106189. }
  106190. this.activeSubSystems.forEach(function (subSystem) {
  106191. subSystem.stop(true);
  106192. });
  106193. this.activeSubSystems = new Array();
  106194. };
  106195. ParticleSystem.prototype._removeFromRoot = function () {
  106196. if (!this._rootParticleSystem) {
  106197. return;
  106198. }
  106199. var index = this._rootParticleSystem.activeSubSystems.indexOf(this);
  106200. if (index !== -1) {
  106201. this._rootParticleSystem.activeSubSystems.splice(index, 1);
  106202. }
  106203. this._rootParticleSystem = null;
  106204. };
  106205. // End of sub system methods
  106206. ParticleSystem.prototype._update = function (newParticles) {
  106207. var _this = this;
  106208. // Update current
  106209. this._alive = this._particles.length > 0;
  106210. if (this.emitter.position) {
  106211. var emitterMesh = this.emitter;
  106212. this._emitterWorldMatrix = emitterMesh.getWorldMatrix();
  106213. }
  106214. else {
  106215. var emitterPosition = this.emitter;
  106216. this._emitterWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  106217. }
  106218. this.updateFunction(this._particles);
  106219. // Add new ones
  106220. var particle;
  106221. var _loop_2 = function () {
  106222. if (this_1._particles.length === this_1._capacity) {
  106223. return "break";
  106224. }
  106225. particle = this_1._createParticle();
  106226. this_1._particles.push(particle);
  106227. // Emitter
  106228. var emitPower = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minEmitPower, this_1.maxEmitPower);
  106229. if (this_1.startPositionFunction) {
  106230. this_1.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  106231. }
  106232. else {
  106233. this_1.particleEmitterType.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  106234. }
  106235. if (this_1.startDirectionFunction) {
  106236. this_1.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  106237. }
  106238. else {
  106239. this_1.particleEmitterType.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  106240. }
  106241. if (emitPower === 0) {
  106242. if (!particle._initialDirection) {
  106243. particle._initialDirection = particle.direction.clone();
  106244. }
  106245. else {
  106246. particle._initialDirection.copyFrom(particle.direction);
  106247. }
  106248. }
  106249. else {
  106250. particle._initialDirection = null;
  106251. }
  106252. particle.direction.scaleInPlace(emitPower);
  106253. // Life time
  106254. if (this_1.targetStopDuration && this_1._lifeTimeGradients && this_1._lifeTimeGradients.length > 0) {
  106255. var ratio_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(this_1._actualFrame / this_1.targetStopDuration);
  106256. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio_1, this_1._lifeTimeGradients, function (currentGradient, nextGradient) {
  106257. var factorGradient1 = currentGradient;
  106258. var factorGradient2 = nextGradient;
  106259. var lifeTime1 = factorGradient1.getFactor();
  106260. var lifeTime2 = factorGradient2.getFactor();
  106261. var gradient = (ratio_1 - factorGradient1.gradient) / (factorGradient2.gradient - factorGradient1.gradient);
  106262. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(lifeTime1, lifeTime2, gradient);
  106263. });
  106264. }
  106265. else {
  106266. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minLifeTime, this_1.maxLifeTime);
  106267. }
  106268. // Size
  106269. if (!this_1._sizeGradients || this_1._sizeGradients.length === 0) {
  106270. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minSize, this_1.maxSize);
  106271. }
  106272. else {
  106273. particle._currentSizeGradient = this_1._sizeGradients[0];
  106274. particle._currentSize1 = particle._currentSizeGradient.getFactor();
  106275. particle.size = particle._currentSize1;
  106276. if (this_1._sizeGradients.length > 1) {
  106277. particle._currentSize2 = this_1._sizeGradients[1].getFactor();
  106278. }
  106279. else {
  106280. particle._currentSize2 = particle._currentSize1;
  106281. }
  106282. }
  106283. // Size and scale
  106284. 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));
  106285. // Adjust scale by start size
  106286. if (this_1._startSizeGradients && this_1._startSizeGradients[0] && this_1.targetStopDuration) {
  106287. var ratio = this_1._actualFrame / this_1.targetStopDuration;
  106288. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this_1._startSizeGradients, function (currentGradient, nextGradient, scale) {
  106289. if (currentGradient !== _this._currentStartSizeGradient) {
  106290. _this._currentStartSize1 = _this._currentStartSize2;
  106291. _this._currentStartSize2 = nextGradient.getFactor();
  106292. _this._currentStartSizeGradient = currentGradient;
  106293. }
  106294. var value = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentStartSize1, _this._currentStartSize2, scale);
  106295. particle.scale.scaleInPlace(value);
  106296. });
  106297. }
  106298. // Angle
  106299. if (!this_1._angularSpeedGradients || this_1._angularSpeedGradients.length === 0) {
  106300. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minAngularSpeed, this_1.maxAngularSpeed);
  106301. }
  106302. else {
  106303. particle._currentAngularSpeedGradient = this_1._angularSpeedGradients[0];
  106304. particle.angularSpeed = particle._currentAngularSpeedGradient.getFactor();
  106305. particle._currentAngularSpeed1 = particle.angularSpeed;
  106306. if (this_1._angularSpeedGradients.length > 1) {
  106307. particle._currentAngularSpeed2 = this_1._angularSpeedGradients[1].getFactor();
  106308. }
  106309. else {
  106310. particle._currentAngularSpeed2 = particle._currentAngularSpeed1;
  106311. }
  106312. }
  106313. particle.angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minInitialRotation, this_1.maxInitialRotation);
  106314. // Velocity
  106315. if (this_1._velocityGradients && this_1._velocityGradients.length > 0) {
  106316. particle._currentVelocityGradient = this_1._velocityGradients[0];
  106317. particle._currentVelocity1 = particle._currentVelocityGradient.getFactor();
  106318. if (this_1._velocityGradients.length > 1) {
  106319. particle._currentVelocity2 = this_1._velocityGradients[1].getFactor();
  106320. }
  106321. else {
  106322. particle._currentVelocity2 = particle._currentVelocity1;
  106323. }
  106324. }
  106325. // Limit velocity
  106326. if (this_1._limitVelocityGradients && this_1._limitVelocityGradients.length > 0) {
  106327. particle._currentLimitVelocityGradient = this_1._limitVelocityGradients[0];
  106328. particle._currentLimitVelocity1 = particle._currentLimitVelocityGradient.getFactor();
  106329. if (this_1._limitVelocityGradients.length > 1) {
  106330. particle._currentLimitVelocity2 = this_1._limitVelocityGradients[1].getFactor();
  106331. }
  106332. else {
  106333. particle._currentLimitVelocity2 = particle._currentLimitVelocity1;
  106334. }
  106335. }
  106336. // Drag
  106337. if (this_1._dragGradients && this_1._dragGradients.length > 0) {
  106338. particle._currentDragGradient = this_1._dragGradients[0];
  106339. particle._currentDrag1 = particle._currentDragGradient.getFactor();
  106340. if (this_1._dragGradients.length > 1) {
  106341. particle._currentDrag2 = this_1._dragGradients[1].getFactor();
  106342. }
  106343. else {
  106344. particle._currentDrag2 = particle._currentDrag1;
  106345. }
  106346. }
  106347. // Color
  106348. if (!this_1._colorGradients || this_1._colorGradients.length === 0) {
  106349. step = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(0, 1.0);
  106350. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(this_1.color1, this_1.color2, step, particle.color);
  106351. this_1.colorDead.subtractToRef(particle.color, this_1._colorDiff);
  106352. this_1._colorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);
  106353. }
  106354. else {
  106355. particle._currentColorGradient = this_1._colorGradients[0];
  106356. particle._currentColorGradient.getColorToRef(particle.color);
  106357. particle._currentColor1.copyFrom(particle.color);
  106358. if (this_1._colorGradients.length > 1) {
  106359. this_1._colorGradients[1].getColorToRef(particle._currentColor2);
  106360. }
  106361. else {
  106362. particle._currentColor2.copyFrom(particle.color);
  106363. }
  106364. }
  106365. // Sheet
  106366. if (this_1._isAnimationSheetEnabled) {
  106367. particle._initialStartSpriteCellID = this_1.startSpriteCellID;
  106368. particle._initialEndSpriteCellID = this_1.endSpriteCellID;
  106369. }
  106370. // Inherited Velocity
  106371. particle.direction.addInPlace(this_1._inheritedVelocityOffset);
  106372. // Ramp
  106373. if (this_1._useRampGradients) {
  106374. particle.remapData = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector4"](0, 1, 0, 1);
  106375. }
  106376. // Noise texture coordinates
  106377. if (this_1.noiseTexture) {
  106378. if (particle._randomNoiseCoordinates1) {
  106379. particle._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random());
  106380. particle._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random());
  106381. }
  106382. else {
  106383. particle._randomNoiseCoordinates1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  106384. particle._randomNoiseCoordinates2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  106385. }
  106386. }
  106387. // Update the position of the attached sub-emitters to match their attached particle
  106388. particle._inheritParticleInfoToSubEmitters();
  106389. };
  106390. var this_1 = this, step;
  106391. for (var index = 0; index < newParticles; index++) {
  106392. var state_1 = _loop_2();
  106393. if (state_1 === "break")
  106394. break;
  106395. }
  106396. };
  106397. /** @hidden */
  106398. ParticleSystem._GetAttributeNamesOrOptions = function (isAnimationSheetEnabled, isBillboardBased, useRampGradients) {
  106399. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  106400. if (isBillboardBased === void 0) { isBillboardBased = false; }
  106401. if (useRampGradients === void 0) { useRampGradients = false; }
  106402. var attributeNamesOrOptions = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, "angle", "offset", "size"];
  106403. if (isAnimationSheetEnabled) {
  106404. attributeNamesOrOptions.push("cellIndex");
  106405. }
  106406. if (!isBillboardBased) {
  106407. attributeNamesOrOptions.push("direction");
  106408. }
  106409. if (useRampGradients) {
  106410. attributeNamesOrOptions.push("remapData");
  106411. }
  106412. return attributeNamesOrOptions;
  106413. };
  106414. /** @hidden */
  106415. ParticleSystem._GetEffectCreationOptions = function (isAnimationSheetEnabled) {
  106416. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  106417. var effectCreationOption = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "textureMask", "translationPivot", "eyePosition"];
  106418. if (isAnimationSheetEnabled) {
  106419. effectCreationOption.push("particlesInfos");
  106420. }
  106421. return effectCreationOption;
  106422. };
  106423. /** @hidden */
  106424. ParticleSystem.prototype._getEffect = function (blendMode) {
  106425. if (this._customEffect) {
  106426. return this._customEffect;
  106427. }
  106428. var defines = [];
  106429. if (this._scene.clipPlane) {
  106430. defines.push("#define CLIPPLANE");
  106431. }
  106432. if (this._scene.clipPlane2) {
  106433. defines.push("#define CLIPPLANE2");
  106434. }
  106435. if (this._scene.clipPlane3) {
  106436. defines.push("#define CLIPPLANE3");
  106437. }
  106438. if (this._scene.clipPlane4) {
  106439. defines.push("#define CLIPPLANE4");
  106440. }
  106441. if (this._isAnimationSheetEnabled) {
  106442. defines.push("#define ANIMATESHEET");
  106443. }
  106444. if (blendMode === ParticleSystem.BLENDMODE_MULTIPLY) {
  106445. defines.push("#define BLENDMULTIPLYMODE");
  106446. }
  106447. if (this._useRampGradients) {
  106448. defines.push("#define RAMPGRADIENT");
  106449. }
  106450. if (this._isBillboardBased) {
  106451. defines.push("#define BILLBOARD");
  106452. switch (this.billboardMode) {
  106453. case ParticleSystem.BILLBOARDMODE_Y:
  106454. defines.push("#define BILLBOARDY");
  106455. break;
  106456. case ParticleSystem.BILLBOARDMODE_STRETCHED:
  106457. defines.push("#define BILLBOARDSTRETCHED");
  106458. break;
  106459. case ParticleSystem.BILLBOARDMODE_ALL:
  106460. default:
  106461. break;
  106462. }
  106463. }
  106464. if (this._imageProcessingConfiguration) {
  106465. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  106466. defines.push(this._imageProcessingConfigurationDefines.toString());
  106467. }
  106468. // Effect
  106469. var join = defines.join("\n");
  106470. if (this._cachedDefines !== join) {
  106471. this._cachedDefines = join;
  106472. var attributesNamesOrOptions = ParticleSystem._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== ParticleSystem.BILLBOARDMODE_STRETCHED, this._useRampGradients);
  106473. var effectCreationOption = ParticleSystem._GetEffectCreationOptions(this._isAnimationSheetEnabled);
  106474. var samplers = ["diffuseSampler", "rampSampler"];
  106475. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"]) {
  106476. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareUniforms(effectCreationOption, this._imageProcessingConfigurationDefines);
  106477. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  106478. }
  106479. this._effect = this._scene.getEngine().createEffect("particles", attributesNamesOrOptions, effectCreationOption, samplers, join);
  106480. }
  106481. return this._effect;
  106482. };
  106483. /**
  106484. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  106485. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  106486. */
  106487. ParticleSystem.prototype.animate = function (preWarmOnly) {
  106488. var _this = this;
  106489. if (preWarmOnly === void 0) { preWarmOnly = false; }
  106490. if (!this._started) {
  106491. return;
  106492. }
  106493. if (!preWarmOnly) {
  106494. // Check
  106495. if (!this.isReady()) {
  106496. return;
  106497. }
  106498. if (this._currentRenderId === this._scene.getFrameId()) {
  106499. return;
  106500. }
  106501. this._currentRenderId = this._scene.getFrameId();
  106502. }
  106503. this._scaledUpdateSpeed = this.updateSpeed * (preWarmOnly ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  106504. // Determine the number of particles we need to create
  106505. var newParticles;
  106506. if (this.manualEmitCount > -1) {
  106507. newParticles = this.manualEmitCount;
  106508. this._newPartsExcess = 0;
  106509. this.manualEmitCount = 0;
  106510. }
  106511. else {
  106512. var rate_1 = this.emitRate;
  106513. if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
  106514. var ratio = this._actualFrame / this.targetStopDuration;
  106515. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._emitRateGradients, function (currentGradient, nextGradient, scale) {
  106516. if (currentGradient !== _this._currentEmitRateGradient) {
  106517. _this._currentEmitRate1 = _this._currentEmitRate2;
  106518. _this._currentEmitRate2 = nextGradient.getFactor();
  106519. _this._currentEmitRateGradient = currentGradient;
  106520. }
  106521. rate_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentEmitRate1, _this._currentEmitRate2, scale);
  106522. });
  106523. }
  106524. newParticles = ((rate_1 * this._scaledUpdateSpeed) >> 0);
  106525. this._newPartsExcess += rate_1 * this._scaledUpdateSpeed - newParticles;
  106526. }
  106527. if (this._newPartsExcess > 1.0) {
  106528. newParticles += this._newPartsExcess >> 0;
  106529. this._newPartsExcess -= this._newPartsExcess >> 0;
  106530. }
  106531. this._alive = false;
  106532. if (!this._stopped) {
  106533. this._actualFrame += this._scaledUpdateSpeed;
  106534. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  106535. this.stop();
  106536. }
  106537. }
  106538. else {
  106539. newParticles = 0;
  106540. }
  106541. this._update(newParticles);
  106542. // Stopped?
  106543. if (this._stopped) {
  106544. if (!this._alive) {
  106545. this._started = false;
  106546. if (this.onAnimationEnd) {
  106547. this.onAnimationEnd();
  106548. }
  106549. if (this.disposeOnStop) {
  106550. this._scene._toBeDisposed.push(this);
  106551. }
  106552. }
  106553. }
  106554. if (!preWarmOnly) {
  106555. // Update VBO
  106556. var offset = 0;
  106557. for (var index = 0; index < this._particles.length; index++) {
  106558. var particle = this._particles[index];
  106559. this._appendParticleVertices(offset, particle);
  106560. offset += this._useInstancing ? 1 : 4;
  106561. }
  106562. if (this._vertexBuffer) {
  106563. this._vertexBuffer.update(this._vertexData);
  106564. }
  106565. }
  106566. if (this.manualEmitCount === 0 && this.disposeOnStop) {
  106567. this.stop();
  106568. }
  106569. };
  106570. ParticleSystem.prototype._appendParticleVertices = function (offset, particle) {
  106571. this._appendParticleVertex(offset++, particle, 0, 0);
  106572. if (!this._useInstancing) {
  106573. this._appendParticleVertex(offset++, particle, 1, 0);
  106574. this._appendParticleVertex(offset++, particle, 1, 1);
  106575. this._appendParticleVertex(offset++, particle, 0, 1);
  106576. }
  106577. };
  106578. /**
  106579. * Rebuilds the particle system.
  106580. */
  106581. ParticleSystem.prototype.rebuild = function () {
  106582. this._createIndexBuffer();
  106583. if (this._vertexBuffer) {
  106584. this._vertexBuffer._rebuild();
  106585. }
  106586. };
  106587. /**
  106588. * Is this system ready to be used/rendered
  106589. * @return true if the system is ready
  106590. */
  106591. ParticleSystem.prototype.isReady = function () {
  106592. if (!this.emitter || !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  106593. return false;
  106594. }
  106595. if (this.blendMode !== ParticleSystem.BLENDMODE_MULTIPLYADD) {
  106596. if (!this._getEffect(this.blendMode).isReady()) {
  106597. return false;
  106598. }
  106599. }
  106600. else {
  106601. if (!this._getEffect(ParticleSystem.BLENDMODE_MULTIPLY).isReady()) {
  106602. return false;
  106603. }
  106604. if (!this._getEffect(ParticleSystem.BLENDMODE_ADD).isReady()) {
  106605. return false;
  106606. }
  106607. }
  106608. return true;
  106609. };
  106610. ParticleSystem.prototype._render = function (blendMode) {
  106611. var effect = this._getEffect(blendMode);
  106612. var engine = this._scene.getEngine();
  106613. // Render
  106614. engine.enableEffect(effect);
  106615. var viewMatrix = this._scene.getViewMatrix();
  106616. effect.setTexture("diffuseSampler", this.particleTexture);
  106617. effect.setMatrix("view", viewMatrix);
  106618. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  106619. if (this._isAnimationSheetEnabled && this.particleTexture) {
  106620. var baseSize = this.particleTexture.getBaseSize();
  106621. effect.setFloat3("particlesInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  106622. }
  106623. effect.setVector2("translationPivot", this.translationPivot);
  106624. effect.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a);
  106625. if (this._isBillboardBased) {
  106626. var camera = this._scene.activeCamera;
  106627. effect.setVector3("eyePosition", camera.globalPosition);
  106628. }
  106629. if (this._rampGradientsTexture) {
  106630. effect.setTexture("rampSampler", this._rampGradientsTexture);
  106631. }
  106632. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  106633. var invView = viewMatrix.clone();
  106634. invView.invert();
  106635. effect.setMatrix("invView", invView);
  106636. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__["MaterialHelper"].BindClipPlane(effect, this._scene);
  106637. }
  106638. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  106639. // image processing
  106640. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  106641. this._imageProcessingConfiguration.bind(effect);
  106642. }
  106643. // Draw order
  106644. switch (blendMode) {
  106645. case ParticleSystem.BLENDMODE_ADD:
  106646. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ADD);
  106647. break;
  106648. case ParticleSystem.BLENDMODE_ONEONE:
  106649. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ONEONE);
  106650. break;
  106651. case ParticleSystem.BLENDMODE_STANDARD:
  106652. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_COMBINE);
  106653. break;
  106654. case ParticleSystem.BLENDMODE_MULTIPLY:
  106655. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_MULTIPLY);
  106656. break;
  106657. }
  106658. if (this._useInstancing) {
  106659. engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFanDrawMode, 0, 4, this._particles.length);
  106660. }
  106661. else {
  106662. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, this._particles.length * 6);
  106663. }
  106664. return this._particles.length;
  106665. };
  106666. /**
  106667. * Renders the particle system in its current state.
  106668. * @returns the current number of particles
  106669. */
  106670. ParticleSystem.prototype.render = function () {
  106671. // Check
  106672. if (!this.isReady() || !this._particles.length) {
  106673. return 0;
  106674. }
  106675. var engine = this._scene.getEngine();
  106676. engine.setState(false);
  106677. if (this.forceDepthWrite) {
  106678. engine.setDepthWrite(true);
  106679. }
  106680. var outparticles = 0;
  106681. if (this.blendMode === ParticleSystem.BLENDMODE_MULTIPLYADD) {
  106682. outparticles = this._render(ParticleSystem.BLENDMODE_MULTIPLY) + this._render(ParticleSystem.BLENDMODE_ADD);
  106683. }
  106684. outparticles = this._render(this.blendMode);
  106685. engine.unbindInstanceAttributes();
  106686. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_DISABLE);
  106687. return outparticles;
  106688. };
  106689. /**
  106690. * Disposes the particle system and free the associated resources
  106691. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  106692. */
  106693. ParticleSystem.prototype.dispose = function (disposeTexture) {
  106694. if (disposeTexture === void 0) { disposeTexture = true; }
  106695. if (this._vertexBuffer) {
  106696. this._vertexBuffer.dispose();
  106697. this._vertexBuffer = null;
  106698. }
  106699. if (this._spriteBuffer) {
  106700. this._spriteBuffer.dispose();
  106701. this._spriteBuffer = null;
  106702. }
  106703. if (this._indexBuffer) {
  106704. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  106705. this._indexBuffer = null;
  106706. }
  106707. if (disposeTexture && this.particleTexture) {
  106708. this.particleTexture.dispose();
  106709. this.particleTexture = null;
  106710. }
  106711. if (disposeTexture && this.noiseTexture) {
  106712. this.noiseTexture.dispose();
  106713. this.noiseTexture = null;
  106714. }
  106715. if (this._rampGradientsTexture) {
  106716. this._rampGradientsTexture.dispose();
  106717. this._rampGradientsTexture = null;
  106718. }
  106719. this._removeFromRoot();
  106720. if (this._subEmitters && this._subEmitters.length) {
  106721. for (var index = 0; index < this._subEmitters.length; index++) {
  106722. for (var _i = 0, _a = this._subEmitters[index]; _i < _a.length; _i++) {
  106723. var subEmitter = _a[_i];
  106724. subEmitter.dispose();
  106725. }
  106726. }
  106727. this._subEmitters = [];
  106728. this.subEmitters = [];
  106729. }
  106730. if (this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose) {
  106731. this.emitter.dispose(true);
  106732. }
  106733. // Remove from scene
  106734. var index = this._scene.particleSystems.indexOf(this);
  106735. if (index > -1) {
  106736. this._scene.particleSystems.splice(index, 1);
  106737. }
  106738. this._scene._activeParticleSystems.dispose();
  106739. // Callback
  106740. this.onDisposeObservable.notifyObservers(this);
  106741. this.onDisposeObservable.clear();
  106742. this.reset();
  106743. };
  106744. // Clone
  106745. /**
  106746. * Clones the particle system.
  106747. * @param name The name of the cloned object
  106748. * @param newEmitter The new emitter to use
  106749. * @returns the cloned particle system
  106750. */
  106751. ParticleSystem.prototype.clone = function (name, newEmitter) {
  106752. var custom = null;
  106753. var program = null;
  106754. if (this.customShader != null) {
  106755. program = this.customShader;
  106756. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  106757. custom = this._scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  106758. }
  106759. else if (this._customEffect) {
  106760. custom = this._customEffect;
  106761. }
  106762. var result = new ParticleSystem(name, this._capacity, this._scene, custom);
  106763. result.customShader = program;
  106764. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__["DeepCopier"].DeepCopy(this, result, ["particles", "customShader", "noiseTexture"]);
  106765. if (newEmitter === undefined) {
  106766. newEmitter = this.emitter;
  106767. }
  106768. result.noiseTexture = this.noiseTexture;
  106769. result.emitter = newEmitter;
  106770. if (this.particleTexture) {
  106771. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](this.particleTexture.url, this._scene);
  106772. }
  106773. // Clone gradients
  106774. if (this._colorGradients) {
  106775. this._colorGradients.forEach(function (v) {
  106776. result.addColorGradient(v.gradient, v.color1, v.color2);
  106777. });
  106778. }
  106779. if (this._dragGradients) {
  106780. this._dragGradients.forEach(function (v) {
  106781. result.addDragGradient(v.gradient, v.factor1, v.factor2);
  106782. });
  106783. }
  106784. if (this._angularSpeedGradients) {
  106785. this._angularSpeedGradients.forEach(function (v) {
  106786. result.addAngularSpeedGradient(v.gradient, v.factor1, v.factor2);
  106787. });
  106788. }
  106789. if (this._emitRateGradients) {
  106790. this._emitRateGradients.forEach(function (v) {
  106791. result.addEmitRateGradient(v.gradient, v.factor1, v.factor2);
  106792. });
  106793. }
  106794. if (this._lifeTimeGradients) {
  106795. this._lifeTimeGradients.forEach(function (v) {
  106796. result.addLifeTimeGradient(v.gradient, v.factor1, v.factor2);
  106797. });
  106798. }
  106799. if (this._limitVelocityGradients) {
  106800. this._limitVelocityGradients.forEach(function (v) {
  106801. result.addLimitVelocityGradient(v.gradient, v.factor1, v.factor2);
  106802. });
  106803. }
  106804. if (this._sizeGradients) {
  106805. this._sizeGradients.forEach(function (v) {
  106806. result.addSizeGradient(v.gradient, v.factor1, v.factor2);
  106807. });
  106808. }
  106809. if (this._startSizeGradients) {
  106810. this._startSizeGradients.forEach(function (v) {
  106811. result.addStartSizeGradient(v.gradient, v.factor1, v.factor2);
  106812. });
  106813. }
  106814. if (this._velocityGradients) {
  106815. this._velocityGradients.forEach(function (v) {
  106816. result.addVelocityGradient(v.gradient, v.factor1, v.factor2);
  106817. });
  106818. }
  106819. if (this._rampGradients) {
  106820. this._rampGradients.forEach(function (v) {
  106821. result.addRampGradient(v.gradient, v.color);
  106822. });
  106823. }
  106824. if (this._colorRemapGradients) {
  106825. this._colorRemapGradients.forEach(function (v) {
  106826. result.addColorRemapGradient(v.gradient, v.factor1, v.factor2);
  106827. });
  106828. }
  106829. if (this._alphaRemapGradients) {
  106830. this._alphaRemapGradients.forEach(function (v) {
  106831. result.addAlphaRemapGradient(v.gradient, v.factor1, v.factor2);
  106832. });
  106833. }
  106834. if (!this.preventAutoStart) {
  106835. result.start();
  106836. }
  106837. return result;
  106838. };
  106839. /**
  106840. * Serializes the particle system to a JSON object.
  106841. * @returns the JSON object
  106842. */
  106843. ParticleSystem.prototype.serialize = function () {
  106844. var serializationObject = {};
  106845. ParticleSystem._Serialize(serializationObject, this);
  106846. serializationObject.textureMask = this.textureMask.asArray();
  106847. serializationObject.customShader = this.customShader;
  106848. serializationObject.preventAutoStart = this.preventAutoStart;
  106849. // SubEmitters
  106850. if (this.subEmitters) {
  106851. serializationObject.subEmitters = [];
  106852. if (!this._subEmitters) {
  106853. this._prepareSubEmitterInternalArray();
  106854. }
  106855. for (var _i = 0, _a = this._subEmitters; _i < _a.length; _i++) {
  106856. var subs = _a[_i];
  106857. var cell = [];
  106858. for (var _b = 0, subs_1 = subs; _b < subs_1.length; _b++) {
  106859. var sub = subs_1[_b];
  106860. cell.push(sub.serialize());
  106861. }
  106862. serializationObject.subEmitters.push(cell);
  106863. }
  106864. }
  106865. return serializationObject;
  106866. };
  106867. /** @hidden */
  106868. ParticleSystem._Serialize = function (serializationObject, particleSystem) {
  106869. serializationObject.name = particleSystem.name;
  106870. serializationObject.id = particleSystem.id;
  106871. serializationObject.capacity = particleSystem.getCapacity();
  106872. // Emitter
  106873. if (particleSystem.emitter.position) {
  106874. var emitterMesh = particleSystem.emitter;
  106875. serializationObject.emitterId = emitterMesh.id;
  106876. }
  106877. else {
  106878. var emitterPosition = particleSystem.emitter;
  106879. serializationObject.emitter = emitterPosition.asArray();
  106880. }
  106881. // Emitter
  106882. if (particleSystem.particleEmitterType) {
  106883. serializationObject.particleEmitterType = particleSystem.particleEmitterType.serialize();
  106884. }
  106885. if (particleSystem.particleTexture) {
  106886. serializationObject.textureName = particleSystem.particleTexture.name;
  106887. serializationObject.invertY = particleSystem.particleTexture._invertY;
  106888. }
  106889. // Animations
  106890. _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__["SerializationHelper"].AppendSerializedAnimations(particleSystem, serializationObject);
  106891. serializationObject.beginAnimationOnStart = particleSystem.beginAnimationOnStart;
  106892. serializationObject.beginAnimationFrom = particleSystem.beginAnimationFrom;
  106893. serializationObject.beginAnimationTo = particleSystem.beginAnimationTo;
  106894. serializationObject.beginAnimationLoop = particleSystem.beginAnimationLoop;
  106895. // Particle system
  106896. serializationObject.startDelay = particleSystem.startDelay;
  106897. serializationObject.renderingGroupId = particleSystem.renderingGroupId;
  106898. serializationObject.isBillboardBased = particleSystem.isBillboardBased;
  106899. serializationObject.billboardMode = particleSystem.billboardMode;
  106900. serializationObject.minAngularSpeed = particleSystem.minAngularSpeed;
  106901. serializationObject.maxAngularSpeed = particleSystem.maxAngularSpeed;
  106902. serializationObject.minSize = particleSystem.minSize;
  106903. serializationObject.maxSize = particleSystem.maxSize;
  106904. serializationObject.minScaleX = particleSystem.minScaleX;
  106905. serializationObject.maxScaleX = particleSystem.maxScaleX;
  106906. serializationObject.minScaleY = particleSystem.minScaleY;
  106907. serializationObject.maxScaleY = particleSystem.maxScaleY;
  106908. serializationObject.minEmitPower = particleSystem.minEmitPower;
  106909. serializationObject.maxEmitPower = particleSystem.maxEmitPower;
  106910. serializationObject.minLifeTime = particleSystem.minLifeTime;
  106911. serializationObject.maxLifeTime = particleSystem.maxLifeTime;
  106912. serializationObject.emitRate = particleSystem.emitRate;
  106913. serializationObject.gravity = particleSystem.gravity.asArray();
  106914. serializationObject.noiseStrength = particleSystem.noiseStrength.asArray();
  106915. serializationObject.color1 = particleSystem.color1.asArray();
  106916. serializationObject.color2 = particleSystem.color2.asArray();
  106917. serializationObject.colorDead = particleSystem.colorDead.asArray();
  106918. serializationObject.updateSpeed = particleSystem.updateSpeed;
  106919. serializationObject.targetStopDuration = particleSystem.targetStopDuration;
  106920. serializationObject.blendMode = particleSystem.blendMode;
  106921. serializationObject.preWarmCycles = particleSystem.preWarmCycles;
  106922. serializationObject.preWarmStepOffset = particleSystem.preWarmStepOffset;
  106923. serializationObject.minInitialRotation = particleSystem.minInitialRotation;
  106924. serializationObject.maxInitialRotation = particleSystem.maxInitialRotation;
  106925. serializationObject.startSpriteCellID = particleSystem.startSpriteCellID;
  106926. serializationObject.endSpriteCellID = particleSystem.endSpriteCellID;
  106927. serializationObject.spriteCellChangeSpeed = particleSystem.spriteCellChangeSpeed;
  106928. serializationObject.spriteCellWidth = particleSystem.spriteCellWidth;
  106929. serializationObject.spriteCellHeight = particleSystem.spriteCellHeight;
  106930. serializationObject.spriteRandomStartCell = particleSystem.spriteRandomStartCell;
  106931. serializationObject.isAnimationSheetEnabled = particleSystem.isAnimationSheetEnabled;
  106932. var colorGradients = particleSystem.getColorGradients();
  106933. if (colorGradients) {
  106934. serializationObject.colorGradients = [];
  106935. for (var _i = 0, colorGradients_1 = colorGradients; _i < colorGradients_1.length; _i++) {
  106936. var colorGradient = colorGradients_1[_i];
  106937. var serializedGradient = {
  106938. gradient: colorGradient.gradient,
  106939. color1: colorGradient.color1.asArray()
  106940. };
  106941. if (colorGradient.color2) {
  106942. serializedGradient.color2 = colorGradient.color2.asArray();
  106943. }
  106944. serializationObject.colorGradients.push(serializedGradient);
  106945. }
  106946. }
  106947. var rampGradients = particleSystem.getRampGradients();
  106948. if (rampGradients) {
  106949. serializationObject.rampGradients = [];
  106950. for (var _a = 0, rampGradients_1 = rampGradients; _a < rampGradients_1.length; _a++) {
  106951. var rampGradient = rampGradients_1[_a];
  106952. var serializedGradient = {
  106953. gradient: rampGradient.gradient,
  106954. color: rampGradient.color.asArray()
  106955. };
  106956. serializationObject.rampGradients.push(serializedGradient);
  106957. }
  106958. serializationObject.useRampGradients = particleSystem.useRampGradients;
  106959. }
  106960. var colorRemapGradients = particleSystem.getColorRemapGradients();
  106961. if (colorRemapGradients) {
  106962. serializationObject.colorRemapGradients = [];
  106963. for (var _b = 0, colorRemapGradients_1 = colorRemapGradients; _b < colorRemapGradients_1.length; _b++) {
  106964. var colorRemapGradient = colorRemapGradients_1[_b];
  106965. var serializedGradient = {
  106966. gradient: colorRemapGradient.gradient,
  106967. factor1: colorRemapGradient.factor1
  106968. };
  106969. if (colorRemapGradient.factor2 !== undefined) {
  106970. serializedGradient.factor2 = colorRemapGradient.factor2;
  106971. }
  106972. serializationObject.colorRemapGradients.push(serializedGradient);
  106973. }
  106974. }
  106975. var alphaRemapGradients = particleSystem.getAlphaRemapGradients();
  106976. if (alphaRemapGradients) {
  106977. serializationObject.alphaRemapGradients = [];
  106978. for (var _c = 0, alphaRemapGradients_1 = alphaRemapGradients; _c < alphaRemapGradients_1.length; _c++) {
  106979. var alphaRemapGradient = alphaRemapGradients_1[_c];
  106980. var serializedGradient = {
  106981. gradient: alphaRemapGradient.gradient,
  106982. factor1: alphaRemapGradient.factor1
  106983. };
  106984. if (alphaRemapGradient.factor2 !== undefined) {
  106985. serializedGradient.factor2 = alphaRemapGradient.factor2;
  106986. }
  106987. serializationObject.alphaRemapGradients.push(serializedGradient);
  106988. }
  106989. }
  106990. var sizeGradients = particleSystem.getSizeGradients();
  106991. if (sizeGradients) {
  106992. serializationObject.sizeGradients = [];
  106993. for (var _d = 0, sizeGradients_1 = sizeGradients; _d < sizeGradients_1.length; _d++) {
  106994. var sizeGradient = sizeGradients_1[_d];
  106995. var serializedGradient = {
  106996. gradient: sizeGradient.gradient,
  106997. factor1: sizeGradient.factor1
  106998. };
  106999. if (sizeGradient.factor2 !== undefined) {
  107000. serializedGradient.factor2 = sizeGradient.factor2;
  107001. }
  107002. serializationObject.sizeGradients.push(serializedGradient);
  107003. }
  107004. }
  107005. var angularSpeedGradients = particleSystem.getAngularSpeedGradients();
  107006. if (angularSpeedGradients) {
  107007. serializationObject.angularSpeedGradients = [];
  107008. for (var _e = 0, angularSpeedGradients_1 = angularSpeedGradients; _e < angularSpeedGradients_1.length; _e++) {
  107009. var angularSpeedGradient = angularSpeedGradients_1[_e];
  107010. var serializedGradient = {
  107011. gradient: angularSpeedGradient.gradient,
  107012. factor1: angularSpeedGradient.factor1
  107013. };
  107014. if (angularSpeedGradient.factor2 !== undefined) {
  107015. serializedGradient.factor2 = angularSpeedGradient.factor2;
  107016. }
  107017. serializationObject.angularSpeedGradients.push(serializedGradient);
  107018. }
  107019. }
  107020. var velocityGradients = particleSystem.getVelocityGradients();
  107021. if (velocityGradients) {
  107022. serializationObject.velocityGradients = [];
  107023. for (var _f = 0, velocityGradients_1 = velocityGradients; _f < velocityGradients_1.length; _f++) {
  107024. var velocityGradient = velocityGradients_1[_f];
  107025. var serializedGradient = {
  107026. gradient: velocityGradient.gradient,
  107027. factor1: velocityGradient.factor1
  107028. };
  107029. if (velocityGradient.factor2 !== undefined) {
  107030. serializedGradient.factor2 = velocityGradient.factor2;
  107031. }
  107032. serializationObject.velocityGradients.push(serializedGradient);
  107033. }
  107034. }
  107035. var dragGradients = particleSystem.getDragGradients();
  107036. if (dragGradients) {
  107037. serializationObject.dragyGradients = [];
  107038. for (var _g = 0, dragGradients_1 = dragGradients; _g < dragGradients_1.length; _g++) {
  107039. var dragGradient = dragGradients_1[_g];
  107040. var serializedGradient = {
  107041. gradient: dragGradient.gradient,
  107042. factor1: dragGradient.factor1
  107043. };
  107044. if (dragGradient.factor2 !== undefined) {
  107045. serializedGradient.factor2 = dragGradient.factor2;
  107046. }
  107047. serializationObject.dragGradients.push(serializedGradient);
  107048. }
  107049. }
  107050. var emitRateGradients = particleSystem.getEmitRateGradients();
  107051. if (emitRateGradients) {
  107052. serializationObject.emitRateGradients = [];
  107053. for (var _h = 0, emitRateGradients_1 = emitRateGradients; _h < emitRateGradients_1.length; _h++) {
  107054. var emitRateGradient = emitRateGradients_1[_h];
  107055. var serializedGradient = {
  107056. gradient: emitRateGradient.gradient,
  107057. factor1: emitRateGradient.factor1
  107058. };
  107059. if (emitRateGradient.factor2 !== undefined) {
  107060. serializedGradient.factor2 = emitRateGradient.factor2;
  107061. }
  107062. serializationObject.emitRateGradients.push(serializedGradient);
  107063. }
  107064. }
  107065. var startSizeGradients = particleSystem.getStartSizeGradients();
  107066. if (startSizeGradients) {
  107067. serializationObject.startSizeGradients = [];
  107068. for (var _j = 0, startSizeGradients_1 = startSizeGradients; _j < startSizeGradients_1.length; _j++) {
  107069. var startSizeGradient = startSizeGradients_1[_j];
  107070. var serializedGradient = {
  107071. gradient: startSizeGradient.gradient,
  107072. factor1: startSizeGradient.factor1
  107073. };
  107074. if (startSizeGradient.factor2 !== undefined) {
  107075. serializedGradient.factor2 = startSizeGradient.factor2;
  107076. }
  107077. serializationObject.startSizeGradients.push(serializedGradient);
  107078. }
  107079. }
  107080. var lifeTimeGradients = particleSystem.getLifeTimeGradients();
  107081. if (lifeTimeGradients) {
  107082. serializationObject.lifeTimeGradients = [];
  107083. for (var _k = 0, lifeTimeGradients_1 = lifeTimeGradients; _k < lifeTimeGradients_1.length; _k++) {
  107084. var lifeTimeGradient = lifeTimeGradients_1[_k];
  107085. var serializedGradient = {
  107086. gradient: lifeTimeGradient.gradient,
  107087. factor1: lifeTimeGradient.factor1
  107088. };
  107089. if (lifeTimeGradient.factor2 !== undefined) {
  107090. serializedGradient.factor2 = lifeTimeGradient.factor2;
  107091. }
  107092. serializationObject.lifeTimeGradients.push(serializedGradient);
  107093. }
  107094. }
  107095. var limitVelocityGradients = particleSystem.getLimitVelocityGradients();
  107096. if (limitVelocityGradients) {
  107097. serializationObject.limitVelocityGradients = [];
  107098. for (var _l = 0, limitVelocityGradients_1 = limitVelocityGradients; _l < limitVelocityGradients_1.length; _l++) {
  107099. var limitVelocityGradient = limitVelocityGradients_1[_l];
  107100. var serializedGradient = {
  107101. gradient: limitVelocityGradient.gradient,
  107102. factor1: limitVelocityGradient.factor1
  107103. };
  107104. if (limitVelocityGradient.factor2 !== undefined) {
  107105. serializedGradient.factor2 = limitVelocityGradient.factor2;
  107106. }
  107107. serializationObject.limitVelocityGradients.push(serializedGradient);
  107108. }
  107109. serializationObject.limitVelocityDamping = particleSystem.limitVelocityDamping;
  107110. }
  107111. if (particleSystem.noiseTexture) {
  107112. serializationObject.noiseTexture = particleSystem.noiseTexture.serialize();
  107113. }
  107114. };
  107115. /** @hidden */
  107116. ParticleSystem._Parse = function (parsedParticleSystem, particleSystem, scene, rootUrl) {
  107117. // Texture
  107118. if (parsedParticleSystem.textureName) {
  107119. particleSystem.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](rootUrl + parsedParticleSystem.textureName, scene, false, parsedParticleSystem.invertY !== undefined ? parsedParticleSystem.invertY : true);
  107120. particleSystem.particleTexture.name = parsedParticleSystem.textureName;
  107121. }
  107122. // Emitter
  107123. if (!parsedParticleSystem.emitterId && parsedParticleSystem.emitterId !== 0 && parsedParticleSystem.emitter === undefined) {
  107124. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  107125. }
  107126. else if (parsedParticleSystem.emitterId) {
  107127. particleSystem.emitter = scene.getLastMeshByID(parsedParticleSystem.emitterId);
  107128. }
  107129. else {
  107130. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.emitter);
  107131. }
  107132. // Misc.
  107133. if (parsedParticleSystem.renderingGroupId !== undefined) {
  107134. particleSystem.renderingGroupId = parsedParticleSystem.renderingGroupId;
  107135. }
  107136. if (parsedParticleSystem.isBillboardBased !== undefined) {
  107137. particleSystem.isBillboardBased = parsedParticleSystem.isBillboardBased;
  107138. }
  107139. if (parsedParticleSystem.billboardMode !== undefined) {
  107140. particleSystem.billboardMode = parsedParticleSystem.billboardMode;
  107141. }
  107142. // Animations
  107143. if (parsedParticleSystem.animations) {
  107144. for (var animationIndex = 0; animationIndex < parsedParticleSystem.animations.length; animationIndex++) {
  107145. var parsedAnimation = parsedParticleSystem.animations[animationIndex];
  107146. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__["_TypeStore"].GetClass("BABYLON.Animation");
  107147. if (internalClass) {
  107148. particleSystem.animations.push(internalClass.Parse(parsedAnimation));
  107149. }
  107150. }
  107151. particleSystem.beginAnimationOnStart = parsedParticleSystem.beginAnimationOnStart;
  107152. particleSystem.beginAnimationFrom = parsedParticleSystem.beginAnimationFrom;
  107153. particleSystem.beginAnimationTo = parsedParticleSystem.beginAnimationTo;
  107154. particleSystem.beginAnimationLoop = parsedParticleSystem.beginAnimationLoop;
  107155. }
  107156. if (parsedParticleSystem.autoAnimate) {
  107157. scene.beginAnimation(particleSystem, parsedParticleSystem.autoAnimateFrom, parsedParticleSystem.autoAnimateTo, parsedParticleSystem.autoAnimateLoop, parsedParticleSystem.autoAnimateSpeed || 1.0);
  107158. }
  107159. // Particle system
  107160. particleSystem.startDelay = parsedParticleSystem.startDelay | 0;
  107161. particleSystem.minAngularSpeed = parsedParticleSystem.minAngularSpeed;
  107162. particleSystem.maxAngularSpeed = parsedParticleSystem.maxAngularSpeed;
  107163. particleSystem.minSize = parsedParticleSystem.minSize;
  107164. particleSystem.maxSize = parsedParticleSystem.maxSize;
  107165. if (parsedParticleSystem.minScaleX) {
  107166. particleSystem.minScaleX = parsedParticleSystem.minScaleX;
  107167. particleSystem.maxScaleX = parsedParticleSystem.maxScaleX;
  107168. particleSystem.minScaleY = parsedParticleSystem.minScaleY;
  107169. particleSystem.maxScaleY = parsedParticleSystem.maxScaleY;
  107170. }
  107171. if (parsedParticleSystem.preWarmCycles !== undefined) {
  107172. particleSystem.preWarmCycles = parsedParticleSystem.preWarmCycles;
  107173. particleSystem.preWarmStepOffset = parsedParticleSystem.preWarmStepOffset;
  107174. }
  107175. if (parsedParticleSystem.minInitialRotation !== undefined) {
  107176. particleSystem.minInitialRotation = parsedParticleSystem.minInitialRotation;
  107177. particleSystem.maxInitialRotation = parsedParticleSystem.maxInitialRotation;
  107178. }
  107179. particleSystem.minLifeTime = parsedParticleSystem.minLifeTime;
  107180. particleSystem.maxLifeTime = parsedParticleSystem.maxLifeTime;
  107181. particleSystem.minEmitPower = parsedParticleSystem.minEmitPower;
  107182. particleSystem.maxEmitPower = parsedParticleSystem.maxEmitPower;
  107183. particleSystem.emitRate = parsedParticleSystem.emitRate;
  107184. particleSystem.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.gravity);
  107185. if (parsedParticleSystem.noiseStrength) {
  107186. particleSystem.noiseStrength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.noiseStrength);
  107187. }
  107188. particleSystem.color1 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color1);
  107189. particleSystem.color2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color2);
  107190. particleSystem.colorDead = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.colorDead);
  107191. particleSystem.updateSpeed = parsedParticleSystem.updateSpeed;
  107192. particleSystem.targetStopDuration = parsedParticleSystem.targetStopDuration;
  107193. particleSystem.blendMode = parsedParticleSystem.blendMode;
  107194. if (parsedParticleSystem.colorGradients) {
  107195. for (var _i = 0, _a = parsedParticleSystem.colorGradients; _i < _a.length; _i++) {
  107196. var colorGradient = _a[_i];
  107197. 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);
  107198. }
  107199. }
  107200. if (parsedParticleSystem.rampGradients) {
  107201. for (var _b = 0, _c = parsedParticleSystem.rampGradients; _b < _c.length; _b++) {
  107202. var rampGradient = _c[_b];
  107203. particleSystem.addRampGradient(rampGradient.gradient, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].FromArray(rampGradient.color));
  107204. }
  107205. particleSystem.useRampGradients = parsedParticleSystem.useRampGradients;
  107206. }
  107207. if (parsedParticleSystem.colorRemapGradients) {
  107208. for (var _d = 0, _e = parsedParticleSystem.colorRemapGradients; _d < _e.length; _d++) {
  107209. var colorRemapGradient = _e[_d];
  107210. particleSystem.addColorRemapGradient(colorRemapGradient.gradient, colorRemapGradient.factor1 !== undefined ? colorRemapGradient.factor1 : colorRemapGradient.factor, colorRemapGradient.factor2);
  107211. }
  107212. }
  107213. if (parsedParticleSystem.alphaRemapGradients) {
  107214. for (var _f = 0, _g = parsedParticleSystem.alphaRemapGradients; _f < _g.length; _f++) {
  107215. var alphaRemapGradient = _g[_f];
  107216. particleSystem.addAlphaRemapGradient(alphaRemapGradient.gradient, alphaRemapGradient.factor1 !== undefined ? alphaRemapGradient.factor1 : alphaRemapGradient.factor, alphaRemapGradient.factor2);
  107217. }
  107218. }
  107219. if (parsedParticleSystem.sizeGradients) {
  107220. for (var _h = 0, _j = parsedParticleSystem.sizeGradients; _h < _j.length; _h++) {
  107221. var sizeGradient = _j[_h];
  107222. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  107223. }
  107224. }
  107225. if (parsedParticleSystem.sizeGradients) {
  107226. for (var _k = 0, _l = parsedParticleSystem.sizeGradients; _k < _l.length; _k++) {
  107227. var sizeGradient = _l[_k];
  107228. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  107229. }
  107230. }
  107231. if (parsedParticleSystem.angularSpeedGradients) {
  107232. for (var _m = 0, _o = parsedParticleSystem.angularSpeedGradients; _m < _o.length; _m++) {
  107233. var angularSpeedGradient = _o[_m];
  107234. particleSystem.addAngularSpeedGradient(angularSpeedGradient.gradient, angularSpeedGradient.factor1 !== undefined ? angularSpeedGradient.factor1 : angularSpeedGradient.factor, angularSpeedGradient.factor2);
  107235. }
  107236. }
  107237. if (parsedParticleSystem.velocityGradients) {
  107238. for (var _p = 0, _q = parsedParticleSystem.velocityGradients; _p < _q.length; _p++) {
  107239. var velocityGradient = _q[_p];
  107240. particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ? velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
  107241. }
  107242. }
  107243. if (parsedParticleSystem.dragGradients) {
  107244. for (var _r = 0, _s = parsedParticleSystem.dragGradients; _r < _s.length; _r++) {
  107245. var dragGradient = _s[_r];
  107246. particleSystem.addDragGradient(dragGradient.gradient, dragGradient.factor1 !== undefined ? dragGradient.factor1 : dragGradient.factor, dragGradient.factor2);
  107247. }
  107248. }
  107249. if (parsedParticleSystem.emitRateGradients) {
  107250. for (var _t = 0, _u = parsedParticleSystem.emitRateGradients; _t < _u.length; _t++) {
  107251. var emitRateGradient = _u[_t];
  107252. particleSystem.addEmitRateGradient(emitRateGradient.gradient, emitRateGradient.factor1 !== undefined ? emitRateGradient.factor1 : emitRateGradient.factor, emitRateGradient.factor2);
  107253. }
  107254. }
  107255. if (parsedParticleSystem.startSizeGradients) {
  107256. for (var _v = 0, _w = parsedParticleSystem.startSizeGradients; _v < _w.length; _v++) {
  107257. var startSizeGradient = _w[_v];
  107258. particleSystem.addStartSizeGradient(startSizeGradient.gradient, startSizeGradient.factor1 !== undefined ? startSizeGradient.factor1 : startSizeGradient.factor, startSizeGradient.factor2);
  107259. }
  107260. }
  107261. if (parsedParticleSystem.lifeTimeGradients) {
  107262. for (var _x = 0, _y = parsedParticleSystem.lifeTimeGradients; _x < _y.length; _x++) {
  107263. var lifeTimeGradient = _y[_x];
  107264. particleSystem.addLifeTimeGradient(lifeTimeGradient.gradient, lifeTimeGradient.factor1 !== undefined ? lifeTimeGradient.factor1 : lifeTimeGradient.factor, lifeTimeGradient.factor2);
  107265. }
  107266. }
  107267. if (parsedParticleSystem.limitVelocityGradients) {
  107268. for (var _z = 0, _0 = parsedParticleSystem.limitVelocityGradients; _z < _0.length; _z++) {
  107269. var limitVelocityGradient = _0[_z];
  107270. particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ? limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
  107271. }
  107272. particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
  107273. }
  107274. if (parsedParticleSystem.noiseTexture) {
  107275. particleSystem.noiseTexture = _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__["ProceduralTexture"].Parse(parsedParticleSystem.noiseTexture, scene, rootUrl);
  107276. }
  107277. // Emitter
  107278. var emitterType;
  107279. if (parsedParticleSystem.particleEmitterType) {
  107280. switch (parsedParticleSystem.particleEmitterType.type) {
  107281. case "SphereParticleEmitter":
  107282. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereParticleEmitter"]();
  107283. break;
  107284. case "SphereDirectedParticleEmitter":
  107285. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereDirectedParticleEmitter"]();
  107286. break;
  107287. case "ConeEmitter":
  107288. case "ConeParticleEmitter":
  107289. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["ConeParticleEmitter"]();
  107290. break;
  107291. case "CylinderParticleEmitter":
  107292. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["CylinderParticleEmitter"]();
  107293. break;
  107294. case "HemisphericParticleEmitter":
  107295. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["HemisphericParticleEmitter"]();
  107296. break;
  107297. case "BoxEmitter":
  107298. case "BoxParticleEmitter":
  107299. default:
  107300. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  107301. break;
  107302. }
  107303. emitterType.parse(parsedParticleSystem.particleEmitterType);
  107304. }
  107305. else {
  107306. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  107307. emitterType.parse(parsedParticleSystem);
  107308. }
  107309. particleSystem.particleEmitterType = emitterType;
  107310. // Animation sheet
  107311. particleSystem.startSpriteCellID = parsedParticleSystem.startSpriteCellID;
  107312. particleSystem.endSpriteCellID = parsedParticleSystem.endSpriteCellID;
  107313. particleSystem.spriteCellWidth = parsedParticleSystem.spriteCellWidth;
  107314. particleSystem.spriteCellHeight = parsedParticleSystem.spriteCellHeight;
  107315. particleSystem.spriteCellChangeSpeed = parsedParticleSystem.spriteCellChangeSpeed;
  107316. particleSystem.spriteRandomStartCell = parsedParticleSystem.spriteRandomStartCell;
  107317. };
  107318. /**
  107319. * Parses a JSON object to create a particle system.
  107320. * @param parsedParticleSystem The JSON object to parse
  107321. * @param scene The scene to create the particle system in
  107322. * @param rootUrl The root url to use to load external dependencies like texture
  107323. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  107324. * @returns the Parsed particle system
  107325. */
  107326. ParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  107327. if (doNotStart === void 0) { doNotStart = false; }
  107328. var name = parsedParticleSystem.name;
  107329. var custom = null;
  107330. var program = null;
  107331. if (parsedParticleSystem.customShader) {
  107332. program = parsedParticleSystem.customShader;
  107333. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  107334. custom = scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  107335. }
  107336. var particleSystem = new ParticleSystem(name, parsedParticleSystem.capacity, scene, custom, parsedParticleSystem.isAnimationSheetEnabled);
  107337. particleSystem.customShader = program;
  107338. if (parsedParticleSystem.id) {
  107339. particleSystem.id = parsedParticleSystem.id;
  107340. }
  107341. // SubEmitters
  107342. if (parsedParticleSystem.subEmitters) {
  107343. particleSystem.subEmitters = [];
  107344. for (var _i = 0, _a = parsedParticleSystem.subEmitters; _i < _a.length; _i++) {
  107345. var cell = _a[_i];
  107346. var cellArray = [];
  107347. for (var _b = 0, cell_1 = cell; _b < cell_1.length; _b++) {
  107348. var sub = cell_1[_b];
  107349. cellArray.push(_subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"].Parse(sub, scene, rootUrl));
  107350. }
  107351. particleSystem.subEmitters.push(cellArray);
  107352. }
  107353. }
  107354. ParticleSystem._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  107355. particleSystem.textureMask = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.textureMask);
  107356. // Auto start
  107357. if (parsedParticleSystem.preventAutoStart) {
  107358. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  107359. }
  107360. if (!doNotStart && !particleSystem.preventAutoStart) {
  107361. particleSystem.start();
  107362. }
  107363. return particleSystem;
  107364. };
  107365. /**
  107366. * Billboard mode will only apply to Y axis
  107367. */
  107368. ParticleSystem.BILLBOARDMODE_Y = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_Y;
  107369. /**
  107370. * Billboard mode will apply to all axes
  107371. */
  107372. ParticleSystem.BILLBOARDMODE_ALL = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  107373. /**
  107374. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  107375. */
  107376. ParticleSystem.BILLBOARDMODE_STRETCHED = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_STRETCHED;
  107377. return ParticleSystem;
  107378. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__["BaseParticleSystem"]));
  107379. _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]._ParseParticleSystem = ParticleSystem.Parse;
  107380. /***/ }),
  107381. /***/ "./Particles/particleSystemComponent.ts":
  107382. /*!**********************************************!*\
  107383. !*** ./Particles/particleSystemComponent.ts ***!
  107384. \**********************************************/
  107385. /*! exports provided: _IDoNeedToBeInTheBuild */
  107386. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107387. "use strict";
  107388. __webpack_require__.r(__webpack_exports__);
  107389. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _IDoNeedToBeInTheBuild; });
  107390. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  107391. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  107392. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  107393. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  107394. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  107395. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  107396. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  107397. // Adds the parsers to the scene parsers.
  107398. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedData, scene, container, rootUrl) {
  107399. var individualParser = _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  107400. if (!individualParser) {
  107401. return;
  107402. }
  107403. // Particles Systems
  107404. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  107405. for (var index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  107406. var parsedParticleSystem = parsedData.particleSystems[index];
  107407. container.particleSystems.push(individualParser(parsedParticleSystem, scene, rootUrl));
  107408. }
  107409. }
  107410. });
  107411. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedParticleSystem, scene, rootUrl) {
  107412. if (parsedParticleSystem.activeParticleCount) {
  107413. var ps = _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__["GPUParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  107414. return ps;
  107415. }
  107416. else {
  107417. var ps = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  107418. return ps;
  107419. }
  107420. });
  107421. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createEffectForParticles = function (fragmentName, uniformsNames, samplers, defines, fallbacks, onCompiled, onError) {
  107422. if (uniformsNames === void 0) { uniformsNames = []; }
  107423. if (samplers === void 0) { samplers = []; }
  107424. if (defines === void 0) { defines = ""; }
  107425. var attributesNamesOrOptions = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetAttributeNamesOrOptions();
  107426. var effectCreationOption = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetEffectCreationOptions();
  107427. if (defines.indexOf(" BILLBOARD") === -1) {
  107428. defines += "\n#define BILLBOARD\n";
  107429. }
  107430. if (samplers.indexOf("diffuseSampler") === -1) {
  107431. samplers.push("diffuseSampler");
  107432. }
  107433. return this.createEffect({
  107434. vertex: "particles",
  107435. fragmentElement: fragmentName
  107436. }, attributesNamesOrOptions, effectCreationOption.concat(uniformsNames), samplers, defines, fallbacks, onCompiled, onError);
  107437. };
  107438. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getEmittedParticleSystems = function () {
  107439. var results = new Array();
  107440. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  107441. var particleSystem = this.getScene().particleSystems[index];
  107442. if (particleSystem.emitter === this) {
  107443. results.push(particleSystem);
  107444. }
  107445. }
  107446. return results;
  107447. };
  107448. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getHierarchyEmittedParticleSystems = function () {
  107449. var results = new Array();
  107450. var descendants = this.getDescendants();
  107451. descendants.push(this);
  107452. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  107453. var particleSystem = this.getScene().particleSystems[index];
  107454. var emitter = particleSystem.emitter;
  107455. if (emitter.position && descendants.indexOf(emitter) !== -1) {
  107456. results.push(particleSystem);
  107457. }
  107458. }
  107459. return results;
  107460. };
  107461. /**
  107462. * @hidden
  107463. */
  107464. var _IDoNeedToBeInTheBuild = 42;
  107465. /***/ }),
  107466. /***/ "./Particles/particleSystemSet.ts":
  107467. /*!****************************************!*\
  107468. !*** ./Particles/particleSystemSet.ts ***!
  107469. \****************************************/
  107470. /*! exports provided: ParticleSystemSet */
  107471. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107472. "use strict";
  107473. __webpack_require__.r(__webpack_exports__);
  107474. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return ParticleSystemSet; });
  107475. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  107476. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  107477. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  107478. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  107479. /* harmony import */ var _Particles_particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Particles/particleSystem */ "./Particles/particleSystem.ts");
  107480. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  107481. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  107482. /** Internal class used to store shapes for emitters */
  107483. var ParticleSystemSetEmitterCreationOptions = /** @class */ (function () {
  107484. function ParticleSystemSetEmitterCreationOptions() {
  107485. }
  107486. return ParticleSystemSetEmitterCreationOptions;
  107487. }());
  107488. /**
  107489. * Represents a set of particle systems working together to create a specific effect
  107490. */
  107491. var ParticleSystemSet = /** @class */ (function () {
  107492. function ParticleSystemSet() {
  107493. /**
  107494. * Gets the particle system list
  107495. */
  107496. this.systems = new Array();
  107497. }
  107498. Object.defineProperty(ParticleSystemSet.prototype, "emitterNode", {
  107499. /**
  107500. * Gets the emitter node used with this set
  107501. */
  107502. get: function () {
  107503. return this._emitterNode;
  107504. },
  107505. enumerable: true,
  107506. configurable: true
  107507. });
  107508. /**
  107509. * Creates a new emitter mesh as a sphere
  107510. * @param options defines the options used to create the sphere
  107511. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  107512. * @param scene defines the hosting scene
  107513. */
  107514. ParticleSystemSet.prototype.setEmitterAsSphere = function (options, renderingGroupId, scene) {
  107515. if (this._emitterNode) {
  107516. this._emitterNode.dispose();
  107517. }
  107518. this._emitterCreationOptions = {
  107519. kind: "Sphere",
  107520. options: options,
  107521. renderingGroupId: renderingGroupId
  107522. };
  107523. var emitterMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere("emitterSphere", { diameter: options.diameter, segments: options.segments }, scene);
  107524. emitterMesh.renderingGroupId = renderingGroupId;
  107525. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("emitterSphereMaterial", scene);
  107526. material.emissiveColor = options.color;
  107527. emitterMesh.material = material;
  107528. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  107529. var system = _a[_i];
  107530. system.emitter = emitterMesh;
  107531. }
  107532. this._emitterNode = emitterMesh;
  107533. };
  107534. /**
  107535. * Starts all particle systems of the set
  107536. * @param emitter defines an optional mesh to use as emitter for the particle systems
  107537. */
  107538. ParticleSystemSet.prototype.start = function (emitter) {
  107539. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  107540. var system = _a[_i];
  107541. if (emitter) {
  107542. system.emitter = emitter;
  107543. }
  107544. system.start();
  107545. }
  107546. };
  107547. /**
  107548. * Release all associated resources
  107549. */
  107550. ParticleSystemSet.prototype.dispose = function () {
  107551. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  107552. var system = _a[_i];
  107553. system.dispose();
  107554. }
  107555. this.systems = [];
  107556. if (this._emitterNode) {
  107557. this._emitterNode.dispose();
  107558. this._emitterNode = null;
  107559. }
  107560. };
  107561. /**
  107562. * Serialize the set into a JSON compatible object
  107563. * @returns a JSON compatible representation of the set
  107564. */
  107565. ParticleSystemSet.prototype.serialize = function () {
  107566. var result = {};
  107567. result.systems = [];
  107568. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  107569. var system = _a[_i];
  107570. result.systems.push(system.serialize());
  107571. }
  107572. if (this._emitterNode) {
  107573. result.emitter = this._emitterCreationOptions;
  107574. }
  107575. return result;
  107576. };
  107577. /**
  107578. * Parse a new ParticleSystemSet from a serialized source
  107579. * @param data defines a JSON compatible representation of the set
  107580. * @param scene defines the hosting scene
  107581. * @param gpu defines if we want GPU particles or CPU particles
  107582. * @returns a new ParticleSystemSet
  107583. */
  107584. ParticleSystemSet.Parse = function (data, scene, gpu) {
  107585. if (gpu === void 0) { gpu = false; }
  107586. var result = new ParticleSystemSet();
  107587. var rootUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].PARTICLES_BaseAssetsUrl + "/textures/";
  107588. scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  107589. for (var _i = 0, _a = data.systems; _i < _a.length; _i++) {
  107590. var system = _a[_i];
  107591. 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));
  107592. }
  107593. if (data.emitter) {
  107594. var options = data.emitter.options;
  107595. switch (data.emitter.kind) {
  107596. case "Sphere":
  107597. result.setEmitterAsSphere({
  107598. diameter: options.diameter,
  107599. segments: options.segments,
  107600. color: _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(options.color)
  107601. }, data.emitter.renderingGroupId, scene);
  107602. break;
  107603. }
  107604. }
  107605. return result;
  107606. };
  107607. return ParticleSystemSet;
  107608. }());
  107609. /***/ }),
  107610. /***/ "./Particles/solidParticle.ts":
  107611. /*!************************************!*\
  107612. !*** ./Particles/solidParticle.ts ***!
  107613. \************************************/
  107614. /*! exports provided: SolidParticle, ModelShape, DepthSortedParticle */
  107615. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107616. "use strict";
  107617. __webpack_require__.r(__webpack_exports__);
  107618. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return SolidParticle; });
  107619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return ModelShape; });
  107620. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return DepthSortedParticle; });
  107621. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  107622. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  107623. /* harmony import */ var _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/boundingSphere */ "./Culling/boundingSphere.ts");
  107624. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  107625. /**
  107626. * Represents one particle of a solid particle system.
  107627. */
  107628. var SolidParticle = /** @class */ (function () {
  107629. /**
  107630. * Creates a Solid Particle object.
  107631. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  107632. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  107633. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  107634. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  107635. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  107636. * @param shapeId (integer) is the model shape identifier in the SPS.
  107637. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  107638. * @param sps defines the sps it is associated to
  107639. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  107640. */
  107641. function SolidParticle(particleIndex, positionIndex, indiceIndex, model, shapeId, idxInShape, sps, modelBoundingInfo) {
  107642. if (modelBoundingInfo === void 0) { modelBoundingInfo = null; }
  107643. /**
  107644. * particle global index
  107645. */
  107646. this.idx = 0;
  107647. /**
  107648. * The color of the particle
  107649. */
  107650. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  107651. /**
  107652. * The world space position of the particle.
  107653. */
  107654. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107655. /**
  107656. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  107657. */
  107658. this.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107659. /**
  107660. * The scaling of the particle.
  107661. */
  107662. this.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  107663. /**
  107664. * The uvs of the particle.
  107665. */
  107666. this.uvs = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  107667. /**
  107668. * The current speed of the particle.
  107669. */
  107670. this.velocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107671. /**
  107672. * The pivot point in the particle local space.
  107673. */
  107674. this.pivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107675. /**
  107676. * Must the particle be translated from its pivot point in its local space ?
  107677. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  107678. * Default : false
  107679. */
  107680. this.translateFromPivot = false;
  107681. /**
  107682. * Is the particle active or not ?
  107683. */
  107684. this.alive = true;
  107685. /**
  107686. * Is the particle visible or not ?
  107687. */
  107688. this.isVisible = true;
  107689. /**
  107690. * Index of this particle in the global "positions" array (Internal use)
  107691. * @hidden
  107692. */
  107693. this._pos = 0;
  107694. /**
  107695. * @hidden Index of this particle in the global "indices" array (Internal use)
  107696. */
  107697. this._ind = 0;
  107698. /**
  107699. * ModelShape id of this particle
  107700. */
  107701. this.shapeId = 0;
  107702. /**
  107703. * Index of the particle in its shape id (Internal use)
  107704. */
  107705. this.idxInShape = 0;
  107706. /**
  107707. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  107708. */
  107709. this._stillInvisible = false;
  107710. /**
  107711. * @hidden Last computed particle rotation matrix
  107712. */
  107713. this._rotationMatrix = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0];
  107714. /**
  107715. * Parent particle Id, if any.
  107716. * Default null.
  107717. */
  107718. this.parentId = null;
  107719. /**
  107720. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  107721. * The possible values are :
  107722. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  107723. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  107724. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  107725. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  107726. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  107727. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  107728. * */
  107729. this.cullingStrategy = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"].CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  107730. /**
  107731. * @hidden Internal global position in the SPS.
  107732. */
  107733. this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107734. this.idx = particleIndex;
  107735. this._pos = positionIndex;
  107736. this._ind = indiceIndex;
  107737. this._model = model;
  107738. this.shapeId = shapeId;
  107739. this.idxInShape = idxInShape;
  107740. this._sps = sps;
  107741. if (modelBoundingInfo) {
  107742. this._modelBoundingInfo = modelBoundingInfo;
  107743. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"](modelBoundingInfo.minimum, modelBoundingInfo.maximum);
  107744. }
  107745. }
  107746. Object.defineProperty(SolidParticle.prototype, "scale", {
  107747. /**
  107748. * Legacy support, changed scale to scaling
  107749. */
  107750. get: function () {
  107751. return this.scaling;
  107752. },
  107753. /**
  107754. * Legacy support, changed scale to scaling
  107755. */
  107756. set: function (scale) {
  107757. this.scaling = scale;
  107758. },
  107759. enumerable: true,
  107760. configurable: true
  107761. });
  107762. Object.defineProperty(SolidParticle.prototype, "quaternion", {
  107763. /**
  107764. * Legacy support, changed quaternion to rotationQuaternion
  107765. */
  107766. get: function () {
  107767. return this.rotationQuaternion;
  107768. },
  107769. /**
  107770. * Legacy support, changed quaternion to rotationQuaternion
  107771. */
  107772. set: function (q) {
  107773. this.rotationQuaternion = q;
  107774. },
  107775. enumerable: true,
  107776. configurable: true
  107777. });
  107778. /**
  107779. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  107780. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  107781. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  107782. * @returns true if it intersects
  107783. */
  107784. SolidParticle.prototype.intersectsMesh = function (target) {
  107785. if (!this._boundingInfo || !target._boundingInfo) {
  107786. return false;
  107787. }
  107788. if (this._sps._bSphereOnly) {
  107789. return _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"].Intersects(this._boundingInfo.boundingSphere, target._boundingInfo.boundingSphere);
  107790. }
  107791. return this._boundingInfo.intersects(target._boundingInfo, false);
  107792. };
  107793. /**
  107794. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  107795. * A particle is in the frustum if its bounding box intersects the frustum
  107796. * @param frustumPlanes defines the frustum to test
  107797. * @returns true if the particle is in the frustum planes
  107798. */
  107799. SolidParticle.prototype.isInFrustum = function (frustumPlanes) {
  107800. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  107801. };
  107802. /**
  107803. * get the rotation matrix of the particle
  107804. * @hidden
  107805. */
  107806. SolidParticle.prototype.getRotationMatrix = function (m) {
  107807. var quaternion;
  107808. if (this.rotationQuaternion) {
  107809. quaternion = this.rotationQuaternion;
  107810. }
  107811. else {
  107812. quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  107813. var rotation = this.rotation;
  107814. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  107815. }
  107816. quaternion.toRotationMatrix(m);
  107817. };
  107818. return SolidParticle;
  107819. }());
  107820. /**
  107821. * Represents the shape of the model used by one particle of a solid particle system.
  107822. * SPS internal tool, don't use it manually.
  107823. */
  107824. var ModelShape = /** @class */ (function () {
  107825. /**
  107826. * 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.
  107827. * SPS internal tool, don't use it manually.
  107828. * @hidden
  107829. */
  107830. function ModelShape(id, shape, indicesLength, shapeUV, posFunction, vtxFunction) {
  107831. /**
  107832. * length of the shape in the model indices array (internal use)
  107833. * @hidden
  107834. */
  107835. this._indicesLength = 0;
  107836. this.shapeID = id;
  107837. this._shape = shape;
  107838. this._indicesLength = indicesLength;
  107839. this._shapeUV = shapeUV;
  107840. this._positionFunction = posFunction;
  107841. this._vertexFunction = vtxFunction;
  107842. }
  107843. return ModelShape;
  107844. }());
  107845. /**
  107846. * Represents a Depth Sorted Particle in the solid particle system.
  107847. */
  107848. var DepthSortedParticle = /** @class */ (function () {
  107849. function DepthSortedParticle() {
  107850. /**
  107851. * Index of the particle in the "indices" array
  107852. */
  107853. this.ind = 0;
  107854. /**
  107855. * Length of the particle shape in the "indices" array
  107856. */
  107857. this.indicesLength = 0;
  107858. /**
  107859. * Squared distance from the particle to the camera
  107860. */
  107861. this.sqDistance = 0.0;
  107862. }
  107863. return DepthSortedParticle;
  107864. }());
  107865. /***/ }),
  107866. /***/ "./Particles/solidParticleSystem.ts":
  107867. /*!******************************************!*\
  107868. !*** ./Particles/solidParticleSystem.ts ***!
  107869. \******************************************/
  107870. /*! exports provided: SolidParticleSystem */
  107871. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107872. "use strict";
  107873. __webpack_require__.r(__webpack_exports__);
  107874. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return SolidParticleSystem; });
  107875. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  107876. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  107877. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  107878. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  107879. /* harmony import */ var _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  107880. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  107881. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  107882. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  107883. var depthSortFunction = function (p1, p2) { return p2.sqDistance - p1.sqDistance; };
  107884. /**
  107885. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  107886. *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.
  107887. * The SPS is also a particle system. It provides some methods to manage the particles.
  107888. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  107889. *
  107890. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  107891. */
  107892. var SolidParticleSystem = /** @class */ (function () {
  107893. /**
  107894. * Creates a SPS (Solid Particle System) object.
  107895. * @param name (String) is the SPS name, this will be the underlying mesh name.
  107896. * @param scene (Scene) is the scene in which the SPS is added.
  107897. * @param options defines the options of the sps e.g.
  107898. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  107899. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  107900. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  107901. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  107902. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  107903. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  107904. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  107905. */
  107906. function SolidParticleSystem(name, scene, options) {
  107907. /**
  107908. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  107909. * Example : var p = SPS.particles[i];
  107910. */
  107911. this.particles = new Array();
  107912. /**
  107913. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  107914. */
  107915. this.nbParticles = 0;
  107916. /**
  107917. * If the particles must ever face the camera (default false). Useful for planar particles.
  107918. */
  107919. this.billboard = false;
  107920. /**
  107921. * Recompute normals when adding a shape
  107922. */
  107923. this.recomputeNormals = true;
  107924. /**
  107925. * This a counter ofr your own usage. It's not set by any SPS functions.
  107926. */
  107927. this.counter = 0;
  107928. /**
  107929. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  107930. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  107931. */
  107932. this.vars = {};
  107933. /**
  107934. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  107935. * @hidden
  107936. */
  107937. this._bSphereOnly = false;
  107938. /**
  107939. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  107940. * @hidden
  107941. */
  107942. this._bSphereRadiusFactor = 1.0;
  107943. this._positions = new Array();
  107944. this._indices = new Array();
  107945. this._normals = new Array();
  107946. this._colors = new Array();
  107947. this._uvs = new Array();
  107948. this._index = 0; // indices index
  107949. this._updatable = true;
  107950. this._pickable = false;
  107951. this._isVisibilityBoxLocked = false;
  107952. this._alwaysVisible = false;
  107953. this._depthSort = false;
  107954. this._shapeCounter = 0;
  107955. this._copy = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](0, 0, 0, null, 0, 0, this);
  107956. this._color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  107957. this._computeParticleColor = true;
  107958. this._computeParticleTexture = true;
  107959. this._computeParticleRotation = true;
  107960. this._computeParticleVertex = false;
  107961. this._computeBoundingBox = false;
  107962. this._depthSortParticles = true;
  107963. this._mustUnrotateFixedNormals = false;
  107964. this._particlesIntersect = false;
  107965. this._needs32Bits = false;
  107966. this.name = name;
  107967. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  107968. this._camera = scene.activeCamera;
  107969. this._pickable = options ? options.isPickable : false;
  107970. this._depthSort = options ? options.enableDepthSort : false;
  107971. this._particlesIntersect = options ? options.particleIntersection : false;
  107972. this._bSphereOnly = options ? options.boundingSphereOnly : false;
  107973. this._bSphereRadiusFactor = (options && options.bSphereRadiusFactor) ? options.bSphereRadiusFactor : 1.0;
  107974. if (options && options.updatable !== undefined) {
  107975. this._updatable = options.updatable;
  107976. }
  107977. else {
  107978. this._updatable = true;
  107979. }
  107980. if (this._pickable) {
  107981. this.pickedParticles = [];
  107982. }
  107983. if (this._depthSort) {
  107984. this.depthSortedParticles = [];
  107985. }
  107986. }
  107987. /**
  107988. * Builds the SPS underlying mesh. Returns a standard Mesh.
  107989. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  107990. * @returns the created mesh
  107991. */
  107992. SolidParticleSystem.prototype.buildMesh = function () {
  107993. if (this.nbParticles === 0) {
  107994. var triangle = _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__["DiscBuilder"].CreateDisc("", { radius: 1, tessellation: 3 }, this._scene);
  107995. this.addShape(triangle, 1);
  107996. triangle.dispose();
  107997. }
  107998. this._indices32 = (this._needs32Bits) ? new Uint32Array(this._indices) : new Uint16Array(this._indices);
  107999. this._positions32 = new Float32Array(this._positions);
  108000. this._uvs32 = new Float32Array(this._uvs);
  108001. this._colors32 = new Float32Array(this._colors);
  108002. if (this.recomputeNormals) {
  108003. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(this._positions32, this._indices32, this._normals);
  108004. }
  108005. this._normals32 = new Float32Array(this._normals);
  108006. this._fixedNormal32 = new Float32Array(this._normals);
  108007. if (this._mustUnrotateFixedNormals) { // the particles could be created already rotated in the mesh with a positionFunction
  108008. this._unrotateFixedNormals();
  108009. }
  108010. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  108011. vertexData.indices = (this._depthSort) ? this._indices : this._indices32;
  108012. vertexData.set(this._positions32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  108013. vertexData.set(this._normals32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  108014. if (this._uvs32.length > 0) {
  108015. vertexData.set(this._uvs32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  108016. }
  108017. if (this._colors32.length > 0) {
  108018. vertexData.set(this._colors32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  108019. }
  108020. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this.name, this._scene);
  108021. vertexData.applyToMesh(mesh, this._updatable);
  108022. this.mesh = mesh;
  108023. this.mesh.isPickable = this._pickable;
  108024. // free memory
  108025. if (!this._depthSort) {
  108026. this._indices = null;
  108027. }
  108028. this._positions = null;
  108029. this._normals = null;
  108030. this._uvs = null;
  108031. this._colors = null;
  108032. if (!this._updatable) {
  108033. this.particles.length = 0;
  108034. }
  108035. return mesh;
  108036. };
  108037. /**
  108038. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  108039. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  108040. * Thus the particles generated from `digest()` have their property `position` set yet.
  108041. * @param mesh ( Mesh ) is the mesh to be digested
  108042. * @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
  108043. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  108044. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  108045. * @returns the current SPS
  108046. */
  108047. SolidParticleSystem.prototype.digest = function (mesh, options) {
  108048. var size = (options && options.facetNb) || 1;
  108049. var number = (options && options.number) || 0;
  108050. var delta = (options && options.delta) || 0;
  108051. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  108052. var meshInd = mesh.getIndices();
  108053. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  108054. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  108055. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  108056. var f = 0; // facet counter
  108057. var totalFacets = meshInd.length / 3; // a facet is a triangle, so 3 indices
  108058. // compute size from number
  108059. if (number) {
  108060. number = (number > totalFacets) ? totalFacets : number;
  108061. size = Math.round(totalFacets / number);
  108062. delta = 0;
  108063. }
  108064. else {
  108065. size = (size > totalFacets) ? totalFacets : size;
  108066. }
  108067. var facetPos = []; // submesh positions
  108068. var facetInd = []; // submesh indices
  108069. var facetUV = []; // submesh UV
  108070. var facetCol = []; // submesh colors
  108071. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  108072. var sizeO = size;
  108073. while (f < totalFacets) {
  108074. size = sizeO + Math.floor((1 + delta) * Math.random());
  108075. if (f > totalFacets - size) {
  108076. size = totalFacets - f;
  108077. }
  108078. // reset temp arrays
  108079. facetPos.length = 0;
  108080. facetInd.length = 0;
  108081. facetUV.length = 0;
  108082. facetCol.length = 0;
  108083. // iterate over "size" facets
  108084. var fi = 0;
  108085. for (var j = f * 3; j < (f + size) * 3; j++) {
  108086. facetInd.push(fi);
  108087. var i = meshInd[j];
  108088. facetPos.push(meshPos[i * 3], meshPos[i * 3 + 1], meshPos[i * 3 + 2]);
  108089. if (meshUV) {
  108090. facetUV.push(meshUV[i * 2], meshUV[i * 2 + 1]);
  108091. }
  108092. if (meshCol) {
  108093. facetCol.push(meshCol[i * 4], meshCol[i * 4 + 1], meshCol[i * 4 + 2], meshCol[i * 4 + 3]);
  108094. }
  108095. fi++;
  108096. }
  108097. // create a model shape for each single particle
  108098. var idx = this.nbParticles;
  108099. var shape = this._posToShape(facetPos);
  108100. var shapeUV = this._uvsToShapeUV(facetUV);
  108101. // compute the barycenter of the shape
  108102. var v;
  108103. for (v = 0; v < shape.length; v++) {
  108104. barycenter.addInPlace(shape[v]);
  108105. }
  108106. barycenter.scaleInPlace(1 / shape.length);
  108107. // shift the shape from its barycenter to the origin
  108108. for (v = 0; v < shape.length; v++) {
  108109. shape[v].subtractInPlace(barycenter);
  108110. }
  108111. var bInfo;
  108112. if (this._particlesIntersect) {
  108113. bInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](barycenter, barycenter);
  108114. }
  108115. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, size * 3, shapeUV, null, null);
  108116. // add the particle in the SPS
  108117. var currentPos = this._positions.length;
  108118. var currentInd = this._indices.length;
  108119. this._meshBuilder(this._index, shape, this._positions, facetInd, this._indices, facetUV, this._uvs, facetCol, this._colors, meshNor, this._normals, idx, 0, null);
  108120. this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, 0, bInfo);
  108121. // initialize the particle position
  108122. this.particles[this.nbParticles].position.addInPlace(barycenter);
  108123. this._index += shape.length;
  108124. idx++;
  108125. this.nbParticles++;
  108126. this._shapeCounter++;
  108127. f += size;
  108128. }
  108129. return this;
  108130. };
  108131. // unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  108132. SolidParticleSystem.prototype._unrotateFixedNormals = function () {
  108133. var index = 0;
  108134. var idx = 0;
  108135. var tmpNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  108136. var quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  108137. var invertedRotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  108138. for (var p = 0; p < this.particles.length; p++) {
  108139. var particle = this.particles[p];
  108140. var shape = particle._model._shape;
  108141. // computing the inverse of the rotation matrix from the quaternion
  108142. // is equivalent to computing the matrix of the inverse quaternion, i.e of the conjugate quaternion
  108143. if (particle.rotationQuaternion) {
  108144. particle.rotationQuaternion.conjugateToRef(quaternion);
  108145. }
  108146. else {
  108147. var rotation = particle.rotation;
  108148. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  108149. quaternion.conjugateInPlace();
  108150. }
  108151. quaternion.toRotationMatrix(invertedRotMatrix);
  108152. for (var pt = 0; pt < shape.length; pt++) {
  108153. idx = index + pt * 3;
  108154. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(this._normals32[idx], this._normals32[idx + 1], this._normals32[idx + 2], invertedRotMatrix, tmpNormal);
  108155. tmpNormal.toArray(this._fixedNormal32, idx);
  108156. }
  108157. index = idx + 3;
  108158. }
  108159. };
  108160. //reset copy
  108161. SolidParticleSystem.prototype._resetCopy = function () {
  108162. var copy = this._copy;
  108163. copy.position.setAll(0);
  108164. copy.rotation.setAll(0);
  108165. copy.rotationQuaternion = null;
  108166. copy.scaling.setAll(1);
  108167. copy.uvs.copyFromFloats(0.0, 0.0, 1.0, 1.0);
  108168. copy.color = null;
  108169. copy.translateFromPivot = false;
  108170. };
  108171. // _meshBuilder : inserts the shape model in the global SPS mesh
  108172. SolidParticleSystem.prototype._meshBuilder = function (p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options) {
  108173. var i;
  108174. var u = 0;
  108175. var c = 0;
  108176. var n = 0;
  108177. this._resetCopy();
  108178. var copy = this._copy;
  108179. if (options && options.positionFunction) { // call to custom positionFunction
  108180. options.positionFunction(copy, idx, idxInShape);
  108181. this._mustUnrotateFixedNormals = true;
  108182. }
  108183. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  108184. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  108185. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  108186. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  108187. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  108188. copy.getRotationMatrix(rotMatrix);
  108189. copy.pivot.multiplyToRef(copy.scaling, scaledPivot);
  108190. if (copy.translateFromPivot) {
  108191. pivotBackTranslation.setAll(0.0);
  108192. }
  108193. else {
  108194. pivotBackTranslation.copyFrom(scaledPivot);
  108195. }
  108196. for (i = 0; i < shape.length; i++) {
  108197. tmpVertex.copyFrom(shape[i]);
  108198. if (options && options.vertexFunction) {
  108199. options.vertexFunction(copy, tmpVertex, i);
  108200. }
  108201. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  108202. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  108203. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position);
  108204. positions.push(tmpRotated.x, tmpRotated.y, tmpRotated.z);
  108205. if (meshUV) {
  108206. var copyUvs = copy.uvs;
  108207. uvs.push((copyUvs.z - copyUvs.x) * meshUV[u] + copyUvs.x, (copyUvs.w - copyUvs.y) * meshUV[u + 1] + copyUvs.y);
  108208. u += 2;
  108209. }
  108210. if (copy.color) {
  108211. this._color = copy.color;
  108212. }
  108213. else {
  108214. var color = this._color;
  108215. if (meshCol && meshCol[c] !== undefined) {
  108216. color.r = meshCol[c];
  108217. color.g = meshCol[c + 1];
  108218. color.b = meshCol[c + 2];
  108219. color.a = meshCol[c + 3];
  108220. }
  108221. else {
  108222. color.r = 1.0;
  108223. color.g = 1.0;
  108224. color.b = 1.0;
  108225. color.a = 1.0;
  108226. }
  108227. }
  108228. colors.push(this._color.r, this._color.g, this._color.b, this._color.a);
  108229. c += 4;
  108230. if (!this.recomputeNormals && meshNor) {
  108231. tmpVertex.x = meshNor[n];
  108232. tmpVertex.y = meshNor[n + 1];
  108233. tmpVertex.z = meshNor[n + 2];
  108234. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, rotMatrix, tmpVertex);
  108235. normals.push(tmpVertex.x, tmpVertex.y, tmpVertex.z);
  108236. n += 3;
  108237. }
  108238. }
  108239. for (i = 0; i < meshInd.length; i++) {
  108240. var current_ind = p + meshInd[i];
  108241. indices.push(current_ind);
  108242. if (current_ind > 65535) {
  108243. this._needs32Bits = true;
  108244. }
  108245. }
  108246. if (this._pickable) {
  108247. var nbfaces = meshInd.length / 3;
  108248. for (i = 0; i < nbfaces; i++) {
  108249. this.pickedParticles.push({ idx: idx, faceId: i });
  108250. }
  108251. }
  108252. if (this._depthSort) {
  108253. this.depthSortedParticles.push(new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["DepthSortedParticle"]());
  108254. }
  108255. return copy;
  108256. };
  108257. // returns a shape array from positions array
  108258. SolidParticleSystem.prototype._posToShape = function (positions) {
  108259. var shape = [];
  108260. for (var i = 0; i < positions.length; i += 3) {
  108261. shape.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, i));
  108262. }
  108263. return shape;
  108264. };
  108265. // returns a shapeUV array from a Vector4 uvs
  108266. SolidParticleSystem.prototype._uvsToShapeUV = function (uvs) {
  108267. var shapeUV = [];
  108268. if (uvs) {
  108269. for (var i = 0; i < uvs.length; i++) {
  108270. shapeUV.push(uvs[i]);
  108271. }
  108272. }
  108273. return shapeUV;
  108274. };
  108275. // adds a new particle object in the particles array
  108276. SolidParticleSystem.prototype._addParticle = function (idx, idxpos, idxind, model, shapeId, idxInShape, bInfo) {
  108277. if (bInfo === void 0) { bInfo = null; }
  108278. var sp = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](idx, idxpos, idxind, model, shapeId, idxInShape, this, bInfo);
  108279. this.particles.push(sp);
  108280. return sp;
  108281. };
  108282. /**
  108283. * Adds some particles to the SPS from the model shape. Returns the shape id.
  108284. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  108285. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  108286. * @param nb (positive integer) the number of particles to be created from this model
  108287. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  108288. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  108289. * @returns the number of shapes in the system
  108290. */
  108291. SolidParticleSystem.prototype.addShape = function (mesh, nb, options) {
  108292. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  108293. var meshInd = mesh.getIndices();
  108294. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  108295. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  108296. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  108297. var bbInfo;
  108298. if (this._particlesIntersect) {
  108299. bbInfo = mesh.getBoundingInfo();
  108300. }
  108301. var shape = this._posToShape(meshPos);
  108302. var shapeUV = this._uvsToShapeUV(meshUV);
  108303. var posfunc = options ? options.positionFunction : null;
  108304. var vtxfunc = options ? options.vertexFunction : null;
  108305. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, meshInd.length, shapeUV, posfunc, vtxfunc);
  108306. // particles
  108307. var sp;
  108308. var currentCopy;
  108309. var idx = this.nbParticles;
  108310. for (var i = 0; i < nb; i++) {
  108311. var currentPos = this._positions.length;
  108312. var currentInd = this._indices.length;
  108313. currentCopy = this._meshBuilder(this._index, shape, this._positions, meshInd, this._indices, meshUV, this._uvs, meshCol, this._colors, meshNor, this._normals, idx, i, options);
  108314. if (this._updatable) {
  108315. sp = this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, i, bbInfo);
  108316. sp.position.copyFrom(currentCopy.position);
  108317. sp.rotation.copyFrom(currentCopy.rotation);
  108318. if (currentCopy.rotationQuaternion && sp.rotationQuaternion) {
  108319. sp.rotationQuaternion.copyFrom(currentCopy.rotationQuaternion);
  108320. }
  108321. if (currentCopy.color && sp.color) {
  108322. sp.color.copyFrom(currentCopy.color);
  108323. }
  108324. sp.scaling.copyFrom(currentCopy.scaling);
  108325. sp.uvs.copyFrom(currentCopy.uvs);
  108326. }
  108327. this._index += shape.length;
  108328. idx++;
  108329. }
  108330. this.nbParticles += nb;
  108331. this._shapeCounter++;
  108332. return this._shapeCounter - 1;
  108333. };
  108334. // rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  108335. SolidParticleSystem.prototype._rebuildParticle = function (particle) {
  108336. this._resetCopy();
  108337. var copy = this._copy;
  108338. if (particle._model._positionFunction) { // recall to stored custom positionFunction
  108339. particle._model._positionFunction(copy, particle.idx, particle.idxInShape);
  108340. }
  108341. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  108342. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  108343. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  108344. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  108345. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  108346. copy.getRotationMatrix(rotMatrix);
  108347. particle.pivot.multiplyToRef(particle.scaling, scaledPivot);
  108348. if (copy.translateFromPivot) {
  108349. pivotBackTranslation.copyFromFloats(0.0, 0.0, 0.0);
  108350. }
  108351. else {
  108352. pivotBackTranslation.copyFrom(scaledPivot);
  108353. }
  108354. var shape = particle._model._shape;
  108355. for (var pt = 0; pt < shape.length; pt++) {
  108356. tmpVertex.copyFrom(shape[pt]);
  108357. if (particle._model._vertexFunction) {
  108358. particle._model._vertexFunction(copy, tmpVertex, pt); // recall to stored vertexFunction
  108359. }
  108360. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  108361. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  108362. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position).toArray(this._positions32, particle._pos + pt * 3);
  108363. }
  108364. particle.position.setAll(0.0);
  108365. particle.rotation.setAll(0.0);
  108366. particle.rotationQuaternion = null;
  108367. particle.scaling.setAll(1.0);
  108368. particle.uvs.setAll(0.0);
  108369. particle.pivot.setAll(0.0);
  108370. particle.translateFromPivot = false;
  108371. particle.parentId = null;
  108372. };
  108373. /**
  108374. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  108375. * @returns the SPS.
  108376. */
  108377. SolidParticleSystem.prototype.rebuildMesh = function () {
  108378. for (var p = 0; p < this.particles.length; p++) {
  108379. this._rebuildParticle(this.particles[p]);
  108380. }
  108381. this.mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this._positions32, false, false);
  108382. return this;
  108383. };
  108384. /**
  108385. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  108386. * This method calls `updateParticle()` for each particle of the SPS.
  108387. * For an animated SPS, it is usually called within the render loop.
  108388. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  108389. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  108390. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  108391. * @returns the SPS.
  108392. */
  108393. SolidParticleSystem.prototype.setParticles = function (start, end, update) {
  108394. if (start === void 0) { start = 0; }
  108395. if (end === void 0) { end = this.nbParticles - 1; }
  108396. if (update === void 0) { update = true; }
  108397. if (!this._updatable) {
  108398. return this;
  108399. }
  108400. // custom beforeUpdate
  108401. this.beforeUpdateParticles(start, end, update);
  108402. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  108403. var invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  108404. var mesh = this.mesh;
  108405. var colors32 = this._colors32;
  108406. var positions32 = this._positions32;
  108407. var normals32 = this._normals32;
  108408. var uvs32 = this._uvs32;
  108409. var indices32 = this._indices32;
  108410. var indices = this._indices;
  108411. var fixedNormal32 = this._fixedNormal32;
  108412. var tempVectors = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3;
  108413. var camAxisX = tempVectors[5].copyFromFloats(1.0, 0.0, 0.0);
  108414. var camAxisY = tempVectors[6].copyFromFloats(0.0, 1.0, 0.0);
  108415. var camAxisZ = tempVectors[7].copyFromFloats(0.0, 0.0, 1.0);
  108416. var minimum = tempVectors[8].setAll(Number.MAX_VALUE);
  108417. var maximum = tempVectors[9].setAll(-Number.MAX_VALUE);
  108418. var camInvertedPosition = tempVectors[10].setAll(0);
  108419. // cases when the World Matrix is to be computed first
  108420. if (this.billboard || this._depthSort) {
  108421. this.mesh.computeWorldMatrix(true);
  108422. this.mesh._worldMatrix.invertToRef(invertedMatrix);
  108423. }
  108424. // if the particles will always face the camera
  108425. if (this.billboard) {
  108426. // compute the camera position and un-rotate it by the current mesh rotation
  108427. var tmpVertex = tempVectors[0];
  108428. this._camera.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Z, tmpVertex);
  108429. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, invertedMatrix, camAxisZ);
  108430. camAxisZ.normalize();
  108431. // same for camera up vector extracted from the cam view matrix
  108432. var view = this._camera.getViewMatrix(true);
  108433. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(view.m[1], view.m[5], view.m[9], invertedMatrix, camAxisY);
  108434. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(camAxisY, camAxisZ, camAxisX);
  108435. camAxisY.normalize();
  108436. camAxisX.normalize();
  108437. }
  108438. // if depthSort, compute the camera global position in the mesh local system
  108439. if (this._depthSort) {
  108440. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._camera.globalPosition, invertedMatrix, camInvertedPosition); // then un-rotate the camera
  108441. }
  108442. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(rotMatrix);
  108443. var idx = 0; // current position index in the global array positions32
  108444. var index = 0; // position start index in the global array positions32 of the current particle
  108445. var colidx = 0; // current color index in the global array colors32
  108446. var colorIndex = 0; // color start index in the global array colors32 of the current particle
  108447. var uvidx = 0; // current uv index in the global array uvs32
  108448. var uvIndex = 0; // uv start index in the global array uvs32 of the current particle
  108449. var pt = 0; // current index in the particle model shape
  108450. if (this.mesh.isFacetDataEnabled) {
  108451. this._computeBoundingBox = true;
  108452. }
  108453. end = (end >= this.nbParticles) ? this.nbParticles - 1 : end;
  108454. if (this._computeBoundingBox) {
  108455. if (start != 0 || end != this.nbParticles - 1) { // only some particles are updated, then use the current existing BBox basis. Note : it can only increase.
  108456. var boundingInfo = this.mesh._boundingInfo;
  108457. if (boundingInfo) {
  108458. minimum.copyFrom(boundingInfo.minimum);
  108459. maximum.copyFrom(boundingInfo.maximum);
  108460. }
  108461. }
  108462. }
  108463. // particle loop
  108464. index = this.particles[start]._pos;
  108465. var vpos = (index / 3) | 0;
  108466. colorIndex = vpos * 4;
  108467. uvIndex = vpos * 2;
  108468. for (var p = start; p <= end; p++) {
  108469. var particle = this.particles[p];
  108470. // call to custom user function to update the particle properties
  108471. this.updateParticle(particle);
  108472. var shape = particle._model._shape;
  108473. var shapeUV = particle._model._shapeUV;
  108474. var particleRotationMatrix = particle._rotationMatrix;
  108475. var particlePosition = particle.position;
  108476. var particleRotation = particle.rotation;
  108477. var particleScaling = particle.scaling;
  108478. var particleGlobalPosition = particle._globalPosition;
  108479. // camera-particle distance for depth sorting
  108480. if (this._depthSort && this._depthSortParticles) {
  108481. var dsp = this.depthSortedParticles[p];
  108482. dsp.ind = particle._ind;
  108483. dsp.indicesLength = particle._model._indicesLength;
  108484. dsp.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(particle.position, camInvertedPosition);
  108485. }
  108486. // skip the computations for inactive or already invisible particles
  108487. if (!particle.alive || (particle._stillInvisible && !particle.isVisible)) {
  108488. // increment indexes for the next particle
  108489. pt = shape.length;
  108490. index += pt * 3;
  108491. colorIndex += pt * 4;
  108492. uvIndex += pt * 2;
  108493. continue;
  108494. }
  108495. if (particle.isVisible) {
  108496. particle._stillInvisible = false; // un-mark permanent invisibility
  108497. var scaledPivot = tempVectors[12];
  108498. particle.pivot.multiplyToRef(particleScaling, scaledPivot);
  108499. // particle rotation matrix
  108500. if (this.billboard) {
  108501. particleRotation.x = 0.0;
  108502. particleRotation.y = 0.0;
  108503. }
  108504. if (this._computeParticleRotation || this.billboard) {
  108505. particle.getRotationMatrix(rotMatrix);
  108506. }
  108507. var particleHasParent = (particle.parentId !== null);
  108508. if (particleHasParent) {
  108509. var parent_1 = this.particles[particle.parentId];
  108510. var parentRotationMatrix = parent_1._rotationMatrix;
  108511. var parentGlobalPosition = parent_1._globalPosition;
  108512. var rotatedY = particlePosition.x * parentRotationMatrix[1] + particlePosition.y * parentRotationMatrix[4] + particlePosition.z * parentRotationMatrix[7];
  108513. var rotatedX = particlePosition.x * parentRotationMatrix[0] + particlePosition.y * parentRotationMatrix[3] + particlePosition.z * parentRotationMatrix[6];
  108514. var rotatedZ = particlePosition.x * parentRotationMatrix[2] + particlePosition.y * parentRotationMatrix[5] + particlePosition.z * parentRotationMatrix[8];
  108515. particleGlobalPosition.x = parentGlobalPosition.x + rotatedX;
  108516. particleGlobalPosition.y = parentGlobalPosition.y + rotatedY;
  108517. particleGlobalPosition.z = parentGlobalPosition.z + rotatedZ;
  108518. if (this._computeParticleRotation || this.billboard) {
  108519. var rotMatrixValues = rotMatrix.m;
  108520. particleRotationMatrix[0] = rotMatrixValues[0] * parentRotationMatrix[0] + rotMatrixValues[1] * parentRotationMatrix[3] + rotMatrixValues[2] * parentRotationMatrix[6];
  108521. particleRotationMatrix[1] = rotMatrixValues[0] * parentRotationMatrix[1] + rotMatrixValues[1] * parentRotationMatrix[4] + rotMatrixValues[2] * parentRotationMatrix[7];
  108522. particleRotationMatrix[2] = rotMatrixValues[0] * parentRotationMatrix[2] + rotMatrixValues[1] * parentRotationMatrix[5] + rotMatrixValues[2] * parentRotationMatrix[8];
  108523. particleRotationMatrix[3] = rotMatrixValues[4] * parentRotationMatrix[0] + rotMatrixValues[5] * parentRotationMatrix[3] + rotMatrixValues[6] * parentRotationMatrix[6];
  108524. particleRotationMatrix[4] = rotMatrixValues[4] * parentRotationMatrix[1] + rotMatrixValues[5] * parentRotationMatrix[4] + rotMatrixValues[6] * parentRotationMatrix[7];
  108525. particleRotationMatrix[5] = rotMatrixValues[4] * parentRotationMatrix[2] + rotMatrixValues[5] * parentRotationMatrix[5] + rotMatrixValues[6] * parentRotationMatrix[8];
  108526. particleRotationMatrix[6] = rotMatrixValues[8] * parentRotationMatrix[0] + rotMatrixValues[9] * parentRotationMatrix[3] + rotMatrixValues[10] * parentRotationMatrix[6];
  108527. particleRotationMatrix[7] = rotMatrixValues[8] * parentRotationMatrix[1] + rotMatrixValues[9] * parentRotationMatrix[4] + rotMatrixValues[10] * parentRotationMatrix[7];
  108528. particleRotationMatrix[8] = rotMatrixValues[8] * parentRotationMatrix[2] + rotMatrixValues[9] * parentRotationMatrix[5] + rotMatrixValues[10] * parentRotationMatrix[8];
  108529. }
  108530. }
  108531. else {
  108532. particleGlobalPosition.x = particlePosition.x;
  108533. particleGlobalPosition.y = particlePosition.y;
  108534. particleGlobalPosition.z = particlePosition.z;
  108535. if (this._computeParticleRotation || this.billboard) {
  108536. var rotMatrixValues = rotMatrix.m;
  108537. particleRotationMatrix[0] = rotMatrixValues[0];
  108538. particleRotationMatrix[1] = rotMatrixValues[1];
  108539. particleRotationMatrix[2] = rotMatrixValues[2];
  108540. particleRotationMatrix[3] = rotMatrixValues[4];
  108541. particleRotationMatrix[4] = rotMatrixValues[5];
  108542. particleRotationMatrix[5] = rotMatrixValues[6];
  108543. particleRotationMatrix[6] = rotMatrixValues[8];
  108544. particleRotationMatrix[7] = rotMatrixValues[9];
  108545. particleRotationMatrix[8] = rotMatrixValues[10];
  108546. }
  108547. }
  108548. var pivotBackTranslation = tempVectors[11];
  108549. if (particle.translateFromPivot) {
  108550. pivotBackTranslation.setAll(0.0);
  108551. }
  108552. else {
  108553. pivotBackTranslation.copyFrom(scaledPivot);
  108554. }
  108555. // particle vertex loop
  108556. for (pt = 0; pt < shape.length; pt++) {
  108557. idx = index + pt * 3;
  108558. colidx = colorIndex + pt * 4;
  108559. uvidx = uvIndex + pt * 2;
  108560. var tmpVertex = tempVectors[0];
  108561. tmpVertex.copyFrom(shape[pt]);
  108562. if (this._computeParticleVertex) {
  108563. this.updateParticleVertex(particle, tmpVertex, pt);
  108564. }
  108565. // positions
  108566. var vertexX = tmpVertex.x * particleScaling.x - scaledPivot.x;
  108567. var vertexY = tmpVertex.y * particleScaling.y - scaledPivot.y;
  108568. var vertexZ = tmpVertex.z * particleScaling.z - scaledPivot.z;
  108569. var rotatedX = vertexX * particleRotationMatrix[0] + vertexY * particleRotationMatrix[3] + vertexZ * particleRotationMatrix[6];
  108570. var rotatedY = vertexX * particleRotationMatrix[1] + vertexY * particleRotationMatrix[4] + vertexZ * particleRotationMatrix[7];
  108571. var rotatedZ = vertexX * particleRotationMatrix[2] + vertexY * particleRotationMatrix[5] + vertexZ * particleRotationMatrix[8];
  108572. rotatedX += pivotBackTranslation.x;
  108573. rotatedY += pivotBackTranslation.y;
  108574. rotatedZ += pivotBackTranslation.z;
  108575. var px = positions32[idx] = particleGlobalPosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  108576. var py = positions32[idx + 1] = particleGlobalPosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  108577. var pz = positions32[idx + 2] = particleGlobalPosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  108578. if (this._computeBoundingBox) {
  108579. minimum.minimizeInPlaceFromFloats(px, py, pz);
  108580. maximum.maximizeInPlaceFromFloats(px, py, pz);
  108581. }
  108582. // normals : if the particles can't be morphed then just rotate the normals, what is much more faster than ComputeNormals()
  108583. if (!this._computeParticleVertex) {
  108584. var normalx = fixedNormal32[idx];
  108585. var normaly = fixedNormal32[idx + 1];
  108586. var normalz = fixedNormal32[idx + 2];
  108587. var rotatedx = normalx * particleRotationMatrix[0] + normaly * particleRotationMatrix[3] + normalz * particleRotationMatrix[6];
  108588. var rotatedy = normalx * particleRotationMatrix[1] + normaly * particleRotationMatrix[4] + normalz * particleRotationMatrix[7];
  108589. var rotatedz = normalx * particleRotationMatrix[2] + normaly * particleRotationMatrix[5] + normalz * particleRotationMatrix[8];
  108590. normals32[idx] = camAxisX.x * rotatedx + camAxisY.x * rotatedy + camAxisZ.x * rotatedz;
  108591. normals32[idx + 1] = camAxisX.y * rotatedx + camAxisY.y * rotatedy + camAxisZ.y * rotatedz;
  108592. normals32[idx + 2] = camAxisX.z * rotatedx + camAxisY.z * rotatedy + camAxisZ.z * rotatedz;
  108593. }
  108594. if (this._computeParticleColor && particle.color) {
  108595. var color = particle.color;
  108596. var colors32_1 = this._colors32;
  108597. colors32_1[colidx] = color.r;
  108598. colors32_1[colidx + 1] = color.g;
  108599. colors32_1[colidx + 2] = color.b;
  108600. colors32_1[colidx + 3] = color.a;
  108601. }
  108602. if (this._computeParticleTexture) {
  108603. var uvs = particle.uvs;
  108604. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  108605. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  108606. }
  108607. }
  108608. }
  108609. // particle just set invisible : scaled to zero and positioned at the origin
  108610. else {
  108611. particle._stillInvisible = true; // mark the particle as invisible
  108612. for (pt = 0; pt < shape.length; pt++) {
  108613. idx = index + pt * 3;
  108614. colidx = colorIndex + pt * 4;
  108615. uvidx = uvIndex + pt * 2;
  108616. positions32[idx] = positions32[idx + 1] = positions32[idx + 2] = 0;
  108617. normals32[idx] = normals32[idx + 1] = normals32[idx + 2] = 0;
  108618. if (this._computeParticleColor && particle.color) {
  108619. var color = particle.color;
  108620. colors32[colidx] = color.r;
  108621. colors32[colidx + 1] = color.g;
  108622. colors32[colidx + 2] = color.b;
  108623. colors32[colidx + 3] = color.a;
  108624. }
  108625. if (this._computeParticleTexture) {
  108626. var uvs = particle.uvs;
  108627. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  108628. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  108629. }
  108630. }
  108631. }
  108632. // if the particle intersections must be computed : update the bbInfo
  108633. if (this._particlesIntersect) {
  108634. var bInfo = particle._boundingInfo;
  108635. var bBox = bInfo.boundingBox;
  108636. var bSphere = bInfo.boundingSphere;
  108637. var modelBoundingInfo = particle._modelBoundingInfo;
  108638. if (!this._bSphereOnly) {
  108639. // place, scale and rotate the particle bbox within the SPS local system, then update it
  108640. var modelBoundingInfoVectors = modelBoundingInfo.boundingBox.vectors;
  108641. var tempMin = tempVectors[1];
  108642. var tempMax = tempVectors[2];
  108643. tempMin.setAll(Number.MAX_VALUE);
  108644. tempMax.setAll(-Number.MAX_VALUE);
  108645. for (var b = 0; b < 8; b++) {
  108646. var scaledX = modelBoundingInfoVectors[b].x * particleScaling.x;
  108647. var scaledY = modelBoundingInfoVectors[b].y * particleScaling.y;
  108648. var scaledZ = modelBoundingInfoVectors[b].z * particleScaling.z;
  108649. var rotatedX = scaledX * particleRotationMatrix[0] + scaledY * particleRotationMatrix[3] + scaledZ * particleRotationMatrix[6];
  108650. var rotatedY = scaledX * particleRotationMatrix[1] + scaledY * particleRotationMatrix[4] + scaledZ * particleRotationMatrix[7];
  108651. var rotatedZ = scaledX * particleRotationMatrix[2] + scaledY * particleRotationMatrix[5] + scaledZ * particleRotationMatrix[8];
  108652. var x = particlePosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  108653. var y = particlePosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  108654. var z = particlePosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  108655. tempMin.minimizeInPlaceFromFloats(x, y, z);
  108656. tempMax.maximizeInPlaceFromFloats(x, y, z);
  108657. }
  108658. bBox.reConstruct(tempMin, tempMax, mesh._worldMatrix);
  108659. }
  108660. // place and scale the particle bouding sphere in the SPS local system, then update it
  108661. var minBbox = modelBoundingInfo.minimum.multiplyToRef(particleScaling, tempVectors[1]);
  108662. var maxBbox = modelBoundingInfo.maximum.multiplyToRef(particleScaling, tempVectors[2]);
  108663. var bSphereCenter = maxBbox.addToRef(minBbox, tempVectors[3]).scaleInPlace(0.5).addInPlace(particleGlobalPosition);
  108664. var halfDiag = maxBbox.subtractToRef(minBbox, tempVectors[4]).scaleInPlace(0.5 * this._bSphereRadiusFactor);
  108665. var bSphereMinBbox = bSphereCenter.subtractToRef(halfDiag, tempVectors[1]);
  108666. var bSphereMaxBbox = bSphereCenter.addToRef(halfDiag, tempVectors[2]);
  108667. bSphere.reConstruct(bSphereMinBbox, bSphereMaxBbox, mesh._worldMatrix);
  108668. }
  108669. // increment indexes for the next particle
  108670. index = idx + 3;
  108671. colorIndex = colidx + 4;
  108672. uvIndex = uvidx + 2;
  108673. }
  108674. // if the VBO must be updated
  108675. if (update) {
  108676. if (this._computeParticleColor) {
  108677. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, colors32, false, false);
  108678. }
  108679. if (this._computeParticleTexture) {
  108680. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs32, false, false);
  108681. }
  108682. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, positions32, false, false);
  108683. if (!mesh.areNormalsFrozen || mesh.isFacetDataEnabled) {
  108684. if (this._computeParticleVertex || mesh.isFacetDataEnabled) {
  108685. // recompute the normals only if the particles can be morphed, update then also the normal reference array _fixedNormal32[]
  108686. var params = mesh.isFacetDataEnabled ? mesh.getFacetDataParameters() : null;
  108687. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions32, indices32, normals32, params);
  108688. for (var i = 0; i < normals32.length; i++) {
  108689. fixedNormal32[i] = normals32[i];
  108690. }
  108691. }
  108692. if (!mesh.areNormalsFrozen) {
  108693. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals32, false, false);
  108694. }
  108695. }
  108696. if (this._depthSort && this._depthSortParticles) {
  108697. var depthSortedParticles = this.depthSortedParticles;
  108698. depthSortedParticles.sort(depthSortFunction);
  108699. var dspl = depthSortedParticles.length;
  108700. var sid = 0;
  108701. for (var sorted = 0; sorted < dspl; sorted++) {
  108702. var lind = depthSortedParticles[sorted].indicesLength;
  108703. var sind = depthSortedParticles[sorted].ind;
  108704. for (var i = 0; i < lind; i++) {
  108705. indices32[sid] = indices[sind + i];
  108706. sid++;
  108707. }
  108708. }
  108709. mesh.updateIndices(indices32);
  108710. }
  108711. }
  108712. if (this._computeBoundingBox) {
  108713. if (mesh._boundingInfo) {
  108714. mesh._boundingInfo.reConstruct(minimum, maximum, mesh._worldMatrix);
  108715. }
  108716. else {
  108717. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](minimum, maximum, mesh._worldMatrix);
  108718. }
  108719. }
  108720. this.afterUpdateParticles(start, end, update);
  108721. return this;
  108722. };
  108723. /**
  108724. * Disposes the SPS.
  108725. */
  108726. SolidParticleSystem.prototype.dispose = function () {
  108727. this.mesh.dispose();
  108728. this.vars = null;
  108729. // drop references to internal big arrays for the GC
  108730. this._positions = null;
  108731. this._indices = null;
  108732. this._normals = null;
  108733. this._uvs = null;
  108734. this._colors = null;
  108735. this._indices32 = null;
  108736. this._positions32 = null;
  108737. this._normals32 = null;
  108738. this._fixedNormal32 = null;
  108739. this._uvs32 = null;
  108740. this._colors32 = null;
  108741. this.pickedParticles = null;
  108742. };
  108743. /**
  108744. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  108745. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108746. * @returns the SPS.
  108747. */
  108748. SolidParticleSystem.prototype.refreshVisibleSize = function () {
  108749. if (!this._isVisibilityBoxLocked) {
  108750. this.mesh.refreshBoundingInfo();
  108751. }
  108752. return this;
  108753. };
  108754. /**
  108755. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  108756. * @param size the size (float) of the visibility box
  108757. * note : this doesn't lock the SPS mesh bounding box.
  108758. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108759. */
  108760. SolidParticleSystem.prototype.setVisibilityBox = function (size) {
  108761. var vis = size / 2;
  108762. 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));
  108763. };
  108764. Object.defineProperty(SolidParticleSystem.prototype, "isAlwaysVisible", {
  108765. /**
  108766. * Gets whether the SPS as always visible or not
  108767. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108768. */
  108769. get: function () {
  108770. return this._alwaysVisible;
  108771. },
  108772. /**
  108773. * Sets the SPS as always visible or not
  108774. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108775. */
  108776. set: function (val) {
  108777. this._alwaysVisible = val;
  108778. this.mesh.alwaysSelectAsActiveMesh = val;
  108779. },
  108780. enumerable: true,
  108781. configurable: true
  108782. });
  108783. Object.defineProperty(SolidParticleSystem.prototype, "isVisibilityBoxLocked", {
  108784. /**
  108785. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108786. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108787. */
  108788. get: function () {
  108789. return this._isVisibilityBoxLocked;
  108790. },
  108791. /**
  108792. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108793. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108794. */
  108795. set: function (val) {
  108796. this._isVisibilityBoxLocked = val;
  108797. var boundingInfo = this.mesh.getBoundingInfo();
  108798. boundingInfo.isLocked = val;
  108799. },
  108800. enumerable: true,
  108801. configurable: true
  108802. });
  108803. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleRotation", {
  108804. /**
  108805. * Gets if `setParticles()` computes the particle rotations or not.
  108806. * Default value : true. The SPS is faster when it's set to false.
  108807. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108808. */
  108809. get: function () {
  108810. return this._computeParticleRotation;
  108811. },
  108812. /**
  108813. * Tells to `setParticles()` to compute the particle rotations or not.
  108814. * Default value : true. The SPS is faster when it's set to false.
  108815. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108816. */
  108817. set: function (val) {
  108818. this._computeParticleRotation = val;
  108819. },
  108820. enumerable: true,
  108821. configurable: true
  108822. });
  108823. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleColor", {
  108824. /**
  108825. * Gets if `setParticles()` computes the particle colors or not.
  108826. * Default value : true. The SPS is faster when it's set to false.
  108827. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108828. */
  108829. get: function () {
  108830. return this._computeParticleColor;
  108831. },
  108832. /**
  108833. * Tells to `setParticles()` to compute the particle colors or not.
  108834. * Default value : true. The SPS is faster when it's set to false.
  108835. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108836. */
  108837. set: function (val) {
  108838. this._computeParticleColor = val;
  108839. },
  108840. enumerable: true,
  108841. configurable: true
  108842. });
  108843. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleTexture", {
  108844. /**
  108845. * Gets if `setParticles()` computes the particle textures or not.
  108846. * Default value : true. The SPS is faster when it's set to false.
  108847. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  108848. */
  108849. get: function () {
  108850. return this._computeParticleTexture;
  108851. },
  108852. set: function (val) {
  108853. this._computeParticleTexture = val;
  108854. },
  108855. enumerable: true,
  108856. configurable: true
  108857. });
  108858. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleVertex", {
  108859. /**
  108860. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  108861. * Default value : false. The SPS is faster when it's set to false.
  108862. * Note : the particle custom vertex positions aren't stored values.
  108863. */
  108864. get: function () {
  108865. return this._computeParticleVertex;
  108866. },
  108867. /**
  108868. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  108869. * Default value : false. The SPS is faster when it's set to false.
  108870. * Note : the particle custom vertex positions aren't stored values.
  108871. */
  108872. set: function (val) {
  108873. this._computeParticleVertex = val;
  108874. },
  108875. enumerable: true,
  108876. configurable: true
  108877. });
  108878. Object.defineProperty(SolidParticleSystem.prototype, "computeBoundingBox", {
  108879. /**
  108880. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  108881. */
  108882. get: function () {
  108883. return this._computeBoundingBox;
  108884. },
  108885. /**
  108886. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  108887. */
  108888. set: function (val) {
  108889. this._computeBoundingBox = val;
  108890. },
  108891. enumerable: true,
  108892. configurable: true
  108893. });
  108894. Object.defineProperty(SolidParticleSystem.prototype, "depthSortParticles", {
  108895. /**
  108896. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  108897. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108898. * Default : `true`
  108899. */
  108900. get: function () {
  108901. return this._depthSortParticles;
  108902. },
  108903. /**
  108904. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  108905. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108906. * Default : `true`
  108907. */
  108908. set: function (val) {
  108909. this._depthSortParticles = val;
  108910. },
  108911. enumerable: true,
  108912. configurable: true
  108913. });
  108914. // =======================================================================
  108915. // Particle behavior logic
  108916. // these following methods may be overwritten by the user to fit his needs
  108917. /**
  108918. * This function does nothing. It may be overwritten to set all the particle first values.
  108919. * The SPS doesn't call this function, you may have to call it by your own.
  108920. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  108921. */
  108922. SolidParticleSystem.prototype.initParticles = function () {
  108923. };
  108924. /**
  108925. * This function does nothing. It may be overwritten to recycle a particle.
  108926. * The SPS doesn't call this function, you may have to call it by your own.
  108927. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  108928. * @param particle The particle to recycle
  108929. * @returns the recycled particle
  108930. */
  108931. SolidParticleSystem.prototype.recycleParticle = function (particle) {
  108932. return particle;
  108933. };
  108934. /**
  108935. * Updates a particle : this function should be overwritten by the user.
  108936. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  108937. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  108938. * @example : just set a particle position or velocity and recycle conditions
  108939. * @param particle The particle to update
  108940. * @returns the updated particle
  108941. */
  108942. SolidParticleSystem.prototype.updateParticle = function (particle) {
  108943. return particle;
  108944. };
  108945. /**
  108946. * Updates a vertex of a particle : it can be overwritten by the user.
  108947. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  108948. * @param particle the current particle
  108949. * @param vertex the current index of the current particle
  108950. * @param pt the index of the current vertex in the particle shape
  108951. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  108952. * @example : just set a vertex particle position
  108953. * @returns the updated vertex
  108954. */
  108955. SolidParticleSystem.prototype.updateParticleVertex = function (particle, vertex, pt) {
  108956. return vertex;
  108957. };
  108958. /**
  108959. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  108960. * This does nothing and may be overwritten by the user.
  108961. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108962. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108963. * @param update the boolean update value actually passed to setParticles()
  108964. */
  108965. SolidParticleSystem.prototype.beforeUpdateParticles = function (start, stop, update) {
  108966. };
  108967. /**
  108968. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  108969. * This will be passed three parameters.
  108970. * This does nothing and may be overwritten by the user.
  108971. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108972. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108973. * @param update the boolean update value actually passed to setParticles()
  108974. */
  108975. SolidParticleSystem.prototype.afterUpdateParticles = function (start, stop, update) {
  108976. };
  108977. return SolidParticleSystem;
  108978. }());
  108979. /***/ }),
  108980. /***/ "./Particles/subEmitter.ts":
  108981. /*!*********************************!*\
  108982. !*** ./Particles/subEmitter.ts ***!
  108983. \*********************************/
  108984. /*! exports provided: SubEmitterType, SubEmitter */
  108985. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108986. "use strict";
  108987. __webpack_require__.r(__webpack_exports__);
  108988. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return SubEmitterType; });
  108989. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return SubEmitter; });
  108990. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  108991. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  108992. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  108993. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  108994. /**
  108995. * Type of sub emitter
  108996. */
  108997. var SubEmitterType;
  108998. (function (SubEmitterType) {
  108999. /**
  109000. * Attached to the particle over it's lifetime
  109001. */
  109002. SubEmitterType[SubEmitterType["ATTACHED"] = 0] = "ATTACHED";
  109003. /**
  109004. * Created when the particle dies
  109005. */
  109006. SubEmitterType[SubEmitterType["END"] = 1] = "END";
  109007. })(SubEmitterType || (SubEmitterType = {}));
  109008. /**
  109009. * Sub emitter class used to emit particles from an existing particle
  109010. */
  109011. var SubEmitter = /** @class */ (function () {
  109012. /**
  109013. * Creates a sub emitter
  109014. * @param particleSystem the particle system to be used by the sub emitter
  109015. */
  109016. function SubEmitter(
  109017. /**
  109018. * the particle system to be used by the sub emitter
  109019. */
  109020. particleSystem) {
  109021. this.particleSystem = particleSystem;
  109022. /**
  109023. * Type of the submitter (Default: END)
  109024. */
  109025. this.type = SubEmitterType.END;
  109026. /**
  109027. * 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)
  109028. * Note: This only is supported when using an emitter of type Mesh
  109029. */
  109030. this.inheritDirection = false;
  109031. /**
  109032. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  109033. */
  109034. this.inheritedVelocityAmount = 0;
  109035. // Create mesh as emitter to support rotation
  109036. if (!particleSystem.emitter || !particleSystem.emitter.dispose) {
  109037. particleSystem.emitter = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("SubemitterSystemEmitter", particleSystem.getScene());
  109038. }
  109039. // Automatically dispose of subemitter when system is disposed
  109040. particleSystem.onDisposeObservable.add(function () {
  109041. if (particleSystem.emitter && particleSystem.emitter.dispose) {
  109042. particleSystem.emitter.dispose();
  109043. }
  109044. });
  109045. }
  109046. /**
  109047. * Clones the sub emitter
  109048. * @returns the cloned sub emitter
  109049. */
  109050. SubEmitter.prototype.clone = function () {
  109051. // Clone particle system
  109052. var emitter = this.particleSystem.emitter;
  109053. if (!emitter) {
  109054. emitter = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  109055. }
  109056. else if (emitter instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  109057. emitter = emitter.clone();
  109058. }
  109059. else if (emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  109060. emitter = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", emitter.getScene());
  109061. emitter.isVisible = false;
  109062. }
  109063. var clone = new SubEmitter(this.particleSystem.clone("", emitter));
  109064. // Clone properties
  109065. clone.type = this.type;
  109066. clone.inheritDirection = this.inheritDirection;
  109067. clone.inheritedVelocityAmount = this.inheritedVelocityAmount;
  109068. clone.particleSystem._disposeEmitterOnDispose = true;
  109069. clone.particleSystem.disposeOnStop = true;
  109070. return clone;
  109071. };
  109072. /**
  109073. * Serialize current object to a JSON object
  109074. * @returns the serialized object
  109075. */
  109076. SubEmitter.prototype.serialize = function () {
  109077. var serializationObject = {};
  109078. serializationObject.type = this.type;
  109079. serializationObject.inheritDirection = this.inheritDirection;
  109080. serializationObject.inheritedVelocityAmount = this.inheritedVelocityAmount;
  109081. serializationObject.particleSystem = this.particleSystem.serialize();
  109082. return serializationObject;
  109083. };
  109084. /** @hidden */
  109085. SubEmitter._ParseParticleSystem = function (system, scene, rootUrl) {
  109086. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("ParseParticle");
  109087. };
  109088. /**
  109089. * Creates a new SubEmitter from a serialized JSON version
  109090. * @param serializationObject defines the JSON object to read from
  109091. * @param scene defines the hosting scene
  109092. * @param rootUrl defines the rootUrl for data loading
  109093. * @returns a new SubEmitter
  109094. */
  109095. SubEmitter.Parse = function (serializationObject, scene, rootUrl) {
  109096. var system = serializationObject.particleSystem;
  109097. var subEmitter = new SubEmitter(SubEmitter._ParseParticleSystem(system, scene, rootUrl));
  109098. subEmitter.type = serializationObject.type;
  109099. subEmitter.inheritDirection = serializationObject.inheritDirection;
  109100. subEmitter.inheritedVelocityAmount = serializationObject.inheritedVelocityAmount;
  109101. subEmitter.particleSystem._isSubEmitter = true;
  109102. return subEmitter;
  109103. };
  109104. /** Release associated resources */
  109105. SubEmitter.prototype.dispose = function () {
  109106. this.particleSystem.dispose();
  109107. };
  109108. return SubEmitter;
  109109. }());
  109110. /***/ }),
  109111. /***/ "./Physics/Plugins/ammoJSPlugin.ts":
  109112. /*!*****************************************!*\
  109113. !*** ./Physics/Plugins/ammoJSPlugin.ts ***!
  109114. \*****************************************/
  109115. /*! exports provided: AmmoJSPlugin */
  109116. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109117. "use strict";
  109118. __webpack_require__.r(__webpack_exports__);
  109119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return AmmoJSPlugin; });
  109120. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  109121. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  109122. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  109123. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  109124. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  109125. /**
  109126. * AmmoJS Physics plugin
  109127. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  109128. * @see https://github.com/kripken/ammo.js/
  109129. */
  109130. var AmmoJSPlugin = /** @class */ (function () {
  109131. /**
  109132. * Initializes the ammoJS plugin
  109133. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  109134. * @param ammoInjection can be used to inject your own ammo reference
  109135. */
  109136. function AmmoJSPlugin(_useDeltaForWorldStep, ammoInjection) {
  109137. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  109138. if (ammoInjection === void 0) { ammoInjection = Ammo; }
  109139. var _this = this;
  109140. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  109141. /**
  109142. * Reference to the Ammo library
  109143. */
  109144. this.bjsAMMO = {};
  109145. /**
  109146. * Name of the plugin
  109147. */
  109148. this.name = "AmmoJSPlugin";
  109149. this._timeStep = 1 / 60;
  109150. this._fixedTimeStep = 1 / 60;
  109151. this._maxSteps = 5;
  109152. this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  109153. this._tmpContactCallbackResult = false;
  109154. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  109155. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  109156. if (typeof ammoInjection === "function") {
  109157. ammoInjection(this.bjsAMMO);
  109158. }
  109159. else {
  109160. this.bjsAMMO = ammoInjection;
  109161. }
  109162. if (!this.isSupported()) {
  109163. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("AmmoJS is not available. Please make sure you included the js file.");
  109164. return;
  109165. }
  109166. // Initialize the physics world
  109167. this._collisionConfiguration = new this.bjsAMMO.btDefaultCollisionConfiguration();
  109168. this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration);
  109169. this._overlappingPairCache = new this.bjsAMMO.btDbvtBroadphase();
  109170. this._solver = new this.bjsAMMO.btSequentialImpulseConstraintSolver();
  109171. this.world = new this.bjsAMMO.btDiscreteDynamicsWorld(this._dispatcher, this._overlappingPairCache, this._solver, this._collisionConfiguration);
  109172. this._tmpAmmoConcreteContactResultCallback = new this.bjsAMMO.ConcreteContactResultCallback();
  109173. this._tmpAmmoConcreteContactResultCallback.addSingleResult = function () { _this._tmpContactCallbackResult = true; };
  109174. // Create temp ammo variables
  109175. this._tmpAmmoTransform = new this.bjsAMMO.btTransform();
  109176. this._tmpAmmoTransform.setIdentity();
  109177. this._tmpAmmoQuaternion = new this.bjsAMMO.btQuaternion(0, 0, 0, 1);
  109178. this._tmpAmmoVectorA = new this.bjsAMMO.btVector3(0, 0, 0);
  109179. this._tmpAmmoVectorB = new this.bjsAMMO.btVector3(0, 0, 0);
  109180. this._tmpAmmoVectorC = new this.bjsAMMO.btVector3(0, 0, 0);
  109181. }
  109182. /**
  109183. * Sets the gravity of the physics world (m/(s^2))
  109184. * @param gravity Gravity to set
  109185. */
  109186. AmmoJSPlugin.prototype.setGravity = function (gravity) {
  109187. this._tmpAmmoVectorA.setValue(gravity.x, gravity.y, gravity.z);
  109188. this.world.setGravity(this._tmpAmmoVectorA);
  109189. };
  109190. /**
  109191. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  109192. * @param timeStep timestep to use in seconds
  109193. */
  109194. AmmoJSPlugin.prototype.setTimeStep = function (timeStep) {
  109195. this._timeStep = timeStep;
  109196. };
  109197. /**
  109198. * 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)
  109199. * @param fixedTimeStep fixedTimeStep to use in seconds
  109200. */
  109201. AmmoJSPlugin.prototype.setFixedTimeStep = function (fixedTimeStep) {
  109202. this._fixedTimeStep = fixedTimeStep;
  109203. };
  109204. /**
  109205. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  109206. * @param maxSteps the maximum number of steps by the physics engine per frame
  109207. */
  109208. AmmoJSPlugin.prototype.setMaxSteps = function (maxSteps) {
  109209. this._maxSteps = maxSteps;
  109210. };
  109211. /**
  109212. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  109213. * @returns the current timestep in seconds
  109214. */
  109215. AmmoJSPlugin.prototype.getTimeStep = function () {
  109216. return this._timeStep;
  109217. };
  109218. // Ammo's contactTest and contactPairTest take a callback that runs synchronously, wrap them so that they are easier to consume
  109219. AmmoJSPlugin.prototype._isImpostorInContact = function (impostor) {
  109220. this._tmpContactCallbackResult = false;
  109221. this.world.contactTest(impostor.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  109222. return this._tmpContactCallbackResult;
  109223. };
  109224. // Ammo's collision events have some weird quirks
  109225. // contactPairTest fires too many events as it fires events even when objects are close together but contactTest does not
  109226. // so only fire event if both contactTest and contactPairTest have a hit
  109227. AmmoJSPlugin.prototype._isImpostorPairInContact = function (impostorA, impostorB) {
  109228. this._tmpContactCallbackResult = false;
  109229. this.world.contactPairTest(impostorA.physicsBody, impostorB.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  109230. return this._tmpContactCallbackResult;
  109231. };
  109232. // Ammo's behavior when maxSteps > 0 does not behave as described in docs
  109233. // @see http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Stepping_The_World
  109234. //
  109235. // When maxSteps is 0 do the entire simulation in one step
  109236. // 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)
  109237. // Note: To get deterministic physics, timeStep would always need to be divisible by fixedTimeStep
  109238. AmmoJSPlugin.prototype._stepSimulation = function (timeStep, maxSteps, fixedTimeStep) {
  109239. if (timeStep === void 0) { timeStep = 1 / 60; }
  109240. if (maxSteps === void 0) { maxSteps = 10; }
  109241. if (fixedTimeStep === void 0) { fixedTimeStep = 1 / 60; }
  109242. if (maxSteps == 0) {
  109243. this.world.stepSimulation(timeStep, 0);
  109244. }
  109245. else {
  109246. while (maxSteps > 0 && timeStep > 0) {
  109247. if (timeStep - fixedTimeStep < fixedTimeStep) {
  109248. this.world.stepSimulation(timeStep, 0);
  109249. timeStep = 0;
  109250. }
  109251. else {
  109252. timeStep -= fixedTimeStep;
  109253. this.world.stepSimulation(fixedTimeStep, 0);
  109254. }
  109255. maxSteps--;
  109256. }
  109257. }
  109258. };
  109259. /**
  109260. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  109261. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  109262. * After the step the babylon meshes are set to the position of the physics imposters
  109263. * @param delta amount of time to step forward
  109264. * @param impostors array of imposters to update before/after the step
  109265. */
  109266. AmmoJSPlugin.prototype.executeStep = function (delta, impostors) {
  109267. for (var _i = 0, impostors_1 = impostors; _i < impostors_1.length; _i++) {
  109268. var impostor = impostors_1[_i];
  109269. // Update physics world objects to match babylon world
  109270. impostor.beforeStep();
  109271. }
  109272. this._stepSimulation(this._useDeltaForWorldStep ? delta : this._timeStep, this._maxSteps, this._fixedTimeStep);
  109273. for (var _a = 0, impostors_2 = impostors; _a < impostors_2.length; _a++) {
  109274. var mainImpostor = impostors_2[_a];
  109275. // After physics update make babylon world objects match physics world objects
  109276. mainImpostor.afterStep();
  109277. // Handle collision event
  109278. if (mainImpostor._onPhysicsCollideCallbacks.length > 0) {
  109279. if (this._isImpostorInContact(mainImpostor)) {
  109280. for (var _b = 0, _c = mainImpostor._onPhysicsCollideCallbacks; _b < _c.length; _b++) {
  109281. var collideCallback = _c[_b];
  109282. for (var _d = 0, _e = collideCallback.otherImpostors; _d < _e.length; _d++) {
  109283. var otherImpostor = _e[_d];
  109284. if (mainImpostor.physicsBody.isActive() || otherImpostor.physicsBody.isActive()) {
  109285. if (this._isImpostorPairInContact(mainImpostor, otherImpostor)) {
  109286. mainImpostor.onCollide({ body: otherImpostor.physicsBody });
  109287. otherImpostor.onCollide({ body: mainImpostor.physicsBody });
  109288. }
  109289. }
  109290. }
  109291. }
  109292. }
  109293. }
  109294. }
  109295. };
  109296. /**
  109297. * Applies an implulse on the imposter
  109298. * @param impostor imposter to apply impulse
  109299. * @param force amount of force to be applied to the imposter
  109300. * @param contactPoint the location to apply the impulse on the imposter
  109301. */
  109302. AmmoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  109303. impostor.physicsBody.activate();
  109304. var worldPoint = this._tmpAmmoVectorA;
  109305. var impulse = this._tmpAmmoVectorB;
  109306. // Convert contactPoint into world space
  109307. if (impostor.object && impostor.object.getWorldMatrix) {
  109308. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  109309. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  109310. contactPoint = this._tmpVector;
  109311. }
  109312. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  109313. impulse.setValue(force.x, force.y, force.z);
  109314. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  109315. };
  109316. /**
  109317. * Applies a force on the imposter
  109318. * @param impostor imposter to apply force
  109319. * @param force amount of force to be applied to the imposter
  109320. * @param contactPoint the location to apply the force on the imposter
  109321. */
  109322. AmmoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  109323. impostor.physicsBody.activate();
  109324. var worldPoint = this._tmpAmmoVectorA;
  109325. var impulse = this._tmpAmmoVectorB;
  109326. // Convert contactPoint into world space
  109327. if (impostor.object && impostor.object.getWorldMatrix) {
  109328. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  109329. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  109330. contactPoint = this._tmpVector;
  109331. }
  109332. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  109333. impulse.setValue(force.x, force.y, force.z);
  109334. impostor.physicsBody.applyForce(impulse, worldPoint);
  109335. };
  109336. /**
  109337. * Creates a physics body using the plugin
  109338. * @param impostor the imposter to create the physics body on
  109339. */
  109340. AmmoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  109341. impostor._pluginData = { toDispose: [] };
  109342. //parent-child relationship
  109343. if (impostor.parent) {
  109344. if (impostor.physicsBody) {
  109345. this.removePhysicsBody(impostor);
  109346. impostor.forceUpdate();
  109347. }
  109348. return;
  109349. }
  109350. if (impostor.isBodyInitRequired()) {
  109351. var colShape = this._createShape(impostor);
  109352. var mass = impostor.getParam("mass");
  109353. impostor._pluginData.mass = mass;
  109354. var localInertia = new Ammo.btVector3(0, 0, 0);
  109355. var startTransform = new Ammo.btTransform();
  109356. startTransform.setIdentity();
  109357. if (mass !== 0) {
  109358. colShape.calculateLocalInertia(mass, localInertia);
  109359. }
  109360. this._tmpAmmoVectorA.setValue(impostor.object.position.x, impostor.object.position.y, impostor.object.position.z);
  109361. this._tmpAmmoQuaternion.setValue(impostor.object.rotationQuaternion.x, impostor.object.rotationQuaternion.y, impostor.object.rotationQuaternion.z, impostor.object.rotationQuaternion.w);
  109362. startTransform.setOrigin(this._tmpAmmoVectorA);
  109363. startTransform.setRotation(this._tmpAmmoQuaternion);
  109364. var myMotionState = new Ammo.btDefaultMotionState(startTransform);
  109365. var rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia);
  109366. var body = new Ammo.btRigidBody(rbInfo);
  109367. // Make objects kinematic if it's mass is 0
  109368. if (mass === 0) {
  109369. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.KINEMATIC_FLAG);
  109370. body.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  109371. }
  109372. // Disable collision if NoImpostor, but keep collision if shape is btCompoundShape
  109373. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor && !colShape.getChildShape) {
  109374. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.DISABLE_COLLISION_FLAG);
  109375. }
  109376. this.world.addRigidBody(body);
  109377. impostor.physicsBody = body;
  109378. this.setBodyRestitution(impostor, impostor.getParam("restitution"));
  109379. this.setBodyFriction(impostor, impostor.getParam("friction"));
  109380. impostor._pluginData.toDispose.concat([body, rbInfo, myMotionState, startTransform, localInertia, colShape]);
  109381. }
  109382. };
  109383. /**
  109384. * Removes the physics body from the imposter and disposes of the body's memory
  109385. * @param impostor imposter to remove the physics body from
  109386. */
  109387. AmmoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  109388. var _this = this;
  109389. if (this.world) {
  109390. this.world.removeRigidBody(impostor.physicsBody);
  109391. impostor._pluginData.toDispose.forEach(function (d) {
  109392. _this.bjsAMMO.destroy(d);
  109393. });
  109394. }
  109395. };
  109396. /**
  109397. * Generates a joint
  109398. * @param impostorJoint the imposter joint to create the joint with
  109399. */
  109400. AmmoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  109401. var mainBody = impostorJoint.mainImpostor.physicsBody;
  109402. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  109403. if (!mainBody || !connectedBody) {
  109404. return;
  109405. }
  109406. var jointData = impostorJoint.joint.jointData;
  109407. if (!jointData.mainPivot) {
  109408. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  109409. }
  109410. if (!jointData.connectedPivot) {
  109411. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  109412. }
  109413. var joint;
  109414. switch (impostorJoint.joint.type) {
  109415. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].DistanceJoint:
  109416. var distance = jointData.maxDistance;
  109417. if (distance) {
  109418. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -distance / 2, 0);
  109419. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, distance / 2, 0);
  109420. }
  109421. 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));
  109422. break;
  109423. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].HingeJoint:
  109424. if (!jointData.mainAxis) {
  109425. jointData.mainAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  109426. }
  109427. if (!jointData.connectedAxis) {
  109428. jointData.connectedAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  109429. }
  109430. var mainAxis = new Ammo.btVector3(jointData.mainAxis.x, jointData.mainAxis.y, jointData.mainAxis.z);
  109431. var connectedAxis = new Ammo.btVector3(jointData.connectedAxis.x, jointData.connectedAxis.y, jointData.connectedAxis.z);
  109432. 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);
  109433. break;
  109434. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].BallAndSocketJoint:
  109435. 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));
  109436. break;
  109437. default:
  109438. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("JointType not currently supported by the Ammo plugin, falling back to 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. }
  109442. this.world.addConstraint(joint, !impostorJoint.joint.jointData.collision);
  109443. impostorJoint.joint.physicsJoint = joint;
  109444. };
  109445. /**
  109446. * Removes a joint
  109447. * @param impostorJoint the imposter joint to remove the joint from
  109448. */
  109449. AmmoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  109450. if (this.world) {
  109451. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  109452. }
  109453. };
  109454. // adds all verticies (including child verticies) to the triangle mesh
  109455. AmmoJSPlugin.prototype._addMeshVerts = function (btTriangleMesh, topLevelObject, object) {
  109456. var _this = this;
  109457. var triangleCount = 0;
  109458. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  109459. var indices = object.getIndices();
  109460. if (!indices) {
  109461. indices = [];
  109462. }
  109463. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  109464. if (!vertexPositions) {
  109465. vertexPositions = [];
  109466. }
  109467. object.computeWorldMatrix(false);
  109468. var faceCount = indices.length / 3;
  109469. for (var i = 0; i < faceCount; i++) {
  109470. var triPoints = [];
  109471. for (var point = 0; point < 3; point++) {
  109472. 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]);
  109473. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, object.getWorldMatrix());
  109474. v.subtractInPlace(topLevelObject.position);
  109475. var vec;
  109476. if (point == 0) {
  109477. vec = this._tmpAmmoVectorA;
  109478. }
  109479. else if (point == 1) {
  109480. vec = this._tmpAmmoVectorB;
  109481. }
  109482. else {
  109483. vec = this._tmpAmmoVectorC;
  109484. }
  109485. vec.setValue(v.x, v.y, v.z);
  109486. triPoints.push(vec);
  109487. }
  109488. btTriangleMesh.addTriangle(triPoints[0], triPoints[1], triPoints[2]);
  109489. triangleCount++;
  109490. }
  109491. object.getChildMeshes().forEach(function (m) {
  109492. triangleCount += _this._addMeshVerts(btTriangleMesh, topLevelObject, m);
  109493. });
  109494. }
  109495. return triangleCount;
  109496. };
  109497. AmmoJSPlugin.prototype._createShape = function (impostor, ignoreChildren) {
  109498. var _this = this;
  109499. if (ignoreChildren === void 0) { ignoreChildren = false; }
  109500. var object = impostor.object;
  109501. var returnValue;
  109502. var extendSize = impostor.getObjectExtendSize();
  109503. if (!ignoreChildren) {
  109504. var meshChildren = impostor.object.getChildMeshes ? impostor.object.getChildMeshes(true) : [];
  109505. returnValue = new Ammo.btCompoundShape();
  109506. // Add shape of all children to the compound shape
  109507. var childrenAdded = 0;
  109508. meshChildren.forEach(function (childMesh) {
  109509. var childImpostor = childMesh.getPhysicsImpostor();
  109510. if (childImpostor) {
  109511. var shape = _this._createShape(childImpostor);
  109512. // Position needs to be scaled based on parent's scaling
  109513. var parentMat = childMesh.parent.getWorldMatrix().clone();
  109514. var s = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  109515. parentMat.decompose(s);
  109516. _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x * s.x, childMesh.position.y * s.y, childMesh.position.z * s.z);
  109517. _this._tmpAmmoQuaternion.setValue(childMesh.rotationQuaternion.x, childMesh.rotationQuaternion.y, childMesh.rotationQuaternion.z, childMesh.rotationQuaternion.w);
  109518. _this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
  109519. returnValue.addChildShape(_this._tmpAmmoTransform, shape);
  109520. childImpostor.dispose();
  109521. childrenAdded++;
  109522. }
  109523. });
  109524. if (childrenAdded > 0) {
  109525. // Add parents shape as a child if present
  109526. if (impostor.type != _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor) {
  109527. var shape = this._createShape(impostor, true);
  109528. if (shape) {
  109529. this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0);
  109530. this._tmpAmmoQuaternion.setValue(0, 0, 0, 1);
  109531. this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
  109532. returnValue.addChildShape(this._tmpAmmoTransform, shape);
  109533. }
  109534. }
  109535. return returnValue;
  109536. }
  109537. else {
  109538. // If no children with impostors create the actual shape below instead
  109539. Ammo.destroy(returnValue);
  109540. returnValue = null;
  109541. }
  109542. }
  109543. switch (impostor.type) {
  109544. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SphereImpostor:
  109545. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  109546. break;
  109547. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].CylinderImpostor:
  109548. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  109549. returnValue = new Ammo.btCylinderShape(this._tmpAmmoVectorA);
  109550. break;
  109551. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].PlaneImpostor:
  109552. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].BoxImpostor:
  109553. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  109554. returnValue = new Ammo.btBoxShape(this._tmpAmmoVectorA);
  109555. break;
  109556. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].MeshImpostor:
  109557. var tetraMesh = new Ammo.btTriangleMesh();
  109558. impostor._pluginData.toDispose.concat([tetraMesh]);
  109559. var triangeCount = this._addMeshVerts(tetraMesh, object, object);
  109560. if (triangeCount == 0) {
  109561. returnValue = new Ammo.btCompoundShape();
  109562. }
  109563. else {
  109564. returnValue = new Ammo.btBvhTriangleMeshShape(tetraMesh);
  109565. }
  109566. break;
  109567. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor:
  109568. // Fill with sphere but collision is disabled on the rigid body in generatePhysicsBody, using an empty shape caused unexpected movement with joints
  109569. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  109570. break;
  109571. default:
  109572. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The impostor type is not currently supported by the ammo plugin.");
  109573. break;
  109574. }
  109575. return returnValue;
  109576. };
  109577. /**
  109578. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  109579. * @param impostor imposter containing the physics body and babylon object
  109580. */
  109581. AmmoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  109582. impostor.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  109583. impostor.object.position.set(this._tmpAmmoTransform.getOrigin().x(), this._tmpAmmoTransform.getOrigin().y(), this._tmpAmmoTransform.getOrigin().z());
  109584. if (!impostor.object.rotationQuaternion) {
  109585. if (impostor.object.rotation) {
  109586. this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  109587. this._tmpQuaternion.toEulerAnglesToRef(impostor.object.rotation);
  109588. }
  109589. }
  109590. else {
  109591. impostor.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  109592. }
  109593. };
  109594. /**
  109595. * Sets the babylon object's position/rotation from the physics body's position/rotation
  109596. * @param impostor imposter containing the physics body and babylon object
  109597. * @param newPosition new position
  109598. * @param newRotation new rotation
  109599. */
  109600. AmmoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  109601. var trans = impostor.physicsBody.getWorldTransform();
  109602. // If rotation/position has changed update and activate riged body
  109603. if (trans.getOrigin().x() != newPosition.x ||
  109604. trans.getOrigin().y() != newPosition.y ||
  109605. trans.getOrigin().z() != newPosition.z ||
  109606. trans.getRotation().x() != newRotation.x ||
  109607. trans.getRotation().y() != newRotation.y ||
  109608. trans.getRotation().z() != newRotation.z ||
  109609. trans.getRotation().w() != newRotation.w) {
  109610. this._tmpAmmoVectorA.setValue(newPosition.x, newPosition.y, newPosition.z);
  109611. trans.setOrigin(this._tmpAmmoVectorA);
  109612. this._tmpAmmoQuaternion.setValue(newRotation.x, newRotation.y, newRotation.z, newRotation.w);
  109613. trans.setRotation(this._tmpAmmoQuaternion);
  109614. impostor.physicsBody.setWorldTransform(trans);
  109615. if (impostor.mass == 0) {
  109616. // Kinematic objects must be updated using motion state
  109617. var motionState = impostor.physicsBody.getMotionState();
  109618. if (motionState) {
  109619. motionState.setWorldTransform(trans);
  109620. }
  109621. }
  109622. else {
  109623. impostor.physicsBody.activate();
  109624. }
  109625. }
  109626. };
  109627. /**
  109628. * If this plugin is supported
  109629. * @returns true if its supported
  109630. */
  109631. AmmoJSPlugin.prototype.isSupported = function () {
  109632. return this.bjsAMMO !== undefined;
  109633. };
  109634. /**
  109635. * Sets the linear velocity of the physics body
  109636. * @param impostor imposter to set the velocity on
  109637. * @param velocity velocity to set
  109638. */
  109639. AmmoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  109640. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  109641. impostor.physicsBody.setLinearVelocity(this._tmpAmmoVectorA);
  109642. };
  109643. /**
  109644. * Sets the angular velocity of the physics body
  109645. * @param impostor imposter to set the velocity on
  109646. * @param velocity velocity to set
  109647. */
  109648. AmmoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  109649. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  109650. impostor.physicsBody.setAngularVelocity(this._tmpAmmoVectorA);
  109651. };
  109652. /**
  109653. * gets the linear velocity
  109654. * @param impostor imposter to get linear velocity from
  109655. * @returns linear velocity
  109656. */
  109657. AmmoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  109658. var v = impostor.physicsBody.getLinearVelocity();
  109659. if (!v) {
  109660. return null;
  109661. }
  109662. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  109663. };
  109664. /**
  109665. * gets the angular velocity
  109666. * @param impostor imposter to get angular velocity from
  109667. * @returns angular velocity
  109668. */
  109669. AmmoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  109670. var v = impostor.physicsBody.getAngularVelocity();
  109671. if (!v) {
  109672. return null;
  109673. }
  109674. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  109675. };
  109676. /**
  109677. * Sets the mass of physics body
  109678. * @param impostor imposter to set the mass on
  109679. * @param mass mass to set
  109680. */
  109681. AmmoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  109682. impostor.physicsBody.setMassProps(mass);
  109683. impostor._pluginData.mass = mass;
  109684. };
  109685. /**
  109686. * Gets the mass of the physics body
  109687. * @param impostor imposter to get the mass from
  109688. * @returns mass
  109689. */
  109690. AmmoJSPlugin.prototype.getBodyMass = function (impostor) {
  109691. return impostor._pluginData.mass;
  109692. };
  109693. /**
  109694. * Gets friction of the impostor
  109695. * @param impostor impostor to get friction from
  109696. * @returns friction value
  109697. */
  109698. AmmoJSPlugin.prototype.getBodyFriction = function (impostor) {
  109699. return impostor._pluginData.friction;
  109700. };
  109701. /**
  109702. * Sets friction of the impostor
  109703. * @param impostor impostor to set friction on
  109704. * @param friction friction value
  109705. */
  109706. AmmoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  109707. impostor.physicsBody.setFriction(friction);
  109708. impostor._pluginData.friction = friction;
  109709. };
  109710. /**
  109711. * Gets restitution of the impostor
  109712. * @param impostor impostor to get restitution from
  109713. * @returns restitution value
  109714. */
  109715. AmmoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  109716. return impostor._pluginData.restitution;
  109717. };
  109718. /**
  109719. * Sets resitution of the impostor
  109720. * @param impostor impostor to set resitution on
  109721. * @param restitution resitution value
  109722. */
  109723. AmmoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  109724. impostor.physicsBody.setRestitution(restitution);
  109725. impostor._pluginData.restitution = restitution;
  109726. };
  109727. /**
  109728. * Sleeps the physics body and stops it from being active
  109729. * @param impostor impostor to sleep
  109730. */
  109731. AmmoJSPlugin.prototype.sleepBody = function (impostor) {
  109732. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("sleepBody is not currently supported by the Ammo physics plugin");
  109733. };
  109734. /**
  109735. * Activates the physics body
  109736. * @param impostor impostor to activate
  109737. */
  109738. AmmoJSPlugin.prototype.wakeUpBody = function (impostor) {
  109739. impostor.physicsBody.activate();
  109740. };
  109741. /**
  109742. * Updates the distance parameters of the joint
  109743. * @param joint joint to update
  109744. * @param maxDistance maximum distance of the joint
  109745. * @param minDistance minimum distance of the joint
  109746. */
  109747. AmmoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  109748. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin");
  109749. };
  109750. /**
  109751. * Sets a motor on the joint
  109752. * @param joint joint to set motor on
  109753. * @param speed speed of the motor
  109754. * @param maxForce maximum force of the motor
  109755. * @param motorIndex index of the motor
  109756. */
  109757. AmmoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  109758. joint.physicsJoint.enableAngularMotor(true, speed, maxForce);
  109759. };
  109760. /**
  109761. * Sets the motors limit
  109762. * @param joint joint to set limit on
  109763. * @param upperLimit upper limit
  109764. * @param lowerLimit lower limit
  109765. */
  109766. AmmoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  109767. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("setLimit is not currently supported by the Ammo physics plugin");
  109768. };
  109769. /**
  109770. * Syncs the position and rotation of a mesh with the impostor
  109771. * @param mesh mesh to sync
  109772. * @param impostor impostor to update the mesh with
  109773. */
  109774. AmmoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  109775. var body = impostor.physicsBody;
  109776. body.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  109777. mesh.position.x = this._tmpAmmoTransform.getOrigin().x();
  109778. mesh.position.y = this._tmpAmmoTransform.getOrigin().y();
  109779. mesh.position.z = this._tmpAmmoTransform.getOrigin().z();
  109780. if (mesh.rotationQuaternion) {
  109781. mesh.rotationQuaternion.x = this._tmpAmmoTransform.getRotation().x();
  109782. mesh.rotationQuaternion.y = this._tmpAmmoTransform.getRotation().y();
  109783. mesh.rotationQuaternion.z = this._tmpAmmoTransform.getRotation().z();
  109784. mesh.rotationQuaternion.w = this._tmpAmmoTransform.getRotation().w();
  109785. }
  109786. };
  109787. /**
  109788. * Gets the radius of the impostor
  109789. * @param impostor impostor to get radius from
  109790. * @returns the radius
  109791. */
  109792. AmmoJSPlugin.prototype.getRadius = function (impostor) {
  109793. var exntend = impostor.getObjectExtendSize();
  109794. return exntend.x / 2;
  109795. };
  109796. /**
  109797. * Gets the box size of the impostor
  109798. * @param impostor impostor to get box size from
  109799. * @param result the resulting box size
  109800. */
  109801. AmmoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  109802. var exntend = impostor.getObjectExtendSize();
  109803. result.x = exntend.x;
  109804. result.y = exntend.y;
  109805. result.z = exntend.z;
  109806. };
  109807. /**
  109808. * Disposes of the impostor
  109809. */
  109810. AmmoJSPlugin.prototype.dispose = function () {
  109811. // Dispose of world
  109812. Ammo.destroy(this.world);
  109813. Ammo.destroy(this._solver);
  109814. Ammo.destroy(this._overlappingPairCache);
  109815. Ammo.destroy(this._dispatcher);
  109816. Ammo.destroy(this._collisionConfiguration);
  109817. // Dispose of tmp variables
  109818. Ammo.destroy(this._tmpAmmoVectorA);
  109819. Ammo.destroy(this._tmpAmmoVectorB);
  109820. Ammo.destroy(this._tmpAmmoVectorC);
  109821. Ammo.destroy(this._tmpAmmoTransform);
  109822. Ammo.destroy(this._tmpAmmoQuaternion);
  109823. Ammo.destroy(this._tmpAmmoConcreteContactResultCallback);
  109824. this.world = null;
  109825. };
  109826. AmmoJSPlugin.DISABLE_COLLISION_FLAG = 4;
  109827. AmmoJSPlugin.KINEMATIC_FLAG = 2;
  109828. AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG = 4;
  109829. return AmmoJSPlugin;
  109830. }());
  109831. /***/ }),
  109832. /***/ "./Physics/Plugins/cannonJSPlugin.ts":
  109833. /*!*******************************************!*\
  109834. !*** ./Physics/Plugins/cannonJSPlugin.ts ***!
  109835. \*******************************************/
  109836. /*! exports provided: CannonJSPlugin */
  109837. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109838. "use strict";
  109839. __webpack_require__.r(__webpack_exports__);
  109840. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return CannonJSPlugin; });
  109841. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  109842. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  109843. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  109844. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  109845. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  109846. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  109847. /** @hidden */
  109848. var CannonJSPlugin = /** @class */ (function () {
  109849. function CannonJSPlugin(_useDeltaForWorldStep, iterations, cannonInjection) {
  109850. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  109851. if (iterations === void 0) { iterations = 10; }
  109852. if (cannonInjection === void 0) { cannonInjection = CANNON; }
  109853. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  109854. this.name = "CannonJSPlugin";
  109855. this._physicsMaterials = new Array();
  109856. this._fixedTimeStep = 1 / 60;
  109857. this._minus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-0.7071067811865475, 0, 0, 0.7071067811865475);
  109858. this._plus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](0.7071067811865475, 0, 0, 0.7071067811865475);
  109859. this._tmpPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  109860. this._tmpDeltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  109861. this._tmpUnityRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  109862. this.BJSCANNON = cannonInjection;
  109863. if (!this.isSupported()) {
  109864. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("CannonJS is not available. Please make sure you included the js file.");
  109865. return;
  109866. }
  109867. this._extendNamespace();
  109868. this.world = new this.BJSCANNON.World();
  109869. this.world.broadphase = new this.BJSCANNON.NaiveBroadphase();
  109870. this.world.solver.iterations = iterations;
  109871. }
  109872. CannonJSPlugin.prototype.setGravity = function (gravity) {
  109873. this.world.gravity.copy(gravity);
  109874. };
  109875. CannonJSPlugin.prototype.setTimeStep = function (timeStep) {
  109876. this._fixedTimeStep = timeStep;
  109877. };
  109878. CannonJSPlugin.prototype.getTimeStep = function () {
  109879. return this._fixedTimeStep;
  109880. };
  109881. CannonJSPlugin.prototype.executeStep = function (delta) {
  109882. this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta : 0, 3);
  109883. };
  109884. CannonJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  109885. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  109886. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  109887. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  109888. };
  109889. CannonJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  109890. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  109891. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  109892. impostor.physicsBody.applyForce(impulse, worldPoint);
  109893. };
  109894. CannonJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  109895. //parent-child relationship. Does this impostor has a parent impostor?
  109896. if (impostor.parent) {
  109897. if (impostor.physicsBody) {
  109898. this.removePhysicsBody(impostor);
  109899. //TODO is that needed?
  109900. impostor.forceUpdate();
  109901. }
  109902. return;
  109903. }
  109904. //should a new body be created for this impostor?
  109905. if (impostor.isBodyInitRequired()) {
  109906. var shape = this._createShape(impostor);
  109907. //unregister events, if body is being changed
  109908. var oldBody = impostor.physicsBody;
  109909. if (oldBody) {
  109910. this.removePhysicsBody(impostor);
  109911. }
  109912. //create the body and material
  109913. var material = this._addMaterial("mat-" + impostor.uniqueId, impostor.getParam("friction"), impostor.getParam("restitution"));
  109914. var bodyCreationObject = {
  109915. mass: impostor.getParam("mass"),
  109916. material: material
  109917. };
  109918. // A simple extend, in case native options were used.
  109919. var nativeOptions = impostor.getParam("nativeOptions");
  109920. for (var key in nativeOptions) {
  109921. if (nativeOptions.hasOwnProperty(key)) {
  109922. bodyCreationObject[key] = nativeOptions[key];
  109923. }
  109924. }
  109925. impostor.physicsBody = new this.BJSCANNON.Body(bodyCreationObject);
  109926. impostor.physicsBody.addEventListener("collide", impostor.onCollide);
  109927. this.world.addEventListener("preStep", impostor.beforeStep);
  109928. this.world.addEventListener("postStep", impostor.afterStep);
  109929. impostor.physicsBody.addShape(shape);
  109930. this.world.add(impostor.physicsBody);
  109931. //try to keep the body moving in the right direction by taking old properties.
  109932. //Should be tested!
  109933. if (oldBody) {
  109934. ['force', 'torque', 'velocity', 'angularVelocity'].forEach(function (param) {
  109935. impostor.physicsBody[param].copy(oldBody[param]);
  109936. });
  109937. }
  109938. this._processChildMeshes(impostor);
  109939. }
  109940. //now update the body's transformation
  109941. this._updatePhysicsBodyTransformation(impostor);
  109942. };
  109943. CannonJSPlugin.prototype._processChildMeshes = function (mainImpostor) {
  109944. var _this = this;
  109945. var meshChildren = mainImpostor.object.getChildMeshes ? mainImpostor.object.getChildMeshes(true) : [];
  109946. var currentRotation = mainImpostor.object.rotationQuaternion;
  109947. if (meshChildren.length) {
  109948. var processMesh = function (localPosition, mesh) {
  109949. if (!currentRotation || !mesh.rotationQuaternion) {
  109950. return;
  109951. }
  109952. var childImpostor = mesh.getPhysicsImpostor();
  109953. if (childImpostor) {
  109954. var parent = childImpostor.parent;
  109955. if (parent !== mainImpostor) {
  109956. var pPosition = mesh.getAbsolutePosition().subtract(mainImpostor.object.getAbsolutePosition());
  109957. var localRotation = mesh.rotationQuaternion.multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Inverse(currentRotation));
  109958. if (childImpostor.physicsBody) {
  109959. _this.removePhysicsBody(childImpostor);
  109960. childImpostor.physicsBody = null;
  109961. }
  109962. childImpostor.parent = mainImpostor;
  109963. childImpostor.resetUpdateFlags();
  109964. 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));
  109965. //Add the mass of the children.
  109966. mainImpostor.physicsBody.mass += childImpostor.getParam("mass");
  109967. }
  109968. }
  109969. currentRotation.multiplyInPlace(mesh.rotationQuaternion);
  109970. mesh.getChildMeshes(true).filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(_this, mesh.getAbsolutePosition()));
  109971. };
  109972. meshChildren.filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(this, mainImpostor.object.getAbsolutePosition()));
  109973. }
  109974. };
  109975. CannonJSPlugin.prototype.removePhysicsBody = function (impostor) {
  109976. impostor.physicsBody.removeEventListener("collide", impostor.onCollide);
  109977. this.world.removeEventListener("preStep", impostor.beforeStep);
  109978. this.world.removeEventListener("postStep", impostor.afterStep);
  109979. this.world.remove(impostor.physicsBody);
  109980. };
  109981. CannonJSPlugin.prototype.generateJoint = function (impostorJoint) {
  109982. var mainBody = impostorJoint.mainImpostor.physicsBody;
  109983. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  109984. if (!mainBody || !connectedBody) {
  109985. return;
  109986. }
  109987. var constraint;
  109988. var jointData = impostorJoint.joint.jointData;
  109989. //TODO - https://github.com/schteppe/this.BJSCANNON.js/blob/gh-pages/demos/collisionFilter.html
  109990. var constraintData = {
  109991. pivotA: jointData.mainPivot ? new this.BJSCANNON.Vec3().copy(jointData.mainPivot) : null,
  109992. pivotB: jointData.connectedPivot ? new this.BJSCANNON.Vec3().copy(jointData.connectedPivot) : null,
  109993. axisA: jointData.mainAxis ? new this.BJSCANNON.Vec3().copy(jointData.mainAxis) : null,
  109994. axisB: jointData.connectedAxis ? new this.BJSCANNON.Vec3().copy(jointData.connectedAxis) : null,
  109995. maxForce: jointData.nativeParams.maxForce,
  109996. collideConnected: !!jointData.collision
  109997. };
  109998. switch (impostorJoint.joint.type) {
  109999. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].HingeJoint:
  110000. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].Hinge2Joint:
  110001. constraint = new this.BJSCANNON.HingeConstraint(mainBody, connectedBody, constraintData);
  110002. break;
  110003. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].DistanceJoint:
  110004. constraint = new this.BJSCANNON.DistanceConstraint(mainBody, connectedBody, jointData.maxDistance || 2);
  110005. break;
  110006. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint:
  110007. var springData = jointData;
  110008. constraint = new this.BJSCANNON.Spring(mainBody, connectedBody, {
  110009. restLength: springData.length,
  110010. stiffness: springData.stiffness,
  110011. damping: springData.damping,
  110012. localAnchorA: constraintData.pivotA,
  110013. localAnchorB: constraintData.pivotB
  110014. });
  110015. break;
  110016. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].LockJoint:
  110017. constraint = new this.BJSCANNON.LockConstraint(mainBody, connectedBody, constraintData);
  110018. break;
  110019. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].PointToPointJoint:
  110020. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].BallAndSocketJoint:
  110021. default:
  110022. constraint = new this.BJSCANNON.PointToPointConstraint(mainBody, constraintData.pivotA, connectedBody, constraintData.pivotB, constraintData.maxForce);
  110023. break;
  110024. }
  110025. //set the collideConnected flag after the creation, since DistanceJoint ignores it.
  110026. constraint.collideConnected = !!jointData.collision;
  110027. impostorJoint.joint.physicsJoint = constraint;
  110028. //don't add spring as constraint, as it is not one.
  110029. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  110030. this.world.addConstraint(constraint);
  110031. }
  110032. else {
  110033. impostorJoint.joint.jointData.forceApplicationCallback = impostorJoint.joint.jointData.forceApplicationCallback || function () {
  110034. constraint.applyForce();
  110035. };
  110036. impostorJoint.mainImpostor.registerAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  110037. }
  110038. };
  110039. CannonJSPlugin.prototype.removeJoint = function (impostorJoint) {
  110040. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  110041. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  110042. }
  110043. else {
  110044. impostorJoint.mainImpostor.unregisterAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  110045. }
  110046. };
  110047. CannonJSPlugin.prototype._addMaterial = function (name, friction, restitution) {
  110048. var index;
  110049. var mat;
  110050. for (index = 0; index < this._physicsMaterials.length; index++) {
  110051. mat = this._physicsMaterials[index];
  110052. if (mat.friction === friction && mat.restitution === restitution) {
  110053. return mat;
  110054. }
  110055. }
  110056. var currentMat = new this.BJSCANNON.Material(name);
  110057. currentMat.friction = friction;
  110058. currentMat.restitution = restitution;
  110059. this._physicsMaterials.push(currentMat);
  110060. return currentMat;
  110061. };
  110062. CannonJSPlugin.prototype._checkWithEpsilon = function (value) {
  110063. return value < _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon ? _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon : value;
  110064. };
  110065. CannonJSPlugin.prototype._createShape = function (impostor) {
  110066. var object = impostor.object;
  110067. var returnValue;
  110068. var extendSize = impostor.getObjectExtendSize();
  110069. switch (impostor.type) {
  110070. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].SphereImpostor:
  110071. var radiusX = extendSize.x;
  110072. var radiusY = extendSize.y;
  110073. var radiusZ = extendSize.z;
  110074. returnValue = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(radiusX), this._checkWithEpsilon(radiusY), this._checkWithEpsilon(radiusZ)) / 2);
  110075. break;
  110076. //TMP also for cylinder - TODO Cannon supports cylinder natively.
  110077. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].CylinderImpostor:
  110078. var nativeParams = impostor.getParam("nativeOptions");
  110079. if (!nativeParams) {
  110080. nativeParams = {};
  110081. }
  110082. var radiusTop = nativeParams.radiusTop !== undefined ? nativeParams.radiusTop : this._checkWithEpsilon(extendSize.x) / 2;
  110083. var radiusBottom = nativeParams.radiusBottom !== undefined ? nativeParams.radiusBottom : this._checkWithEpsilon(extendSize.x) / 2;
  110084. var height = nativeParams.height !== undefined ? nativeParams.height : this._checkWithEpsilon(extendSize.y);
  110085. var numSegments = nativeParams.numSegments !== undefined ? nativeParams.numSegments : 16;
  110086. returnValue = new this.BJSCANNON.Cylinder(radiusTop, radiusBottom, height, numSegments);
  110087. // Rotate 90 degrees as this shape is horizontal in cannon
  110088. var quat = new this.BJSCANNON.Quaternion();
  110089. quat.setFromAxisAngle(new this.BJSCANNON.Vec3(1, 0, 0), -Math.PI / 2);
  110090. var translation = new this.BJSCANNON.Vec3(0, 0, 0);
  110091. returnValue.transformAllPoints(translation, quat);
  110092. break;
  110093. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].BoxImpostor:
  110094. var box = extendSize.scale(0.5);
  110095. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));
  110096. break;
  110097. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor:
  110098. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead");
  110099. returnValue = new this.BJSCANNON.Plane();
  110100. break;
  110101. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor:
  110102. // should transform the vertex data to world coordinates!!
  110103. var rawVerts = object.getVerticesData ? object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) : [];
  110104. var rawFaces = object.getIndices ? object.getIndices() : [];
  110105. if (!rawVerts) {
  110106. return;
  110107. }
  110108. // get only scale! so the object could transform correctly.
  110109. var oldPosition = object.position.clone();
  110110. var oldRotation = object.rotation && object.rotation.clone();
  110111. var oldQuaternion = object.rotationQuaternion && object.rotationQuaternion.clone();
  110112. object.position.copyFromFloats(0, 0, 0);
  110113. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  110114. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  110115. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  110116. var transform = object.computeWorldMatrix(true);
  110117. // convert rawVerts to object space
  110118. var temp = new Array();
  110119. var index;
  110120. for (index = 0; index < rawVerts.length; index += 3) {
  110121. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(rawVerts, index), transform).toArray(temp, index);
  110122. }
  110123. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("MeshImpostor only collides against spheres.");
  110124. returnValue = new this.BJSCANNON.Trimesh(temp, rawFaces);
  110125. //now set back the transformation!
  110126. object.position.copyFrom(oldPosition);
  110127. oldRotation && object.rotation && object.rotation.copyFrom(oldRotation);
  110128. oldQuaternion && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion);
  110129. break;
  110130. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor:
  110131. var oldPosition2 = object.position.clone();
  110132. var oldRotation2 = object.rotation && object.rotation.clone();
  110133. var oldQuaternion2 = object.rotationQuaternion && object.rotationQuaternion.clone();
  110134. object.position.copyFromFloats(0, 0, 0);
  110135. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  110136. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  110137. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  110138. object.rotationQuaternion && object.rotationQuaternion.multiplyInPlace(this._minus90X);
  110139. returnValue = this._createHeightmap(object);
  110140. object.position.copyFrom(oldPosition2);
  110141. oldRotation2 && object.rotation && object.rotation.copyFrom(oldRotation2);
  110142. oldQuaternion2 && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion2);
  110143. object.computeWorldMatrix(true);
  110144. break;
  110145. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].ParticleImpostor:
  110146. returnValue = new this.BJSCANNON.Particle();
  110147. break;
  110148. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].NoImpostor:
  110149. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0, 0, 0));
  110150. break;
  110151. }
  110152. return returnValue;
  110153. };
  110154. CannonJSPlugin.prototype._createHeightmap = function (object, pointDepth) {
  110155. var pos = (object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  110156. var transform = object.computeWorldMatrix(true);
  110157. // convert rawVerts to object space
  110158. var temp = new Array();
  110159. var index;
  110160. for (index = 0; index < pos.length; index += 3) {
  110161. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(pos, index), transform).toArray(temp, index);
  110162. }
  110163. pos = temp;
  110164. var matrix = new Array();
  110165. //For now pointDepth will not be used and will be automatically calculated.
  110166. //Future reference - try and find the best place to add a reference to the pointDepth variable.
  110167. var arraySize = pointDepth || ~~(Math.sqrt(pos.length / 3) - 1);
  110168. var boundingInfo = object.getBoundingInfo();
  110169. var dim = Math.min(boundingInfo.boundingBox.extendSizeWorld.x, boundingInfo.boundingBox.extendSizeWorld.y);
  110170. var minY = boundingInfo.boundingBox.extendSizeWorld.z;
  110171. var elementSize = dim * 2 / arraySize;
  110172. for (var i = 0; i < pos.length; i = i + 3) {
  110173. var x = Math.round((pos[i + 0]) / elementSize + arraySize / 2);
  110174. var z = Math.round(((pos[i + 1]) / elementSize - arraySize / 2) * -1);
  110175. var y = -pos[i + 2] + minY;
  110176. if (!matrix[x]) {
  110177. matrix[x] = [];
  110178. }
  110179. if (!matrix[x][z]) {
  110180. matrix[x][z] = y;
  110181. }
  110182. matrix[x][z] = Math.max(y, matrix[x][z]);
  110183. }
  110184. for (var x = 0; x <= arraySize; ++x) {
  110185. if (!matrix[x]) {
  110186. var loc = 1;
  110187. while (!matrix[(x + loc) % arraySize]) {
  110188. loc++;
  110189. }
  110190. matrix[x] = matrix[(x + loc) % arraySize].slice();
  110191. //console.log("missing x", x);
  110192. }
  110193. for (var z = 0; z <= arraySize; ++z) {
  110194. if (!matrix[x][z]) {
  110195. var loc = 1;
  110196. var newValue;
  110197. while (newValue === undefined) {
  110198. newValue = matrix[x][(z + loc++) % arraySize];
  110199. }
  110200. matrix[x][z] = newValue;
  110201. }
  110202. }
  110203. }
  110204. var shape = new this.BJSCANNON.Heightfield(matrix, {
  110205. elementSize: elementSize
  110206. });
  110207. //For future reference, needed for body transformation
  110208. shape.minY = minY;
  110209. return shape;
  110210. };
  110211. CannonJSPlugin.prototype._updatePhysicsBodyTransformation = function (impostor) {
  110212. var object = impostor.object;
  110213. //make sure it is updated...
  110214. object.computeWorldMatrix && object.computeWorldMatrix(true);
  110215. // The delta between the mesh position and the mesh bounding box center
  110216. var bInfo = object.getBoundingInfo();
  110217. if (!bInfo) {
  110218. return;
  110219. }
  110220. var center = impostor.getObjectCenter();
  110221. //m.getAbsolutePosition().subtract(m.getBoundingInfo().boundingBox.centerWorld)
  110222. this._tmpDeltaPosition.copyFrom(object.getAbsolutePivotPoint().subtract(center));
  110223. this._tmpDeltaPosition.divideInPlace(impostor.object.scaling);
  110224. this._tmpPosition.copyFrom(center);
  110225. var quaternion = object.rotationQuaternion;
  110226. if (!quaternion) {
  110227. return;
  110228. }
  110229. //is shape is a plane or a heightmap, it must be rotated 90 degs in the X axis.
  110230. //ideally these would be rotated at time of creation like cylinder but they dont extend ConvexPolyhedron
  110231. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor || impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  110232. //-90 DEG in X, precalculated
  110233. quaternion = quaternion.multiply(this._minus90X);
  110234. //Invert! (Precalculated, 90 deg in X)
  110235. //No need to clone. this will never change.
  110236. impostor.setDeltaRotation(this._plus90X);
  110237. }
  110238. //If it is a heightfield, if should be centered.
  110239. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  110240. var mesh = object;
  110241. var boundingInfo = mesh.getBoundingInfo();
  110242. //calculate the correct body position:
  110243. var rotationQuaternion = mesh.rotationQuaternion;
  110244. mesh.rotationQuaternion = this._tmpUnityRotation;
  110245. mesh.computeWorldMatrix(true);
  110246. //get original center with no rotation
  110247. var c = center.clone();
  110248. var oldPivot = mesh.getPivotMatrix();
  110249. if (oldPivot) {
  110250. // create a copy the pivot Matrix as it is modified in place
  110251. oldPivot = oldPivot.clone();
  110252. }
  110253. else {
  110254. oldPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  110255. }
  110256. //calculate the new center using a pivot (since this.BJSCANNON.js doesn't center height maps)
  110257. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Translation(boundingInfo.boundingBox.extendSizeWorld.x, 0, -boundingInfo.boundingBox.extendSizeWorld.z);
  110258. mesh.setPreTransformMatrix(p);
  110259. mesh.computeWorldMatrix(true);
  110260. //calculate the translation
  110261. var translation = boundingInfo.boundingBox.centerWorld.subtract(center).subtract(mesh.position).negate();
  110262. this._tmpPosition.copyFromFloats(translation.x, translation.y - boundingInfo.boundingBox.extendSizeWorld.y, translation.z);
  110263. //add it inverted to the delta
  110264. this._tmpDeltaPosition.copyFrom(boundingInfo.boundingBox.centerWorld.subtract(c));
  110265. this._tmpDeltaPosition.y += boundingInfo.boundingBox.extendSizeWorld.y;
  110266. //rotation is back
  110267. mesh.rotationQuaternion = rotationQuaternion;
  110268. mesh.setPreTransformMatrix(oldPivot);
  110269. mesh.computeWorldMatrix(true);
  110270. }
  110271. else if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor) {
  110272. this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
  110273. //this._tmpPosition.copyFrom(object.position);
  110274. }
  110275. impostor.setDeltaPosition(this._tmpDeltaPosition);
  110276. //Now update the impostor object
  110277. impostor.physicsBody.position.copy(this._tmpPosition);
  110278. impostor.physicsBody.quaternion.copy(quaternion);
  110279. };
  110280. CannonJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  110281. impostor.object.position.copyFrom(impostor.physicsBody.position);
  110282. if (impostor.object.rotationQuaternion) {
  110283. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.quaternion);
  110284. }
  110285. };
  110286. CannonJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  110287. impostor.physicsBody.position.copy(newPosition);
  110288. impostor.physicsBody.quaternion.copy(newRotation);
  110289. };
  110290. CannonJSPlugin.prototype.isSupported = function () {
  110291. return this.BJSCANNON !== undefined;
  110292. };
  110293. CannonJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  110294. impostor.physicsBody.velocity.copy(velocity);
  110295. };
  110296. CannonJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  110297. impostor.physicsBody.angularVelocity.copy(velocity);
  110298. };
  110299. CannonJSPlugin.prototype.getLinearVelocity = function (impostor) {
  110300. var v = impostor.physicsBody.velocity;
  110301. if (!v) {
  110302. return null;
  110303. }
  110304. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  110305. };
  110306. CannonJSPlugin.prototype.getAngularVelocity = function (impostor) {
  110307. var v = impostor.physicsBody.angularVelocity;
  110308. if (!v) {
  110309. return null;
  110310. }
  110311. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  110312. };
  110313. CannonJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  110314. impostor.physicsBody.mass = mass;
  110315. impostor.physicsBody.updateMassProperties();
  110316. };
  110317. CannonJSPlugin.prototype.getBodyMass = function (impostor) {
  110318. return impostor.physicsBody.mass;
  110319. };
  110320. CannonJSPlugin.prototype.getBodyFriction = function (impostor) {
  110321. return impostor.physicsBody.material.friction;
  110322. };
  110323. CannonJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  110324. impostor.physicsBody.material.friction = friction;
  110325. };
  110326. CannonJSPlugin.prototype.getBodyRestitution = function (impostor) {
  110327. return impostor.physicsBody.material.restitution;
  110328. };
  110329. CannonJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  110330. impostor.physicsBody.material.restitution = restitution;
  110331. };
  110332. CannonJSPlugin.prototype.sleepBody = function (impostor) {
  110333. impostor.physicsBody.sleep();
  110334. };
  110335. CannonJSPlugin.prototype.wakeUpBody = function (impostor) {
  110336. impostor.physicsBody.wakeUp();
  110337. };
  110338. CannonJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance) {
  110339. joint.physicsJoint.distance = maxDistance;
  110340. };
  110341. // private enableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  110342. // if (!motorIndex) {
  110343. // joint.physicsJoint.enableMotor();
  110344. // }
  110345. // }
  110346. // private disableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  110347. // if (!motorIndex) {
  110348. // joint.physicsJoint.disableMotor();
  110349. // }
  110350. // }
  110351. CannonJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  110352. if (!motorIndex) {
  110353. joint.physicsJoint.enableMotor();
  110354. joint.physicsJoint.setMotorSpeed(speed);
  110355. if (maxForce) {
  110356. this.setLimit(joint, maxForce);
  110357. }
  110358. }
  110359. };
  110360. CannonJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  110361. joint.physicsJoint.motorEquation.maxForce = upperLimit;
  110362. joint.physicsJoint.motorEquation.minForce = lowerLimit === void 0 ? -upperLimit : lowerLimit;
  110363. };
  110364. CannonJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  110365. var body = impostor.physicsBody;
  110366. mesh.position.x = body.position.x;
  110367. mesh.position.y = body.position.y;
  110368. mesh.position.z = body.position.z;
  110369. if (mesh.rotationQuaternion) {
  110370. mesh.rotationQuaternion.x = body.quaternion.x;
  110371. mesh.rotationQuaternion.y = body.quaternion.y;
  110372. mesh.rotationQuaternion.z = body.quaternion.z;
  110373. mesh.rotationQuaternion.w = body.quaternion.w;
  110374. }
  110375. };
  110376. CannonJSPlugin.prototype.getRadius = function (impostor) {
  110377. var shape = impostor.physicsBody.shapes[0];
  110378. return shape.boundingSphereRadius;
  110379. };
  110380. CannonJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  110381. var shape = impostor.physicsBody.shapes[0];
  110382. result.x = shape.halfExtents.x * 2;
  110383. result.y = shape.halfExtents.y * 2;
  110384. result.z = shape.halfExtents.z * 2;
  110385. };
  110386. CannonJSPlugin.prototype.dispose = function () {
  110387. };
  110388. CannonJSPlugin.prototype._extendNamespace = function () {
  110389. //this will force cannon to execute at least one step when using interpolation
  110390. var step_tmp1 = new this.BJSCANNON.Vec3();
  110391. var Engine = this.BJSCANNON;
  110392. this.BJSCANNON.World.prototype.step = function (dt, timeSinceLastCalled, maxSubSteps) {
  110393. maxSubSteps = maxSubSteps || 10;
  110394. timeSinceLastCalled = timeSinceLastCalled || 0;
  110395. if (timeSinceLastCalled === 0) {
  110396. this.internalStep(dt);
  110397. this.time += dt;
  110398. }
  110399. else {
  110400. var internalSteps = Math.floor((this.time + timeSinceLastCalled) / dt) - Math.floor(this.time / dt);
  110401. internalSteps = Math.min(internalSteps, maxSubSteps) || 1;
  110402. var t0 = performance.now();
  110403. for (var i = 0; i !== internalSteps; i++) {
  110404. this.internalStep(dt);
  110405. if (performance.now() - t0 > dt * 1000) {
  110406. break;
  110407. }
  110408. }
  110409. this.time += timeSinceLastCalled;
  110410. var h = this.time % dt;
  110411. var h_div_dt = h / dt;
  110412. var interpvelo = step_tmp1;
  110413. var bodies = this.bodies;
  110414. for (var j = 0; j !== bodies.length; j++) {
  110415. var b = bodies[j];
  110416. if (b.type !== Engine.Body.STATIC && b.sleepState !== Engine.Body.SLEEPING) {
  110417. b.position.vsub(b.previousPosition, interpvelo);
  110418. interpvelo.scale(h_div_dt, interpvelo);
  110419. b.position.vadd(interpvelo, b.interpolatedPosition);
  110420. }
  110421. else {
  110422. b.interpolatedPosition.copy(b.position);
  110423. b.interpolatedQuaternion.copy(b.quaternion);
  110424. }
  110425. }
  110426. }
  110427. };
  110428. };
  110429. return CannonJSPlugin;
  110430. }());
  110431. _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].DefaultPluginFactory = function () { return new CannonJSPlugin(); };
  110432. /***/ }),
  110433. /***/ "./Physics/Plugins/index.ts":
  110434. /*!**********************************!*\
  110435. !*** ./Physics/Plugins/index.ts ***!
  110436. \**********************************/
  110437. /*! exports provided: CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  110438. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110439. "use strict";
  110440. __webpack_require__.r(__webpack_exports__);
  110441. /* harmony import */ var _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  110442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  110443. /* harmony import */ var _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ammoJSPlugin */ "./Physics/Plugins/ammoJSPlugin.ts");
  110444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__["AmmoJSPlugin"]; });
  110445. /* harmony import */ var _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  110446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__["OimoJSPlugin"]; });
  110447. /***/ }),
  110448. /***/ "./Physics/Plugins/oimoJSPlugin.ts":
  110449. /*!*****************************************!*\
  110450. !*** ./Physics/Plugins/oimoJSPlugin.ts ***!
  110451. \*****************************************/
  110452. /*! exports provided: OimoJSPlugin */
  110453. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110454. "use strict";
  110455. __webpack_require__.r(__webpack_exports__);
  110456. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return OimoJSPlugin; });
  110457. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  110458. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  110459. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  110460. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  110461. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  110462. /** @hidden */
  110463. var OimoJSPlugin = /** @class */ (function () {
  110464. function OimoJSPlugin(iterations, oimoInjection) {
  110465. if (oimoInjection === void 0) { oimoInjection = OIMO; }
  110466. this.name = "OimoJSPlugin";
  110467. this._tmpImpostorsArray = [];
  110468. this._tmpPositionVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  110469. this.BJSOIMO = oimoInjection;
  110470. this.world = new this.BJSOIMO.World({
  110471. iterations: iterations
  110472. });
  110473. this.world.clear();
  110474. }
  110475. OimoJSPlugin.prototype.setGravity = function (gravity) {
  110476. this.world.gravity.copy(gravity);
  110477. };
  110478. OimoJSPlugin.prototype.setTimeStep = function (timeStep) {
  110479. this.world.timeStep = timeStep;
  110480. };
  110481. OimoJSPlugin.prototype.getTimeStep = function () {
  110482. return this.world.timeStep;
  110483. };
  110484. OimoJSPlugin.prototype.executeStep = function (delta, impostors) {
  110485. var _this = this;
  110486. impostors.forEach(function (impostor) {
  110487. impostor.beforeStep();
  110488. });
  110489. this.world.step();
  110490. impostors.forEach(function (impostor) {
  110491. impostor.afterStep();
  110492. //update the ordered impostors array
  110493. _this._tmpImpostorsArray[impostor.uniqueId] = impostor;
  110494. });
  110495. //check for collisions
  110496. var contact = this.world.contacts;
  110497. while (contact !== null) {
  110498. if (contact.touching && !contact.body1.sleeping && !contact.body2.sleeping) {
  110499. contact = contact.next;
  110500. continue;
  110501. }
  110502. //is this body colliding with any other? get the impostor
  110503. var mainImpostor = this._tmpImpostorsArray[+contact.body1.name];
  110504. var collidingImpostor = this._tmpImpostorsArray[+contact.body2.name];
  110505. if (!mainImpostor || !collidingImpostor) {
  110506. contact = contact.next;
  110507. continue;
  110508. }
  110509. mainImpostor.onCollide({ body: collidingImpostor.physicsBody });
  110510. collidingImpostor.onCollide({ body: mainImpostor.physicsBody });
  110511. contact = contact.next;
  110512. }
  110513. };
  110514. OimoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  110515. var mass = impostor.physicsBody.mass;
  110516. impostor.physicsBody.applyImpulse(contactPoint.scale(this.world.invScale), force.scale(this.world.invScale * mass));
  110517. };
  110518. OimoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  110519. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("Oimo doesn't support applying force. Using impule instead.");
  110520. this.applyImpulse(impostor, force, contactPoint);
  110521. };
  110522. OimoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  110523. var _this = this;
  110524. //parent-child relationship. Does this impostor has a parent impostor?
  110525. if (impostor.parent) {
  110526. if (impostor.physicsBody) {
  110527. this.removePhysicsBody(impostor);
  110528. //TODO is that needed?
  110529. impostor.forceUpdate();
  110530. }
  110531. return;
  110532. }
  110533. if (impostor.isBodyInitRequired()) {
  110534. var bodyConfig = {
  110535. name: impostor.uniqueId,
  110536. //Oimo must have mass, also for static objects.
  110537. config: [impostor.getParam("mass") || 1, impostor.getParam("friction"), impostor.getParam("restitution")],
  110538. size: [],
  110539. type: [],
  110540. pos: [],
  110541. posShape: [],
  110542. rot: [],
  110543. rotShape: [],
  110544. move: impostor.getParam("mass") !== 0,
  110545. density: impostor.getParam("mass"),
  110546. friction: impostor.getParam("friction"),
  110547. restitution: impostor.getParam("restitution"),
  110548. //Supporting older versions of Oimo
  110549. world: this.world
  110550. };
  110551. var impostors = [impostor];
  110552. var addToArray = function (parent) {
  110553. if (!parent.getChildMeshes) {
  110554. return;
  110555. }
  110556. parent.getChildMeshes().forEach(function (m) {
  110557. if (m.physicsImpostor) {
  110558. impostors.push(m.physicsImpostor);
  110559. //m.physicsImpostor._init();
  110560. }
  110561. });
  110562. };
  110563. addToArray(impostor.object);
  110564. var checkWithEpsilon_1 = function (value) {
  110565. return Math.max(value, _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__["PhysicsEngine"].Epsilon);
  110566. };
  110567. var globalQuaternion_1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  110568. impostors.forEach(function (i) {
  110569. if (!i.object.rotationQuaternion) {
  110570. return;
  110571. }
  110572. //get the correct bounding box
  110573. var oldQuaternion = i.object.rotationQuaternion;
  110574. globalQuaternion_1 = oldQuaternion.clone();
  110575. var rot = oldQuaternion.toEulerAngles();
  110576. var extendSize = i.getObjectExtendSize();
  110577. var radToDeg = 57.295779513082320876;
  110578. if (i === impostor) {
  110579. var center = impostor.getObjectCenter();
  110580. impostor.object.getAbsolutePivotPoint().subtractToRef(center, _this._tmpPositionVector);
  110581. _this._tmpPositionVector.divideInPlace(impostor.object.scaling);
  110582. //Can also use Array.prototype.push.apply
  110583. bodyConfig.pos.push(center.x);
  110584. bodyConfig.pos.push(center.y);
  110585. bodyConfig.pos.push(center.z);
  110586. bodyConfig.posShape.push(0, 0, 0);
  110587. bodyConfig.rotShape.push(0, 0, 0);
  110588. }
  110589. else {
  110590. var localPosition = i.object.getAbsolutePosition().subtract(impostor.object.getAbsolutePosition());
  110591. bodyConfig.posShape.push(localPosition.x);
  110592. bodyConfig.posShape.push(localPosition.y);
  110593. bodyConfig.posShape.push(localPosition.z);
  110594. bodyConfig.pos.push(0, 0, 0);
  110595. bodyConfig.rotShape.push(rot.x * radToDeg);
  110596. bodyConfig.rotShape.push(rot.y * radToDeg);
  110597. bodyConfig.rotShape.push(rot.z * radToDeg);
  110598. }
  110599. // register mesh
  110600. switch (i.type) {
  110601. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].ParticleImpostor:
  110602. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("No Particle support in OIMO.js. using SphereImpostor instead");
  110603. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].SphereImpostor:
  110604. var radiusX = extendSize.x;
  110605. var radiusY = extendSize.y;
  110606. var radiusZ = extendSize.z;
  110607. var size = Math.max(checkWithEpsilon_1(radiusX), checkWithEpsilon_1(radiusY), checkWithEpsilon_1(radiusZ)) / 2;
  110608. bodyConfig.type.push('sphere');
  110609. //due to the way oimo works with compounds, add 3 times
  110610. bodyConfig.size.push(size);
  110611. bodyConfig.size.push(size);
  110612. bodyConfig.size.push(size);
  110613. break;
  110614. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].CylinderImpostor:
  110615. var sizeX = checkWithEpsilon_1(extendSize.x) / 2;
  110616. var sizeY = checkWithEpsilon_1(extendSize.y);
  110617. bodyConfig.type.push('cylinder');
  110618. bodyConfig.size.push(sizeX);
  110619. bodyConfig.size.push(sizeY);
  110620. //due to the way oimo works with compounds, add one more value.
  110621. bodyConfig.size.push(sizeY);
  110622. break;
  110623. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].PlaneImpostor:
  110624. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].BoxImpostor:
  110625. default:
  110626. var sizeX = checkWithEpsilon_1(extendSize.x);
  110627. var sizeY = checkWithEpsilon_1(extendSize.y);
  110628. var sizeZ = checkWithEpsilon_1(extendSize.z);
  110629. bodyConfig.type.push('box');
  110630. //if (i === impostor) {
  110631. bodyConfig.size.push(sizeX);
  110632. bodyConfig.size.push(sizeY);
  110633. bodyConfig.size.push(sizeZ);
  110634. //} else {
  110635. // bodyConfig.size.push(0,0,0);
  110636. //}
  110637. break;
  110638. }
  110639. //actually not needed, but hey...
  110640. i.object.rotationQuaternion = oldQuaternion;
  110641. });
  110642. impostor.physicsBody = this.world.add(bodyConfig);
  110643. // set the quaternion, ignoring the previously defined (euler) rotation
  110644. impostor.physicsBody.resetQuaternion(globalQuaternion_1);
  110645. // update with delta 0, so the body will reveive the new rotation.
  110646. impostor.physicsBody.updatePosition(0);
  110647. }
  110648. else {
  110649. this._tmpPositionVector.copyFromFloats(0, 0, 0);
  110650. }
  110651. impostor.setDeltaPosition(this._tmpPositionVector);
  110652. //this._tmpPositionVector.addInPlace(impostor.mesh.getBoundingInfo().boundingBox.center);
  110653. //this.setPhysicsBodyTransformation(impostor, this._tmpPositionVector, impostor.mesh.rotationQuaternion);
  110654. };
  110655. OimoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  110656. //impostor.physicsBody.dispose();
  110657. //Same as : (older oimo versions)
  110658. this.world.removeRigidBody(impostor.physicsBody);
  110659. };
  110660. OimoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  110661. var mainBody = impostorJoint.mainImpostor.physicsBody;
  110662. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  110663. if (!mainBody || !connectedBody) {
  110664. return;
  110665. }
  110666. var jointData = impostorJoint.joint.jointData;
  110667. var options = jointData.nativeParams || {};
  110668. var type;
  110669. var nativeJointData = {
  110670. body1: mainBody,
  110671. body2: connectedBody,
  110672. axe1: options.axe1 || (jointData.mainAxis ? jointData.mainAxis.asArray() : null),
  110673. axe2: options.axe2 || (jointData.connectedAxis ? jointData.connectedAxis.asArray() : null),
  110674. pos1: options.pos1 || (jointData.mainPivot ? jointData.mainPivot.asArray() : null),
  110675. pos2: options.pos2 || (jointData.connectedPivot ? jointData.connectedPivot.asArray() : null),
  110676. min: options.min,
  110677. max: options.max,
  110678. collision: options.collision || jointData.collision,
  110679. spring: options.spring,
  110680. //supporting older version of Oimo
  110681. world: this.world
  110682. };
  110683. switch (impostorJoint.joint.type) {
  110684. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].BallAndSocketJoint:
  110685. type = "jointBall";
  110686. break;
  110687. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SpringJoint:
  110688. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
  110689. var springData = jointData;
  110690. nativeJointData.min = springData.length || nativeJointData.min;
  110691. //Max should also be set, just make sure it is at least min
  110692. nativeJointData.max = Math.max(nativeJointData.min, nativeJointData.max);
  110693. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].DistanceJoint:
  110694. type = "jointDistance";
  110695. nativeJointData.max = jointData.maxDistance;
  110696. break;
  110697. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].PrismaticJoint:
  110698. type = "jointPrisme";
  110699. break;
  110700. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SliderJoint:
  110701. type = "jointSlide";
  110702. break;
  110703. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].WheelJoint:
  110704. type = "jointWheel";
  110705. break;
  110706. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].HingeJoint:
  110707. default:
  110708. type = "jointHinge";
  110709. break;
  110710. }
  110711. nativeJointData.type = type;
  110712. impostorJoint.joint.physicsJoint = this.world.add(nativeJointData);
  110713. };
  110714. OimoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  110715. //Bug in Oimo prevents us from disposing a joint in the playground
  110716. //joint.joint.physicsJoint.dispose();
  110717. //So we will bruteforce it!
  110718. try {
  110719. this.world.removeJoint(impostorJoint.joint.physicsJoint);
  110720. }
  110721. catch (e) {
  110722. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn(e);
  110723. }
  110724. };
  110725. OimoJSPlugin.prototype.isSupported = function () {
  110726. return this.BJSOIMO !== undefined;
  110727. };
  110728. OimoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  110729. if (!impostor.physicsBody.sleeping) {
  110730. //TODO check that
  110731. /*if (impostor.physicsBody.shapes.next) {
  110732. var parentShape = this._getLastShape(impostor.physicsBody);
  110733. impostor.object.position.copyFrom(parentShape.position);
  110734. console.log(parentShape.position);
  110735. } else {*/
  110736. impostor.object.position.copyFrom(impostor.physicsBody.getPosition());
  110737. //}
  110738. if (impostor.object.rotationQuaternion) {
  110739. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.getQuaternion());
  110740. }
  110741. }
  110742. };
  110743. OimoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  110744. var body = impostor.physicsBody;
  110745. body.position.copy(newPosition);
  110746. body.orientation.copy(newRotation);
  110747. body.syncShapes();
  110748. body.awake();
  110749. };
  110750. /*private _getLastShape(body: any): any {
  110751. var lastShape = body.shapes;
  110752. while (lastShape.next) {
  110753. lastShape = lastShape.next;
  110754. }
  110755. return lastShape;
  110756. }*/
  110757. OimoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  110758. impostor.physicsBody.linearVelocity.copy(velocity);
  110759. };
  110760. OimoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  110761. impostor.physicsBody.angularVelocity.copy(velocity);
  110762. };
  110763. OimoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  110764. var v = impostor.physicsBody.linearVelocity;
  110765. if (!v) {
  110766. return null;
  110767. }
  110768. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  110769. };
  110770. OimoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  110771. var v = impostor.physicsBody.angularVelocity;
  110772. if (!v) {
  110773. return null;
  110774. }
  110775. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  110776. };
  110777. OimoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  110778. var staticBody = mass === 0;
  110779. //this will actually set the body's density and not its mass.
  110780. //But this is how oimo treats the mass variable.
  110781. impostor.physicsBody.shapes.density = staticBody ? 1 : mass;
  110782. impostor.physicsBody.setupMass(staticBody ? 0x2 : 0x1);
  110783. };
  110784. OimoJSPlugin.prototype.getBodyMass = function (impostor) {
  110785. return impostor.physicsBody.shapes.density;
  110786. };
  110787. OimoJSPlugin.prototype.getBodyFriction = function (impostor) {
  110788. return impostor.physicsBody.shapes.friction;
  110789. };
  110790. OimoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  110791. impostor.physicsBody.shapes.friction = friction;
  110792. };
  110793. OimoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  110794. return impostor.physicsBody.shapes.restitution;
  110795. };
  110796. OimoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  110797. impostor.physicsBody.shapes.restitution = restitution;
  110798. };
  110799. OimoJSPlugin.prototype.sleepBody = function (impostor) {
  110800. impostor.physicsBody.sleep();
  110801. };
  110802. OimoJSPlugin.prototype.wakeUpBody = function (impostor) {
  110803. impostor.physicsBody.awake();
  110804. };
  110805. OimoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  110806. joint.physicsJoint.limitMotor.upperLimit = maxDistance;
  110807. if (minDistance !== void 0) {
  110808. joint.physicsJoint.limitMotor.lowerLimit = minDistance;
  110809. }
  110810. };
  110811. OimoJSPlugin.prototype.setMotor = function (joint, speed, force, motorIndex) {
  110812. if (force !== undefined) {
  110813. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter");
  110814. }
  110815. else {
  110816. force = 1e6;
  110817. }
  110818. speed *= -1;
  110819. //TODO separate rotational and transational motors.
  110820. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  110821. if (motor) {
  110822. motor.setMotor(speed, force);
  110823. }
  110824. };
  110825. OimoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit, motorIndex) {
  110826. //TODO separate rotational and transational motors.
  110827. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  110828. if (motor) {
  110829. motor.setLimit(upperLimit, lowerLimit === void 0 ? -upperLimit : lowerLimit);
  110830. }
  110831. };
  110832. OimoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  110833. var body = impostor.physicsBody;
  110834. mesh.position.x = body.position.x;
  110835. mesh.position.y = body.position.y;
  110836. mesh.position.z = body.position.z;
  110837. if (mesh.rotationQuaternion) {
  110838. mesh.rotationQuaternion.x = body.orientation.x;
  110839. mesh.rotationQuaternion.y = body.orientation.y;
  110840. mesh.rotationQuaternion.z = body.orientation.z;
  110841. mesh.rotationQuaternion.w = body.orientation.s;
  110842. }
  110843. };
  110844. OimoJSPlugin.prototype.getRadius = function (impostor) {
  110845. return impostor.physicsBody.shapes.radius;
  110846. };
  110847. OimoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  110848. var shape = impostor.physicsBody.shapes;
  110849. result.x = shape.halfWidth * 2;
  110850. result.y = shape.halfHeight * 2;
  110851. result.z = shape.halfDepth * 2;
  110852. };
  110853. OimoJSPlugin.prototype.dispose = function () {
  110854. this.world.clear();
  110855. };
  110856. return OimoJSPlugin;
  110857. }());
  110858. /***/ }),
  110859. /***/ "./Physics/index.ts":
  110860. /*!**************************!*\
  110861. !*** ./Physics/index.ts ***!
  110862. \**************************/
  110863. /*! exports provided: PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  110864. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110865. "use strict";
  110866. __webpack_require__.r(__webpack_exports__);
  110867. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  110868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _physicsEngine__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  110869. /* harmony import */ var _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./physicsEngineComponent */ "./Physics/physicsEngineComponent.ts");
  110870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__["PhysicsEngineSceneComponent"]; });
  110871. /* harmony import */ var _physicsHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./physicsHelper */ "./Physics/physicsHelper.ts");
  110872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsHelper"]; });
  110873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialExplosionEvent"]; });
  110874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsGravitationalFieldEvent"]; });
  110875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftEvent"]; });
  110876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsVortexEvent"]; });
  110877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialImpulseFalloff"]; });
  110878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftMode"]; });
  110879. /* harmony import */ var _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsImpostor */ "./Physics/physicsImpostor.ts");
  110880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"]; });
  110881. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  110882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"]; });
  110883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["DistanceJoint"]; });
  110884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["MotorEnabledJoint"]; });
  110885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["HingeJoint"]; });
  110886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["Hinge2Joint"]; });
  110887. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Plugins/index */ "./Physics/Plugins/index.ts");
  110888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["CannonJSPlugin"]; });
  110889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["AmmoJSPlugin"]; });
  110890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["OimoJSPlugin"]; });
  110891. /***/ }),
  110892. /***/ "./Physics/physicsEngine.ts":
  110893. /*!**********************************!*\
  110894. !*** ./Physics/physicsEngine.ts ***!
  110895. \**********************************/
  110896. /*! exports provided: PhysicsEngine */
  110897. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110898. "use strict";
  110899. __webpack_require__.r(__webpack_exports__);
  110900. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return PhysicsEngine; });
  110901. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  110902. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  110903. /**
  110904. * Class used to control physics engine
  110905. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  110906. */
  110907. var PhysicsEngine = /** @class */ (function () {
  110908. /**
  110909. * Creates a new Physics Engine
  110910. * @param gravity defines the gravity vector used by the simulation
  110911. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  110912. */
  110913. function PhysicsEngine(gravity, _physicsPlugin) {
  110914. if (_physicsPlugin === void 0) { _physicsPlugin = PhysicsEngine.DefaultPluginFactory(); }
  110915. this._physicsPlugin = _physicsPlugin;
  110916. this._impostors = [];
  110917. this._joints = [];
  110918. if (!this._physicsPlugin.isSupported()) {
  110919. throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. "
  110920. + "Please make sure it is included.");
  110921. }
  110922. gravity = gravity || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -9.807, 0);
  110923. this.setGravity(gravity);
  110924. this.setTimeStep();
  110925. }
  110926. /**
  110927. * Factory used to create the default physics plugin.
  110928. * @returns The default physics plugin
  110929. */
  110930. PhysicsEngine.DefaultPluginFactory = function () {
  110931. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__["_DevTools"].WarnImport("CannonJSPlugin");
  110932. };
  110933. /**
  110934. * Sets the gravity vector used by the simulation
  110935. * @param gravity defines the gravity vector to use
  110936. */
  110937. PhysicsEngine.prototype.setGravity = function (gravity) {
  110938. this.gravity = gravity;
  110939. this._physicsPlugin.setGravity(this.gravity);
  110940. };
  110941. /**
  110942. * Set the time step of the physics engine.
  110943. * Default is 1/60.
  110944. * To slow it down, enter 1/600 for example.
  110945. * To speed it up, 1/30
  110946. * @param newTimeStep defines the new timestep to apply to this world.
  110947. */
  110948. PhysicsEngine.prototype.setTimeStep = function (newTimeStep) {
  110949. if (newTimeStep === void 0) { newTimeStep = 1 / 60; }
  110950. this._physicsPlugin.setTimeStep(newTimeStep);
  110951. };
  110952. /**
  110953. * Get the time step of the physics engine.
  110954. * @returns the current time step
  110955. */
  110956. PhysicsEngine.prototype.getTimeStep = function () {
  110957. return this._physicsPlugin.getTimeStep();
  110958. };
  110959. /**
  110960. * Release all resources
  110961. */
  110962. PhysicsEngine.prototype.dispose = function () {
  110963. this._impostors.forEach(function (impostor) {
  110964. impostor.dispose();
  110965. });
  110966. this._physicsPlugin.dispose();
  110967. };
  110968. /**
  110969. * Gets the name of the current physics plugin
  110970. * @returns the name of the plugin
  110971. */
  110972. PhysicsEngine.prototype.getPhysicsPluginName = function () {
  110973. return this._physicsPlugin.name;
  110974. };
  110975. /**
  110976. * Adding a new impostor for the impostor tracking.
  110977. * This will be done by the impostor itself.
  110978. * @param impostor the impostor to add
  110979. */
  110980. PhysicsEngine.prototype.addImpostor = function (impostor) {
  110981. impostor.uniqueId = this._impostors.push(impostor);
  110982. //if no parent, generate the body
  110983. if (!impostor.parent) {
  110984. this._physicsPlugin.generatePhysicsBody(impostor);
  110985. }
  110986. };
  110987. /**
  110988. * Remove an impostor from the engine.
  110989. * This impostor and its mesh will not longer be updated by the physics engine.
  110990. * @param impostor the impostor to remove
  110991. */
  110992. PhysicsEngine.prototype.removeImpostor = function (impostor) {
  110993. var index = this._impostors.indexOf(impostor);
  110994. if (index > -1) {
  110995. var removed = this._impostors.splice(index, 1);
  110996. //Is it needed?
  110997. if (removed.length) {
  110998. //this will also remove it from the world.
  110999. removed[0].physicsBody = null;
  111000. }
  111001. }
  111002. };
  111003. /**
  111004. * Add a joint to the physics engine
  111005. * @param mainImpostor defines the main impostor to which the joint is added.
  111006. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  111007. * @param joint defines the joint that will connect both impostors.
  111008. */
  111009. PhysicsEngine.prototype.addJoint = function (mainImpostor, connectedImpostor, joint) {
  111010. var impostorJoint = {
  111011. mainImpostor: mainImpostor,
  111012. connectedImpostor: connectedImpostor,
  111013. joint: joint
  111014. };
  111015. joint.physicsPlugin = this._physicsPlugin;
  111016. this._joints.push(impostorJoint);
  111017. this._physicsPlugin.generateJoint(impostorJoint);
  111018. };
  111019. /**
  111020. * Removes a joint from the simulation
  111021. * @param mainImpostor defines the impostor used with the joint
  111022. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  111023. * @param joint defines the joint to remove
  111024. */
  111025. PhysicsEngine.prototype.removeJoint = function (mainImpostor, connectedImpostor, joint) {
  111026. var matchingJoints = this._joints.filter(function (impostorJoint) {
  111027. return (impostorJoint.connectedImpostor === connectedImpostor
  111028. && impostorJoint.joint === joint
  111029. && impostorJoint.mainImpostor === mainImpostor);
  111030. });
  111031. if (matchingJoints.length) {
  111032. this._physicsPlugin.removeJoint(matchingJoints[0]);
  111033. //TODO remove it from the list as well
  111034. }
  111035. };
  111036. /**
  111037. * Called by the scene. No need to call it.
  111038. * @param delta defines the timespam between frames
  111039. */
  111040. PhysicsEngine.prototype._step = function (delta) {
  111041. var _this = this;
  111042. //check if any mesh has no body / requires an update
  111043. this._impostors.forEach(function (impostor) {
  111044. if (impostor.isBodyInitRequired()) {
  111045. _this._physicsPlugin.generatePhysicsBody(impostor);
  111046. }
  111047. });
  111048. if (delta > 0.1) {
  111049. delta = 0.1;
  111050. }
  111051. else if (delta <= 0) {
  111052. delta = 1.0 / 60.0;
  111053. }
  111054. this._physicsPlugin.executeStep(delta, this._impostors);
  111055. };
  111056. /**
  111057. * Gets the current plugin used to run the simulation
  111058. * @returns current plugin
  111059. */
  111060. PhysicsEngine.prototype.getPhysicsPlugin = function () {
  111061. return this._physicsPlugin;
  111062. };
  111063. /**
  111064. * Gets the list of physic impostors
  111065. * @returns an array of PhysicsImpostor
  111066. */
  111067. PhysicsEngine.prototype.getImpostors = function () {
  111068. return this._impostors;
  111069. };
  111070. /**
  111071. * Gets the impostor for a physics enabled object
  111072. * @param object defines the object impersonated by the impostor
  111073. * @returns the PhysicsImpostor or null if not found
  111074. */
  111075. PhysicsEngine.prototype.getImpostorForPhysicsObject = function (object) {
  111076. for (var i = 0; i < this._impostors.length; ++i) {
  111077. if (this._impostors[i].object === object) {
  111078. return this._impostors[i];
  111079. }
  111080. }
  111081. return null;
  111082. };
  111083. /**
  111084. * Gets the impostor for a physics body object
  111085. * @param body defines physics body used by the impostor
  111086. * @returns the PhysicsImpostor or null if not found
  111087. */
  111088. PhysicsEngine.prototype.getImpostorWithPhysicsBody = function (body) {
  111089. for (var i = 0; i < this._impostors.length; ++i) {
  111090. if (this._impostors[i].physicsBody === body) {
  111091. return this._impostors[i];
  111092. }
  111093. }
  111094. return null;
  111095. };
  111096. /**
  111097. * Global value used to control the smallest number supported by the simulation
  111098. */
  111099. PhysicsEngine.Epsilon = 0.001;
  111100. return PhysicsEngine;
  111101. }());
  111102. /***/ }),
  111103. /***/ "./Physics/physicsEngineComponent.ts":
  111104. /*!*******************************************!*\
  111105. !*** ./Physics/physicsEngineComponent.ts ***!
  111106. \*******************************************/
  111107. /*! exports provided: PhysicsEngineSceneComponent */
  111108. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111109. "use strict";
  111110. __webpack_require__.r(__webpack_exports__);
  111111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return PhysicsEngineSceneComponent; });
  111112. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  111113. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  111114. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  111115. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  111116. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  111117. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  111118. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  111119. /**
  111120. * Gets the current physics engine
  111121. * @returns a IPhysicsEngine or null if none attached
  111122. */
  111123. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.getPhysicsEngine = function () {
  111124. return this._physicsEngine;
  111125. };
  111126. /**
  111127. * Enables physics to the current scene
  111128. * @param gravity defines the scene's gravity for the physics engine
  111129. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  111130. * @return a boolean indicating if the physics engine was initialized
  111131. */
  111132. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.enablePhysics = function (gravity, plugin) {
  111133. if (gravity === void 0) { gravity = null; }
  111134. if (this._physicsEngine) {
  111135. return true;
  111136. }
  111137. // Register the component to the scene
  111138. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE);
  111139. if (!component) {
  111140. component = new PhysicsEngineSceneComponent(this);
  111141. this._addComponent(component);
  111142. }
  111143. try {
  111144. this._physicsEngine = new _physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"](gravity, plugin);
  111145. return true;
  111146. }
  111147. catch (e) {
  111148. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error(e.message);
  111149. return false;
  111150. }
  111151. };
  111152. /**
  111153. * Disables and disposes the physics engine associated with the scene
  111154. */
  111155. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.disablePhysicsEngine = function () {
  111156. if (!this._physicsEngine) {
  111157. return;
  111158. }
  111159. this._physicsEngine.dispose();
  111160. this._physicsEngine = null;
  111161. };
  111162. /**
  111163. * Gets a boolean indicating if there is an active physics engine
  111164. * @returns a boolean indicating if there is an active physics engine
  111165. */
  111166. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.isPhysicsEnabled = function () {
  111167. return this._physicsEngine !== undefined;
  111168. };
  111169. /**
  111170. * Deletes a physics compound impostor
  111171. * @param compound defines the compound to delete
  111172. */
  111173. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.deleteCompoundImpostor = function (compound) {
  111174. var mesh = compound.parts[0].mesh;
  111175. if (mesh.physicsImpostor) {
  111176. mesh.physicsImpostor.dispose( /*true*/);
  111177. mesh.physicsImpostor = null;
  111178. }
  111179. };
  111180. /** @hidden */
  111181. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._advancePhysicsEngineStep = function (step) {
  111182. if (this._physicsEngine) {
  111183. this.onBeforePhysicsObservable.notifyObservers(this);
  111184. this._physicsEngine._step(step / 1000);
  111185. this.onAfterPhysicsObservable.notifyObservers(this);
  111186. }
  111187. };
  111188. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "physicsImpostor", {
  111189. get: function () {
  111190. return this._physicsImpostor;
  111191. },
  111192. set: function (value) {
  111193. var _this = this;
  111194. if (this._physicsImpostor === value) {
  111195. return;
  111196. }
  111197. if (this._disposePhysicsObserver) {
  111198. this.onDisposeObservable.remove(this._disposePhysicsObserver);
  111199. }
  111200. this._physicsImpostor = value;
  111201. if (value) {
  111202. this._disposePhysicsObserver = this.onDisposeObservable.add(function () {
  111203. // Physics
  111204. if (_this.physicsImpostor) {
  111205. _this.physicsImpostor.dispose( /*!doNotRecurse*/);
  111206. _this.physicsImpostor = null;
  111207. }
  111208. });
  111209. }
  111210. },
  111211. enumerable: true,
  111212. configurable: true
  111213. });
  111214. /**
  111215. * Gets the current physics impostor
  111216. * @see http://doc.babylonjs.com/features/physics_engine
  111217. * @returns a physics impostor or null
  111218. */
  111219. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.getPhysicsImpostor = function () {
  111220. return this.physicsImpostor;
  111221. };
  111222. /**
  111223. * Apply a physic impulse to the mesh
  111224. * @param force defines the force to apply
  111225. * @param contactPoint defines where to apply the force
  111226. * @returns the current mesh
  111227. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111228. */
  111229. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.applyImpulse = function (force, contactPoint) {
  111230. if (!this.physicsImpostor) {
  111231. return this;
  111232. }
  111233. this.physicsImpostor.applyImpulse(force, contactPoint);
  111234. return this;
  111235. };
  111236. /**
  111237. * Creates a physic joint between two meshes
  111238. * @param otherMesh defines the other mesh to use
  111239. * @param pivot1 defines the pivot to use on this mesh
  111240. * @param pivot2 defines the pivot to use on the other mesh
  111241. * @param options defines additional options (can be plugin dependent)
  111242. * @returns the current mesh
  111243. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  111244. */
  111245. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.setPhysicsLinkWith = function (otherMesh, pivot1, pivot2, options) {
  111246. if (!this.physicsImpostor || !otherMesh.physicsImpostor) {
  111247. return this;
  111248. }
  111249. this.physicsImpostor.createJoint(otherMesh.physicsImpostor, _physicsJoint__WEBPACK_IMPORTED_MODULE_6__["PhysicsJoint"].HingeJoint, {
  111250. mainPivot: pivot1,
  111251. connectedPivot: pivot2,
  111252. nativeParams: options
  111253. });
  111254. return this;
  111255. };
  111256. /**
  111257. * Defines the physics engine scene component responsible to manage a physics engine
  111258. */
  111259. var PhysicsEngineSceneComponent = /** @class */ (function () {
  111260. /**
  111261. * Creates a new instance of the component for the given scene
  111262. * @param scene Defines the scene to register the component in
  111263. */
  111264. function PhysicsEngineSceneComponent(scene) {
  111265. var _this = this;
  111266. /**
  111267. * The component name helpful to identify the component in the list of scene components.
  111268. */
  111269. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE;
  111270. this.scene = scene;
  111271. this.scene.onBeforePhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  111272. this.scene.onAfterPhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  111273. // Replace the function used to get the deterministic frame time
  111274. this.scene.getDeterministicFrameTime = function () {
  111275. if (_this.scene._physicsEngine) {
  111276. return _this.scene._physicsEngine.getTimeStep() * 1000;
  111277. }
  111278. return 1000.0 / 60.0;
  111279. };
  111280. }
  111281. /**
  111282. * Registers the component in a given scene
  111283. */
  111284. PhysicsEngineSceneComponent.prototype.register = function () {
  111285. };
  111286. /**
  111287. * Rebuilds the elements related to this component in case of
  111288. * context lost for instance.
  111289. */
  111290. PhysicsEngineSceneComponent.prototype.rebuild = function () {
  111291. // Nothing to do for this component
  111292. };
  111293. /**
  111294. * Disposes the component and the associated ressources
  111295. */
  111296. PhysicsEngineSceneComponent.prototype.dispose = function () {
  111297. this.scene.onBeforePhysicsObservable.clear();
  111298. this.scene.onAfterPhysicsObservable.clear();
  111299. if (this.scene._physicsEngine) {
  111300. this.scene.disablePhysicsEngine();
  111301. }
  111302. };
  111303. return PhysicsEngineSceneComponent;
  111304. }());
  111305. /***/ }),
  111306. /***/ "./Physics/physicsHelper.ts":
  111307. /*!**********************************!*\
  111308. !*** ./Physics/physicsHelper.ts ***!
  111309. \**********************************/
  111310. /*! exports provided: PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode */
  111311. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111312. "use strict";
  111313. __webpack_require__.r(__webpack_exports__);
  111314. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return PhysicsHelper; });
  111315. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return PhysicsRadialExplosionEvent; });
  111316. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return PhysicsGravitationalFieldEvent; });
  111317. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return PhysicsUpdraftEvent; });
  111318. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return PhysicsVortexEvent; });
  111319. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return PhysicsRadialImpulseFalloff; });
  111320. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return PhysicsUpdraftMode; });
  111321. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  111322. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  111323. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  111324. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  111325. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  111326. /**
  111327. * A helper for physics simulations
  111328. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111329. */
  111330. var PhysicsHelper = /** @class */ (function () {
  111331. /**
  111332. * Initializes the Physics helper
  111333. * @param scene Babylon.js scene
  111334. */
  111335. function PhysicsHelper(scene) {
  111336. this._scene = scene;
  111337. this._physicsEngine = this._scene.getPhysicsEngine();
  111338. if (!this._physicsEngine) {
  111339. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you can use the methods.');
  111340. }
  111341. }
  111342. /**
  111343. * Applies a radial explosion impulse
  111344. * @param origin the origin of the explosion
  111345. * @param radius the explosion radius
  111346. * @param strength the explosion strength
  111347. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111348. * @returns A physics radial explosion event, or null
  111349. */
  111350. PhysicsHelper.prototype.applyRadialExplosionImpulse = function (origin, radius, strength, falloff) {
  111351. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  111352. if (!this._physicsEngine) {
  111353. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call this method.');
  111354. return null;
  111355. }
  111356. var impostors = this._physicsEngine.getImpostors();
  111357. if (impostors.length === 0) {
  111358. return null;
  111359. }
  111360. var event = new PhysicsRadialExplosionEvent(this._scene);
  111361. impostors.forEach(function (impostor) {
  111362. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin, radius, strength, falloff);
  111363. if (!impostorForceAndContactPoint) {
  111364. return;
  111365. }
  111366. impostor.applyImpulse(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  111367. });
  111368. event.dispose(false);
  111369. return event;
  111370. };
  111371. /**
  111372. * Applies a radial explosion force
  111373. * @param origin the origin of the explosion
  111374. * @param radius the explosion radius
  111375. * @param strength the explosion strength
  111376. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111377. * @returns A physics radial explosion event, or null
  111378. */
  111379. PhysicsHelper.prototype.applyRadialExplosionForce = function (origin, radius, strength, falloff) {
  111380. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  111381. if (!this._physicsEngine) {
  111382. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  111383. return null;
  111384. }
  111385. var impostors = this._physicsEngine.getImpostors();
  111386. if (impostors.length === 0) {
  111387. return null;
  111388. }
  111389. var event = new PhysicsRadialExplosionEvent(this._scene);
  111390. impostors.forEach(function (impostor) {
  111391. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin, radius, strength, falloff);
  111392. if (!impostorForceAndContactPoint) {
  111393. return;
  111394. }
  111395. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  111396. });
  111397. event.dispose(false);
  111398. return event;
  111399. };
  111400. /**
  111401. * Creates a gravitational field
  111402. * @param origin the origin of the explosion
  111403. * @param radius the explosion radius
  111404. * @param strength the explosion strength
  111405. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111406. * @returns A physics gravitational field event, or null
  111407. */
  111408. PhysicsHelper.prototype.gravitationalField = function (origin, radius, strength, falloff) {
  111409. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  111410. if (!this._physicsEngine) {
  111411. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  111412. return null;
  111413. }
  111414. var impostors = this._physicsEngine.getImpostors();
  111415. if (impostors.length === 0) {
  111416. return null;
  111417. }
  111418. var event = new PhysicsGravitationalFieldEvent(this, this._scene, origin, radius, strength, falloff);
  111419. event.dispose(false);
  111420. return event;
  111421. };
  111422. /**
  111423. * Creates a physics updraft event
  111424. * @param origin the origin of the updraft
  111425. * @param radius the radius of the updraft
  111426. * @param strength the strength of the updraft
  111427. * @param height the height of the updraft
  111428. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  111429. * @returns A physics updraft event, or null
  111430. */
  111431. PhysicsHelper.prototype.updraft = function (origin, radius, strength, height, updraftMode) {
  111432. if (updraftMode === void 0) { updraftMode = PhysicsUpdraftMode.Center; }
  111433. if (!this._physicsEngine) {
  111434. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  111435. return null;
  111436. }
  111437. if (this._physicsEngine.getImpostors().length === 0) {
  111438. return null;
  111439. }
  111440. var event = new PhysicsUpdraftEvent(this._scene, origin, radius, strength, height, updraftMode);
  111441. event.dispose(false);
  111442. return event;
  111443. };
  111444. /**
  111445. * Creates a physics vortex event
  111446. * @param origin the of the vortex
  111447. * @param radius the radius of the vortex
  111448. * @param strength the strength of the vortex
  111449. * @param height the height of the vortex
  111450. * @returns a Physics vortex event, or null
  111451. * A physics vortex event or null
  111452. */
  111453. PhysicsHelper.prototype.vortex = function (origin, radius, strength, height) {
  111454. if (!this._physicsEngine) {
  111455. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  111456. return null;
  111457. }
  111458. if (this._physicsEngine.getImpostors().length === 0) {
  111459. return null;
  111460. }
  111461. var event = new PhysicsVortexEvent(this._scene, origin, radius, strength, height);
  111462. event.dispose(false);
  111463. return event;
  111464. };
  111465. return PhysicsHelper;
  111466. }());
  111467. /**
  111468. * Represents a physics radial explosion event
  111469. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111470. */
  111471. var PhysicsRadialExplosionEvent = /** @class */ (function () {
  111472. /**
  111473. * Initializes a radial explosioin event
  111474. * @param scene BabylonJS scene
  111475. */
  111476. function PhysicsRadialExplosionEvent(scene) {
  111477. this._sphereOptions = { segments: 32, diameter: 1 }; // TODO: make configurable
  111478. this._rays = [];
  111479. this._dataFetched = false; // check if the data has been fetched. If not, do cleanup
  111480. this._scene = scene;
  111481. }
  111482. /**
  111483. * Returns the data related to the radial explosion event (sphere & rays).
  111484. * @returns The radial explosion event data
  111485. */
  111486. PhysicsRadialExplosionEvent.prototype.getData = function () {
  111487. this._dataFetched = true;
  111488. return {
  111489. sphere: this._sphere,
  111490. rays: this._rays,
  111491. };
  111492. };
  111493. /**
  111494. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  111495. * @param impostor A physics imposter
  111496. * @param origin the origin of the explosion
  111497. * @param radius the explosion radius
  111498. * @param strength the explosion strength
  111499. * @param falloff possible options: Constant & Linear
  111500. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  111501. */
  111502. PhysicsRadialExplosionEvent.prototype.getImpostorForceAndContactPoint = function (impostor, origin, radius, strength, falloff) {
  111503. if (impostor.mass === 0) {
  111504. return null;
  111505. }
  111506. if (!this._intersectsWithSphere(impostor, origin, radius)) {
  111507. return null;
  111508. }
  111509. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  111510. return null;
  111511. }
  111512. var impostorObjectCenter = impostor.getObjectCenter();
  111513. var direction = impostorObjectCenter.subtract(origin);
  111514. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_4__["Ray"](origin, direction, radius);
  111515. this._rays.push(ray);
  111516. var hit = ray.intersectsMesh(impostor.object);
  111517. var contactPoint = hit.pickedPoint;
  111518. if (!contactPoint) {
  111519. return null;
  111520. }
  111521. var distanceFromOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(origin, contactPoint);
  111522. if (distanceFromOrigin > radius) {
  111523. return null;
  111524. }
  111525. var multiplier = falloff === PhysicsRadialImpulseFalloff.Constant
  111526. ? strength
  111527. : strength * (1 - (distanceFromOrigin / radius));
  111528. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  111529. return { force: force, contactPoint: contactPoint };
  111530. };
  111531. /**
  111532. * Disposes the sphere.
  111533. * @param force Specifies if the sphere should be disposed by force
  111534. */
  111535. PhysicsRadialExplosionEvent.prototype.dispose = function (force) {
  111536. var _this = this;
  111537. if (force === void 0) { force = true; }
  111538. if (force) {
  111539. this._sphere.dispose();
  111540. }
  111541. else {
  111542. setTimeout(function () {
  111543. if (!_this._dataFetched) {
  111544. _this._sphere.dispose();
  111545. }
  111546. }, 0);
  111547. }
  111548. };
  111549. /*** Helpers ***/
  111550. PhysicsRadialExplosionEvent.prototype._prepareSphere = function () {
  111551. if (!this._sphere) {
  111552. this._sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__["SphereBuilder"].CreateSphere("radialExplosionEventSphere", this._sphereOptions, this._scene);
  111553. this._sphere.isVisible = false;
  111554. }
  111555. };
  111556. PhysicsRadialExplosionEvent.prototype._intersectsWithSphere = function (impostor, origin, radius) {
  111557. var impostorObject = impostor.object;
  111558. this._prepareSphere();
  111559. this._sphere.position = origin;
  111560. this._sphere.scaling = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](radius * 2, radius * 2, radius * 2);
  111561. this._sphere._updateBoundingInfo();
  111562. this._sphere.computeWorldMatrix(true);
  111563. return this._sphere.intersectsMesh(impostorObject, true);
  111564. };
  111565. return PhysicsRadialExplosionEvent;
  111566. }());
  111567. /**
  111568. * Represents a gravitational field event
  111569. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111570. */
  111571. var PhysicsGravitationalFieldEvent = /** @class */ (function () {
  111572. /**
  111573. * Initializes the physics gravitational field event
  111574. * @param physicsHelper A physics helper
  111575. * @param scene BabylonJS scene
  111576. * @param origin The origin position of the gravitational field event
  111577. * @param radius The radius of the gravitational field event
  111578. * @param strength The strength of the gravitational field event
  111579. * @param falloff The falloff for the gravitational field event
  111580. */
  111581. function PhysicsGravitationalFieldEvent(physicsHelper, scene, origin, radius, strength, falloff) {
  111582. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  111583. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  111584. this._physicsHelper = physicsHelper;
  111585. this._scene = scene;
  111586. this._origin = origin;
  111587. this._radius = radius;
  111588. this._strength = strength;
  111589. this._falloff = falloff;
  111590. this._tickCallback = this._tick.bind(this);
  111591. }
  111592. /**
  111593. * Returns the data related to the gravitational field event (sphere).
  111594. * @returns A gravitational field event
  111595. */
  111596. PhysicsGravitationalFieldEvent.prototype.getData = function () {
  111597. this._dataFetched = true;
  111598. return {
  111599. sphere: this._sphere,
  111600. };
  111601. };
  111602. /**
  111603. * Enables the gravitational field.
  111604. */
  111605. PhysicsGravitationalFieldEvent.prototype.enable = function () {
  111606. this._tickCallback.call(this);
  111607. this._scene.registerBeforeRender(this._tickCallback);
  111608. };
  111609. /**
  111610. * Disables the gravitational field.
  111611. */
  111612. PhysicsGravitationalFieldEvent.prototype.disable = function () {
  111613. this._scene.unregisterBeforeRender(this._tickCallback);
  111614. };
  111615. /**
  111616. * Disposes the sphere.
  111617. * @param force The force to dispose from the gravitational field event
  111618. */
  111619. PhysicsGravitationalFieldEvent.prototype.dispose = function (force) {
  111620. var _this = this;
  111621. if (force === void 0) { force = true; }
  111622. if (force) {
  111623. this._sphere.dispose();
  111624. }
  111625. else {
  111626. setTimeout(function () {
  111627. if (!_this._dataFetched) {
  111628. _this._sphere.dispose();
  111629. }
  111630. }, 0);
  111631. }
  111632. };
  111633. PhysicsGravitationalFieldEvent.prototype._tick = function () {
  111634. // Since the params won't change, we fetch the event only once
  111635. if (this._sphere) {
  111636. this._physicsHelper.applyRadialExplosionForce(this._origin, this._radius, this._strength * -1, this._falloff);
  111637. }
  111638. else {
  111639. var radialExplosionEvent = this._physicsHelper.applyRadialExplosionForce(this._origin, this._radius, this._strength * -1, this._falloff);
  111640. if (radialExplosionEvent) {
  111641. this._sphere = radialExplosionEvent.getData().sphere.clone('radialExplosionEventSphereClone');
  111642. }
  111643. }
  111644. };
  111645. return PhysicsGravitationalFieldEvent;
  111646. }());
  111647. /**
  111648. * Represents a physics updraft event
  111649. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111650. */
  111651. var PhysicsUpdraftEvent = /** @class */ (function () {
  111652. /**
  111653. * Initializes the physics updraft event
  111654. * @param _scene BabylonJS scene
  111655. * @param _origin The origin position of the updraft
  111656. * @param _radius The radius of the updraft
  111657. * @param _strength The strength of the updraft
  111658. * @param _height The height of the updraft
  111659. * @param _updraftMode The mode of the updraft
  111660. */
  111661. function PhysicsUpdraftEvent(_scene, _origin, _radius, _strength, _height, _updraftMode) {
  111662. this._scene = _scene;
  111663. this._origin = _origin;
  111664. this._radius = _radius;
  111665. this._strength = _strength;
  111666. this._height = _height;
  111667. this._updraftMode = _updraftMode;
  111668. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // the most upper part of the cylinder
  111669. this._originDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // used if the updraftMode is perpendicular
  111670. 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
  111671. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  111672. this._physicsEngine = this._scene.getPhysicsEngine();
  111673. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height / 2, 0), this._cylinderPosition);
  111674. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height, 0), this._originTop);
  111675. if (this._updraftMode === PhysicsUpdraftMode.Perpendicular) {
  111676. this._originDirection = this._origin.subtract(this._originTop).normalize();
  111677. }
  111678. this._tickCallback = this._tick.bind(this);
  111679. this._prepareCylinder();
  111680. }
  111681. /**
  111682. * Returns the data related to the updraft event (cylinder).
  111683. * @returns A physics updraft event
  111684. */
  111685. PhysicsUpdraftEvent.prototype.getData = function () {
  111686. this._dataFetched = true;
  111687. return {
  111688. cylinder: this._cylinder,
  111689. };
  111690. };
  111691. /**
  111692. * Enables the updraft.
  111693. */
  111694. PhysicsUpdraftEvent.prototype.enable = function () {
  111695. this._tickCallback.call(this);
  111696. this._scene.registerBeforeRender(this._tickCallback);
  111697. };
  111698. /**
  111699. * Disables the cortex.
  111700. */
  111701. PhysicsUpdraftEvent.prototype.disable = function () {
  111702. this._scene.unregisterBeforeRender(this._tickCallback);
  111703. };
  111704. /**
  111705. * Disposes the sphere.
  111706. * @param force Specifies if the updraft should be disposed by force
  111707. */
  111708. PhysicsUpdraftEvent.prototype.dispose = function (force) {
  111709. var _this = this;
  111710. if (force === void 0) { force = true; }
  111711. if (!this._cylinder) {
  111712. return;
  111713. }
  111714. if (force) {
  111715. this._cylinder.dispose();
  111716. }
  111717. else {
  111718. setTimeout(function () {
  111719. if (!_this._dataFetched) {
  111720. _this._cylinder.dispose();
  111721. }
  111722. }, 0);
  111723. }
  111724. };
  111725. PhysicsUpdraftEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  111726. if (impostor.mass === 0) {
  111727. return null;
  111728. }
  111729. if (!this._intersectsWithCylinder(impostor)) {
  111730. return null;
  111731. }
  111732. var impostorObjectCenter = impostor.getObjectCenter();
  111733. if (this._updraftMode === PhysicsUpdraftMode.Perpendicular) {
  111734. var direction = this._originDirection;
  111735. }
  111736. else {
  111737. var direction = impostorObjectCenter.subtract(this._originTop);
  111738. }
  111739. var multiplier = this._strength * -1;
  111740. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  111741. return { force: force, contactPoint: impostorObjectCenter };
  111742. };
  111743. PhysicsUpdraftEvent.prototype._tick = function () {
  111744. var _this = this;
  111745. this._physicsEngine.getImpostors().forEach(function (impostor) {
  111746. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  111747. if (!impostorForceAndContactPoint) {
  111748. return;
  111749. }
  111750. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  111751. });
  111752. };
  111753. /*** Helpers ***/
  111754. PhysicsUpdraftEvent.prototype._prepareCylinder = function () {
  111755. if (!this._cylinder) {
  111756. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_3__["CylinderBuilder"].CreateCylinder("updraftEventCylinder", {
  111757. height: this._height,
  111758. diameter: this._radius * 2,
  111759. }, this._scene);
  111760. this._cylinder.isVisible = false;
  111761. }
  111762. };
  111763. PhysicsUpdraftEvent.prototype._intersectsWithCylinder = function (impostor) {
  111764. var impostorObject = impostor.object;
  111765. this._cylinder.position = this._cylinderPosition;
  111766. return this._cylinder.intersectsMesh(impostorObject, true);
  111767. };
  111768. return PhysicsUpdraftEvent;
  111769. }());
  111770. /**
  111771. * Represents a physics vortex event
  111772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111773. */
  111774. var PhysicsVortexEvent = /** @class */ (function () {
  111775. /**
  111776. * Initializes the physics vortex event
  111777. * @param _scene The BabylonJS scene
  111778. * @param _origin The origin position of the vortex
  111779. * @param _radius The radius of the vortex
  111780. * @param _strength The strength of the vortex
  111781. * @param _height The height of the vortex
  111782. */
  111783. function PhysicsVortexEvent(_scene, _origin, _radius, _strength, _height) {
  111784. this._scene = _scene;
  111785. this._origin = _origin;
  111786. this._radius = _radius;
  111787. this._strength = _strength;
  111788. this._height = _height;
  111789. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // the most upper part of the cylinder
  111790. this._centripetalForceThreshold = 0.7; // at which distance, relative to the radius the centripetal forces should kick in
  111791. this._updraftMultiplier = 0.02;
  111792. 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
  111793. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  111794. this._physicsEngine = this._scene.getPhysicsEngine();
  111795. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height / 2, 0), this._cylinderPosition);
  111796. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height, 0), this._originTop);
  111797. this._tickCallback = this._tick.bind(this);
  111798. this._prepareCylinder();
  111799. }
  111800. /**
  111801. * Returns the data related to the vortex event (cylinder).
  111802. * @returns The physics vortex event data
  111803. */
  111804. PhysicsVortexEvent.prototype.getData = function () {
  111805. this._dataFetched = true;
  111806. return {
  111807. cylinder: this._cylinder,
  111808. };
  111809. };
  111810. /**
  111811. * Enables the vortex.
  111812. */
  111813. PhysicsVortexEvent.prototype.enable = function () {
  111814. this._tickCallback.call(this);
  111815. this._scene.registerBeforeRender(this._tickCallback);
  111816. };
  111817. /**
  111818. * Disables the cortex.
  111819. */
  111820. PhysicsVortexEvent.prototype.disable = function () {
  111821. this._scene.unregisterBeforeRender(this._tickCallback);
  111822. };
  111823. /**
  111824. * Disposes the sphere.
  111825. * @param force
  111826. */
  111827. PhysicsVortexEvent.prototype.dispose = function (force) {
  111828. var _this = this;
  111829. if (force === void 0) { force = true; }
  111830. if (force) {
  111831. this._cylinder.dispose();
  111832. }
  111833. else {
  111834. setTimeout(function () {
  111835. if (!_this._dataFetched) {
  111836. _this._cylinder.dispose();
  111837. }
  111838. }, 0);
  111839. }
  111840. };
  111841. PhysicsVortexEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  111842. if (impostor.mass === 0) {
  111843. return null;
  111844. }
  111845. if (!this._intersectsWithCylinder(impostor)) {
  111846. return null;
  111847. }
  111848. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  111849. return null;
  111850. }
  111851. var impostorObjectCenter = impostor.getObjectCenter();
  111852. 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)
  111853. var originToImpostorDirection = impostorObjectCenter.subtract(originOnPlane);
  111854. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_4__["Ray"](originOnPlane, originToImpostorDirection, this._radius);
  111855. var hit = ray.intersectsMesh(impostor.object);
  111856. var contactPoint = hit.pickedPoint;
  111857. if (!contactPoint) {
  111858. return null;
  111859. }
  111860. var absoluteDistanceFromOrigin = hit.distance / this._radius;
  111861. var perpendicularDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(originOnPlane, impostorObjectCenter).normalize();
  111862. var directionToOrigin = contactPoint.normalize();
  111863. if (absoluteDistanceFromOrigin > this._centripetalForceThreshold) {
  111864. directionToOrigin = directionToOrigin.negate();
  111865. }
  111866. // TODO: find a more physically based solution
  111867. if (absoluteDistanceFromOrigin > this._centripetalForceThreshold) {
  111868. var forceX = directionToOrigin.x * this._strength / 8;
  111869. var forceY = directionToOrigin.y * this._updraftMultiplier;
  111870. var forceZ = directionToOrigin.z * this._strength / 8;
  111871. }
  111872. else {
  111873. var forceX = (perpendicularDirection.x + directionToOrigin.x) / 2;
  111874. var forceY = this._originTop.y * this._updraftMultiplier;
  111875. var forceZ = (perpendicularDirection.z + directionToOrigin.z) / 2;
  111876. }
  111877. var force = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](forceX, forceY, forceZ);
  111878. force = force.multiplyByFloats(this._strength, this._strength, this._strength);
  111879. return { force: force, contactPoint: impostorObjectCenter };
  111880. };
  111881. PhysicsVortexEvent.prototype._tick = function () {
  111882. var _this = this;
  111883. this._physicsEngine.getImpostors().forEach(function (impostor) {
  111884. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  111885. if (!impostorForceAndContactPoint) {
  111886. return;
  111887. }
  111888. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  111889. });
  111890. };
  111891. /*** Helpers ***/
  111892. PhysicsVortexEvent.prototype._prepareCylinder = function () {
  111893. if (!this._cylinder) {
  111894. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_3__["CylinderBuilder"].CreateCylinder("vortexEventCylinder", {
  111895. height: this._height,
  111896. diameter: this._radius * 2,
  111897. }, this._scene);
  111898. this._cylinder.isVisible = false;
  111899. }
  111900. };
  111901. PhysicsVortexEvent.prototype._intersectsWithCylinder = function (impostor) {
  111902. var impostorObject = impostor.object;
  111903. this._cylinder.position = this._cylinderPosition;
  111904. return this._cylinder.intersectsMesh(impostorObject, true);
  111905. };
  111906. return PhysicsVortexEvent;
  111907. }());
  111908. /**
  111909. * The strenght of the force in correspondence to the distance of the affected object
  111910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111911. */
  111912. var PhysicsRadialImpulseFalloff;
  111913. (function (PhysicsRadialImpulseFalloff) {
  111914. /** Defines that impulse is constant in strength across it's whole radius */
  111915. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Constant"] = 0] = "Constant";
  111916. /** DEfines that impulse gets weaker if it's further from the origin */
  111917. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Linear"] = 1] = "Linear";
  111918. })(PhysicsRadialImpulseFalloff || (PhysicsRadialImpulseFalloff = {}));
  111919. /**
  111920. * The strength of the force in correspondence to the distance of the affected object
  111921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111922. */
  111923. var PhysicsUpdraftMode;
  111924. (function (PhysicsUpdraftMode) {
  111925. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  111926. PhysicsUpdraftMode[PhysicsUpdraftMode["Center"] = 0] = "Center";
  111927. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  111928. PhysicsUpdraftMode[PhysicsUpdraftMode["Perpendicular"] = 1] = "Perpendicular";
  111929. })(PhysicsUpdraftMode || (PhysicsUpdraftMode = {}));
  111930. /***/ }),
  111931. /***/ "./Physics/physicsImpostor.ts":
  111932. /*!************************************!*\
  111933. !*** ./Physics/physicsImpostor.ts ***!
  111934. \************************************/
  111935. /*! exports provided: PhysicsImpostor */
  111936. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111937. "use strict";
  111938. __webpack_require__.r(__webpack_exports__);
  111939. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return PhysicsImpostor; });
  111940. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  111941. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  111942. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  111943. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  111944. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  111945. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  111946. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  111947. return new PhysicsImpostor(physicObject, jsonObject.physicsImpostor, {
  111948. mass: jsonObject.physicsMass,
  111949. friction: jsonObject.physicsFriction,
  111950. restitution: jsonObject.physicsRestitution
  111951. }, scene);
  111952. };
  111953. /**
  111954. * Represents a physics imposter
  111955. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111956. */
  111957. var PhysicsImpostor = /** @class */ (function () {
  111958. /**
  111959. * Initializes the physics imposter
  111960. * @param object The physics-enabled object used as the physics imposter
  111961. * @param type The type of the physics imposter
  111962. * @param _options The options for the physics imposter
  111963. * @param _scene The Babylon scene
  111964. */
  111965. function PhysicsImpostor(
  111966. /**
  111967. * The physics-enabled object used as the physics imposter
  111968. */
  111969. object,
  111970. /**
  111971. * The type of the physics imposter
  111972. */
  111973. type, _options, _scene) {
  111974. if (_options === void 0) { _options = { mass: 0 }; }
  111975. var _this = this;
  111976. this.object = object;
  111977. this.type = type;
  111978. this._options = _options;
  111979. this._scene = _scene;
  111980. this._bodyUpdateRequired = false;
  111981. this._onBeforePhysicsStepCallbacks = new Array();
  111982. this._onAfterPhysicsStepCallbacks = new Array();
  111983. /** @hidden */
  111984. this._onPhysicsCollideCallbacks = [];
  111985. this._deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  111986. this._isDisposed = false;
  111987. //temp variables for parent rotation calculations
  111988. //private _mats: Array<Matrix> = [new Matrix(), new Matrix()];
  111989. this._tmpQuat = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  111990. this._tmpQuat2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  111991. /**
  111992. * this function is executed by the physics engine.
  111993. */
  111994. this.beforeStep = function () {
  111995. if (!_this._physicsEngine) {
  111996. return;
  111997. }
  111998. _this.object.translate(_this._deltaPosition, -1);
  111999. _this._deltaRotationConjugated && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotationConjugated, _this.object.rotationQuaternion);
  112000. _this.object.computeWorldMatrix(false);
  112001. if (_this.object.parent && _this.object.rotationQuaternion) {
  112002. _this.getParentsRotation();
  112003. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this._tmpQuat);
  112004. }
  112005. else {
  112006. _this._tmpQuat.copyFrom(_this.object.rotationQuaternion || new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]());
  112007. }
  112008. if (!_this._options.disableBidirectionalTransformation) {
  112009. _this.object.rotationQuaternion && _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, /*bInfo.boundingBox.centerWorld*/ _this.object.getAbsolutePosition(), _this._tmpQuat);
  112010. }
  112011. _this._onBeforePhysicsStepCallbacks.forEach(function (func) {
  112012. func(_this);
  112013. });
  112014. };
  112015. /**
  112016. * this function is executed by the physics engine
  112017. */
  112018. this.afterStep = function () {
  112019. if (!_this._physicsEngine) {
  112020. return;
  112021. }
  112022. _this._onAfterPhysicsStepCallbacks.forEach(function (func) {
  112023. func(_this);
  112024. });
  112025. _this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(_this);
  112026. // object has now its world rotation. needs to be converted to local.
  112027. if (_this.object.parent && _this.object.rotationQuaternion) {
  112028. _this.getParentsRotation();
  112029. _this._tmpQuat.conjugateInPlace();
  112030. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this.object.rotationQuaternion);
  112031. }
  112032. // take the position set and make it the absolute position of this object.
  112033. _this.object.setAbsolutePosition(_this.object.position);
  112034. _this._deltaRotation && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotation, _this.object.rotationQuaternion);
  112035. _this.object.translate(_this._deltaPosition, 1);
  112036. };
  112037. /**
  112038. * Legacy collision detection event support
  112039. */
  112040. this.onCollideEvent = null;
  112041. /**
  112042. * event and body object due to cannon's event-based architecture.
  112043. */
  112044. this.onCollide = function (e) {
  112045. if (!_this._onPhysicsCollideCallbacks.length && !_this.onCollideEvent) {
  112046. return;
  112047. }
  112048. if (!_this._physicsEngine) {
  112049. return;
  112050. }
  112051. var otherImpostor = _this._physicsEngine.getImpostorWithPhysicsBody(e.body);
  112052. if (otherImpostor) {
  112053. // Legacy collision detection event support
  112054. if (_this.onCollideEvent) {
  112055. _this.onCollideEvent(_this, otherImpostor);
  112056. }
  112057. _this._onPhysicsCollideCallbacks.filter(function (obj) {
  112058. return obj.otherImpostors.indexOf(otherImpostor) !== -1;
  112059. }).forEach(function (obj) {
  112060. obj.callback(_this, otherImpostor);
  112061. });
  112062. }
  112063. };
  112064. //sanity check!
  112065. if (!this.object) {
  112066. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("No object was provided. A physics object is obligatory");
  112067. return;
  112068. }
  112069. // Legacy support for old syntax.
  112070. if (!this._scene && object.getScene) {
  112071. this._scene = object.getScene();
  112072. }
  112073. if (!this._scene) {
  112074. return;
  112075. }
  112076. this._physicsEngine = this._scene.getPhysicsEngine();
  112077. if (!this._physicsEngine) {
  112078. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.");
  112079. }
  112080. else {
  112081. //set the object's quaternion, if not set
  112082. if (!this.object.rotationQuaternion) {
  112083. if (this.object.rotation) {
  112084. this.object.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z);
  112085. }
  112086. else {
  112087. this.object.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  112088. }
  112089. }
  112090. //default options params
  112091. this._options.mass = (_options.mass === void 0) ? 0 : _options.mass;
  112092. this._options.friction = (_options.friction === void 0) ? 0.2 : _options.friction;
  112093. this._options.restitution = (_options.restitution === void 0) ? 0.2 : _options.restitution;
  112094. this._joints = [];
  112095. //If the mesh has a parent, don't initialize the physicsBody. Instead wait for the parent to do that.
  112096. if (!this.object.parent || this._options.ignoreParent) {
  112097. this._init();
  112098. }
  112099. else if (this.object.parent.physicsImpostor) {
  112100. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("You must affect impostors to children before affecting impostor to parent.");
  112101. }
  112102. }
  112103. }
  112104. Object.defineProperty(PhysicsImpostor.prototype, "isDisposed", {
  112105. /**
  112106. * Specifies if the physics imposter is disposed
  112107. */
  112108. get: function () {
  112109. return this._isDisposed;
  112110. },
  112111. enumerable: true,
  112112. configurable: true
  112113. });
  112114. Object.defineProperty(PhysicsImpostor.prototype, "mass", {
  112115. /**
  112116. * Gets the mass of the physics imposter
  112117. */
  112118. get: function () {
  112119. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0;
  112120. },
  112121. set: function (value) {
  112122. this.setMass(value);
  112123. },
  112124. enumerable: true,
  112125. configurable: true
  112126. });
  112127. Object.defineProperty(PhysicsImpostor.prototype, "friction", {
  112128. /**
  112129. * Gets the coefficient of friction
  112130. */
  112131. get: function () {
  112132. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0;
  112133. },
  112134. /**
  112135. * Sets the coefficient of friction
  112136. */
  112137. set: function (value) {
  112138. if (!this._physicsEngine) {
  112139. return;
  112140. }
  112141. this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, value);
  112142. },
  112143. enumerable: true,
  112144. configurable: true
  112145. });
  112146. Object.defineProperty(PhysicsImpostor.prototype, "restitution", {
  112147. /**
  112148. * Gets the coefficient of restitution
  112149. */
  112150. get: function () {
  112151. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0;
  112152. },
  112153. /**
  112154. * Sets the coefficient of restitution
  112155. */
  112156. set: function (value) {
  112157. if (!this._physicsEngine) {
  112158. return;
  112159. }
  112160. this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, value);
  112161. },
  112162. enumerable: true,
  112163. configurable: true
  112164. });
  112165. /**
  112166. * This function will completly initialize this impostor.
  112167. * It will create a new body - but only if this mesh has no parent.
  112168. * If it has, this impostor will not be used other than to define the impostor
  112169. * of the child mesh.
  112170. * @hidden
  112171. */
  112172. PhysicsImpostor.prototype._init = function () {
  112173. if (!this._physicsEngine) {
  112174. return;
  112175. }
  112176. this._physicsEngine.removeImpostor(this);
  112177. this.physicsBody = null;
  112178. this._parent = this._parent || this._getPhysicsParent();
  112179. if (!this._isDisposed && (!this.parent || this._options.ignoreParent)) {
  112180. this._physicsEngine.addImpostor(this);
  112181. }
  112182. };
  112183. PhysicsImpostor.prototype._getPhysicsParent = function () {
  112184. if (this.object.parent instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]) {
  112185. var parentMesh = this.object.parent;
  112186. return parentMesh.physicsImpostor;
  112187. }
  112188. return null;
  112189. };
  112190. /**
  112191. * Should a new body be generated.
  112192. * @returns boolean specifying if body initialization is required
  112193. */
  112194. PhysicsImpostor.prototype.isBodyInitRequired = function () {
  112195. return this._bodyUpdateRequired || (!this._physicsBody && !this._parent);
  112196. };
  112197. /**
  112198. * Sets the updated scaling
  112199. * @param updated Specifies if the scaling is updated
  112200. */
  112201. PhysicsImpostor.prototype.setScalingUpdated = function () {
  112202. this.forceUpdate();
  112203. };
  112204. /**
  112205. * Force a regeneration of this or the parent's impostor's body.
  112206. * Use under cautious - This will remove all joints already implemented.
  112207. */
  112208. PhysicsImpostor.prototype.forceUpdate = function () {
  112209. this._init();
  112210. if (this.parent && !this._options.ignoreParent) {
  112211. this.parent.forceUpdate();
  112212. }
  112213. };
  112214. Object.defineProperty(PhysicsImpostor.prototype, "physicsBody", {
  112215. /*public get mesh(): AbstractMesh {
  112216. return this._mesh;
  112217. }*/
  112218. /**
  112219. * Gets the body that holds this impostor. Either its own, or its parent.
  112220. */
  112221. get: function () {
  112222. return (this._parent && !this._options.ignoreParent) ? this._parent.physicsBody : this._physicsBody;
  112223. },
  112224. /**
  112225. * Set the physics body. Used mainly by the physics engine/plugin
  112226. */
  112227. set: function (physicsBody) {
  112228. if (this._physicsBody && this._physicsEngine) {
  112229. this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this);
  112230. }
  112231. this._physicsBody = physicsBody;
  112232. this.resetUpdateFlags();
  112233. },
  112234. enumerable: true,
  112235. configurable: true
  112236. });
  112237. Object.defineProperty(PhysicsImpostor.prototype, "parent", {
  112238. /**
  112239. * Get the parent of the physics imposter
  112240. * @returns Physics imposter or null
  112241. */
  112242. get: function () {
  112243. return !this._options.ignoreParent && this._parent ? this._parent : null;
  112244. },
  112245. /**
  112246. * Sets the parent of the physics imposter
  112247. */
  112248. set: function (value) {
  112249. this._parent = value;
  112250. },
  112251. enumerable: true,
  112252. configurable: true
  112253. });
  112254. /**
  112255. * Resets the update flags
  112256. */
  112257. PhysicsImpostor.prototype.resetUpdateFlags = function () {
  112258. this._bodyUpdateRequired = false;
  112259. };
  112260. /**
  112261. * Gets the object extend size
  112262. * @returns the object extend size
  112263. */
  112264. PhysicsImpostor.prototype.getObjectExtendSize = function () {
  112265. if (this.object.getBoundingInfo) {
  112266. var q = this.object.rotationQuaternion;
  112267. //reset rotation
  112268. this.object.rotationQuaternion = PhysicsImpostor.IDENTITY_QUATERNION;
  112269. //calculate the world matrix with no rotation
  112270. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  112271. var boundingInfo = this.object.getBoundingInfo();
  112272. var size = boundingInfo.boundingBox.extendSizeWorld.scale(2);
  112273. //bring back the rotation
  112274. this.object.rotationQuaternion = q;
  112275. //calculate the world matrix with the new rotation
  112276. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  112277. return size;
  112278. }
  112279. else {
  112280. return PhysicsImpostor.DEFAULT_OBJECT_SIZE;
  112281. }
  112282. };
  112283. /**
  112284. * Gets the object center
  112285. * @returns The object center
  112286. */
  112287. PhysicsImpostor.prototype.getObjectCenter = function () {
  112288. if (this.object.getBoundingInfo) {
  112289. var boundingInfo = this.object.getBoundingInfo();
  112290. return boundingInfo.boundingBox.centerWorld;
  112291. }
  112292. else {
  112293. return this.object.position;
  112294. }
  112295. };
  112296. /**
  112297. * Get a specific parametes from the options parameter
  112298. * @param paramName The object parameter name
  112299. * @returns The object parameter
  112300. */
  112301. PhysicsImpostor.prototype.getParam = function (paramName) {
  112302. return this._options[paramName];
  112303. };
  112304. /**
  112305. * Sets a specific parameter in the options given to the physics plugin
  112306. * @param paramName The parameter name
  112307. * @param value The value of the parameter
  112308. */
  112309. PhysicsImpostor.prototype.setParam = function (paramName, value) {
  112310. this._options[paramName] = value;
  112311. this._bodyUpdateRequired = true;
  112312. };
  112313. /**
  112314. * Specifically change the body's mass option. Won't recreate the physics body object
  112315. * @param mass The mass of the physics imposter
  112316. */
  112317. PhysicsImpostor.prototype.setMass = function (mass) {
  112318. if (this.getParam("mass") !== mass) {
  112319. this.setParam("mass", mass);
  112320. }
  112321. if (this._physicsEngine) {
  112322. this._physicsEngine.getPhysicsPlugin().setBodyMass(this, mass);
  112323. }
  112324. };
  112325. /**
  112326. * Gets the linear velocity
  112327. * @returns linear velocity or null
  112328. */
  112329. PhysicsImpostor.prototype.getLinearVelocity = function () {
  112330. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  112331. };
  112332. /**
  112333. * Sets the linear velocity
  112334. * @param velocity linear velocity or null
  112335. */
  112336. PhysicsImpostor.prototype.setLinearVelocity = function (velocity) {
  112337. if (this._physicsEngine) {
  112338. this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, velocity);
  112339. }
  112340. };
  112341. /**
  112342. * Gets the angular velocity
  112343. * @returns angular velocity or null
  112344. */
  112345. PhysicsImpostor.prototype.getAngularVelocity = function () {
  112346. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  112347. };
  112348. /**
  112349. * Sets the angular velocity
  112350. * @param velocity The velocity or null
  112351. */
  112352. PhysicsImpostor.prototype.setAngularVelocity = function (velocity) {
  112353. if (this._physicsEngine) {
  112354. this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, velocity);
  112355. }
  112356. };
  112357. /**
  112358. * Execute a function with the physics plugin native code
  112359. * Provide a function the will have two variables - the world object and the physics body object
  112360. * @param func The function to execute with the physics plugin native code
  112361. */
  112362. PhysicsImpostor.prototype.executeNativeFunction = function (func) {
  112363. if (this._physicsEngine) {
  112364. func(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody);
  112365. }
  112366. };
  112367. /**
  112368. * Register a function that will be executed before the physics world is stepping forward
  112369. * @param func The function to execute before the physics world is stepped forward
  112370. */
  112371. PhysicsImpostor.prototype.registerBeforePhysicsStep = function (func) {
  112372. this._onBeforePhysicsStepCallbacks.push(func);
  112373. };
  112374. /**
  112375. * Unregister a function that will be executed before the physics world is stepping forward
  112376. * @param func The function to execute before the physics world is stepped forward
  112377. */
  112378. PhysicsImpostor.prototype.unregisterBeforePhysicsStep = function (func) {
  112379. var index = this._onBeforePhysicsStepCallbacks.indexOf(func);
  112380. if (index > -1) {
  112381. this._onBeforePhysicsStepCallbacks.splice(index, 1);
  112382. }
  112383. else {
  112384. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  112385. }
  112386. };
  112387. /**
  112388. * Register a function that will be executed after the physics step
  112389. * @param func The function to execute after physics step
  112390. */
  112391. PhysicsImpostor.prototype.registerAfterPhysicsStep = function (func) {
  112392. this._onAfterPhysicsStepCallbacks.push(func);
  112393. };
  112394. /**
  112395. * Unregisters a function that will be executed after the physics step
  112396. * @param func The function to execute after physics step
  112397. */
  112398. PhysicsImpostor.prototype.unregisterAfterPhysicsStep = function (func) {
  112399. var index = this._onAfterPhysicsStepCallbacks.indexOf(func);
  112400. if (index > -1) {
  112401. this._onAfterPhysicsStepCallbacks.splice(index, 1);
  112402. }
  112403. else {
  112404. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  112405. }
  112406. };
  112407. /**
  112408. * register a function that will be executed when this impostor collides against a different body
  112409. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  112410. * @param func Callback that is executed on collision
  112411. */
  112412. PhysicsImpostor.prototype.registerOnPhysicsCollide = function (collideAgainst, func) {
  112413. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  112414. this._onPhysicsCollideCallbacks.push({ callback: func, otherImpostors: collidedAgainstList });
  112415. };
  112416. /**
  112417. * Unregisters the physics imposter on contact
  112418. * @param collideAgainst The physics object to collide against
  112419. * @param func Callback to execute on collision
  112420. */
  112421. PhysicsImpostor.prototype.unregisterOnPhysicsCollide = function (collideAgainst, func) {
  112422. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  112423. var index = -1;
  112424. var found = this._onPhysicsCollideCallbacks.some(function (cbDef, idx) {
  112425. if (cbDef.callback === func && cbDef.otherImpostors.length === collidedAgainstList.length) {
  112426. // chcek the arrays match
  112427. var sameList = cbDef.otherImpostors.every(function (impostor) {
  112428. return collidedAgainstList.indexOf(impostor) > -1;
  112429. });
  112430. if (sameList) {
  112431. index = idx;
  112432. }
  112433. return sameList;
  112434. }
  112435. return false;
  112436. });
  112437. if (found) {
  112438. this._onPhysicsCollideCallbacks.splice(index, 1);
  112439. }
  112440. else {
  112441. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  112442. }
  112443. };
  112444. /**
  112445. * Get the parent rotation
  112446. * @returns The parent rotation
  112447. */
  112448. PhysicsImpostor.prototype.getParentsRotation = function () {
  112449. var parent = this.object.parent;
  112450. this._tmpQuat.copyFromFloats(0, 0, 0, 1);
  112451. while (parent) {
  112452. if (parent.rotationQuaternion) {
  112453. this._tmpQuat2.copyFrom(parent.rotationQuaternion);
  112454. }
  112455. else {
  112456. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(parent.rotation.y, parent.rotation.x, parent.rotation.z, this._tmpQuat2);
  112457. }
  112458. this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat);
  112459. parent = parent.parent;
  112460. }
  112461. return this._tmpQuat;
  112462. };
  112463. /**
  112464. * Apply a force
  112465. * @param force The force to apply
  112466. * @param contactPoint The contact point for the force
  112467. * @returns The physics imposter
  112468. */
  112469. PhysicsImpostor.prototype.applyForce = function (force, contactPoint) {
  112470. if (this._physicsEngine) {
  112471. this._physicsEngine.getPhysicsPlugin().applyForce(this, force, contactPoint);
  112472. }
  112473. return this;
  112474. };
  112475. /**
  112476. * Apply an impulse
  112477. * @param force The impulse force
  112478. * @param contactPoint The contact point for the impulse force
  112479. * @returns The physics imposter
  112480. */
  112481. PhysicsImpostor.prototype.applyImpulse = function (force, contactPoint) {
  112482. if (this._physicsEngine) {
  112483. this._physicsEngine.getPhysicsPlugin().applyImpulse(this, force, contactPoint);
  112484. }
  112485. return this;
  112486. };
  112487. /**
  112488. * A help function to create a joint
  112489. * @param otherImpostor A physics imposter used to create a joint
  112490. * @param jointType The type of joint
  112491. * @param jointData The data for the joint
  112492. * @returns The physics imposter
  112493. */
  112494. PhysicsImpostor.prototype.createJoint = function (otherImpostor, jointType, jointData) {
  112495. var joint = new _physicsJoint__WEBPACK_IMPORTED_MODULE_5__["PhysicsJoint"](jointType, jointData);
  112496. this.addJoint(otherImpostor, joint);
  112497. return this;
  112498. };
  112499. /**
  112500. * Add a joint to this impostor with a different impostor
  112501. * @param otherImpostor A physics imposter used to add a joint
  112502. * @param joint The joint to add
  112503. * @returns The physics imposter
  112504. */
  112505. PhysicsImpostor.prototype.addJoint = function (otherImpostor, joint) {
  112506. this._joints.push({
  112507. otherImpostor: otherImpostor,
  112508. joint: joint
  112509. });
  112510. if (this._physicsEngine) {
  112511. this._physicsEngine.addJoint(this, otherImpostor, joint);
  112512. }
  112513. return this;
  112514. };
  112515. /**
  112516. * Will keep this body still, in a sleep mode.
  112517. * @returns the physics imposter
  112518. */
  112519. PhysicsImpostor.prototype.sleep = function () {
  112520. if (this._physicsEngine) {
  112521. this._physicsEngine.getPhysicsPlugin().sleepBody(this);
  112522. }
  112523. return this;
  112524. };
  112525. /**
  112526. * Wake the body up.
  112527. * @returns The physics imposter
  112528. */
  112529. PhysicsImpostor.prototype.wakeUp = function () {
  112530. if (this._physicsEngine) {
  112531. this._physicsEngine.getPhysicsPlugin().wakeUpBody(this);
  112532. }
  112533. return this;
  112534. };
  112535. /**
  112536. * Clones the physics imposter
  112537. * @param newObject The physics imposter clones to this physics-enabled object
  112538. * @returns A nullable physics imposter
  112539. */
  112540. PhysicsImpostor.prototype.clone = function (newObject) {
  112541. if (!newObject) {
  112542. return null;
  112543. }
  112544. return new PhysicsImpostor(newObject, this.type, this._options, this._scene);
  112545. };
  112546. /**
  112547. * Disposes the physics imposter
  112548. */
  112549. PhysicsImpostor.prototype.dispose = function ( /*disposeChildren: boolean = true*/) {
  112550. var _this = this;
  112551. //no dispose if no physics engine is available.
  112552. if (!this._physicsEngine) {
  112553. return;
  112554. }
  112555. this._joints.forEach(function (j) {
  112556. if (_this._physicsEngine) {
  112557. _this._physicsEngine.removeJoint(_this, j.otherImpostor, j.joint);
  112558. }
  112559. });
  112560. //dispose the physics body
  112561. this._physicsEngine.removeImpostor(this);
  112562. if (this.parent) {
  112563. this.parent.forceUpdate();
  112564. }
  112565. else {
  112566. /*this._object.getChildMeshes().forEach(function(mesh) {
  112567. if (mesh.physicsImpostor) {
  112568. if (disposeChildren) {
  112569. mesh.physicsImpostor.dispose();
  112570. mesh.physicsImpostor = null;
  112571. }
  112572. }
  112573. })*/
  112574. }
  112575. this._isDisposed = true;
  112576. };
  112577. /**
  112578. * Sets the delta position
  112579. * @param position The delta position amount
  112580. */
  112581. PhysicsImpostor.prototype.setDeltaPosition = function (position) {
  112582. this._deltaPosition.copyFrom(position);
  112583. };
  112584. /**
  112585. * Sets the delta rotation
  112586. * @param rotation The delta rotation amount
  112587. */
  112588. PhysicsImpostor.prototype.setDeltaRotation = function (rotation) {
  112589. if (!this._deltaRotation) {
  112590. this._deltaRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  112591. }
  112592. this._deltaRotation.copyFrom(rotation);
  112593. this._deltaRotationConjugated = this._deltaRotation.conjugate();
  112594. };
  112595. /**
  112596. * Gets the box size of the physics imposter and stores the result in the input parameter
  112597. * @param result Stores the box size
  112598. * @returns The physics imposter
  112599. */
  112600. PhysicsImpostor.prototype.getBoxSizeToRef = function (result) {
  112601. if (this._physicsEngine) {
  112602. this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, result);
  112603. }
  112604. return this;
  112605. };
  112606. /**
  112607. * Gets the radius of the physics imposter
  112608. * @returns Radius of the physics imposter
  112609. */
  112610. PhysicsImpostor.prototype.getRadius = function () {
  112611. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0;
  112612. };
  112613. /**
  112614. * Sync a bone with this impostor
  112615. * @param bone The bone to sync to the impostor.
  112616. * @param boneMesh The mesh that the bone is influencing.
  112617. * @param jointPivot The pivot of the joint / bone in local space.
  112618. * @param distToJoint Optional distance from the impostor to the joint.
  112619. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  112620. */
  112621. PhysicsImpostor.prototype.syncBoneWithImpostor = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation) {
  112622. var tempVec = PhysicsImpostor._tmpVecs[0];
  112623. var mesh = this.object;
  112624. if (mesh.rotationQuaternion) {
  112625. if (adjustRotation) {
  112626. var tempQuat = PhysicsImpostor._tmpQuat;
  112627. mesh.rotationQuaternion.multiplyToRef(adjustRotation, tempQuat);
  112628. bone.setRotationQuaternion(tempQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  112629. }
  112630. else {
  112631. bone.setRotationQuaternion(mesh.rotationQuaternion, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  112632. }
  112633. }
  112634. tempVec.x = 0;
  112635. tempVec.y = 0;
  112636. tempVec.z = 0;
  112637. if (jointPivot) {
  112638. tempVec.x = jointPivot.x;
  112639. tempVec.y = jointPivot.y;
  112640. tempVec.z = jointPivot.z;
  112641. bone.getDirectionToRef(tempVec, boneMesh, tempVec);
  112642. if (distToJoint === undefined || distToJoint === null) {
  112643. distToJoint = jointPivot.length();
  112644. }
  112645. tempVec.x *= distToJoint;
  112646. tempVec.y *= distToJoint;
  112647. tempVec.z *= distToJoint;
  112648. }
  112649. if (bone.getParent()) {
  112650. tempVec.addInPlace(mesh.getAbsolutePosition());
  112651. bone.setAbsolutePosition(tempVec, boneMesh);
  112652. }
  112653. else {
  112654. boneMesh.setAbsolutePosition(mesh.getAbsolutePosition());
  112655. boneMesh.position.x -= tempVec.x;
  112656. boneMesh.position.y -= tempVec.y;
  112657. boneMesh.position.z -= tempVec.z;
  112658. }
  112659. };
  112660. /**
  112661. * Sync impostor to a bone
  112662. * @param bone The bone that the impostor will be synced to.
  112663. * @param boneMesh The mesh that the bone is influencing.
  112664. * @param jointPivot The pivot of the joint / bone in local space.
  112665. * @param distToJoint Optional distance from the impostor to the joint.
  112666. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  112667. * @param boneAxis Optional vector3 axis the bone is aligned with
  112668. */
  112669. PhysicsImpostor.prototype.syncImpostorWithBone = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation, boneAxis) {
  112670. var mesh = this.object;
  112671. if (mesh.rotationQuaternion) {
  112672. if (adjustRotation) {
  112673. var tempQuat = PhysicsImpostor._tmpQuat;
  112674. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, tempQuat);
  112675. tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);
  112676. }
  112677. else {
  112678. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, mesh.rotationQuaternion);
  112679. }
  112680. }
  112681. var pos = PhysicsImpostor._tmpVecs[0];
  112682. var boneDir = PhysicsImpostor._tmpVecs[1];
  112683. if (!boneAxis) {
  112684. boneAxis = PhysicsImpostor._tmpVecs[2];
  112685. boneAxis.x = 0;
  112686. boneAxis.y = 1;
  112687. boneAxis.z = 0;
  112688. }
  112689. bone.getDirectionToRef(boneAxis, boneMesh, boneDir);
  112690. bone.getAbsolutePositionToRef(boneMesh, pos);
  112691. if ((distToJoint === undefined || distToJoint === null) && jointPivot) {
  112692. distToJoint = jointPivot.length();
  112693. }
  112694. if (distToJoint !== undefined && distToJoint !== null) {
  112695. pos.x += boneDir.x * distToJoint;
  112696. pos.y += boneDir.y * distToJoint;
  112697. pos.z += boneDir.z * distToJoint;
  112698. }
  112699. mesh.setAbsolutePosition(pos);
  112700. };
  112701. /**
  112702. * The default object size of the imposter
  112703. */
  112704. PhysicsImpostor.DEFAULT_OBJECT_SIZE = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  112705. /**
  112706. * The identity quaternion of the imposter
  112707. */
  112708. PhysicsImpostor.IDENTITY_QUATERNION = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  112709. PhysicsImpostor._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero);
  112710. PhysicsImpostor._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  112711. //Impostor types
  112712. /**
  112713. * No-Imposter type
  112714. */
  112715. PhysicsImpostor.NoImpostor = 0;
  112716. /**
  112717. * Sphere-Imposter type
  112718. */
  112719. PhysicsImpostor.SphereImpostor = 1;
  112720. /**
  112721. * Box-Imposter type
  112722. */
  112723. PhysicsImpostor.BoxImpostor = 2;
  112724. /**
  112725. * Plane-Imposter type
  112726. */
  112727. PhysicsImpostor.PlaneImpostor = 3;
  112728. /**
  112729. * Mesh-imposter type
  112730. */
  112731. PhysicsImpostor.MeshImpostor = 4;
  112732. /**
  112733. * Cylinder-Imposter type
  112734. */
  112735. PhysicsImpostor.CylinderImpostor = 7;
  112736. /**
  112737. * Particle-Imposter type
  112738. */
  112739. PhysicsImpostor.ParticleImpostor = 8;
  112740. /**
  112741. * Heightmap-Imposter type
  112742. */
  112743. PhysicsImpostor.HeightmapImpostor = 9;
  112744. return PhysicsImpostor;
  112745. }());
  112746. /***/ }),
  112747. /***/ "./Physics/physicsJoint.ts":
  112748. /*!*********************************!*\
  112749. !*** ./Physics/physicsJoint.ts ***!
  112750. \*********************************/
  112751. /*! exports provided: PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint */
  112752. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112753. "use strict";
  112754. __webpack_require__.r(__webpack_exports__);
  112755. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return PhysicsJoint; });
  112756. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return DistanceJoint; });
  112757. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return MotorEnabledJoint; });
  112758. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return HingeJoint; });
  112759. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return Hinge2Joint; });
  112760. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  112761. /**
  112762. * This is a holder class for the physics joint created by the physics plugin
  112763. * It holds a set of functions to control the underlying joint
  112764. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112765. */
  112766. var PhysicsJoint = /** @class */ (function () {
  112767. /**
  112768. * Initializes the physics joint
  112769. * @param type The type of the physics joint
  112770. * @param jointData The data for the physics joint
  112771. */
  112772. function PhysicsJoint(
  112773. /**
  112774. * The type of the physics joint
  112775. */
  112776. type,
  112777. /**
  112778. * The data for the physics joint
  112779. */
  112780. jointData) {
  112781. this.type = type;
  112782. this.jointData = jointData;
  112783. jointData.nativeParams = jointData.nativeParams || {};
  112784. }
  112785. Object.defineProperty(PhysicsJoint.prototype, "physicsJoint", {
  112786. /**
  112787. * Gets the physics joint
  112788. */
  112789. get: function () {
  112790. return this._physicsJoint;
  112791. },
  112792. /**
  112793. * Sets the physics joint
  112794. */
  112795. set: function (newJoint) {
  112796. if (this._physicsJoint) {
  112797. //remove from the wolrd
  112798. }
  112799. this._physicsJoint = newJoint;
  112800. },
  112801. enumerable: true,
  112802. configurable: true
  112803. });
  112804. Object.defineProperty(PhysicsJoint.prototype, "physicsPlugin", {
  112805. /**
  112806. * Sets the physics plugin
  112807. */
  112808. set: function (physicsPlugin) {
  112809. this._physicsPlugin = physicsPlugin;
  112810. },
  112811. enumerable: true,
  112812. configurable: true
  112813. });
  112814. /**
  112815. * Execute a function that is physics-plugin specific.
  112816. * @param {Function} func the function that will be executed.
  112817. * It accepts two parameters: the physics world and the physics joint
  112818. */
  112819. PhysicsJoint.prototype.executeNativeFunction = function (func) {
  112820. func(this._physicsPlugin.world, this._physicsJoint);
  112821. };
  112822. //TODO check if the native joints are the same
  112823. //Joint Types
  112824. /**
  112825. * Distance-Joint type
  112826. */
  112827. PhysicsJoint.DistanceJoint = 0;
  112828. /**
  112829. * Hinge-Joint type
  112830. */
  112831. PhysicsJoint.HingeJoint = 1;
  112832. /**
  112833. * Ball-and-Socket joint type
  112834. */
  112835. PhysicsJoint.BallAndSocketJoint = 2;
  112836. /**
  112837. * Wheel-Joint type
  112838. */
  112839. PhysicsJoint.WheelJoint = 3;
  112840. /**
  112841. * Slider-Joint type
  112842. */
  112843. PhysicsJoint.SliderJoint = 4;
  112844. //OIMO
  112845. /**
  112846. * Prismatic-Joint type
  112847. */
  112848. PhysicsJoint.PrismaticJoint = 5;
  112849. //
  112850. /**
  112851. * Universal-Joint type
  112852. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  112853. */
  112854. PhysicsJoint.UniversalJoint = 6;
  112855. /**
  112856. * Hinge-Joint 2 type
  112857. */
  112858. PhysicsJoint.Hinge2Joint = PhysicsJoint.WheelJoint;
  112859. //Cannon
  112860. /**
  112861. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  112862. */
  112863. PhysicsJoint.PointToPointJoint = 8;
  112864. //Cannon only at the moment
  112865. /**
  112866. * Spring-Joint type
  112867. */
  112868. PhysicsJoint.SpringJoint = 9;
  112869. /**
  112870. * Lock-Joint type
  112871. */
  112872. PhysicsJoint.LockJoint = 10;
  112873. return PhysicsJoint;
  112874. }());
  112875. /**
  112876. * A class representing a physics distance joint
  112877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112878. */
  112879. var DistanceJoint = /** @class */ (function (_super) {
  112880. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DistanceJoint, _super);
  112881. /**
  112882. *
  112883. * @param jointData The data for the Distance-Joint
  112884. */
  112885. function DistanceJoint(jointData) {
  112886. return _super.call(this, PhysicsJoint.DistanceJoint, jointData) || this;
  112887. }
  112888. /**
  112889. * Update the predefined distance.
  112890. * @param maxDistance The maximum preferred distance
  112891. * @param minDistance The minimum preferred distance
  112892. */
  112893. DistanceJoint.prototype.updateDistance = function (maxDistance, minDistance) {
  112894. this._physicsPlugin.updateDistanceJoint(this, maxDistance, minDistance);
  112895. };
  112896. return DistanceJoint;
  112897. }(PhysicsJoint));
  112898. /**
  112899. * Represents a Motor-Enabled Joint
  112900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112901. */
  112902. var MotorEnabledJoint = /** @class */ (function (_super) {
  112903. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotorEnabledJoint, _super);
  112904. /**
  112905. * Initializes the Motor-Enabled Joint
  112906. * @param type The type of the joint
  112907. * @param jointData The physica joint data for the joint
  112908. */
  112909. function MotorEnabledJoint(type, jointData) {
  112910. return _super.call(this, type, jointData) || this;
  112911. }
  112912. /**
  112913. * Set the motor values.
  112914. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112915. * @param force the force to apply
  112916. * @param maxForce max force for this motor.
  112917. */
  112918. MotorEnabledJoint.prototype.setMotor = function (force, maxForce) {
  112919. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  112920. };
  112921. /**
  112922. * Set the motor's limits.
  112923. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112924. * @param upperLimit The upper limit of the motor
  112925. * @param lowerLimit The lower limit of the motor
  112926. */
  112927. MotorEnabledJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  112928. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  112929. };
  112930. return MotorEnabledJoint;
  112931. }(PhysicsJoint));
  112932. /**
  112933. * This class represents a single physics Hinge-Joint
  112934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112935. */
  112936. var HingeJoint = /** @class */ (function (_super) {
  112937. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HingeJoint, _super);
  112938. /**
  112939. * Initializes the Hinge-Joint
  112940. * @param jointData The joint data for the Hinge-Joint
  112941. */
  112942. function HingeJoint(jointData) {
  112943. return _super.call(this, PhysicsJoint.HingeJoint, jointData) || this;
  112944. }
  112945. /**
  112946. * Set the motor values.
  112947. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112948. * @param {number} force the force to apply
  112949. * @param {number} maxForce max force for this motor.
  112950. */
  112951. HingeJoint.prototype.setMotor = function (force, maxForce) {
  112952. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  112953. };
  112954. /**
  112955. * Set the motor's limits.
  112956. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112957. * @param upperLimit The upper limit of the motor
  112958. * @param lowerLimit The lower limit of the motor
  112959. */
  112960. HingeJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  112961. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  112962. };
  112963. return HingeJoint;
  112964. }(MotorEnabledJoint));
  112965. /**
  112966. * This class represents a dual hinge physics joint (same as wheel joint)
  112967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112968. */
  112969. var Hinge2Joint = /** @class */ (function (_super) {
  112970. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Hinge2Joint, _super);
  112971. /**
  112972. * Initializes the Hinge2-Joint
  112973. * @param jointData The joint data for the Hinge2-Joint
  112974. */
  112975. function Hinge2Joint(jointData) {
  112976. return _super.call(this, PhysicsJoint.Hinge2Joint, jointData) || this;
  112977. }
  112978. /**
  112979. * Set the motor values.
  112980. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112981. * @param {number} targetSpeed the speed the motor is to reach
  112982. * @param {number} maxForce max force for this motor.
  112983. * @param {motorIndex} the motor's index, 0 or 1.
  112984. */
  112985. Hinge2Joint.prototype.setMotor = function (targetSpeed, maxForce, motorIndex) {
  112986. if (motorIndex === void 0) { motorIndex = 0; }
  112987. this._physicsPlugin.setMotor(this, targetSpeed || 0, maxForce, motorIndex);
  112988. };
  112989. /**
  112990. * Set the motor limits.
  112991. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112992. * @param {number} upperLimit the upper limit
  112993. * @param {number} lowerLimit lower limit
  112994. * @param {motorIndex} the motor's index, 0 or 1.
  112995. */
  112996. Hinge2Joint.prototype.setLimit = function (upperLimit, lowerLimit, motorIndex) {
  112997. if (motorIndex === void 0) { motorIndex = 0; }
  112998. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit, motorIndex);
  112999. };
  113000. return Hinge2Joint;
  113001. }(MotorEnabledJoint));
  113002. /***/ }),
  113003. /***/ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts":
  113004. /*!****************************************************************************!*\
  113005. !*** ./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts ***!
  113006. \****************************************************************************/
  113007. /*! exports provided: DefaultRenderingPipeline */
  113008. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113009. "use strict";
  113010. __webpack_require__.r(__webpack_exports__);
  113011. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return DefaultRenderingPipeline; });
  113012. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  113013. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  113014. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  113015. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  113016. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  113017. /* harmony import */ var _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Layers/glowLayer */ "./Layers/glowLayer.ts");
  113018. /* harmony import */ var _PostProcesses_sharpenPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  113019. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  113020. /* harmony import */ var _PostProcesses_chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  113021. /* harmony import */ var _PostProcesses_grainPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  113022. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  113023. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  113024. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  113025. /* harmony import */ var _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../PostProcesses/depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  113026. /* harmony import */ var _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../../PostProcesses/bloomEffect */ "./PostProcesses/bloomEffect.ts");
  113027. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  113028. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  113029. /**
  113030. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  113031. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113032. */
  113033. var DefaultRenderingPipeline = /** @class */ (function (_super) {
  113034. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DefaultRenderingPipeline, _super);
  113035. /**
  113036. * @constructor
  113037. * @param name - The rendering pipeline name (default: "")
  113038. * @param hdr - If high dynamic range textures should be used (default: true)
  113039. * @param scene - The scene linked to this pipeline (default: the last created scene)
  113040. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  113041. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  113042. */
  113043. function DefaultRenderingPipeline(name, hdr, scene, cameras, automaticBuild) {
  113044. if (name === void 0) { name = ""; }
  113045. if (hdr === void 0) { hdr = true; }
  113046. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene; }
  113047. if (automaticBuild === void 0) { automaticBuild = true; }
  113048. var _this = _super.call(this, scene.getEngine(), name) || this;
  113049. _this._camerasToBeAttached = [];
  113050. /**
  113051. * ID of the sharpen post process,
  113052. */
  113053. _this.SharpenPostProcessId = "SharpenPostProcessEffect";
  113054. /**
  113055. * @ignore
  113056. * ID of the image processing post process;
  113057. */
  113058. _this.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect";
  113059. /**
  113060. * @ignore
  113061. * ID of the Fast Approximate Anti-Aliasing post process;
  113062. */
  113063. _this.FxaaPostProcessId = "FxaaPostProcessEffect";
  113064. /**
  113065. * ID of the chromatic aberration post process,
  113066. */
  113067. _this.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect";
  113068. /**
  113069. * ID of the grain post process
  113070. */
  113071. _this.GrainPostProcessId = "GrainPostProcessEffect";
  113072. /**
  113073. * Glow post process which adds a glow to emmisive areas of the image
  113074. */
  113075. _this._glowLayer = null;
  113076. /**
  113077. * Animations which can be used to tweak settings over a period of time
  113078. */
  113079. _this.animations = [];
  113080. _this._imageProcessingConfigurationObserver = null;
  113081. // Values
  113082. _this._sharpenEnabled = false;
  113083. _this._bloomEnabled = false;
  113084. _this._depthOfFieldEnabled = false;
  113085. _this._depthOfFieldBlurLevel = _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffectBlurLevel"].Low;
  113086. _this._fxaaEnabled = false;
  113087. _this._imageProcessingEnabled = true;
  113088. _this._bloomScale = 0.5;
  113089. _this._chromaticAberrationEnabled = false;
  113090. _this._grainEnabled = false;
  113091. _this._buildAllowed = true;
  113092. _this._resizeObserver = null;
  113093. _this._hardwareScaleLevel = 1.0;
  113094. _this._bloomKernel = 64;
  113095. /**
  113096. * Specifies the weight of the bloom in the final rendering
  113097. */
  113098. _this._bloomWeight = 0.15;
  113099. /**
  113100. * Specifies the luma threshold for the area that will be blurred by the bloom
  113101. */
  113102. _this._bloomThreshold = 0.9;
  113103. _this._samples = 1;
  113104. _this._hasCleared = false;
  113105. _this._prevPostProcess = null;
  113106. _this._prevPrevPostProcess = null;
  113107. _this._depthOfFieldSceneObserver = null;
  113108. _this._cameras = cameras || scene.cameras;
  113109. _this._cameras = _this._cameras.slice();
  113110. _this._camerasToBeAttached = _this._cameras.slice();
  113111. _this._buildAllowed = automaticBuild;
  113112. // Initialize
  113113. _this._scene = scene;
  113114. var caps = _this._scene.getEngine().getCaps();
  113115. _this._hdr = hdr && (caps.textureHalfFloatRender || caps.textureFloatRender);
  113116. // Misc
  113117. if (_this._hdr) {
  113118. if (caps.textureHalfFloatRender) {
  113119. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_HALF_FLOAT;
  113120. }
  113121. else if (caps.textureFloatRender) {
  113122. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_FLOAT;
  113123. }
  113124. }
  113125. else {
  113126. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  113127. }
  113128. // Attach
  113129. scene.postProcessRenderPipelineManager.addPipeline(_this);
  113130. var engine = _this._scene.getEngine();
  113131. // Create post processes before hand so they can be modified before enabled.
  113132. // Block compilation flag is set to true to avoid compilation prior to use, these will be updated on first use in build pipeline.
  113133. _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);
  113134. _this._sharpenEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.SharpenPostProcessId, function () { return _this.sharpen; }, true);
  113135. _this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](_this._scene, null, _this._depthOfFieldBlurLevel, _this._defaultPipelineTextureType, true);
  113136. _this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](_this._scene, _this._bloomScale, _this._bloomWeight, _this.bloomKernel, _this._defaultPipelineTextureType, true);
  113137. _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);
  113138. _this._chromaticAberrationEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.ChromaticAberrationPostProcessId, function () { return _this.chromaticAberration; }, true);
  113139. _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);
  113140. _this._grainEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.GrainPostProcessId, function () { return _this.grain; }, true);
  113141. _this._resizeObserver = engine.onResizeObservable.add(function () {
  113142. _this._hardwareScaleLevel = engine.getHardwareScalingLevel();
  113143. _this.bloomKernel = _this.bloomKernel;
  113144. });
  113145. _this._imageProcessingConfigurationObserver = _this._scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  113146. _this.bloom._downscale._exposure = _this._scene.imageProcessingConfiguration.exposure;
  113147. });
  113148. _this._buildPipeline();
  113149. return _this;
  113150. }
  113151. Object.defineProperty(DefaultRenderingPipeline.prototype, "sharpenEnabled", {
  113152. get: function () {
  113153. return this._sharpenEnabled;
  113154. },
  113155. /**
  113156. * Enable or disable the sharpen process from the pipeline
  113157. */
  113158. set: function (enabled) {
  113159. if (this._sharpenEnabled === enabled) {
  113160. return;
  113161. }
  113162. this._sharpenEnabled = enabled;
  113163. this._buildPipeline();
  113164. },
  113165. enumerable: true,
  113166. configurable: true
  113167. });
  113168. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomKernel", {
  113169. /**
  113170. * Specifies the size of the bloom blur kernel, relative to the final output size
  113171. */
  113172. get: function () {
  113173. return this._bloomKernel;
  113174. },
  113175. set: function (value) {
  113176. this._bloomKernel = value;
  113177. this.bloom.kernel = value / this._hardwareScaleLevel;
  113178. },
  113179. enumerable: true,
  113180. configurable: true
  113181. });
  113182. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomWeight", {
  113183. get: function () {
  113184. return this._bloomWeight;
  113185. },
  113186. /**
  113187. * The strength of the bloom.
  113188. */
  113189. set: function (value) {
  113190. if (this._bloomWeight === value) {
  113191. return;
  113192. }
  113193. this.bloom.weight = value;
  113194. this._bloomWeight = value;
  113195. },
  113196. enumerable: true,
  113197. configurable: true
  113198. });
  113199. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomThreshold", {
  113200. get: function () {
  113201. return this._bloomThreshold;
  113202. },
  113203. /**
  113204. * The strength of the bloom.
  113205. */
  113206. set: function (value) {
  113207. if (this._bloomThreshold === value) {
  113208. return;
  113209. }
  113210. this.bloom.threshold = value;
  113211. this._bloomThreshold = value;
  113212. },
  113213. enumerable: true,
  113214. configurable: true
  113215. });
  113216. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomScale", {
  113217. get: function () {
  113218. return this._bloomScale;
  113219. },
  113220. /**
  113221. * The scale of the bloom, lower value will provide better performance.
  113222. */
  113223. set: function (value) {
  113224. if (this._bloomScale === value) {
  113225. return;
  113226. }
  113227. this._bloomScale = value;
  113228. // recreate bloom and dispose old as this setting is not dynamic
  113229. this._rebuildBloom();
  113230. this._buildPipeline();
  113231. },
  113232. enumerable: true,
  113233. configurable: true
  113234. });
  113235. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomEnabled", {
  113236. get: function () {
  113237. return this._bloomEnabled;
  113238. },
  113239. /**
  113240. * Enable or disable the bloom from the pipeline
  113241. */
  113242. set: function (enabled) {
  113243. if (this._bloomEnabled === enabled) {
  113244. return;
  113245. }
  113246. this._bloomEnabled = enabled;
  113247. this._buildPipeline();
  113248. },
  113249. enumerable: true,
  113250. configurable: true
  113251. });
  113252. DefaultRenderingPipeline.prototype._rebuildBloom = function () {
  113253. // recreate bloom and dispose old as this setting is not dynamic
  113254. var oldBloom = this.bloom;
  113255. this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](this._scene, this.bloomScale, this._bloomWeight, this.bloomKernel, this._defaultPipelineTextureType, false);
  113256. this.bloom.threshold = oldBloom.threshold;
  113257. for (var i = 0; i < this._cameras.length; i++) {
  113258. oldBloom.disposeEffects(this._cameras[i]);
  113259. }
  113260. };
  113261. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", {
  113262. /**
  113263. * If the depth of field is enabled.
  113264. */
  113265. get: function () {
  113266. return this._depthOfFieldEnabled;
  113267. },
  113268. set: function (enabled) {
  113269. if (this._depthOfFieldEnabled === enabled) {
  113270. return;
  113271. }
  113272. this._depthOfFieldEnabled = enabled;
  113273. this._buildPipeline();
  113274. },
  113275. enumerable: true,
  113276. configurable: true
  113277. });
  113278. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", {
  113279. /**
  113280. * Blur level of the depth of field effect. (Higher blur will effect performance)
  113281. */
  113282. get: function () {
  113283. return this._depthOfFieldBlurLevel;
  113284. },
  113285. set: function (value) {
  113286. if (this._depthOfFieldBlurLevel === value) {
  113287. return;
  113288. }
  113289. this._depthOfFieldBlurLevel = value;
  113290. // recreate dof and dispose old as this setting is not dynamic
  113291. var oldDof = this.depthOfField;
  113292. this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](this._scene, null, this._depthOfFieldBlurLevel, this._defaultPipelineTextureType, false);
  113293. this.depthOfField.focalLength = oldDof.focalLength;
  113294. this.depthOfField.focusDistance = oldDof.focusDistance;
  113295. this.depthOfField.fStop = oldDof.fStop;
  113296. this.depthOfField.lensSize = oldDof.lensSize;
  113297. for (var i = 0; i < this._cameras.length; i++) {
  113298. oldDof.disposeEffects(this._cameras[i]);
  113299. }
  113300. this._buildPipeline();
  113301. },
  113302. enumerable: true,
  113303. configurable: true
  113304. });
  113305. Object.defineProperty(DefaultRenderingPipeline.prototype, "fxaaEnabled", {
  113306. get: function () {
  113307. return this._fxaaEnabled;
  113308. },
  113309. /**
  113310. * If the anti aliasing is enabled.
  113311. */
  113312. set: function (enabled) {
  113313. if (this._fxaaEnabled === enabled) {
  113314. return;
  113315. }
  113316. this._fxaaEnabled = enabled;
  113317. this._buildPipeline();
  113318. },
  113319. enumerable: true,
  113320. configurable: true
  113321. });
  113322. Object.defineProperty(DefaultRenderingPipeline.prototype, "samples", {
  113323. get: function () {
  113324. return this._samples;
  113325. },
  113326. /**
  113327. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113328. */
  113329. set: function (sampleCount) {
  113330. if (this._samples === sampleCount) {
  113331. return;
  113332. }
  113333. this._samples = sampleCount;
  113334. this._buildPipeline();
  113335. },
  113336. enumerable: true,
  113337. configurable: true
  113338. });
  113339. Object.defineProperty(DefaultRenderingPipeline.prototype, "imageProcessingEnabled", {
  113340. get: function () {
  113341. return this._imageProcessingEnabled;
  113342. },
  113343. /**
  113344. * If image processing is enabled.
  113345. */
  113346. set: function (enabled) {
  113347. if (this._imageProcessingEnabled === enabled) {
  113348. return;
  113349. }
  113350. this._imageProcessingEnabled = enabled;
  113351. this._buildPipeline();
  113352. },
  113353. enumerable: true,
  113354. configurable: true
  113355. });
  113356. Object.defineProperty(DefaultRenderingPipeline.prototype, "glowLayerEnabled", {
  113357. get: function () {
  113358. return this._glowLayer == null;
  113359. },
  113360. /**
  113361. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  113362. */
  113363. set: function (enabled) {
  113364. if (enabled && !this._glowLayer) {
  113365. this._glowLayer = new _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__["GlowLayer"]("", this._scene);
  113366. }
  113367. else if (!enabled && this._glowLayer) {
  113368. this._glowLayer.dispose();
  113369. this._glowLayer = null;
  113370. }
  113371. },
  113372. enumerable: true,
  113373. configurable: true
  113374. });
  113375. Object.defineProperty(DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", {
  113376. get: function () {
  113377. return this._chromaticAberrationEnabled;
  113378. },
  113379. /**
  113380. * Enable or disable the chromaticAberration process from the pipeline
  113381. */
  113382. set: function (enabled) {
  113383. if (this._chromaticAberrationEnabled === enabled) {
  113384. return;
  113385. }
  113386. this._chromaticAberrationEnabled = enabled;
  113387. this._buildPipeline();
  113388. },
  113389. enumerable: true,
  113390. configurable: true
  113391. });
  113392. Object.defineProperty(DefaultRenderingPipeline.prototype, "grainEnabled", {
  113393. get: function () {
  113394. return this._grainEnabled;
  113395. },
  113396. /**
  113397. * Enable or disable the grain process from the pipeline
  113398. */
  113399. set: function (enabled) {
  113400. if (this._grainEnabled === enabled) {
  113401. return;
  113402. }
  113403. this._grainEnabled = enabled;
  113404. this._buildPipeline();
  113405. },
  113406. enumerable: true,
  113407. configurable: true
  113408. });
  113409. /**
  113410. * Force the compilation of the entire pipeline.
  113411. */
  113412. DefaultRenderingPipeline.prototype.prepare = function () {
  113413. var previousState = this._buildAllowed;
  113414. this._buildAllowed = true;
  113415. this._buildPipeline();
  113416. this._buildAllowed = previousState;
  113417. };
  113418. DefaultRenderingPipeline.prototype._setAutoClearAndTextureSharing = function (postProcess, skipTextureSharing) {
  113419. if (skipTextureSharing === void 0) { skipTextureSharing = false; }
  113420. if (this._hasCleared) {
  113421. postProcess.autoClear = false;
  113422. }
  113423. else {
  113424. postProcess.autoClear = true;
  113425. this._scene.autoClear = false;
  113426. this._hasCleared = true;
  113427. }
  113428. if (!skipTextureSharing) {
  113429. if (this._prevPrevPostProcess) {
  113430. postProcess.shareOutputWith(this._prevPrevPostProcess);
  113431. }
  113432. else {
  113433. postProcess.useOwnOutput();
  113434. }
  113435. if (this._prevPostProcess) {
  113436. this._prevPrevPostProcess = this._prevPostProcess;
  113437. }
  113438. this._prevPostProcess = postProcess;
  113439. }
  113440. };
  113441. DefaultRenderingPipeline.prototype._buildPipeline = function () {
  113442. var _this = this;
  113443. if (!this._buildAllowed) {
  113444. return;
  113445. }
  113446. this._scene.autoClear = true;
  113447. var engine = this._scene.getEngine();
  113448. this._disposePostProcesses();
  113449. if (this._cameras !== null) {
  113450. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  113451. // get back cameras to be used to reattach pipeline
  113452. this._cameras = this._camerasToBeAttached.slice();
  113453. }
  113454. this._reset();
  113455. this._prevPostProcess = null;
  113456. this._prevPrevPostProcess = null;
  113457. this._hasCleared = false;
  113458. if (this.depthOfFieldEnabled) {
  113459. // Multi camera suport
  113460. if (this._cameras.length > 1) {
  113461. for (var _i = 0, _a = this._cameras; _i < _a.length; _i++) {
  113462. var camera = _a[_i];
  113463. var depthRenderer = this._scene.enableDepthRenderer(camera);
  113464. depthRenderer.useOnlyInActiveCamera = true;
  113465. }
  113466. this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add(function (scene) {
  113467. if (_this._cameras.indexOf(scene.activeCamera) > -1) {
  113468. _this.depthOfField.depthTexture = scene.enableDepthRenderer(scene.activeCamera).getDepthMap();
  113469. }
  113470. });
  113471. }
  113472. else {
  113473. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  113474. var depthRenderer = this._scene.enableDepthRenderer(this._cameras[0]);
  113475. this.depthOfField.depthTexture = depthRenderer.getDepthMap();
  113476. }
  113477. if (!this.depthOfField._isReady()) {
  113478. this.depthOfField._updateEffects();
  113479. }
  113480. this.addEffect(this.depthOfField);
  113481. this._setAutoClearAndTextureSharing(this.depthOfField._effects[0], true);
  113482. }
  113483. else {
  113484. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  113485. }
  113486. if (this.bloomEnabled) {
  113487. if (!this.bloom._isReady()) {
  113488. this.bloom._updateEffects();
  113489. }
  113490. this.addEffect(this.bloom);
  113491. this._setAutoClearAndTextureSharing(this.bloom._effects[0], true);
  113492. }
  113493. if (this._imageProcessingEnabled) {
  113494. 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);
  113495. if (this._hdr) {
  113496. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.ImageProcessingPostProcessId, function () { return _this.imageProcessing; }, true));
  113497. this._setAutoClearAndTextureSharing(this.imageProcessing);
  113498. }
  113499. else {
  113500. this._scene.imageProcessingConfiguration.applyByPostProcess = false;
  113501. }
  113502. }
  113503. if (this.sharpenEnabled) {
  113504. if (!this.sharpen.isReady()) {
  113505. this.sharpen.updateEffect();
  113506. }
  113507. this.addEffect(this._sharpenEffect);
  113508. this._setAutoClearAndTextureSharing(this.sharpen);
  113509. }
  113510. if (this.grainEnabled) {
  113511. if (!this.grain.isReady()) {
  113512. this.grain.updateEffect();
  113513. }
  113514. this.addEffect(this._grainEffect);
  113515. this._setAutoClearAndTextureSharing(this.grain);
  113516. }
  113517. if (this.chromaticAberrationEnabled) {
  113518. if (!this.chromaticAberration.isReady()) {
  113519. this.chromaticAberration.updateEffect();
  113520. }
  113521. this.addEffect(this._chromaticAberrationEffect);
  113522. this._setAutoClearAndTextureSharing(this.chromaticAberration);
  113523. }
  113524. if (this.fxaaEnabled) {
  113525. 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);
  113526. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.FxaaPostProcessId, function () { return _this.fxaa; }, true));
  113527. this._setAutoClearAndTextureSharing(this.fxaa, true);
  113528. }
  113529. if (this._cameras !== null) {
  113530. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  113531. }
  113532. if (!this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1) {
  113533. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  113534. }
  113535. };
  113536. DefaultRenderingPipeline.prototype._disposePostProcesses = function (disposeNonRecreated) {
  113537. if (disposeNonRecreated === void 0) { disposeNonRecreated = false; }
  113538. for (var i = 0; i < this._cameras.length; i++) {
  113539. var camera = this._cameras[i];
  113540. if (this.imageProcessing) {
  113541. this.imageProcessing.dispose(camera);
  113542. }
  113543. if (this.fxaa) {
  113544. this.fxaa.dispose(camera);
  113545. }
  113546. // These are created in the constructor and should not be disposed on every pipeline change
  113547. if (disposeNonRecreated) {
  113548. if (this.sharpen) {
  113549. this.sharpen.dispose(camera);
  113550. }
  113551. if (this.depthOfField) {
  113552. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  113553. this.depthOfField.disposeEffects(camera);
  113554. }
  113555. if (this.bloom) {
  113556. this.bloom.disposeEffects(camera);
  113557. }
  113558. if (this.chromaticAberration) {
  113559. this.chromaticAberration.dispose(camera);
  113560. }
  113561. if (this.grain) {
  113562. this.grain.dispose(camera);
  113563. }
  113564. if (this._glowLayer) {
  113565. this._glowLayer.dispose();
  113566. }
  113567. }
  113568. }
  113569. this.imageProcessing = null;
  113570. this.fxaa = null;
  113571. if (disposeNonRecreated) {
  113572. this.sharpen = null;
  113573. this._sharpenEffect = null;
  113574. this.depthOfField = null;
  113575. this.bloom = null;
  113576. this.chromaticAberration = null;
  113577. this._chromaticAberrationEffect = null;
  113578. this.grain = null;
  113579. this._grainEffect = null;
  113580. this._glowLayer = null;
  113581. }
  113582. };
  113583. /**
  113584. * Adds a camera to the pipeline
  113585. * @param camera the camera to be added
  113586. */
  113587. DefaultRenderingPipeline.prototype.addCamera = function (camera) {
  113588. this._camerasToBeAttached.push(camera);
  113589. this._buildPipeline();
  113590. };
  113591. /**
  113592. * Removes a camera from the pipeline
  113593. * @param camera the camera to remove
  113594. */
  113595. DefaultRenderingPipeline.prototype.removeCamera = function (camera) {
  113596. var index = this._camerasToBeAttached.indexOf(camera);
  113597. this._camerasToBeAttached.splice(index, 1);
  113598. this._buildPipeline();
  113599. };
  113600. /**
  113601. * Dispose of the pipeline and stop all post processes
  113602. */
  113603. DefaultRenderingPipeline.prototype.dispose = function () {
  113604. this._disposePostProcesses(true);
  113605. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  113606. this._scene.autoClear = true;
  113607. if (this._resizeObserver) {
  113608. this._scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  113609. this._resizeObserver = null;
  113610. }
  113611. this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver);
  113612. _super.prototype.dispose.call(this);
  113613. };
  113614. /**
  113615. * Serialize the rendering pipeline (Used when exporting)
  113616. * @returns the serialized object
  113617. */
  113618. DefaultRenderingPipeline.prototype.serialize = function () {
  113619. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  113620. serializationObject.customType = "DefaultRenderingPipeline";
  113621. return serializationObject;
  113622. };
  113623. /**
  113624. * Parse the serialized pipeline
  113625. * @param source Source pipeline.
  113626. * @param scene The scene to load the pipeline to.
  113627. * @param rootUrl The URL of the serialized pipeline.
  113628. * @returns An instantiated pipeline from the serialized object.
  113629. */
  113630. DefaultRenderingPipeline.Parse = function (source, scene, rootUrl) {
  113631. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new DefaultRenderingPipeline(source._name, source._name._hdr, scene); }, source, scene, rootUrl);
  113632. };
  113633. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113634. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113635. ], DefaultRenderingPipeline.prototype, "sharpenEnabled", null);
  113636. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113637. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113638. ], DefaultRenderingPipeline.prototype, "bloomKernel", null);
  113639. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113640. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113641. ], DefaultRenderingPipeline.prototype, "_bloomWeight", void 0);
  113642. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113643. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113644. ], DefaultRenderingPipeline.prototype, "_bloomThreshold", void 0);
  113645. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113646. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113647. ], DefaultRenderingPipeline.prototype, "_hdr", void 0);
  113648. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113649. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113650. ], DefaultRenderingPipeline.prototype, "bloomWeight", null);
  113651. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113652. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113653. ], DefaultRenderingPipeline.prototype, "bloomThreshold", null);
  113654. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113655. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113656. ], DefaultRenderingPipeline.prototype, "bloomScale", null);
  113657. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113658. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113659. ], DefaultRenderingPipeline.prototype, "bloomEnabled", null);
  113660. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113661. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113662. ], DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", null);
  113663. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113664. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113665. ], DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", null);
  113666. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113667. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113668. ], DefaultRenderingPipeline.prototype, "fxaaEnabled", null);
  113669. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113670. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113671. ], DefaultRenderingPipeline.prototype, "samples", null);
  113672. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113673. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113674. ], DefaultRenderingPipeline.prototype, "imageProcessingEnabled", null);
  113675. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113676. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113677. ], DefaultRenderingPipeline.prototype, "glowLayerEnabled", null);
  113678. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113679. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113680. ], DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", null);
  113681. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113682. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113683. ], DefaultRenderingPipeline.prototype, "grainEnabled", null);
  113684. return DefaultRenderingPipeline;
  113685. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__["PostProcessRenderPipeline"]));
  113686. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__["_TypeStore"].RegisteredTypes["BABYLON.DefaultRenderingPipeline"] = DefaultRenderingPipeline;
  113687. /***/ }),
  113688. /***/ "./PostProcesses/RenderPipeline/Pipelines/index.ts":
  113689. /*!*********************************************************!*\
  113690. !*** ./PostProcesses/RenderPipeline/Pipelines/index.ts ***!
  113691. \*********************************************************/
  113692. /*! exports provided: DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  113693. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113694. "use strict";
  113695. __webpack_require__.r(__webpack_exports__);
  113696. /* harmony import */ var _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts");
  113697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  113698. /* harmony import */ var _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts");
  113699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__["LensRenderingPipeline"]; });
  113700. /* harmony import */ var _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ssao2RenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts");
  113701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__["SSAO2RenderingPipeline"]; });
  113702. /* harmony import */ var _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ssaoRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts");
  113703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__["SSAORenderingPipeline"]; });
  113704. /* harmony import */ var _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./standardRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts");
  113705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__["StandardRenderingPipeline"]; });
  113706. /***/ }),
  113707. /***/ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts":
  113708. /*!*************************************************************************!*\
  113709. !*** ./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts ***!
  113710. \*************************************************************************/
  113711. /*! exports provided: LensRenderingPipeline */
  113712. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113713. "use strict";
  113714. __webpack_require__.r(__webpack_exports__);
  113715. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return LensRenderingPipeline; });
  113716. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  113717. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  113718. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  113719. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  113720. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  113721. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  113722. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  113723. /* harmony import */ var _Shaders_lensHighlights_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Shaders/lensHighlights.fragment */ "./Shaders/lensHighlights.fragment.ts");
  113724. /* harmony import */ var _Shaders_depthOfField_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../Shaders/depthOfField.fragment */ "./Shaders/depthOfField.fragment.ts");
  113725. /**
  113726. * BABYLON.JS Chromatic Aberration GLSL Shader
  113727. * Author: Olivier Guyot
  113728. * Separates very slightly R, G and B colors on the edges of the screen
  113729. * Inspired by Francois Tarlier & Martins Upitis
  113730. */
  113731. var LensRenderingPipeline = /** @class */ (function (_super) {
  113732. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensRenderingPipeline, _super);
  113733. /**
  113734. * @constructor
  113735. *
  113736. * Effect parameters are as follow:
  113737. * {
  113738. * chromatic_aberration: number; // from 0 to x (1 for realism)
  113739. * edge_blur: number; // from 0 to x (1 for realism)
  113740. * distortion: number; // from 0 to x (1 for realism)
  113741. * grain_amount: number; // from 0 to 1
  113742. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  113743. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  113744. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  113745. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  113746. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  113747. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  113748. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  113749. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  113750. * }
  113751. * Note: if an effect parameter is unset, effect is disabled
  113752. *
  113753. * @param name The rendering pipeline name
  113754. * @param parameters - An object containing all parameters (see above)
  113755. * @param scene The scene linked to this pipeline
  113756. * @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)
  113757. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113758. */
  113759. function LensRenderingPipeline(name, parameters, scene, ratio, cameras) {
  113760. if (ratio === void 0) { ratio = 1.0; }
  113761. var _this = _super.call(this, scene.getEngine(), name) || this;
  113762. // Lens effects can be of the following:
  113763. // - chromatic aberration (slight shift of RGB colors)
  113764. // - blur on the edge of the lens
  113765. // - lens distortion
  113766. // - depth-of-field blur & highlights enhancing
  113767. // - depth-of-field 'bokeh' effect (shapes appearing in blurred areas)
  113768. // - grain effect (noise or custom texture)
  113769. // Two additional texture samplers are needed:
  113770. // - depth map (for depth-of-field)
  113771. // - grain texture
  113772. /**
  113773. * @ignore
  113774. * The chromatic aberration PostProcess id in the pipeline
  113775. */
  113776. _this.LensChromaticAberrationEffect = "LensChromaticAberrationEffect";
  113777. /**
  113778. * @ignore
  113779. * The highlights enhancing PostProcess id in the pipeline
  113780. */
  113781. _this.HighlightsEnhancingEffect = "HighlightsEnhancingEffect";
  113782. /**
  113783. * @ignore
  113784. * The depth-of-field PostProcess id in the pipeline
  113785. */
  113786. _this.LensDepthOfFieldEffect = "LensDepthOfFieldEffect";
  113787. _this._scene = scene;
  113788. // Fetch texture samplers
  113789. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  113790. if (parameters.grain_texture) {
  113791. _this._grainTexture = parameters.grain_texture;
  113792. }
  113793. else {
  113794. _this._createGrainTexture();
  113795. }
  113796. // save parameters
  113797. _this._edgeBlur = parameters.edge_blur ? parameters.edge_blur : 0;
  113798. _this._grainAmount = parameters.grain_amount ? parameters.grain_amount : 0;
  113799. _this._chromaticAberration = parameters.chromatic_aberration ? parameters.chromatic_aberration : 0;
  113800. _this._distortion = parameters.distortion ? parameters.distortion : 0;
  113801. _this._highlightsGain = parameters.dof_gain !== undefined ? parameters.dof_gain : -1;
  113802. _this._highlightsThreshold = parameters.dof_threshold ? parameters.dof_threshold : 1;
  113803. _this._dofDistance = parameters.dof_focus_distance !== undefined ? parameters.dof_focus_distance : -1;
  113804. _this._dofAperture = parameters.dof_aperture ? parameters.dof_aperture : 1;
  113805. _this._dofDarken = parameters.dof_darken ? parameters.dof_darken : 0;
  113806. _this._dofPentagon = parameters.dof_pentagon !== undefined ? parameters.dof_pentagon : true;
  113807. _this._blurNoise = parameters.blur_noise !== undefined ? parameters.blur_noise : true;
  113808. // Create effects
  113809. _this._createChromaticAberrationPostProcess(ratio);
  113810. _this._createHighlightsPostProcess(ratio);
  113811. _this._createDepthOfFieldPostProcess(ratio / 4);
  113812. // Set up pipeline
  113813. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensChromaticAberrationEffect, function () { return _this._chromaticAberrationPostProcess; }, true));
  113814. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.HighlightsEnhancingEffect, function () { return _this._highlightsPostProcess; }, true));
  113815. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensDepthOfFieldEffect, function () { return _this._depthOfFieldPostProcess; }, true));
  113816. if (_this._highlightsGain === -1) {
  113817. _this._disableEffect(_this.HighlightsEnhancingEffect, null);
  113818. }
  113819. // Finish
  113820. scene.postProcessRenderPipelineManager.addPipeline(_this);
  113821. if (cameras) {
  113822. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  113823. }
  113824. return _this;
  113825. }
  113826. // public methods (self explanatory)
  113827. /**
  113828. * Sets the amount of blur at the edges
  113829. * @param amount blur amount
  113830. */
  113831. LensRenderingPipeline.prototype.setEdgeBlur = function (amount) { this._edgeBlur = amount; };
  113832. /**
  113833. * Sets edge blur to 0
  113834. */
  113835. LensRenderingPipeline.prototype.disableEdgeBlur = function () { this._edgeBlur = 0; };
  113836. /**
  113837. * Sets the amout of grain
  113838. * @param amount Amount of grain
  113839. */
  113840. LensRenderingPipeline.prototype.setGrainAmount = function (amount) { this._grainAmount = amount; };
  113841. /**
  113842. * Set grain amount to 0
  113843. */
  113844. LensRenderingPipeline.prototype.disableGrain = function () { this._grainAmount = 0; };
  113845. /**
  113846. * Sets the chromatic aberration amount
  113847. * @param amount amount of chromatic aberration
  113848. */
  113849. LensRenderingPipeline.prototype.setChromaticAberration = function (amount) { this._chromaticAberration = amount; };
  113850. /**
  113851. * Sets chromatic aberration amount to 0
  113852. */
  113853. LensRenderingPipeline.prototype.disableChromaticAberration = function () { this._chromaticAberration = 0; };
  113854. /**
  113855. * Sets the EdgeDistortion amount
  113856. * @param amount amount of EdgeDistortion
  113857. */
  113858. LensRenderingPipeline.prototype.setEdgeDistortion = function (amount) { this._distortion = amount; };
  113859. /**
  113860. * Sets edge distortion to 0
  113861. */
  113862. LensRenderingPipeline.prototype.disableEdgeDistortion = function () { this._distortion = 0; };
  113863. /**
  113864. * Sets the FocusDistance amount
  113865. * @param amount amount of FocusDistance
  113866. */
  113867. LensRenderingPipeline.prototype.setFocusDistance = function (amount) { this._dofDistance = amount; };
  113868. /**
  113869. * Disables depth of field
  113870. */
  113871. LensRenderingPipeline.prototype.disableDepthOfField = function () { this._dofDistance = -1; };
  113872. /**
  113873. * Sets the Aperture amount
  113874. * @param amount amount of Aperture
  113875. */
  113876. LensRenderingPipeline.prototype.setAperture = function (amount) { this._dofAperture = amount; };
  113877. /**
  113878. * Sets the DarkenOutOfFocus amount
  113879. * @param amount amount of DarkenOutOfFocus
  113880. */
  113881. LensRenderingPipeline.prototype.setDarkenOutOfFocus = function (amount) { this._dofDarken = amount; };
  113882. /**
  113883. * Creates a pentagon bokeh effect
  113884. */
  113885. LensRenderingPipeline.prototype.enablePentagonBokeh = function () {
  113886. this._highlightsPostProcess.updateEffect("#define PENTAGON\n");
  113887. };
  113888. /**
  113889. * Disables the pentagon bokeh effect
  113890. */
  113891. LensRenderingPipeline.prototype.disablePentagonBokeh = function () {
  113892. this._highlightsPostProcess.updateEffect();
  113893. };
  113894. /**
  113895. * Enables noise blur
  113896. */
  113897. LensRenderingPipeline.prototype.enableNoiseBlur = function () { this._blurNoise = true; };
  113898. /**
  113899. * Disables noise blur
  113900. */
  113901. LensRenderingPipeline.prototype.disableNoiseBlur = function () { this._blurNoise = false; };
  113902. /**
  113903. * Sets the HighlightsGain amount
  113904. * @param amount amount of HighlightsGain
  113905. */
  113906. LensRenderingPipeline.prototype.setHighlightsGain = function (amount) {
  113907. this._highlightsGain = amount;
  113908. };
  113909. /**
  113910. * Sets the HighlightsThreshold amount
  113911. * @param amount amount of HighlightsThreshold
  113912. */
  113913. LensRenderingPipeline.prototype.setHighlightsThreshold = function (amount) {
  113914. if (this._highlightsGain === -1) {
  113915. this._highlightsGain = 1.0;
  113916. }
  113917. this._highlightsThreshold = amount;
  113918. };
  113919. /**
  113920. * Disables highlights
  113921. */
  113922. LensRenderingPipeline.prototype.disableHighlights = function () {
  113923. this._highlightsGain = -1;
  113924. };
  113925. /**
  113926. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  113927. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  113928. */
  113929. LensRenderingPipeline.prototype.dispose = function (disableDepthRender) {
  113930. if (disableDepthRender === void 0) { disableDepthRender = false; }
  113931. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  113932. this._chromaticAberrationPostProcess = null;
  113933. this._highlightsPostProcess = null;
  113934. this._depthOfFieldPostProcess = null;
  113935. this._grainTexture.dispose();
  113936. if (disableDepthRender) {
  113937. this._scene.disableDepthRenderer();
  113938. }
  113939. };
  113940. // colors shifting and distortion
  113941. LensRenderingPipeline.prototype._createChromaticAberrationPostProcess = function (ratio) {
  113942. var _this = this;
  113943. this._chromaticAberrationPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensChromaticAberration", "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], // uniforms
  113944. [], // samplers
  113945. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  113946. this._chromaticAberrationPostProcess.onApply = function (effect) {
  113947. effect.setFloat('chromatic_aberration', _this._chromaticAberration);
  113948. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  113949. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  113950. effect.setFloat('radialIntensity', 1);
  113951. effect.setFloat2('direction', 17, 17);
  113952. effect.setFloat2('centerPosition', 0.5, 0.5);
  113953. };
  113954. };
  113955. // highlights enhancing
  113956. LensRenderingPipeline.prototype._createHighlightsPostProcess = function (ratio) {
  113957. var _this = this;
  113958. this._highlightsPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensHighlights", "lensHighlights", ["gain", "threshold", "screen_width", "screen_height"], // uniforms
  113959. [], // samplers
  113960. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, this._dofPentagon ? "#define PENTAGON\n" : "");
  113961. this._highlightsPostProcess.onApply = function (effect) {
  113962. effect.setFloat('gain', _this._highlightsGain);
  113963. effect.setFloat('threshold', _this._highlightsThreshold);
  113964. effect.setTextureFromPostProcess("textureSampler", _this._chromaticAberrationPostProcess);
  113965. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  113966. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  113967. };
  113968. };
  113969. // colors shifting and distortion
  113970. LensRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (ratio) {
  113971. var _this = this;
  113972. this._depthOfFieldPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensDepthOfField", "depthOfField", [
  113973. "grain_amount", "blur_noise", "screen_width", "screen_height", "distortion", "dof_enabled",
  113974. "screen_distance", "aperture", "darken", "edge_blur", "highlights", "near", "far"
  113975. ], ["depthSampler", "grainSampler", "highlightsSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  113976. this._depthOfFieldPostProcess.onApply = function (effect) {
  113977. effect.setTexture("depthSampler", _this._depthTexture);
  113978. effect.setTexture("grainSampler", _this._grainTexture);
  113979. effect.setTextureFromPostProcess("textureSampler", _this._highlightsPostProcess);
  113980. effect.setTextureFromPostProcess("highlightsSampler", _this._depthOfFieldPostProcess);
  113981. effect.setFloat('grain_amount', _this._grainAmount);
  113982. effect.setBool('blur_noise', _this._blurNoise);
  113983. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  113984. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  113985. effect.setFloat('distortion', _this._distortion);
  113986. effect.setBool('dof_enabled', (_this._dofDistance !== -1));
  113987. effect.setFloat('screen_distance', 1.0 / (0.1 - 1.0 / _this._dofDistance));
  113988. effect.setFloat('aperture', _this._dofAperture);
  113989. effect.setFloat('darken', _this._dofDarken);
  113990. effect.setFloat('edge_blur', _this._edgeBlur);
  113991. effect.setBool('highlights', (_this._highlightsGain !== -1));
  113992. if (_this._scene.activeCamera) {
  113993. effect.setFloat('near', _this._scene.activeCamera.minZ);
  113994. effect.setFloat('far', _this._scene.activeCamera.maxZ);
  113995. }
  113996. };
  113997. };
  113998. // creates a black and white random noise texture, 512x512
  113999. LensRenderingPipeline.prototype._createGrainTexture = function () {
  114000. var size = 512;
  114001. 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);
  114002. this._grainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  114003. this._grainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  114004. var context = this._grainTexture.getContext();
  114005. var rand = function (min, max) {
  114006. return Math.random() * (max - min) + min;
  114007. };
  114008. var value;
  114009. for (var x = 0; x < size; x++) {
  114010. for (var y = 0; y < size; y++) {
  114011. value = Math.floor(rand(0.42, 0.58) * 255);
  114012. context.fillStyle = 'rgb(' + value + ', ' + value + ', ' + value + ')';
  114013. context.fillRect(x, y, 1, 1);
  114014. }
  114015. }
  114016. this._grainTexture.update(false);
  114017. };
  114018. return LensRenderingPipeline;
  114019. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipeline"]));
  114020. /***/ }),
  114021. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts":
  114022. /*!**************************************************************************!*\
  114023. !*** ./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts ***!
  114024. \**************************************************************************/
  114025. /*! exports provided: SSAO2RenderingPipeline */
  114026. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114027. "use strict";
  114028. __webpack_require__.r(__webpack_exports__);
  114029. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return SSAO2RenderingPipeline; });
  114030. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  114031. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  114032. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  114033. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  114034. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  114035. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  114036. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  114037. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  114038. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  114039. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  114040. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  114041. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  114042. /* harmony import */ var _Shaders_ssao2_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssao2.fragment */ "./Shaders/ssao2.fragment.ts");
  114043. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  114044. /**
  114045. * Render pipeline to produce ssao effect
  114046. */
  114047. var SSAO2RenderingPipeline = /** @class */ (function (_super) {
  114048. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAO2RenderingPipeline, _super);
  114049. /**
  114050. * @constructor
  114051. * @param name The rendering pipeline name
  114052. * @param scene The scene linked to this pipeline
  114053. * @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 }
  114054. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114055. */
  114056. function SSAO2RenderingPipeline(name, scene, ratio, cameras) {
  114057. var _this = _super.call(this, scene.getEngine(), name) || this;
  114058. // Members
  114059. /**
  114060. * @ignore
  114061. * The PassPostProcess id in the pipeline that contains the original scene color
  114062. */
  114063. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  114064. /**
  114065. * @ignore
  114066. * The SSAO PostProcess id in the pipeline
  114067. */
  114068. _this.SSAORenderEffect = "SSAORenderEffect";
  114069. /**
  114070. * @ignore
  114071. * The horizontal blur PostProcess id in the pipeline
  114072. */
  114073. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  114074. /**
  114075. * @ignore
  114076. * The vertical blur PostProcess id in the pipeline
  114077. */
  114078. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  114079. /**
  114080. * @ignore
  114081. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  114082. */
  114083. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  114084. /**
  114085. * The output strength of the SSAO post-process. Default value is 1.0.
  114086. */
  114087. _this.totalStrength = 1.0;
  114088. /**
  114089. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  114090. */
  114091. _this.maxZ = 100.0;
  114092. /**
  114093. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  114094. */
  114095. _this.minZAspect = 0.2;
  114096. _this._samples = 8;
  114097. _this._textureSamples = 1;
  114098. _this._expensiveBlur = true;
  114099. /**
  114100. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  114101. */
  114102. _this.radius = 2.0;
  114103. /**
  114104. * The base color of the SSAO post-process
  114105. * The final result is "base + ssao" between [0, 1]
  114106. */
  114107. _this.base = 0;
  114108. _this._firstUpdate = true;
  114109. _this._bits = new Uint32Array(1);
  114110. _this._scene = scene;
  114111. _this._ratio = ratio;
  114112. if (!_this.isSupported) {
  114113. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("SSAO 2 needs WebGL 2 support.");
  114114. return _this;
  114115. }
  114116. var ssaoRatio = _this._ratio.ssaoRatio || ratio;
  114117. var blurRatio = _this._ratio.blurRatio || ratio;
  114118. // Set up assets
  114119. var geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  114120. _this._createRandomTexture();
  114121. _this._depthTexture = geometryBufferRenderer.getGBuffer().textures[0];
  114122. _this._normalTexture = geometryBufferRenderer.getGBuffer().textures[1];
  114123. _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);
  114124. _this._originalColorPostProcess.samples = _this.textureSamples;
  114125. _this._createSSAOPostProcess(1.0);
  114126. _this._createBlurPostProcess(ssaoRatio, blurRatio);
  114127. _this._createSSAOCombinePostProcess(blurRatio);
  114128. // Set up pipeline
  114129. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  114130. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  114131. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  114132. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  114133. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  114134. // Finish
  114135. scene.postProcessRenderPipelineManager.addPipeline(_this);
  114136. if (cameras) {
  114137. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  114138. }
  114139. return _this;
  114140. }
  114141. Object.defineProperty(SSAO2RenderingPipeline.prototype, "samples", {
  114142. get: function () {
  114143. return this._samples;
  114144. },
  114145. /**
  114146. * Number of samples used for the SSAO calculations. Default value is 8
  114147. */
  114148. set: function (n) {
  114149. this._ssaoPostProcess.updateEffect("#define SAMPLES " + n + "\n#define SSAO");
  114150. this._samples = n;
  114151. this._sampleSphere = this._generateHemisphere();
  114152. this._firstUpdate = true;
  114153. },
  114154. enumerable: true,
  114155. configurable: true
  114156. });
  114157. Object.defineProperty(SSAO2RenderingPipeline.prototype, "textureSamples", {
  114158. get: function () {
  114159. return this._textureSamples;
  114160. },
  114161. /**
  114162. * Number of samples to use for antialiasing
  114163. */
  114164. set: function (n) {
  114165. this._textureSamples = n;
  114166. this._originalColorPostProcess.samples = n;
  114167. this._blurHPostProcess.samples = n;
  114168. this._blurVPostProcess.samples = n;
  114169. this._ssaoPostProcess.samples = n;
  114170. this._ssaoCombinePostProcess.samples = n;
  114171. },
  114172. enumerable: true,
  114173. configurable: true
  114174. });
  114175. Object.defineProperty(SSAO2RenderingPipeline.prototype, "expensiveBlur", {
  114176. get: function () {
  114177. return this._expensiveBlur;
  114178. },
  114179. /**
  114180. * If bilateral blur should be used
  114181. */
  114182. set: function (b) {
  114183. 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"]);
  114184. this._blurVPostProcess.updateEffect("#define BILATERAL_BLUR\n#define SAMPLES 16\n#define EXPENSIVE " + (b ? "1" : "0") + "\n", null, ["textureSampler", "depthSampler"]);
  114185. this._expensiveBlur = b;
  114186. this._firstUpdate = true;
  114187. },
  114188. enumerable: true,
  114189. configurable: true
  114190. });
  114191. Object.defineProperty(SSAO2RenderingPipeline, "IsSupported", {
  114192. /**
  114193. * Support test.
  114194. */
  114195. get: function () {
  114196. var engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__["EngineStore"].LastCreatedEngine;
  114197. if (!engine) {
  114198. return false;
  114199. }
  114200. return engine.getCaps().drawBuffersExtension;
  114201. },
  114202. enumerable: true,
  114203. configurable: true
  114204. });
  114205. // Public Methods
  114206. /**
  114207. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  114208. */
  114209. SSAO2RenderingPipeline.prototype.dispose = function (disableGeometryBufferRenderer) {
  114210. if (disableGeometryBufferRenderer === void 0) { disableGeometryBufferRenderer = false; }
  114211. for (var i = 0; i < this._scene.cameras.length; i++) {
  114212. var camera = this._scene.cameras[i];
  114213. this._originalColorPostProcess.dispose(camera);
  114214. this._ssaoPostProcess.dispose(camera);
  114215. this._blurHPostProcess.dispose(camera);
  114216. this._blurVPostProcess.dispose(camera);
  114217. this._ssaoCombinePostProcess.dispose(camera);
  114218. }
  114219. this._randomTexture.dispose();
  114220. if (disableGeometryBufferRenderer) {
  114221. this._scene.disableGeometryBufferRenderer();
  114222. }
  114223. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  114224. _super.prototype.dispose.call(this);
  114225. };
  114226. // Private Methods
  114227. SSAO2RenderingPipeline.prototype._createBlurPostProcess = function (ssaoRatio, blurRatio) {
  114228. var _this = this;
  114229. this._samplerOffsets = [];
  114230. var expensive = this.expensiveBlur;
  114231. for (var i = -8; i < 8; i++) {
  114232. this._samplerOffsets.push(i * 2 + 0.5);
  114233. }
  114234. 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");
  114235. this._blurHPostProcess.onApply = function (effect) {
  114236. if (!_this._scene.activeCamera) {
  114237. return;
  114238. }
  114239. effect.setFloat("outSize", _this._ssaoCombinePostProcess.width > 0 ? _this._ssaoCombinePostProcess.width : _this._originalColorPostProcess.width);
  114240. effect.setFloat("near", _this._scene.activeCamera.minZ);
  114241. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  114242. effect.setFloat("radius", _this.radius);
  114243. effect.setTexture("depthSampler", _this._depthTexture);
  114244. if (_this._firstUpdate) {
  114245. effect.setArray("samplerOffsets", _this._samplerOffsets);
  114246. }
  114247. };
  114248. 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");
  114249. this._blurVPostProcess.onApply = function (effect) {
  114250. if (!_this._scene.activeCamera) {
  114251. return;
  114252. }
  114253. effect.setFloat("outSize", _this._ssaoCombinePostProcess.height > 0 ? _this._ssaoCombinePostProcess.height : _this._originalColorPostProcess.height);
  114254. effect.setFloat("near", _this._scene.activeCamera.minZ);
  114255. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  114256. effect.setFloat("radius", _this.radius);
  114257. effect.setTexture("depthSampler", _this._depthTexture);
  114258. if (_this._firstUpdate) {
  114259. effect.setArray("samplerOffsets", _this._samplerOffsets);
  114260. _this._firstUpdate = false;
  114261. }
  114262. };
  114263. this._blurHPostProcess.samples = this.textureSamples;
  114264. this._blurVPostProcess.samples = this.textureSamples;
  114265. };
  114266. /** @hidden */
  114267. SSAO2RenderingPipeline.prototype._rebuild = function () {
  114268. this._firstUpdate = true;
  114269. _super.prototype._rebuild.call(this);
  114270. };
  114271. //Van der Corput radical inverse
  114272. SSAO2RenderingPipeline.prototype._radicalInverse_VdC = function (i) {
  114273. this._bits[0] = i;
  114274. this._bits[0] = ((this._bits[0] << 16) | (this._bits[0] >> 16)) >>> 0;
  114275. this._bits[0] = ((this._bits[0] & 0x55555555) << 1) | ((this._bits[0] & 0xAAAAAAAA) >>> 1) >>> 0;
  114276. this._bits[0] = ((this._bits[0] & 0x33333333) << 2) | ((this._bits[0] & 0xCCCCCCCC) >>> 2) >>> 0;
  114277. this._bits[0] = ((this._bits[0] & 0x0F0F0F0F) << 4) | ((this._bits[0] & 0xF0F0F0F0) >>> 4) >>> 0;
  114278. this._bits[0] = ((this._bits[0] & 0x00FF00FF) << 8) | ((this._bits[0] & 0xFF00FF00) >>> 8) >>> 0;
  114279. return this._bits[0] * 2.3283064365386963e-10; // / 0x100000000 or / 4294967296
  114280. };
  114281. SSAO2RenderingPipeline.prototype._hammersley = function (i, n) {
  114282. return [i / n, this._radicalInverse_VdC(i)];
  114283. };
  114284. SSAO2RenderingPipeline.prototype._hemisphereSample_uniform = function (u, v) {
  114285. var phi = v * 2.0 * Math.PI;
  114286. // rejecting samples that are close to tangent plane to avoid z-fighting artifacts
  114287. var cosTheta = 1.0 - (u * 0.85 + 0.15);
  114288. var sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta);
  114289. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.cos(phi) * sinTheta, Math.sin(phi) * sinTheta, cosTheta);
  114290. };
  114291. SSAO2RenderingPipeline.prototype._generateHemisphere = function () {
  114292. var numSamples = this.samples;
  114293. var result = [];
  114294. var vector;
  114295. var i = 0;
  114296. while (i < numSamples) {
  114297. if (numSamples < 16) {
  114298. vector = this._hemisphereSample_uniform(Math.random(), Math.random());
  114299. }
  114300. else {
  114301. var rand = this._hammersley(i, numSamples);
  114302. vector = this._hemisphereSample_uniform(rand[0], rand[1]);
  114303. }
  114304. result.push(vector.x, vector.y, vector.z);
  114305. i++;
  114306. }
  114307. return result;
  114308. };
  114309. SSAO2RenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  114310. var _this = this;
  114311. var numSamples = this.samples;
  114312. this._sampleSphere = this._generateHemisphere();
  114313. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("ssao2", "ssao2", [
  114314. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  114315. "base", "range", "projection", "near", "far", "texelSize",
  114316. "xViewport", "yViewport", "maxZ", "minZAspect"
  114317. ], ["randomSampler", "normalSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  114318. this._ssaoPostProcess.onApply = function (effect) {
  114319. if (_this._firstUpdate) {
  114320. effect.setArray3("sampleSphere", _this._sampleSphere);
  114321. effect.setFloat("randTextureTiles", 32.0);
  114322. }
  114323. if (!_this._scene.activeCamera) {
  114324. return;
  114325. }
  114326. effect.setFloat("samplesFactor", 1 / _this.samples);
  114327. effect.setFloat("totalStrength", _this.totalStrength);
  114328. effect.setFloat2("texelSize", 1 / _this._ssaoPostProcess.width, 1 / _this._ssaoPostProcess.height);
  114329. effect.setFloat("radius", _this.radius);
  114330. effect.setFloat("maxZ", _this.maxZ);
  114331. effect.setFloat("minZAspect", _this.minZAspect);
  114332. effect.setFloat("base", _this.base);
  114333. effect.setFloat("near", _this._scene.activeCamera.minZ);
  114334. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  114335. effect.setFloat("xViewport", Math.tan(_this._scene.activeCamera.fov / 2) * _this._scene.getEngine().getAspectRatio(_this._scene.activeCamera, true));
  114336. effect.setFloat("yViewport", Math.tan(_this._scene.activeCamera.fov / 2));
  114337. effect.setMatrix("projection", _this._scene.getProjectionMatrix());
  114338. effect.setTexture("textureSampler", _this._depthTexture);
  114339. effect.setTexture("normalSampler", _this._normalTexture);
  114340. effect.setTexture("randomSampler", _this._randomTexture);
  114341. };
  114342. this._ssaoPostProcess.samples = this.textureSamples;
  114343. };
  114344. SSAO2RenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  114345. var _this = this;
  114346. 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);
  114347. this._ssaoCombinePostProcess.onApply = function (effect) {
  114348. var viewport = _this._scene.activeCamera.viewport;
  114349. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector4[0].copyFromFloats(viewport.x, viewport.y, viewport.width, viewport.height));
  114350. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  114351. };
  114352. this._ssaoCombinePostProcess.samples = this.textureSamples;
  114353. };
  114354. SSAO2RenderingPipeline.prototype._createRandomTexture = function () {
  114355. var size = 128;
  114356. 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);
  114357. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  114358. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  114359. var context = this._randomTexture.getContext();
  114360. var rand = function (min, max) {
  114361. return Math.random() * (max - min) + min;
  114362. };
  114363. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  114364. for (var x = 0; x < size; x++) {
  114365. for (var y = 0; y < size; y++) {
  114366. randVector.x = rand(0.0, 1.0);
  114367. randVector.y = rand(0.0, 1.0);
  114368. randVector.z = 0.0;
  114369. randVector.normalize();
  114370. randVector.scaleInPlace(255);
  114371. randVector.x = Math.floor(randVector.x);
  114372. randVector.y = Math.floor(randVector.y);
  114373. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  114374. context.fillRect(x, y, 1, 1);
  114375. }
  114376. }
  114377. this._randomTexture.update(false);
  114378. };
  114379. /**
  114380. * Serialize the rendering pipeline (Used when exporting)
  114381. * @returns the serialized object
  114382. */
  114383. SSAO2RenderingPipeline.prototype.serialize = function () {
  114384. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Serialize(this);
  114385. serializationObject.customType = "SSAO2RenderingPipeline";
  114386. return serializationObject;
  114387. };
  114388. /**
  114389. * Parse the serialized pipeline
  114390. * @param source Source pipeline.
  114391. * @param scene The scene to load the pipeline to.
  114392. * @param rootUrl The URL of the serialized pipeline.
  114393. * @returns An instantiated pipeline from the serialized object.
  114394. */
  114395. SSAO2RenderingPipeline.Parse = function (source, scene, rootUrl) {
  114396. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Parse(function () { return new SSAO2RenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  114397. };
  114398. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114399. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114400. ], SSAO2RenderingPipeline.prototype, "totalStrength", void 0);
  114401. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114402. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114403. ], SSAO2RenderingPipeline.prototype, "maxZ", void 0);
  114404. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114405. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114406. ], SSAO2RenderingPipeline.prototype, "minZAspect", void 0);
  114407. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114408. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("samples")
  114409. ], SSAO2RenderingPipeline.prototype, "_samples", void 0);
  114410. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114411. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("textureSamples")
  114412. ], SSAO2RenderingPipeline.prototype, "_textureSamples", void 0);
  114413. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114414. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114415. ], SSAO2RenderingPipeline.prototype, "_ratio", void 0);
  114416. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114417. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("expensiveBlur")
  114418. ], SSAO2RenderingPipeline.prototype, "_expensiveBlur", void 0);
  114419. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114420. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114421. ], SSAO2RenderingPipeline.prototype, "radius", void 0);
  114422. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114423. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114424. ], SSAO2RenderingPipeline.prototype, "base", void 0);
  114425. return SSAO2RenderingPipeline;
  114426. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  114427. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__["_TypeStore"].RegisteredTypes["BABYLON.SSAO2RenderingPipeline"] = SSAO2RenderingPipeline;
  114428. /***/ }),
  114429. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts":
  114430. /*!*************************************************************************!*\
  114431. !*** ./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts ***!
  114432. \*************************************************************************/
  114433. /*! exports provided: SSAORenderingPipeline */
  114434. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114435. "use strict";
  114436. __webpack_require__.r(__webpack_exports__);
  114437. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return SSAORenderingPipeline; });
  114438. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  114439. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  114440. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  114441. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  114442. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  114443. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  114444. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  114445. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  114446. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  114447. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  114448. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  114449. /* harmony import */ var _Shaders_ssao_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Shaders/ssao.fragment */ "./Shaders/ssao.fragment.ts");
  114450. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  114451. /**
  114452. * Render pipeline to produce ssao effect
  114453. */
  114454. var SSAORenderingPipeline = /** @class */ (function (_super) {
  114455. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAORenderingPipeline, _super);
  114456. /**
  114457. * @constructor
  114458. * @param name - The rendering pipeline name
  114459. * @param scene - The scene linked to this pipeline
  114460. * @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 }
  114461. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  114462. */
  114463. function SSAORenderingPipeline(name, scene, ratio, cameras) {
  114464. var _this = _super.call(this, scene.getEngine(), name) || this;
  114465. // Members
  114466. /**
  114467. * @ignore
  114468. * The PassPostProcess id in the pipeline that contains the original scene color
  114469. */
  114470. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  114471. /**
  114472. * @ignore
  114473. * The SSAO PostProcess id in the pipeline
  114474. */
  114475. _this.SSAORenderEffect = "SSAORenderEffect";
  114476. /**
  114477. * @ignore
  114478. * The horizontal blur PostProcess id in the pipeline
  114479. */
  114480. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  114481. /**
  114482. * @ignore
  114483. * The vertical blur PostProcess id in the pipeline
  114484. */
  114485. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  114486. /**
  114487. * @ignore
  114488. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  114489. */
  114490. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  114491. /**
  114492. * The output strength of the SSAO post-process. Default value is 1.0.
  114493. */
  114494. _this.totalStrength = 1.0;
  114495. /**
  114496. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  114497. */
  114498. _this.radius = 0.0001;
  114499. /**
  114500. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  114501. * Must not be equal to fallOff and superior to fallOff.
  114502. * Default value is 0.975
  114503. */
  114504. _this.area = 0.0075;
  114505. /**
  114506. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  114507. * Must not be equal to area and inferior to area.
  114508. * Default value is 0.0
  114509. */
  114510. _this.fallOff = 0.000001;
  114511. /**
  114512. * The base color of the SSAO post-process
  114513. * The final result is "base + ssao" between [0, 1]
  114514. */
  114515. _this.base = 0.5;
  114516. _this._firstUpdate = true;
  114517. _this._scene = scene;
  114518. // Set up assets
  114519. _this._createRandomTexture();
  114520. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  114521. var ssaoRatio = ratio.ssaoRatio || ratio;
  114522. var combineRatio = ratio.combineRatio || ratio;
  114523. _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);
  114524. _this._createSSAOPostProcess(ssaoRatio);
  114525. _this._createBlurPostProcess(ssaoRatio);
  114526. _this._createSSAOCombinePostProcess(combineRatio);
  114527. // Set up pipeline
  114528. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  114529. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  114530. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  114531. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  114532. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  114533. // Finish
  114534. scene.postProcessRenderPipelineManager.addPipeline(_this);
  114535. if (cameras) {
  114536. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  114537. }
  114538. return _this;
  114539. }
  114540. // Public Methods
  114541. /**
  114542. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  114543. */
  114544. SSAORenderingPipeline.prototype.dispose = function (disableDepthRender) {
  114545. if (disableDepthRender === void 0) { disableDepthRender = false; }
  114546. for (var i = 0; i < this._scene.cameras.length; i++) {
  114547. var camera = this._scene.cameras[i];
  114548. this._originalColorPostProcess.dispose(camera);
  114549. this._ssaoPostProcess.dispose(camera);
  114550. this._blurHPostProcess.dispose(camera);
  114551. this._blurVPostProcess.dispose(camera);
  114552. this._ssaoCombinePostProcess.dispose(camera);
  114553. }
  114554. this._randomTexture.dispose();
  114555. if (disableDepthRender) {
  114556. this._scene.disableDepthRenderer();
  114557. }
  114558. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  114559. _super.prototype.dispose.call(this);
  114560. };
  114561. // Private Methods
  114562. SSAORenderingPipeline.prototype._createBlurPostProcess = function (ratio) {
  114563. var _this = this;
  114564. var size = 16;
  114565. 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);
  114566. 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);
  114567. this._blurHPostProcess.onActivateObservable.add(function () {
  114568. var dw = _this._blurHPostProcess.width / _this._scene.getEngine().getRenderWidth();
  114569. _this._blurHPostProcess.kernel = size * dw;
  114570. });
  114571. this._blurVPostProcess.onActivateObservable.add(function () {
  114572. var dw = _this._blurVPostProcess.height / _this._scene.getEngine().getRenderHeight();
  114573. _this._blurVPostProcess.kernel = size * dw;
  114574. });
  114575. };
  114576. /** @hidden */
  114577. SSAORenderingPipeline.prototype._rebuild = function () {
  114578. this._firstUpdate = true;
  114579. _super.prototype._rebuild.call(this);
  114580. };
  114581. SSAORenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  114582. var _this = this;
  114583. var numSamples = 16;
  114584. var sampleSphere = [
  114585. 0.5381, 0.1856, -0.4319,
  114586. 0.1379, 0.2486, 0.4430,
  114587. 0.3371, 0.5679, -0.0057,
  114588. -0.6999, -0.0451, -0.0019,
  114589. 0.0689, -0.1598, -0.8547,
  114590. 0.0560, 0.0069, -0.1843,
  114591. -0.0146, 0.1402, 0.0762,
  114592. 0.0100, -0.1924, -0.0344,
  114593. -0.3577, -0.5301, -0.4358,
  114594. -0.3169, 0.1063, 0.0158,
  114595. 0.0103, -0.5869, 0.0046,
  114596. -0.0897, -0.4940, 0.3287,
  114597. 0.7119, -0.0154, -0.0918,
  114598. -0.0533, 0.0596, -0.5411,
  114599. 0.0352, -0.0631, 0.5460,
  114600. -0.4776, 0.2847, -0.0271
  114601. ];
  114602. var samplesFactor = 1.0 / numSamples;
  114603. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__["PostProcess"]("ssao", "ssao", [
  114604. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  114605. "area", "fallOff", "base", "range", "viewport"
  114606. ], ["randomSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  114607. this._ssaoPostProcess.onApply = function (effect) {
  114608. if (_this._firstUpdate) {
  114609. effect.setArray3("sampleSphere", sampleSphere);
  114610. effect.setFloat("samplesFactor", samplesFactor);
  114611. effect.setFloat("randTextureTiles", 4.0);
  114612. }
  114613. effect.setFloat("totalStrength", _this.totalStrength);
  114614. effect.setFloat("radius", _this.radius);
  114615. effect.setFloat("area", _this.area);
  114616. effect.setFloat("fallOff", _this.fallOff);
  114617. effect.setFloat("base", _this.base);
  114618. effect.setTexture("textureSampler", _this._depthTexture);
  114619. effect.setTexture("randomSampler", _this._randomTexture);
  114620. };
  114621. };
  114622. SSAORenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  114623. var _this = this;
  114624. 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);
  114625. this._ssaoCombinePostProcess.onApply = function (effect) {
  114626. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector4[0].copyFromFloats(0, 0, 1.0, 1.0));
  114627. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  114628. };
  114629. };
  114630. SSAORenderingPipeline.prototype._createRandomTexture = function () {
  114631. var size = 512;
  114632. 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);
  114633. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  114634. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  114635. var context = this._randomTexture.getContext();
  114636. var rand = function (min, max) {
  114637. return Math.random() * (max - min) + min;
  114638. };
  114639. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  114640. for (var x = 0; x < size; x++) {
  114641. for (var y = 0; y < size; y++) {
  114642. randVector.x = Math.floor(rand(-1.0, 1.0) * 255);
  114643. randVector.y = Math.floor(rand(-1.0, 1.0) * 255);
  114644. randVector.z = Math.floor(rand(-1.0, 1.0) * 255);
  114645. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  114646. context.fillRect(x, y, 1, 1);
  114647. }
  114648. }
  114649. this._randomTexture.update(false);
  114650. };
  114651. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114652. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  114653. ], SSAORenderingPipeline.prototype, "totalStrength", void 0);
  114654. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114655. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  114656. ], SSAORenderingPipeline.prototype, "radius", void 0);
  114657. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114658. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  114659. ], SSAORenderingPipeline.prototype, "area", void 0);
  114660. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114661. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  114662. ], SSAORenderingPipeline.prototype, "fallOff", void 0);
  114663. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114664. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  114665. ], SSAORenderingPipeline.prototype, "base", void 0);
  114666. return SSAORenderingPipeline;
  114667. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderPipeline"]));
  114668. /***/ }),
  114669. /***/ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts":
  114670. /*!*****************************************************************************!*\
  114671. !*** ./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts ***!
  114672. \*****************************************************************************/
  114673. /*! exports provided: StandardRenderingPipeline */
  114674. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114675. "use strict";
  114676. __webpack_require__.r(__webpack_exports__);
  114677. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return StandardRenderingPipeline; });
  114678. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  114679. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  114680. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  114681. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  114682. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  114683. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  114684. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  114685. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  114686. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  114687. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  114688. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  114689. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  114690. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  114691. /* harmony import */ var _Shaders_standard_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/standard.fragment */ "./Shaders/standard.fragment.ts");
  114692. /**
  114693. * Standard rendering pipeline
  114694. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114695. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  114696. */
  114697. var StandardRenderingPipeline = /** @class */ (function (_super) {
  114698. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardRenderingPipeline, _super);
  114699. /**
  114700. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114701. * @constructor
  114702. * @param name The rendering pipeline name
  114703. * @param scene The scene linked to this pipeline
  114704. * @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)
  114705. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  114706. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114707. */
  114708. function StandardRenderingPipeline(name, scene, ratio, originalPostProcess, cameras) {
  114709. if (originalPostProcess === void 0) { originalPostProcess = null; }
  114710. var _this = _super.call(this, scene.getEngine(), name) || this;
  114711. /**
  114712. * Post-process used to down scale an image x4
  114713. */
  114714. _this.downSampleX4PostProcess = null;
  114715. /**
  114716. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  114717. */
  114718. _this.brightPassPostProcess = null;
  114719. /**
  114720. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  114721. */
  114722. _this.blurHPostProcesses = [];
  114723. /**
  114724. * Post-process array storing all the vertical blur post-processes used by the pipeline
  114725. */
  114726. _this.blurVPostProcesses = [];
  114727. /**
  114728. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  114729. */
  114730. _this.textureAdderPostProcess = null;
  114731. /**
  114732. * Post-process used to create volumetric lighting effect
  114733. */
  114734. _this.volumetricLightPostProcess = null;
  114735. /**
  114736. * Post-process used to smooth the previous volumetric light post-process on the X axis
  114737. */
  114738. _this.volumetricLightSmoothXPostProcess = null;
  114739. /**
  114740. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  114741. */
  114742. _this.volumetricLightSmoothYPostProcess = null;
  114743. /**
  114744. * Post-process used to merge the volumetric light effect and the real scene color
  114745. */
  114746. _this.volumetricLightMergePostProces = null;
  114747. /**
  114748. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  114749. */
  114750. _this.volumetricLightFinalPostProcess = null;
  114751. /**
  114752. * Base post-process used to calculate the average luminance of the final image for HDR
  114753. */
  114754. _this.luminancePostProcess = null;
  114755. /**
  114756. * Post-processes used to create down sample post-processes in order to get
  114757. * the average luminance of the final image for HDR
  114758. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  114759. */
  114760. _this.luminanceDownSamplePostProcesses = [];
  114761. /**
  114762. * Post-process used to create a HDR effect (light adaptation)
  114763. */
  114764. _this.hdrPostProcess = null;
  114765. /**
  114766. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  114767. */
  114768. _this.textureAdderFinalPostProcess = null;
  114769. /**
  114770. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  114771. */
  114772. _this.lensFlareFinalPostProcess = null;
  114773. /**
  114774. * Post-process used to merge the final HDR post-process and the real scene color
  114775. */
  114776. _this.hdrFinalPostProcess = null;
  114777. /**
  114778. * Post-process used to create a lens flare effect
  114779. */
  114780. _this.lensFlarePostProcess = null;
  114781. /**
  114782. * Post-process that merges the result of the lens flare post-process and the real scene color
  114783. */
  114784. _this.lensFlareComposePostProcess = null;
  114785. /**
  114786. * Post-process used to create a motion blur effect
  114787. */
  114788. _this.motionBlurPostProcess = null;
  114789. /**
  114790. * Post-process used to create a depth of field effect
  114791. */
  114792. _this.depthOfFieldPostProcess = null;
  114793. /**
  114794. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  114795. */
  114796. _this.fxaaPostProcess = null;
  114797. // Values
  114798. /**
  114799. * Represents the brightness threshold in order to configure the illuminated surfaces
  114800. */
  114801. _this.brightThreshold = 1.0;
  114802. /**
  114803. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  114804. */
  114805. _this.blurWidth = 512.0;
  114806. /**
  114807. * Sets if the blur for highlighted surfaces must be only horizontal
  114808. */
  114809. _this.horizontalBlur = false;
  114810. /**
  114811. * Sets the overall exposure used by the pipeline
  114812. */
  114813. _this.exposure = 1.0;
  114814. /**
  114815. * Texture used typically to simulate "dirty" on camera lens
  114816. */
  114817. _this.lensTexture = null;
  114818. /**
  114819. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  114820. */
  114821. _this.volumetricLightCoefficient = 0.2;
  114822. /**
  114823. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  114824. */
  114825. _this.volumetricLightPower = 4.0;
  114826. /**
  114827. * Used the set the blur intensity to smooth the volumetric lights
  114828. */
  114829. _this.volumetricLightBlurScale = 64.0;
  114830. /**
  114831. * Light (spot or directional) used to generate the volumetric lights rays
  114832. * The source light must have a shadow generate so the pipeline can get its
  114833. * depth map
  114834. */
  114835. _this.sourceLight = null;
  114836. /**
  114837. * For eye adaptation, represents the minimum luminance the eye can see
  114838. */
  114839. _this.hdrMinimumLuminance = 1.0;
  114840. /**
  114841. * For eye adaptation, represents the decrease luminance speed
  114842. */
  114843. _this.hdrDecreaseRate = 0.5;
  114844. /**
  114845. * For eye adaptation, represents the increase luminance speed
  114846. */
  114847. _this.hdrIncreaseRate = 0.5;
  114848. /**
  114849. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  114850. */
  114851. _this.lensColorTexture = null;
  114852. /**
  114853. * The overall strengh for the lens flare effect
  114854. */
  114855. _this.lensFlareStrength = 20.0;
  114856. /**
  114857. * Dispersion coefficient for lens flare ghosts
  114858. */
  114859. _this.lensFlareGhostDispersal = 1.4;
  114860. /**
  114861. * Main lens flare halo width
  114862. */
  114863. _this.lensFlareHaloWidth = 0.7;
  114864. /**
  114865. * Based on the lens distortion effect, defines how much the lens flare result
  114866. * is distorted
  114867. */
  114868. _this.lensFlareDistortionStrength = 16.0;
  114869. /**
  114870. * Lens star texture must be used to simulate rays on the flares and is available
  114871. * in the documentation
  114872. */
  114873. _this.lensStarTexture = null;
  114874. /**
  114875. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  114876. * flare effect by taking account of the dirt texture
  114877. */
  114878. _this.lensFlareDirtTexture = null;
  114879. /**
  114880. * Represents the focal length for the depth of field effect
  114881. */
  114882. _this.depthOfFieldDistance = 10.0;
  114883. /**
  114884. * Represents the blur intensity for the blurred part of the depth of field effect
  114885. */
  114886. _this.depthOfFieldBlurWidth = 64.0;
  114887. /**
  114888. * For motion blur, defines how much the image is blurred by the movement
  114889. */
  114890. _this.motionStrength = 1.0;
  114891. /**
  114892. * List of animations for the pipeline (IAnimatable implementation)
  114893. */
  114894. _this.animations = [];
  114895. _this._currentDepthOfFieldSource = null;
  114896. _this._hdrCurrentLuminance = 1.0;
  114897. // Getters and setters
  114898. _this._bloomEnabled = false;
  114899. _this._depthOfFieldEnabled = false;
  114900. _this._vlsEnabled = false;
  114901. _this._lensFlareEnabled = false;
  114902. _this._hdrEnabled = false;
  114903. _this._motionBlurEnabled = false;
  114904. _this._fxaaEnabled = false;
  114905. _this._motionBlurSamples = 64.0;
  114906. _this._volumetricLightStepsCount = 50.0;
  114907. _this._samples = 1;
  114908. _this._cameras = cameras || [];
  114909. // Initialize
  114910. _this._scene = scene;
  114911. _this._basePostProcess = originalPostProcess;
  114912. _this._ratio = ratio;
  114913. // Misc
  114914. _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;
  114915. // Finish
  114916. scene.postProcessRenderPipelineManager.addPipeline(_this);
  114917. _this._buildPipeline();
  114918. return _this;
  114919. }
  114920. Object.defineProperty(StandardRenderingPipeline.prototype, "BloomEnabled", {
  114921. /**
  114922. * @ignore
  114923. * Specifies if the bloom pipeline is enabled
  114924. */
  114925. get: function () {
  114926. return this._bloomEnabled;
  114927. },
  114928. set: function (enabled) {
  114929. if (this._bloomEnabled === enabled) {
  114930. return;
  114931. }
  114932. this._bloomEnabled = enabled;
  114933. this._buildPipeline();
  114934. },
  114935. enumerable: true,
  114936. configurable: true
  114937. });
  114938. Object.defineProperty(StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", {
  114939. /**
  114940. * @ignore
  114941. * Specifies if the depth of field pipeline is enabed
  114942. */
  114943. get: function () {
  114944. return this._depthOfFieldEnabled;
  114945. },
  114946. set: function (enabled) {
  114947. if (this._depthOfFieldEnabled === enabled) {
  114948. return;
  114949. }
  114950. this._depthOfFieldEnabled = enabled;
  114951. this._buildPipeline();
  114952. },
  114953. enumerable: true,
  114954. configurable: true
  114955. });
  114956. Object.defineProperty(StandardRenderingPipeline.prototype, "LensFlareEnabled", {
  114957. /**
  114958. * @ignore
  114959. * Specifies if the lens flare pipeline is enabed
  114960. */
  114961. get: function () {
  114962. return this._lensFlareEnabled;
  114963. },
  114964. set: function (enabled) {
  114965. if (this._lensFlareEnabled === enabled) {
  114966. return;
  114967. }
  114968. this._lensFlareEnabled = enabled;
  114969. this._buildPipeline();
  114970. },
  114971. enumerable: true,
  114972. configurable: true
  114973. });
  114974. Object.defineProperty(StandardRenderingPipeline.prototype, "HDREnabled", {
  114975. /**
  114976. * @ignore
  114977. * Specifies if the HDR pipeline is enabled
  114978. */
  114979. get: function () {
  114980. return this._hdrEnabled;
  114981. },
  114982. set: function (enabled) {
  114983. if (this._hdrEnabled === enabled) {
  114984. return;
  114985. }
  114986. this._hdrEnabled = enabled;
  114987. this._buildPipeline();
  114988. },
  114989. enumerable: true,
  114990. configurable: true
  114991. });
  114992. Object.defineProperty(StandardRenderingPipeline.prototype, "VLSEnabled", {
  114993. /**
  114994. * @ignore
  114995. * Specifies if the volumetric lights scattering effect is enabled
  114996. */
  114997. get: function () {
  114998. return this._vlsEnabled;
  114999. },
  115000. set: function (enabled) {
  115001. if (this._vlsEnabled === enabled) {
  115002. return;
  115003. }
  115004. if (enabled) {
  115005. var geometry = this._scene.enableGeometryBufferRenderer();
  115006. if (!geometry) {
  115007. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");
  115008. return;
  115009. }
  115010. }
  115011. this._vlsEnabled = enabled;
  115012. this._buildPipeline();
  115013. },
  115014. enumerable: true,
  115015. configurable: true
  115016. });
  115017. Object.defineProperty(StandardRenderingPipeline.prototype, "MotionBlurEnabled", {
  115018. /**
  115019. * @ignore
  115020. * Specifies if the motion blur effect is enabled
  115021. */
  115022. get: function () {
  115023. return this._motionBlurEnabled;
  115024. },
  115025. set: function (enabled) {
  115026. if (this._motionBlurEnabled === enabled) {
  115027. return;
  115028. }
  115029. this._motionBlurEnabled = enabled;
  115030. this._buildPipeline();
  115031. },
  115032. enumerable: true,
  115033. configurable: true
  115034. });
  115035. Object.defineProperty(StandardRenderingPipeline.prototype, "fxaaEnabled", {
  115036. /**
  115037. * Specifies if anti-aliasing is enabled
  115038. */
  115039. get: function () {
  115040. return this._fxaaEnabled;
  115041. },
  115042. set: function (enabled) {
  115043. if (this._fxaaEnabled === enabled) {
  115044. return;
  115045. }
  115046. this._fxaaEnabled = enabled;
  115047. this._buildPipeline();
  115048. },
  115049. enumerable: true,
  115050. configurable: true
  115051. });
  115052. Object.defineProperty(StandardRenderingPipeline.prototype, "volumetricLightStepsCount", {
  115053. /**
  115054. * Specifies the number of steps used to calculate the volumetric lights
  115055. * Typically in interval [50, 200]
  115056. */
  115057. get: function () {
  115058. return this._volumetricLightStepsCount;
  115059. },
  115060. set: function (count) {
  115061. if (this.volumetricLightPostProcess) {
  115062. this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS " + count.toFixed(1));
  115063. }
  115064. this._volumetricLightStepsCount = count;
  115065. },
  115066. enumerable: true,
  115067. configurable: true
  115068. });
  115069. Object.defineProperty(StandardRenderingPipeline.prototype, "motionBlurSamples", {
  115070. /**
  115071. * Specifies the number of samples used for the motion blur effect
  115072. * Typically in interval [16, 64]
  115073. */
  115074. get: function () {
  115075. return this._motionBlurSamples;
  115076. },
  115077. set: function (samples) {
  115078. if (this.motionBlurPostProcess) {
  115079. this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES " + samples.toFixed(1));
  115080. }
  115081. this._motionBlurSamples = samples;
  115082. },
  115083. enumerable: true,
  115084. configurable: true
  115085. });
  115086. Object.defineProperty(StandardRenderingPipeline.prototype, "samples", {
  115087. /**
  115088. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  115089. */
  115090. get: function () {
  115091. return this._samples;
  115092. },
  115093. set: function (sampleCount) {
  115094. if (this._samples === sampleCount) {
  115095. return;
  115096. }
  115097. this._samples = sampleCount;
  115098. this._buildPipeline();
  115099. },
  115100. enumerable: true,
  115101. configurable: true
  115102. });
  115103. StandardRenderingPipeline.prototype._buildPipeline = function () {
  115104. var _this = this;
  115105. var ratio = this._ratio;
  115106. var scene = this._scene;
  115107. this._disposePostProcesses();
  115108. this._reset();
  115109. // Create pass post-process
  115110. if (!this._basePostProcess) {
  115111. 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);
  115112. this.originalPostProcess.onApply = function () {
  115113. _this._currentDepthOfFieldSource = _this.originalPostProcess;
  115114. };
  115115. }
  115116. else {
  115117. this.originalPostProcess = this._basePostProcess;
  115118. }
  115119. if (this._bloomEnabled || this._vlsEnabled || this._lensFlareEnabled || this._depthOfFieldEnabled || this._motionBlurEnabled) {
  115120. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPassPostProcess", function () { return _this.originalPostProcess; }, true));
  115121. }
  115122. this._currentDepthOfFieldSource = this.originalPostProcess;
  115123. if (this._bloomEnabled) {
  115124. // Create down sample X4 post-process
  115125. this._createDownSampleX4PostProcess(scene, ratio / 2);
  115126. // Create bright pass post-process
  115127. this._createBrightPassPostProcess(scene, ratio / 2);
  115128. // Create gaussian blur post-processes (down sampling blurs)
  115129. this._createBlurPostProcesses(scene, ratio / 4, 1);
  115130. // Create texture adder post-process
  115131. this._createTextureAdderPostProcess(scene, ratio);
  115132. // Create depth-of-field source post-process
  115133. 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);
  115134. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBaseDepthOfFieldSource", function () { return _this.textureAdderFinalPostProcess; }, true));
  115135. }
  115136. if (this._vlsEnabled) {
  115137. // Create volumetric light
  115138. this._createVolumetricLightPostProcess(scene, ratio);
  115139. // Create volumetric light final post-process
  115140. 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);
  115141. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSFinal", function () { return _this.volumetricLightFinalPostProcess; }, true));
  115142. }
  115143. if (this._lensFlareEnabled) {
  115144. // Create lens flare post-process
  115145. this._createLensFlarePostProcess(scene, ratio);
  115146. // Create depth-of-field source post-process post lens-flare and disable it now
  115147. 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);
  115148. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostLensFlareDepthOfFieldSource", function () { return _this.lensFlareFinalPostProcess; }, true));
  115149. }
  115150. if (this._hdrEnabled) {
  115151. // Create luminance
  115152. this._createLuminancePostProcesses(scene, this._floatTextureType);
  115153. // Create HDR
  115154. this._createHdrPostProcess(scene, ratio);
  115155. // Create depth-of-field source post-process post hdr and disable it now
  115156. 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);
  115157. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostHDReDepthOfFieldSource", function () { return _this.hdrFinalPostProcess; }, true));
  115158. }
  115159. if (this._depthOfFieldEnabled) {
  115160. // Create gaussian blur used by depth-of-field
  115161. this._createBlurPostProcesses(scene, ratio / 2, 3, "depthOfFieldBlurWidth");
  115162. // Create depth-of-field post-process
  115163. this._createDepthOfFieldPostProcess(scene, ratio);
  115164. }
  115165. if (this._motionBlurEnabled) {
  115166. // Create motion blur post-process
  115167. this._createMotionBlurPostProcess(scene, ratio);
  115168. }
  115169. if (this._fxaaEnabled) {
  115170. // Create fxaa post-process
  115171. 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);
  115172. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRFxaa", function () { return _this.fxaaPostProcess; }, true));
  115173. }
  115174. if (this._cameras !== null) {
  115175. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  115176. }
  115177. if (!this._enableMSAAOnFirstPostProcess(this._samples) && this._samples > 1) {
  115178. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  115179. }
  115180. };
  115181. // Down Sample X4 Post-Processs
  115182. StandardRenderingPipeline.prototype._createDownSampleX4PostProcess = function (scene, ratio) {
  115183. var _this = this;
  115184. var downSampleX4Offsets = new Array(32);
  115185. 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);
  115186. this.downSampleX4PostProcess.onApply = function (effect) {
  115187. var id = 0;
  115188. var width = _this.downSampleX4PostProcess.width;
  115189. var height = _this.downSampleX4PostProcess.height;
  115190. for (var i = -2; i < 2; i++) {
  115191. for (var j = -2; j < 2; j++) {
  115192. downSampleX4Offsets[id] = (i + 0.5) * (1.0 / width);
  115193. downSampleX4Offsets[id + 1] = (j + 0.5) * (1.0 / height);
  115194. id += 2;
  115195. }
  115196. }
  115197. effect.setArray2("dsOffsets", downSampleX4Offsets);
  115198. };
  115199. // Add to pipeline
  115200. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDownSampleX4", function () { return _this.downSampleX4PostProcess; }, true));
  115201. };
  115202. // Brightpass Post-Process
  115203. StandardRenderingPipeline.prototype._createBrightPassPostProcess = function (scene, ratio) {
  115204. var _this = this;
  115205. var brightOffsets = new Array(8);
  115206. 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);
  115207. this.brightPassPostProcess.onApply = function (effect) {
  115208. var sU = (1.0 / _this.brightPassPostProcess.width);
  115209. var sV = (1.0 / _this.brightPassPostProcess.height);
  115210. brightOffsets[0] = -0.5 * sU;
  115211. brightOffsets[1] = 0.5 * sV;
  115212. brightOffsets[2] = 0.5 * sU;
  115213. brightOffsets[3] = 0.5 * sV;
  115214. brightOffsets[4] = -0.5 * sU;
  115215. brightOffsets[5] = -0.5 * sV;
  115216. brightOffsets[6] = 0.5 * sU;
  115217. brightOffsets[7] = -0.5 * sV;
  115218. effect.setArray2("dsOffsets", brightOffsets);
  115219. effect.setFloat("brightThreshold", _this.brightThreshold);
  115220. };
  115221. // Add to pipeline
  115222. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBrightPass", function () { return _this.brightPassPostProcess; }, true));
  115223. };
  115224. // Create blur H&V post-processes
  115225. StandardRenderingPipeline.prototype._createBlurPostProcesses = function (scene, ratio, indice, blurWidthKey) {
  115226. var _this = this;
  115227. if (blurWidthKey === void 0) { blurWidthKey = "blurWidth"; }
  115228. var engine = scene.getEngine();
  115229. 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);
  115230. 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);
  115231. blurX.onActivateObservable.add(function () {
  115232. var dw = blurX.width / engine.getRenderWidth();
  115233. blurX.kernel = _this[blurWidthKey] * dw;
  115234. });
  115235. blurY.onActivateObservable.add(function () {
  115236. var dw = blurY.height / engine.getRenderHeight();
  115237. blurY.kernel = _this.horizontalBlur ? 64 * dw : _this[blurWidthKey] * dw;
  115238. });
  115239. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurH" + indice, function () { return blurX; }, true));
  115240. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurV" + indice, function () { return blurY; }, true));
  115241. this.blurHPostProcesses.push(blurX);
  115242. this.blurVPostProcesses.push(blurY);
  115243. };
  115244. // Create texture adder post-process
  115245. StandardRenderingPipeline.prototype._createTextureAdderPostProcess = function (scene, ratio) {
  115246. var _this = this;
  115247. 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);
  115248. this.textureAdderPostProcess.onApply = function (effect) {
  115249. effect.setTextureFromPostProcess("otherSampler", _this._vlsEnabled ? _this._currentDepthOfFieldSource : _this.originalPostProcess);
  115250. effect.setTexture("lensSampler", _this.lensTexture);
  115251. effect.setFloat("exposure", _this.exposure);
  115252. _this._currentDepthOfFieldSource = _this.textureAdderFinalPostProcess;
  115253. };
  115254. // Add to pipeline
  115255. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRTextureAdder", function () { return _this.textureAdderPostProcess; }, true));
  115256. };
  115257. StandardRenderingPipeline.prototype._createVolumetricLightPostProcess = function (scene, ratio) {
  115258. var _this = this;
  115259. var geometryRenderer = scene.enableGeometryBufferRenderer();
  115260. geometryRenderer.enablePosition = true;
  115261. var geometry = geometryRenderer.getGBuffer();
  115262. // Base post-process
  115263. 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));
  115264. var depthValues = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  115265. this.volumetricLightPostProcess.onApply = function (effect) {
  115266. if (_this.sourceLight && _this.sourceLight.getShadowGenerator() && _this._scene.activeCamera) {
  115267. var generator = _this.sourceLight.getShadowGenerator();
  115268. effect.setTexture("shadowMapSampler", generator.getShadowMap());
  115269. effect.setTexture("positionSampler", geometry.textures[2]);
  115270. effect.setColor3("sunColor", _this.sourceLight.diffuse);
  115271. effect.setVector3("sunDirection", _this.sourceLight.getShadowDirection());
  115272. effect.setVector3("cameraPosition", _this._scene.activeCamera.globalPosition);
  115273. effect.setMatrix("shadowViewProjection", generator.getTransformMatrix());
  115274. effect.setFloat("scatteringCoefficient", _this.volumetricLightCoefficient);
  115275. effect.setFloat("scatteringPower", _this.volumetricLightPower);
  115276. depthValues.x = _this.sourceLight.getDepthMinZ(_this._scene.activeCamera);
  115277. depthValues.y = _this.sourceLight.getDepthMaxZ(_this._scene.activeCamera);
  115278. effect.setVector2("depthValues", depthValues);
  115279. }
  115280. };
  115281. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLS", function () { return _this.volumetricLightPostProcess; }, true));
  115282. // Smooth
  115283. this._createBlurPostProcesses(scene, ratio / 4, 0, "volumetricLightBlurScale");
  115284. // Merge
  115285. 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");
  115286. this.volumetricLightMergePostProces.onApply = function (effect) {
  115287. effect.setTextureFromPostProcess("originalSampler", _this._bloomEnabled ? _this.textureAdderFinalPostProcess : _this.originalPostProcess);
  115288. _this._currentDepthOfFieldSource = _this.volumetricLightFinalPostProcess;
  115289. };
  115290. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSMerge", function () { return _this.volumetricLightMergePostProces; }, true));
  115291. };
  115292. // Create luminance
  115293. StandardRenderingPipeline.prototype._createLuminancePostProcesses = function (scene, textureType) {
  115294. var _this = this;
  115295. // Create luminance
  115296. var size = Math.pow(3, StandardRenderingPipeline.LuminanceSteps);
  115297. 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);
  115298. var offsets = [];
  115299. this.luminancePostProcess.onApply = function (effect) {
  115300. var sU = (1.0 / _this.luminancePostProcess.width);
  115301. var sV = (1.0 / _this.luminancePostProcess.height);
  115302. offsets[0] = -0.5 * sU;
  115303. offsets[1] = 0.5 * sV;
  115304. offsets[2] = 0.5 * sU;
  115305. offsets[3] = 0.5 * sV;
  115306. offsets[4] = -0.5 * sU;
  115307. offsets[5] = -0.5 * sV;
  115308. offsets[6] = 0.5 * sU;
  115309. offsets[7] = -0.5 * sV;
  115310. effect.setArray2("lumOffsets", offsets);
  115311. };
  115312. // Add to pipeline
  115313. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminance", function () { return _this.luminancePostProcess; }, true));
  115314. // Create down sample luminance
  115315. for (var i = StandardRenderingPipeline.LuminanceSteps - 1; i >= 0; i--) {
  115316. var size = Math.pow(3, i);
  115317. var defines = "#define LUMINANCE_DOWN_SAMPLE\n";
  115318. if (i === 0) {
  115319. defines += "#define FINAL_DOWN_SAMPLER";
  115320. }
  115321. 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);
  115322. this.luminanceDownSamplePostProcesses.push(postProcess);
  115323. }
  115324. // Create callbacks and add effects
  115325. var lastLuminance = this.luminancePostProcess;
  115326. this.luminanceDownSamplePostProcesses.forEach(function (pp, index) {
  115327. var downSampleOffsets = new Array(18);
  115328. pp.onApply = function (effect) {
  115329. if (!lastLuminance) {
  115330. return;
  115331. }
  115332. var id = 0;
  115333. for (var x = -1; x < 2; x++) {
  115334. for (var y = -1; y < 2; y++) {
  115335. downSampleOffsets[id] = x / lastLuminance.width;
  115336. downSampleOffsets[id + 1] = y / lastLuminance.height;
  115337. id += 2;
  115338. }
  115339. }
  115340. effect.setArray2("dsOffsets", downSampleOffsets);
  115341. effect.setFloat("halfDestPixelSize", 0.5 / lastLuminance.width);
  115342. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  115343. lastLuminance = _this.luminancePostProcess;
  115344. }
  115345. else {
  115346. lastLuminance = pp;
  115347. }
  115348. };
  115349. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  115350. pp.onAfterRender = function () {
  115351. var pixel = scene.getEngine().readPixels(0, 0, 1, 1);
  115352. 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);
  115353. _this._hdrCurrentLuminance = (pixel[0] * bit_shift.x + pixel[1] * bit_shift.y + pixel[2] * bit_shift.z + pixel[3] * bit_shift.w) / 100.0;
  115354. };
  115355. }
  115356. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminanceDownSample" + index, function () { return pp; }, true));
  115357. });
  115358. };
  115359. // Create HDR post-process
  115360. StandardRenderingPipeline.prototype._createHdrPostProcess = function (scene, ratio) {
  115361. var _this = this;
  115362. 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);
  115363. var outputLiminance = 1;
  115364. var time = 0;
  115365. var lastTime = 0;
  115366. this.hdrPostProcess.onApply = function (effect) {
  115367. effect.setTextureFromPostProcess("textureAdderSampler", _this._currentDepthOfFieldSource);
  115368. time += scene.getEngine().getDeltaTime();
  115369. if (outputLiminance < 0) {
  115370. outputLiminance = _this._hdrCurrentLuminance;
  115371. }
  115372. else {
  115373. var dt = (lastTime - time) / 1000.0;
  115374. if (_this._hdrCurrentLuminance < outputLiminance + _this.hdrDecreaseRate * dt) {
  115375. outputLiminance += _this.hdrDecreaseRate * dt;
  115376. }
  115377. else if (_this._hdrCurrentLuminance > outputLiminance - _this.hdrIncreaseRate * dt) {
  115378. outputLiminance -= _this.hdrIncreaseRate * dt;
  115379. }
  115380. else {
  115381. outputLiminance = _this._hdrCurrentLuminance;
  115382. }
  115383. }
  115384. outputLiminance = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(outputLiminance, _this.hdrMinimumLuminance, 1e20);
  115385. effect.setFloat("averageLuminance", outputLiminance);
  115386. lastTime = time;
  115387. _this._currentDepthOfFieldSource = _this.hdrFinalPostProcess;
  115388. };
  115389. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDR", function () { return _this.hdrPostProcess; }, true));
  115390. };
  115391. // Create lens flare post-process
  115392. StandardRenderingPipeline.prototype._createLensFlarePostProcess = function (scene, ratio) {
  115393. var _this = this;
  115394. 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);
  115395. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlare", function () { return _this.lensFlarePostProcess; }, true));
  115396. this._createBlurPostProcesses(scene, ratio / 4, 2);
  115397. 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);
  115398. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlareCompose", function () { return _this.lensFlareComposePostProcess; }, true));
  115399. var resolution = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  115400. // Lens flare
  115401. this.lensFlarePostProcess.onApply = function (effect) {
  115402. effect.setTextureFromPostProcess("textureSampler", _this._bloomEnabled ? _this.blurHPostProcesses[0] : _this.originalPostProcess);
  115403. effect.setTexture("lensColorSampler", _this.lensColorTexture);
  115404. effect.setFloat("strength", _this.lensFlareStrength);
  115405. effect.setFloat("ghostDispersal", _this.lensFlareGhostDispersal);
  115406. effect.setFloat("haloWidth", _this.lensFlareHaloWidth);
  115407. // Shift
  115408. resolution.x = _this.lensFlarePostProcess.width;
  115409. resolution.y = _this.lensFlarePostProcess.height;
  115410. effect.setVector2("resolution", resolution);
  115411. effect.setFloat("distortionStrength", _this.lensFlareDistortionStrength);
  115412. };
  115413. // Compose
  115414. 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);
  115415. 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);
  115416. this.lensFlareComposePostProcess.onApply = function (effect) {
  115417. if (!_this._scene.activeCamera) {
  115418. return;
  115419. }
  115420. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  115421. effect.setTexture("lensDirtSampler", _this.lensFlareDirtTexture);
  115422. effect.setTexture("lensStarSampler", _this.lensStarTexture);
  115423. // Lens start rotation matrix
  115424. var camerax = _this._scene.activeCamera.getViewMatrix().getRow(0);
  115425. var cameraz = _this._scene.activeCamera.getViewMatrix().getRow(2);
  115426. 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));
  115427. camRot *= 4.0;
  115428. 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);
  115429. var lensStarMatrix = scaleBias2.multiply(starRotation).multiply(scaleBias1);
  115430. effect.setMatrix("lensStarMatrix", lensStarMatrix);
  115431. _this._currentDepthOfFieldSource = _this.lensFlareFinalPostProcess;
  115432. };
  115433. };
  115434. // Create depth-of-field post-process
  115435. StandardRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (scene, ratio) {
  115436. var _this = this;
  115437. 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);
  115438. this.depthOfFieldPostProcess.onApply = function (effect) {
  115439. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  115440. effect.setTexture("depthSampler", _this._getDepthTexture());
  115441. effect.setFloat("distance", _this.depthOfFieldDistance);
  115442. };
  115443. // Add to pipeline
  115444. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDepthOfField", function () { return _this.depthOfFieldPostProcess; }, true));
  115445. };
  115446. // Create motion blur post-process
  115447. StandardRenderingPipeline.prototype._createMotionBlurPostProcess = function (scene, ratio) {
  115448. var _this = this;
  115449. 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);
  115450. var motionScale = 0;
  115451. var prevViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  115452. var invViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  115453. var viewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  115454. var screenSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  115455. this.motionBlurPostProcess.onApply = function (effect) {
  115456. viewProjection = scene.getProjectionMatrix().multiply(scene.getViewMatrix());
  115457. viewProjection.invertToRef(invViewProjection);
  115458. effect.setMatrix("inverseViewProjection", invViewProjection);
  115459. effect.setMatrix("prevViewProjection", prevViewProjection);
  115460. prevViewProjection = viewProjection;
  115461. screenSize.x = _this.motionBlurPostProcess.width;
  115462. screenSize.y = _this.motionBlurPostProcess.height;
  115463. effect.setVector2("screenSize", screenSize);
  115464. motionScale = scene.getEngine().getFps() / 60.0;
  115465. effect.setFloat("motionScale", motionScale);
  115466. effect.setFloat("motionStrength", _this.motionStrength);
  115467. effect.setTexture("depthSampler", _this._getDepthTexture());
  115468. };
  115469. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRMotionBlur", function () { return _this.motionBlurPostProcess; }, true));
  115470. };
  115471. StandardRenderingPipeline.prototype._getDepthTexture = function () {
  115472. if (this._scene.getEngine().getCaps().drawBuffersExtension) {
  115473. var renderer = this._scene.enableGeometryBufferRenderer();
  115474. return renderer.getGBuffer().textures[0];
  115475. }
  115476. return this._scene.enableDepthRenderer().getDepthMap();
  115477. };
  115478. StandardRenderingPipeline.prototype._disposePostProcesses = function () {
  115479. for (var i = 0; i < this._cameras.length; i++) {
  115480. var camera = this._cameras[i];
  115481. if (this.originalPostProcess) {
  115482. this.originalPostProcess.dispose(camera);
  115483. }
  115484. if (this.downSampleX4PostProcess) {
  115485. this.downSampleX4PostProcess.dispose(camera);
  115486. }
  115487. if (this.brightPassPostProcess) {
  115488. this.brightPassPostProcess.dispose(camera);
  115489. }
  115490. if (this.textureAdderPostProcess) {
  115491. this.textureAdderPostProcess.dispose(camera);
  115492. }
  115493. if (this.textureAdderFinalPostProcess) {
  115494. this.textureAdderFinalPostProcess.dispose(camera);
  115495. }
  115496. if (this.volumetricLightPostProcess) {
  115497. this.volumetricLightPostProcess.dispose(camera);
  115498. }
  115499. if (this.volumetricLightSmoothXPostProcess) {
  115500. this.volumetricLightSmoothXPostProcess.dispose(camera);
  115501. }
  115502. if (this.volumetricLightSmoothYPostProcess) {
  115503. this.volumetricLightSmoothYPostProcess.dispose(camera);
  115504. }
  115505. if (this.volumetricLightMergePostProces) {
  115506. this.volumetricLightMergePostProces.dispose(camera);
  115507. }
  115508. if (this.volumetricLightFinalPostProcess) {
  115509. this.volumetricLightFinalPostProcess.dispose(camera);
  115510. }
  115511. if (this.lensFlarePostProcess) {
  115512. this.lensFlarePostProcess.dispose(camera);
  115513. }
  115514. if (this.lensFlareComposePostProcess) {
  115515. this.lensFlareComposePostProcess.dispose(camera);
  115516. }
  115517. for (var j = 0; j < this.luminanceDownSamplePostProcesses.length; j++) {
  115518. this.luminanceDownSamplePostProcesses[j].dispose(camera);
  115519. }
  115520. if (this.luminancePostProcess) {
  115521. this.luminancePostProcess.dispose(camera);
  115522. }
  115523. if (this.hdrPostProcess) {
  115524. this.hdrPostProcess.dispose(camera);
  115525. }
  115526. if (this.hdrFinalPostProcess) {
  115527. this.hdrFinalPostProcess.dispose(camera);
  115528. }
  115529. if (this.depthOfFieldPostProcess) {
  115530. this.depthOfFieldPostProcess.dispose(camera);
  115531. }
  115532. if (this.motionBlurPostProcess) {
  115533. this.motionBlurPostProcess.dispose(camera);
  115534. }
  115535. if (this.fxaaPostProcess) {
  115536. this.fxaaPostProcess.dispose(camera);
  115537. }
  115538. for (var j = 0; j < this.blurHPostProcesses.length; j++) {
  115539. this.blurHPostProcesses[j].dispose(camera);
  115540. }
  115541. for (var j = 0; j < this.blurVPostProcesses.length; j++) {
  115542. this.blurVPostProcesses[j].dispose(camera);
  115543. }
  115544. }
  115545. this.originalPostProcess = null;
  115546. this.downSampleX4PostProcess = null;
  115547. this.brightPassPostProcess = null;
  115548. this.textureAdderPostProcess = null;
  115549. this.textureAdderFinalPostProcess = null;
  115550. this.volumetricLightPostProcess = null;
  115551. this.volumetricLightSmoothXPostProcess = null;
  115552. this.volumetricLightSmoothYPostProcess = null;
  115553. this.volumetricLightMergePostProces = null;
  115554. this.volumetricLightFinalPostProcess = null;
  115555. this.lensFlarePostProcess = null;
  115556. this.lensFlareComposePostProcess = null;
  115557. this.luminancePostProcess = null;
  115558. this.hdrPostProcess = null;
  115559. this.hdrFinalPostProcess = null;
  115560. this.depthOfFieldPostProcess = null;
  115561. this.motionBlurPostProcess = null;
  115562. this.fxaaPostProcess = null;
  115563. this.luminanceDownSamplePostProcesses = [];
  115564. this.blurHPostProcesses = [];
  115565. this.blurVPostProcesses = [];
  115566. };
  115567. /**
  115568. * Dispose of the pipeline and stop all post processes
  115569. */
  115570. StandardRenderingPipeline.prototype.dispose = function () {
  115571. this._disposePostProcesses();
  115572. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  115573. _super.prototype.dispose.call(this);
  115574. };
  115575. /**
  115576. * Serialize the rendering pipeline (Used when exporting)
  115577. * @returns the serialized object
  115578. */
  115579. StandardRenderingPipeline.prototype.serialize = function () {
  115580. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  115581. if (this.sourceLight) {
  115582. serializationObject.sourceLightId = this.sourceLight.id;
  115583. }
  115584. serializationObject.customType = "StandardRenderingPipeline";
  115585. return serializationObject;
  115586. };
  115587. /**
  115588. * Parse the serialized pipeline
  115589. * @param source Source pipeline.
  115590. * @param scene The scene to load the pipeline to.
  115591. * @param rootUrl The URL of the serialized pipeline.
  115592. * @returns An instantiated pipeline from the serialized object.
  115593. */
  115594. StandardRenderingPipeline.Parse = function (source, scene, rootUrl) {
  115595. var p = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardRenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  115596. if (source.sourceLightId) {
  115597. p.sourceLight = scene.getLightByID(source.sourceLightId);
  115598. }
  115599. return p;
  115600. };
  115601. /**
  115602. * Luminance steps
  115603. */
  115604. StandardRenderingPipeline.LuminanceSteps = 6;
  115605. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115606. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115607. ], StandardRenderingPipeline.prototype, "brightThreshold", void 0);
  115608. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115609. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115610. ], StandardRenderingPipeline.prototype, "blurWidth", void 0);
  115611. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115612. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115613. ], StandardRenderingPipeline.prototype, "horizontalBlur", void 0);
  115614. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115615. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115616. ], StandardRenderingPipeline.prototype, "exposure", void 0);
  115617. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115618. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensTexture")
  115619. ], StandardRenderingPipeline.prototype, "lensTexture", void 0);
  115620. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115621. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115622. ], StandardRenderingPipeline.prototype, "volumetricLightCoefficient", void 0);
  115623. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115624. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115625. ], StandardRenderingPipeline.prototype, "volumetricLightPower", void 0);
  115626. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115627. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115628. ], StandardRenderingPipeline.prototype, "volumetricLightBlurScale", void 0);
  115629. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115630. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115631. ], StandardRenderingPipeline.prototype, "hdrMinimumLuminance", void 0);
  115632. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115633. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115634. ], StandardRenderingPipeline.prototype, "hdrDecreaseRate", void 0);
  115635. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115636. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115637. ], StandardRenderingPipeline.prototype, "hdrIncreaseRate", void 0);
  115638. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115639. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensColorTexture")
  115640. ], StandardRenderingPipeline.prototype, "lensColorTexture", void 0);
  115641. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115642. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115643. ], StandardRenderingPipeline.prototype, "lensFlareStrength", void 0);
  115644. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115645. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115646. ], StandardRenderingPipeline.prototype, "lensFlareGhostDispersal", void 0);
  115647. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115648. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115649. ], StandardRenderingPipeline.prototype, "lensFlareHaloWidth", void 0);
  115650. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115651. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115652. ], StandardRenderingPipeline.prototype, "lensFlareDistortionStrength", void 0);
  115653. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115654. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensStarTexture")
  115655. ], StandardRenderingPipeline.prototype, "lensStarTexture", void 0);
  115656. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115657. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensFlareDirtTexture")
  115658. ], StandardRenderingPipeline.prototype, "lensFlareDirtTexture", void 0);
  115659. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115660. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115661. ], StandardRenderingPipeline.prototype, "depthOfFieldDistance", void 0);
  115662. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115663. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115664. ], StandardRenderingPipeline.prototype, "depthOfFieldBlurWidth", void 0);
  115665. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115666. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115667. ], StandardRenderingPipeline.prototype, "motionStrength", void 0);
  115668. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115669. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115670. ], StandardRenderingPipeline.prototype, "_ratio", void 0);
  115671. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115672. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115673. ], StandardRenderingPipeline.prototype, "BloomEnabled", null);
  115674. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115675. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115676. ], StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", null);
  115677. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115678. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115679. ], StandardRenderingPipeline.prototype, "LensFlareEnabled", null);
  115680. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115681. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115682. ], StandardRenderingPipeline.prototype, "HDREnabled", null);
  115683. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115684. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115685. ], StandardRenderingPipeline.prototype, "VLSEnabled", null);
  115686. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115687. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115688. ], StandardRenderingPipeline.prototype, "MotionBlurEnabled", null);
  115689. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115690. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115691. ], StandardRenderingPipeline.prototype, "fxaaEnabled", null);
  115692. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115693. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115694. ], StandardRenderingPipeline.prototype, "volumetricLightStepsCount", null);
  115695. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115696. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115697. ], StandardRenderingPipeline.prototype, "motionBlurSamples", null);
  115698. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115699. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115700. ], StandardRenderingPipeline.prototype, "samples", null);
  115701. return StandardRenderingPipeline;
  115702. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  115703. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardRenderingPipeline"] = StandardRenderingPipeline;
  115704. /***/ }),
  115705. /***/ "./PostProcesses/RenderPipeline/index.ts":
  115706. /*!***********************************************!*\
  115707. !*** ./PostProcesses/RenderPipeline/index.ts ***!
  115708. \***********************************************/
  115709. /*! exports provided: PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  115710. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115711. "use strict";
  115712. __webpack_require__.r(__webpack_exports__);
  115713. /* harmony import */ var _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Pipelines/index */ "./PostProcesses/RenderPipeline/Pipelines/index.ts");
  115714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  115715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  115716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  115717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  115718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  115719. /* harmony import */ var _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  115720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]; });
  115721. /* harmony import */ var _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  115722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__["PostProcessRenderPipeline"]; });
  115723. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  115724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderPipelineManager"]; });
  115725. /* harmony import */ var _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  115726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipelineManagerSceneComponent"]; });
  115727. /***/ }),
  115728. /***/ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts":
  115729. /*!*****************************************************************!*\
  115730. !*** ./PostProcesses/RenderPipeline/postProcessRenderEffect.ts ***!
  115731. \*****************************************************************/
  115732. /*! exports provided: PostProcessRenderEffect */
  115733. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115734. "use strict";
  115735. __webpack_require__.r(__webpack_exports__);
  115736. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return PostProcessRenderEffect; });
  115737. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  115738. /**
  115739. * This represents a set of one or more post processes in Babylon.
  115740. * A post process can be used to apply a shader to a texture after it is rendered.
  115741. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  115742. */
  115743. var PostProcessRenderEffect = /** @class */ (function () {
  115744. /**
  115745. * Instantiates a post process render effect.
  115746. * A post process can be used to apply a shader to a texture after it is rendered.
  115747. * @param engine The engine the effect is tied to
  115748. * @param name The name of the effect
  115749. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  115750. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  115751. */
  115752. function PostProcessRenderEffect(engine, name, getPostProcesses, singleInstance) {
  115753. this._name = name;
  115754. this._singleInstance = singleInstance || true;
  115755. this._getPostProcesses = getPostProcesses;
  115756. this._cameras = {};
  115757. this._indicesForCamera = {};
  115758. this._postProcesses = {};
  115759. }
  115760. Object.defineProperty(PostProcessRenderEffect.prototype, "isSupported", {
  115761. /**
  115762. * Checks if all the post processes in the effect are supported.
  115763. */
  115764. get: function () {
  115765. for (var index in this._postProcesses) {
  115766. if (this._postProcesses.hasOwnProperty(index)) {
  115767. var pps = this._postProcesses[index];
  115768. for (var ppIndex = 0; ppIndex < pps.length; ppIndex++) {
  115769. if (!pps[ppIndex].isSupported) {
  115770. return false;
  115771. }
  115772. }
  115773. }
  115774. }
  115775. return true;
  115776. },
  115777. enumerable: true,
  115778. configurable: true
  115779. });
  115780. /**
  115781. * Updates the current state of the effect
  115782. * @hidden
  115783. */
  115784. PostProcessRenderEffect.prototype._update = function () {
  115785. };
  115786. /**
  115787. * Attaches the effect on cameras
  115788. * @param cameras The camera to attach to.
  115789. * @hidden
  115790. */
  115791. PostProcessRenderEffect.prototype._attachCameras = function (cameras) {
  115792. var _this = this;
  115793. var cameraKey;
  115794. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  115795. if (!cams) {
  115796. return;
  115797. }
  115798. for (var i = 0; i < cams.length; i++) {
  115799. var camera = cams[i];
  115800. var cameraName = camera.name;
  115801. if (this._singleInstance) {
  115802. cameraKey = 0;
  115803. }
  115804. else {
  115805. cameraKey = cameraName;
  115806. }
  115807. if (!this._postProcesses[cameraKey]) {
  115808. var postProcess = this._getPostProcesses();
  115809. if (postProcess) {
  115810. this._postProcesses[cameraKey] = Array.isArray(postProcess) ? postProcess : [postProcess];
  115811. }
  115812. }
  115813. if (!this._indicesForCamera[cameraName]) {
  115814. this._indicesForCamera[cameraName] = [];
  115815. }
  115816. this._postProcesses[cameraKey].forEach(function (postProcess) {
  115817. var index = camera.attachPostProcess(postProcess);
  115818. _this._indicesForCamera[cameraName].push(index);
  115819. });
  115820. if (!this._cameras[cameraName]) {
  115821. this._cameras[cameraName] = camera;
  115822. }
  115823. }
  115824. };
  115825. /**
  115826. * Detatches the effect on cameras
  115827. * @param cameras The camera to detatch from.
  115828. * @hidden
  115829. */
  115830. PostProcessRenderEffect.prototype._detachCameras = function (cameras) {
  115831. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  115832. if (!cams) {
  115833. return;
  115834. }
  115835. for (var i = 0; i < cams.length; i++) {
  115836. var camera = cams[i];
  115837. var cameraName = camera.name;
  115838. var postProcesses = this._postProcesses[this._singleInstance ? 0 : cameraName];
  115839. if (postProcesses) {
  115840. postProcesses.forEach(function (postProcess) {
  115841. camera.detachPostProcess(postProcess);
  115842. });
  115843. }
  115844. if (this._cameras[cameraName]) {
  115845. this._cameras[cameraName] = null;
  115846. }
  115847. }
  115848. };
  115849. /**
  115850. * Enables the effect on given cameras
  115851. * @param cameras The camera to enable.
  115852. * @hidden
  115853. */
  115854. PostProcessRenderEffect.prototype._enable = function (cameras) {
  115855. var _this = this;
  115856. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  115857. if (!cams) {
  115858. return;
  115859. }
  115860. for (var i = 0; i < cams.length; i++) {
  115861. var camera = cams[i];
  115862. var cameraName = camera.name;
  115863. for (var j = 0; j < this._indicesForCamera[cameraName].length; j++) {
  115864. if (camera._postProcesses[this._indicesForCamera[cameraName][j]] === undefined || camera._postProcesses[this._indicesForCamera[cameraName][j]] === null) {
  115865. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  115866. cams[i].attachPostProcess(postProcess, _this._indicesForCamera[cameraName][j]);
  115867. });
  115868. }
  115869. }
  115870. }
  115871. };
  115872. /**
  115873. * Disables the effect on the given cameras
  115874. * @param cameras The camera to disable.
  115875. * @hidden
  115876. */
  115877. PostProcessRenderEffect.prototype._disable = function (cameras) {
  115878. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  115879. if (!cams) {
  115880. return;
  115881. }
  115882. for (var i = 0; i < cams.length; i++) {
  115883. var camera = cams[i];
  115884. var cameraName = camera.name;
  115885. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  115886. camera.detachPostProcess(postProcess);
  115887. });
  115888. }
  115889. };
  115890. /**
  115891. * Gets a list of the post processes contained in the effect.
  115892. * @param camera The camera to get the post processes on.
  115893. * @returns The list of the post processes in the effect.
  115894. */
  115895. PostProcessRenderEffect.prototype.getPostProcesses = function (camera) {
  115896. if (this._singleInstance) {
  115897. return this._postProcesses[0];
  115898. }
  115899. else {
  115900. if (!camera) {
  115901. return null;
  115902. }
  115903. return this._postProcesses[camera.name];
  115904. }
  115905. };
  115906. return PostProcessRenderEffect;
  115907. }());
  115908. /***/ }),
  115909. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts":
  115910. /*!*******************************************************************!*\
  115911. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts ***!
  115912. \*******************************************************************/
  115913. /*! exports provided: PostProcessRenderPipeline */
  115914. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115915. "use strict";
  115916. __webpack_require__.r(__webpack_exports__);
  115917. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return PostProcessRenderPipeline; });
  115918. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115919. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  115920. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  115921. /**
  115922. * PostProcessRenderPipeline
  115923. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  115924. */
  115925. var PostProcessRenderPipeline = /** @class */ (function () {
  115926. /**
  115927. * Initializes a PostProcessRenderPipeline
  115928. * @param engine engine to add the pipeline to
  115929. * @param name name of the pipeline
  115930. */
  115931. function PostProcessRenderPipeline(engine, name) {
  115932. this.engine = engine;
  115933. this._name = name;
  115934. this._renderEffects = {};
  115935. this._renderEffectsForIsolatedPass = new Array();
  115936. this._cameras = [];
  115937. }
  115938. /**
  115939. * "PostProcessRenderPipeline"
  115940. * @returns "PostProcessRenderPipeline"
  115941. */
  115942. PostProcessRenderPipeline.prototype.getClassName = function () {
  115943. return "PostProcessRenderPipeline";
  115944. };
  115945. Object.defineProperty(PostProcessRenderPipeline.prototype, "isSupported", {
  115946. /**
  115947. * If all the render effects in the pipeline are supported
  115948. */
  115949. get: function () {
  115950. for (var renderEffectName in this._renderEffects) {
  115951. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  115952. if (!this._renderEffects[renderEffectName].isSupported) {
  115953. return false;
  115954. }
  115955. }
  115956. }
  115957. return true;
  115958. },
  115959. enumerable: true,
  115960. configurable: true
  115961. });
  115962. /**
  115963. * Adds an effect to the pipeline
  115964. * @param renderEffect the effect to add
  115965. */
  115966. PostProcessRenderPipeline.prototype.addEffect = function (renderEffect) {
  115967. this._renderEffects[renderEffect._name] = renderEffect;
  115968. };
  115969. // private
  115970. /** @hidden */
  115971. PostProcessRenderPipeline.prototype._rebuild = function () {
  115972. };
  115973. /** @hidden */
  115974. PostProcessRenderPipeline.prototype._enableEffect = function (renderEffectName, cameras) {
  115975. var renderEffects = this._renderEffects[renderEffectName];
  115976. if (!renderEffects) {
  115977. return;
  115978. }
  115979. renderEffects._enable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  115980. };
  115981. /** @hidden */
  115982. PostProcessRenderPipeline.prototype._disableEffect = function (renderEffectName, cameras) {
  115983. var renderEffects = this._renderEffects[renderEffectName];
  115984. if (!renderEffects) {
  115985. return;
  115986. }
  115987. renderEffects._disable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  115988. };
  115989. /** @hidden */
  115990. PostProcessRenderPipeline.prototype._attachCameras = function (cameras, unique) {
  115991. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  115992. if (!cams) {
  115993. return;
  115994. }
  115995. var indicesToDelete = [];
  115996. var i;
  115997. for (i = 0; i < cams.length; i++) {
  115998. var camera = cams[i];
  115999. var cameraName = camera.name;
  116000. if (this._cameras.indexOf(camera) === -1) {
  116001. this._cameras[cameraName] = camera;
  116002. }
  116003. else if (unique) {
  116004. indicesToDelete.push(i);
  116005. }
  116006. }
  116007. for (i = 0; i < indicesToDelete.length; i++) {
  116008. cameras.splice(indicesToDelete[i], 1);
  116009. }
  116010. for (var renderEffectName in this._renderEffects) {
  116011. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  116012. this._renderEffects[renderEffectName]._attachCameras(cams);
  116013. }
  116014. }
  116015. };
  116016. /** @hidden */
  116017. PostProcessRenderPipeline.prototype._detachCameras = function (cameras) {
  116018. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  116019. if (!cams) {
  116020. return;
  116021. }
  116022. for (var renderEffectName in this._renderEffects) {
  116023. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  116024. this._renderEffects[renderEffectName]._detachCameras(cams);
  116025. }
  116026. }
  116027. for (var i = 0; i < cams.length; i++) {
  116028. this._cameras.splice(this._cameras.indexOf(cams[i]), 1);
  116029. }
  116030. };
  116031. /** @hidden */
  116032. PostProcessRenderPipeline.prototype._update = function () {
  116033. for (var renderEffectName in this._renderEffects) {
  116034. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  116035. this._renderEffects[renderEffectName]._update();
  116036. }
  116037. }
  116038. for (var i = 0; i < this._cameras.length; i++) {
  116039. var cameraName = this._cameras[i].name;
  116040. if (this._renderEffectsForIsolatedPass[cameraName]) {
  116041. this._renderEffectsForIsolatedPass[cameraName]._update();
  116042. }
  116043. }
  116044. };
  116045. /** @hidden */
  116046. PostProcessRenderPipeline.prototype._reset = function () {
  116047. this._renderEffects = {};
  116048. this._renderEffectsForIsolatedPass = new Array();
  116049. };
  116050. PostProcessRenderPipeline.prototype._enableMSAAOnFirstPostProcess = function (sampleCount) {
  116051. // 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)
  116052. var effectKeys = Object.keys(this._renderEffects);
  116053. if (this.engine.webGLVersion >= 2 && effectKeys.length > 0) {
  116054. var postProcesses = this._renderEffects[effectKeys[0]].getPostProcesses();
  116055. if (postProcesses) {
  116056. postProcesses[0].samples = sampleCount;
  116057. return true;
  116058. }
  116059. }
  116060. return false;
  116061. };
  116062. /**
  116063. * Disposes of the pipeline
  116064. */
  116065. PostProcessRenderPipeline.prototype.dispose = function () {
  116066. // Must be implemented by children
  116067. };
  116068. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116069. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  116070. ], PostProcessRenderPipeline.prototype, "_name", void 0);
  116071. return PostProcessRenderPipeline;
  116072. }());
  116073. /***/ }),
  116074. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts":
  116075. /*!**************************************************************************!*\
  116076. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts ***!
  116077. \**************************************************************************/
  116078. /*! exports provided: PostProcessRenderPipelineManager */
  116079. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116080. "use strict";
  116081. __webpack_require__.r(__webpack_exports__);
  116082. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return PostProcessRenderPipelineManager; });
  116083. /**
  116084. * PostProcessRenderPipelineManager class
  116085. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  116086. */
  116087. var PostProcessRenderPipelineManager = /** @class */ (function () {
  116088. /**
  116089. * Initializes a PostProcessRenderPipelineManager
  116090. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  116091. */
  116092. function PostProcessRenderPipelineManager() {
  116093. this._renderPipelines = {};
  116094. }
  116095. Object.defineProperty(PostProcessRenderPipelineManager.prototype, "supportedPipelines", {
  116096. /**
  116097. * Gets the list of supported render pipelines
  116098. */
  116099. get: function () {
  116100. var result = [];
  116101. for (var renderPipelineName in this._renderPipelines) {
  116102. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  116103. var pipeline = this._renderPipelines[renderPipelineName];
  116104. if (pipeline.isSupported) {
  116105. result.push(pipeline);
  116106. }
  116107. }
  116108. }
  116109. return result;
  116110. },
  116111. enumerable: true,
  116112. configurable: true
  116113. });
  116114. /**
  116115. * Adds a pipeline to the manager
  116116. * @param renderPipeline The pipeline to add
  116117. */
  116118. PostProcessRenderPipelineManager.prototype.addPipeline = function (renderPipeline) {
  116119. this._renderPipelines[renderPipeline._name] = renderPipeline;
  116120. };
  116121. /**
  116122. * Attaches a camera to the pipeline
  116123. * @param renderPipelineName The name of the pipeline to attach to
  116124. * @param cameras the camera to attach
  116125. * @param unique if the camera can be attached multiple times to the pipeline
  116126. */
  116127. PostProcessRenderPipelineManager.prototype.attachCamerasToRenderPipeline = function (renderPipelineName, cameras, unique) {
  116128. if (unique === void 0) { unique = false; }
  116129. var renderPipeline = this._renderPipelines[renderPipelineName];
  116130. if (!renderPipeline) {
  116131. return;
  116132. }
  116133. renderPipeline._attachCameras(cameras, unique);
  116134. };
  116135. /**
  116136. * Detaches a camera from the pipeline
  116137. * @param renderPipelineName The name of the pipeline to detach from
  116138. * @param cameras the camera to detach
  116139. */
  116140. PostProcessRenderPipelineManager.prototype.detachCamerasFromRenderPipeline = function (renderPipelineName, cameras) {
  116141. var renderPipeline = this._renderPipelines[renderPipelineName];
  116142. if (!renderPipeline) {
  116143. return;
  116144. }
  116145. renderPipeline._detachCameras(cameras);
  116146. };
  116147. /**
  116148. * Enables an effect by name on a pipeline
  116149. * @param renderPipelineName the name of the pipeline to enable the effect in
  116150. * @param renderEffectName the name of the effect to enable
  116151. * @param cameras the cameras that the effect should be enabled on
  116152. */
  116153. PostProcessRenderPipelineManager.prototype.enableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  116154. var renderPipeline = this._renderPipelines[renderPipelineName];
  116155. if (!renderPipeline) {
  116156. return;
  116157. }
  116158. renderPipeline._enableEffect(renderEffectName, cameras);
  116159. };
  116160. /**
  116161. * Disables an effect by name on a pipeline
  116162. * @param renderPipelineName the name of the pipeline to disable the effect in
  116163. * @param renderEffectName the name of the effect to disable
  116164. * @param cameras the cameras that the effect should be disabled on
  116165. */
  116166. PostProcessRenderPipelineManager.prototype.disableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  116167. var renderPipeline = this._renderPipelines[renderPipelineName];
  116168. if (!renderPipeline) {
  116169. return;
  116170. }
  116171. renderPipeline._disableEffect(renderEffectName, cameras);
  116172. };
  116173. /**
  116174. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  116175. */
  116176. PostProcessRenderPipelineManager.prototype.update = function () {
  116177. for (var renderPipelineName in this._renderPipelines) {
  116178. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  116179. var pipeline = this._renderPipelines[renderPipelineName];
  116180. if (!pipeline.isSupported) {
  116181. pipeline.dispose();
  116182. delete this._renderPipelines[renderPipelineName];
  116183. }
  116184. else {
  116185. pipeline._update();
  116186. }
  116187. }
  116188. }
  116189. };
  116190. /** @hidden */
  116191. PostProcessRenderPipelineManager.prototype._rebuild = function () {
  116192. for (var renderPipelineName in this._renderPipelines) {
  116193. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  116194. var pipeline = this._renderPipelines[renderPipelineName];
  116195. pipeline._rebuild();
  116196. }
  116197. }
  116198. };
  116199. /**
  116200. * Disposes of the manager and pipelines
  116201. */
  116202. PostProcessRenderPipelineManager.prototype.dispose = function () {
  116203. for (var renderPipelineName in this._renderPipelines) {
  116204. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  116205. var pipeline = this._renderPipelines[renderPipelineName];
  116206. pipeline.dispose();
  116207. }
  116208. }
  116209. };
  116210. return PostProcessRenderPipelineManager;
  116211. }());
  116212. /***/ }),
  116213. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts":
  116214. /*!****************************************************************************************!*\
  116215. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts ***!
  116216. \****************************************************************************************/
  116217. /*! exports provided: PostProcessRenderPipelineManagerSceneComponent */
  116218. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116219. "use strict";
  116220. __webpack_require__.r(__webpack_exports__);
  116221. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return PostProcessRenderPipelineManagerSceneComponent; });
  116222. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  116223. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  116224. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  116225. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype, "postProcessRenderPipelineManager", {
  116226. get: function () {
  116227. if (!this._postProcessRenderPipelineManager) {
  116228. // Register the G Buffer component to the scene.
  116229. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER);
  116230. if (!component) {
  116231. component = new PostProcessRenderPipelineManagerSceneComponent(this);
  116232. this._addComponent(component);
  116233. }
  116234. this._postProcessRenderPipelineManager = new _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderPipelineManager"]();
  116235. }
  116236. return this._postProcessRenderPipelineManager;
  116237. },
  116238. enumerable: true,
  116239. configurable: true
  116240. });
  116241. /**
  116242. * Defines the Render Pipeline scene component responsible to rendering pipelines
  116243. */
  116244. var PostProcessRenderPipelineManagerSceneComponent = /** @class */ (function () {
  116245. /**
  116246. * Creates a new instance of the component for the given scene
  116247. * @param scene Defines the scene to register the component in
  116248. */
  116249. function PostProcessRenderPipelineManagerSceneComponent(scene) {
  116250. /**
  116251. * The component name helpfull to identify the component in the list of scene components.
  116252. */
  116253. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER;
  116254. this.scene = scene;
  116255. }
  116256. /**
  116257. * Registers the component in a given scene
  116258. */
  116259. PostProcessRenderPipelineManagerSceneComponent.prototype.register = function () {
  116260. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets);
  116261. };
  116262. /**
  116263. * Rebuilds the elements related to this component in case of
  116264. * context lost for instance.
  116265. */
  116266. PostProcessRenderPipelineManagerSceneComponent.prototype.rebuild = function () {
  116267. if (this.scene._postProcessRenderPipelineManager) {
  116268. this.scene._postProcessRenderPipelineManager._rebuild();
  116269. }
  116270. };
  116271. /**
  116272. * Disposes the component and the associated ressources
  116273. */
  116274. PostProcessRenderPipelineManagerSceneComponent.prototype.dispose = function () {
  116275. if (this.scene._postProcessRenderPipelineManager) {
  116276. this.scene._postProcessRenderPipelineManager.dispose();
  116277. }
  116278. };
  116279. PostProcessRenderPipelineManagerSceneComponent.prototype._gatherRenderTargets = function () {
  116280. if (this.scene._postProcessRenderPipelineManager) {
  116281. this.scene._postProcessRenderPipelineManager.update();
  116282. }
  116283. };
  116284. return PostProcessRenderPipelineManagerSceneComponent;
  116285. }());
  116286. /***/ }),
  116287. /***/ "./PostProcesses/anaglyphPostProcess.ts":
  116288. /*!**********************************************!*\
  116289. !*** ./PostProcesses/anaglyphPostProcess.ts ***!
  116290. \**********************************************/
  116291. /*! exports provided: AnaglyphPostProcess */
  116292. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116293. "use strict";
  116294. __webpack_require__.r(__webpack_exports__);
  116295. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return AnaglyphPostProcess; });
  116296. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116297. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116298. /* harmony import */ var _Shaders_anaglyph_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/anaglyph.fragment */ "./Shaders/anaglyph.fragment.ts");
  116299. /**
  116300. * Postprocess used to generate anaglyphic rendering
  116301. */
  116302. var AnaglyphPostProcess = /** @class */ (function (_super) {
  116303. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphPostProcess, _super);
  116304. /**
  116305. * Creates a new AnaglyphPostProcess
  116306. * @param name defines postprocess name
  116307. * @param options defines creation options or target ratio scale
  116308. * @param rigCameras defines cameras using this postprocess
  116309. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  116310. * @param engine defines hosting engine
  116311. * @param reusable defines if the postprocess will be reused multiple times per frame
  116312. */
  116313. function AnaglyphPostProcess(name, options, rigCameras, samplingMode, engine, reusable) {
  116314. var _this = _super.call(this, name, "anaglyph", null, ["leftSampler"], options, rigCameras[1], samplingMode, engine, reusable) || this;
  116315. _this._passedProcess = rigCameras[0]._rigPostProcess;
  116316. _this.onApplyObservable.add(function (effect) {
  116317. effect.setTextureFromPostProcess("leftSampler", _this._passedProcess);
  116318. });
  116319. return _this;
  116320. }
  116321. return AnaglyphPostProcess;
  116322. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116323. /***/ }),
  116324. /***/ "./PostProcesses/blackAndWhitePostProcess.ts":
  116325. /*!***************************************************!*\
  116326. !*** ./PostProcesses/blackAndWhitePostProcess.ts ***!
  116327. \***************************************************/
  116328. /*! exports provided: BlackAndWhitePostProcess */
  116329. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116330. "use strict";
  116331. __webpack_require__.r(__webpack_exports__);
  116332. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return BlackAndWhitePostProcess; });
  116333. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116334. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116335. /* harmony import */ var _Shaders_blackAndWhite_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/blackAndWhite.fragment */ "./Shaders/blackAndWhite.fragment.ts");
  116336. /**
  116337. * Post process used to render in black and white
  116338. */
  116339. var BlackAndWhitePostProcess = /** @class */ (function (_super) {
  116340. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlackAndWhitePostProcess, _super);
  116341. /**
  116342. * Creates a black and white post process
  116343. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  116344. * @param name The name of the effect.
  116345. * @param options The required width/height ratio to downsize to before computing the render pass.
  116346. * @param camera The camera to apply the render pass to.
  116347. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116348. * @param engine The engine which the post process will be applied. (default: current engine)
  116349. * @param reusable If the post process can be reused on the same frame. (default: false)
  116350. */
  116351. function BlackAndWhitePostProcess(name, options, camera, samplingMode, engine, reusable) {
  116352. var _this = _super.call(this, name, "blackAndWhite", ["degree"], null, options, camera, samplingMode, engine, reusable) || this;
  116353. /**
  116354. * Linear about to convert he result to black and white (default: 1)
  116355. */
  116356. _this.degree = 1;
  116357. _this.onApplyObservable.add(function (effect) {
  116358. effect.setFloat("degree", _this.degree);
  116359. });
  116360. return _this;
  116361. }
  116362. return BlackAndWhitePostProcess;
  116363. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116364. /***/ }),
  116365. /***/ "./PostProcesses/bloomEffect.ts":
  116366. /*!**************************************!*\
  116367. !*** ./PostProcesses/bloomEffect.ts ***!
  116368. \**************************************/
  116369. /*! exports provided: BloomEffect */
  116370. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116371. "use strict";
  116372. __webpack_require__.r(__webpack_exports__);
  116373. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return BloomEffect; });
  116374. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116375. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  116376. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  116377. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  116378. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  116379. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  116380. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116381. /**
  116382. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  116383. */
  116384. var BloomEffect = /** @class */ (function (_super) {
  116385. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomEffect, _super);
  116386. /**
  116387. * Creates a new instance of @see BloomEffect
  116388. * @param scene The scene the effect belongs to.
  116389. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  116390. * @param bloomKernel The size of the kernel to be used when applying the blur.
  116391. * @param bloomWeight The the strength of bloom.
  116392. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  116393. * @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)
  116394. */
  116395. function BloomEffect(scene, bloomScale, bloomWeight, bloomKernel, pipelineTextureType, blockCompilation) {
  116396. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  116397. if (blockCompilation === void 0) { blockCompilation = false; }
  116398. var _this = _super.call(this, scene.getEngine(), "bloom", function () {
  116399. return _this._effects;
  116400. }, true) || this;
  116401. _this.bloomScale = bloomScale;
  116402. /**
  116403. * @hidden Internal
  116404. */
  116405. _this._effects = [];
  116406. _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);
  116407. _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);
  116408. _this._blurX.alwaysForcePOT = true;
  116409. _this._blurX.autoClear = false;
  116410. _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);
  116411. _this._blurY.alwaysForcePOT = true;
  116412. _this._blurY.autoClear = false;
  116413. _this.kernel = bloomKernel;
  116414. _this._effects = [_this._downscale, _this._blurX, _this._blurY];
  116415. _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);
  116416. _this._merge.autoClear = false;
  116417. _this._effects.push(_this._merge);
  116418. return _this;
  116419. }
  116420. Object.defineProperty(BloomEffect.prototype, "threshold", {
  116421. /**
  116422. * The luminance threshold to find bright areas of the image to bloom.
  116423. */
  116424. get: function () {
  116425. return this._downscale.threshold;
  116426. },
  116427. set: function (value) {
  116428. this._downscale.threshold = value;
  116429. },
  116430. enumerable: true,
  116431. configurable: true
  116432. });
  116433. Object.defineProperty(BloomEffect.prototype, "weight", {
  116434. /**
  116435. * The strength of the bloom.
  116436. */
  116437. get: function () {
  116438. return this._merge.weight;
  116439. },
  116440. set: function (value) {
  116441. this._merge.weight = value;
  116442. },
  116443. enumerable: true,
  116444. configurable: true
  116445. });
  116446. Object.defineProperty(BloomEffect.prototype, "kernel", {
  116447. /**
  116448. * Specifies the size of the bloom blur kernel, relative to the final output size
  116449. */
  116450. get: function () {
  116451. return this._blurX.kernel / this.bloomScale;
  116452. },
  116453. set: function (value) {
  116454. this._blurX.kernel = value * this.bloomScale;
  116455. this._blurY.kernel = value * this.bloomScale;
  116456. },
  116457. enumerable: true,
  116458. configurable: true
  116459. });
  116460. /**
  116461. * Disposes each of the internal effects for a given camera.
  116462. * @param camera The camera to dispose the effect on.
  116463. */
  116464. BloomEffect.prototype.disposeEffects = function (camera) {
  116465. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  116466. this._effects[effectIndex].dispose(camera);
  116467. }
  116468. };
  116469. /**
  116470. * @hidden Internal
  116471. */
  116472. BloomEffect.prototype._updateEffects = function () {
  116473. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  116474. this._effects[effectIndex].updateEffect();
  116475. }
  116476. };
  116477. /**
  116478. * Internal
  116479. * @returns if all the contained post processes are ready.
  116480. * @hidden
  116481. */
  116482. BloomEffect.prototype._isReady = function () {
  116483. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  116484. if (!this._effects[effectIndex].isReady()) {
  116485. return false;
  116486. }
  116487. }
  116488. return true;
  116489. };
  116490. return BloomEffect;
  116491. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]));
  116492. /***/ }),
  116493. /***/ "./PostProcesses/bloomMergePostProcess.ts":
  116494. /*!************************************************!*\
  116495. !*** ./PostProcesses/bloomMergePostProcess.ts ***!
  116496. \************************************************/
  116497. /*! exports provided: BloomMergePostProcess */
  116498. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116499. "use strict";
  116500. __webpack_require__.r(__webpack_exports__);
  116501. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return BloomMergePostProcess; });
  116502. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116503. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116504. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116505. /* harmony import */ var _Shaders_bloomMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/bloomMerge.fragment */ "./Shaders/bloomMerge.fragment.ts");
  116506. /**
  116507. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  116508. */
  116509. var BloomMergePostProcess = /** @class */ (function (_super) {
  116510. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomMergePostProcess, _super);
  116511. /**
  116512. * Creates a new instance of @see BloomMergePostProcess
  116513. * @param name The name of the effect.
  116514. * @param originalFromInput Post process which's input will be used for the merge.
  116515. * @param blurred Blurred highlights post process which's output will be used.
  116516. * @param weight Weight of the bloom to be added to the original input.
  116517. * @param options The required width/height ratio to downsize to before computing the render pass.
  116518. * @param camera The camera to apply the render pass to.
  116519. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116520. * @param engine The engine which the post process will be applied. (default: current engine)
  116521. * @param reusable If the post process can be reused on the same frame. (default: false)
  116522. * @param textureType Type of textures used when performing the post process. (default: 0)
  116523. * @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)
  116524. */
  116525. function BloomMergePostProcess(name, originalFromInput, blurred,
  116526. /** Weight of the bloom to be added to the original input. */
  116527. weight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116528. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116529. if (blockCompilation === void 0) { blockCompilation = false; }
  116530. var _this = _super.call(this, name, "bloomMerge", ["bloomWeight"], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2", "bloomBlur"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  116531. _this.weight = weight;
  116532. _this.onApplyObservable.add(function (effect) {
  116533. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  116534. effect.setTextureFromPostProcessOutput("bloomBlur", blurred);
  116535. effect.setFloat("bloomWeight", _this.weight);
  116536. });
  116537. if (!blockCompilation) {
  116538. _this.updateEffect();
  116539. }
  116540. return _this;
  116541. }
  116542. return BloomMergePostProcess;
  116543. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116544. /***/ }),
  116545. /***/ "./PostProcesses/blurPostProcess.ts":
  116546. /*!******************************************!*\
  116547. !*** ./PostProcesses/blurPostProcess.ts ***!
  116548. \******************************************/
  116549. /*! exports provided: BlurPostProcess */
  116550. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116551. "use strict";
  116552. __webpack_require__.r(__webpack_exports__);
  116553. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return BlurPostProcess; });
  116554. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116555. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116556. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116557. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116558. /* harmony import */ var _Shaders_kernelBlur_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/kernelBlur.fragment */ "./Shaders/kernelBlur.fragment.ts");
  116559. /* harmony import */ var _Shaders_kernelBlur_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/kernelBlur.vertex */ "./Shaders/kernelBlur.vertex.ts");
  116560. /**
  116561. * The Blur Post Process which blurs an image based on a kernel and direction.
  116562. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  116563. */
  116564. var BlurPostProcess = /** @class */ (function (_super) {
  116565. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlurPostProcess, _super);
  116566. /**
  116567. * Creates a new instance BlurPostProcess
  116568. * @param name The name of the effect.
  116569. * @param direction The direction in which to blur the image.
  116570. * @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.
  116571. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  116572. * @param camera The camera to apply the render pass to.
  116573. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116574. * @param engine The engine which the post process will be applied. (default: current engine)
  116575. * @param reusable If the post process can be reused on the same frame. (default: false)
  116576. * @param textureType Type of textures used when performing the post process. (default: 0)
  116577. * @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)
  116578. */
  116579. function BlurPostProcess(name,
  116580. /** The direction in which to blur the image. */
  116581. direction, kernel, options, camera, samplingMode, engine, reusable, textureType, defines, blockCompilation) {
  116582. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  116583. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116584. if (defines === void 0) { defines = ""; }
  116585. if (blockCompilation === void 0) { blockCompilation = false; }
  116586. 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;
  116587. _this.direction = direction;
  116588. _this.blockCompilation = blockCompilation;
  116589. _this._packedFloat = false;
  116590. _this._staticDefines = "";
  116591. _this._staticDefines = defines;
  116592. _this.onApplyObservable.add(function (effect) {
  116593. if (_this._outputTexture) {
  116594. effect.setFloat2('delta', (1 / _this._outputTexture.width) * _this.direction.x, (1 / _this._outputTexture.height) * _this.direction.y);
  116595. }
  116596. else {
  116597. effect.setFloat2('delta', (1 / _this.width) * _this.direction.x, (1 / _this.height) * _this.direction.y);
  116598. }
  116599. });
  116600. _this.kernel = kernel;
  116601. return _this;
  116602. }
  116603. Object.defineProperty(BlurPostProcess.prototype, "kernel", {
  116604. /**
  116605. * Gets the length in pixels of the blur sample region
  116606. */
  116607. get: function () {
  116608. return this._idealKernel;
  116609. },
  116610. /**
  116611. * Sets the length in pixels of the blur sample region
  116612. */
  116613. set: function (v) {
  116614. if (this._idealKernel === v) {
  116615. return;
  116616. }
  116617. v = Math.max(v, 1);
  116618. this._idealKernel = v;
  116619. this._kernel = this._nearestBestKernel(v);
  116620. if (!this.blockCompilation) {
  116621. this._updateParameters();
  116622. }
  116623. },
  116624. enumerable: true,
  116625. configurable: true
  116626. });
  116627. Object.defineProperty(BlurPostProcess.prototype, "packedFloat", {
  116628. /**
  116629. * Gets wether or not the blur is unpacking/repacking floats
  116630. */
  116631. get: function () {
  116632. return this._packedFloat;
  116633. },
  116634. /**
  116635. * Sets wether or not the blur needs to unpack/repack floats
  116636. */
  116637. set: function (v) {
  116638. if (this._packedFloat === v) {
  116639. return;
  116640. }
  116641. this._packedFloat = v;
  116642. if (!this.blockCompilation) {
  116643. this._updateParameters();
  116644. }
  116645. },
  116646. enumerable: true,
  116647. configurable: true
  116648. });
  116649. /**
  116650. * Updates the effect with the current post process compile time values and recompiles the shader.
  116651. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  116652. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  116653. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  116654. * @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
  116655. * @param onCompiled Called when the shader has been compiled.
  116656. * @param onError Called if there is an error when compiling a shader.
  116657. */
  116658. BlurPostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  116659. if (defines === void 0) { defines = null; }
  116660. if (uniforms === void 0) { uniforms = null; }
  116661. if (samplers === void 0) { samplers = null; }
  116662. this._updateParameters(onCompiled, onError);
  116663. };
  116664. BlurPostProcess.prototype._updateParameters = function (onCompiled, onError) {
  116665. // Generate sampling offsets and weights
  116666. var N = this._kernel;
  116667. var centerIndex = (N - 1) / 2;
  116668. // Generate Gaussian sampling weights over kernel
  116669. var offsets = [];
  116670. var weights = [];
  116671. var totalWeight = 0;
  116672. for (var i = 0; i < N; i++) {
  116673. var u = i / (N - 1);
  116674. var w = this._gaussianWeight(u * 2.0 - 1);
  116675. offsets[i] = (i - centerIndex);
  116676. weights[i] = w;
  116677. totalWeight += w;
  116678. }
  116679. // Normalize weights
  116680. for (var i = 0; i < weights.length; i++) {
  116681. weights[i] /= totalWeight;
  116682. }
  116683. // Optimize: combine samples to take advantage of hardware linear sampling
  116684. // Walk from left to center, combining pairs (symmetrically)
  116685. var linearSamplingWeights = [];
  116686. var linearSamplingOffsets = [];
  116687. var linearSamplingMap = [];
  116688. for (var i = 0; i <= centerIndex; i += 2) {
  116689. var j = Math.min(i + 1, Math.floor(centerIndex));
  116690. var singleCenterSample = i === j;
  116691. if (singleCenterSample) {
  116692. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  116693. }
  116694. else {
  116695. var sharedCell = j === centerIndex;
  116696. var weightLinear = (weights[i] + weights[j] * (sharedCell ? .5 : 1.));
  116697. var offsetLinear = offsets[i] + 1 / (1 + weights[i] / weights[j]);
  116698. if (offsetLinear === 0) {
  116699. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  116700. linearSamplingMap.push({ o: offsets[i + 1], w: weights[i + 1] });
  116701. }
  116702. else {
  116703. linearSamplingMap.push({ o: offsetLinear, w: weightLinear });
  116704. linearSamplingMap.push({ o: -offsetLinear, w: weightLinear });
  116705. }
  116706. }
  116707. }
  116708. for (var i = 0; i < linearSamplingMap.length; i++) {
  116709. linearSamplingOffsets[i] = linearSamplingMap[i].o;
  116710. linearSamplingWeights[i] = linearSamplingMap[i].w;
  116711. }
  116712. // Replace with optimized
  116713. offsets = linearSamplingOffsets;
  116714. weights = linearSamplingWeights;
  116715. // Generate shaders
  116716. var maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors;
  116717. var freeVaryingVec2 = Math.max(maxVaryingRows, 0.) - 1; // Because of sampleCenter
  116718. var varyingCount = Math.min(offsets.length, freeVaryingVec2);
  116719. var defines = "";
  116720. defines += this._staticDefines;
  116721. // The DOF fragment should ignore the center pixel when looping as it is handled manualy in the fragment shader.
  116722. if (this._staticDefines.indexOf("DOF") != -1) {
  116723. defines += "#define CENTER_WEIGHT " + this._glslFloat(weights[varyingCount - 1]) + "\r\n";
  116724. varyingCount--;
  116725. }
  116726. for (var i = 0; i < varyingCount; i++) {
  116727. defines += "#define KERNEL_OFFSET" + i + " " + this._glslFloat(offsets[i]) + "\r\n";
  116728. defines += "#define KERNEL_WEIGHT" + i + " " + this._glslFloat(weights[i]) + "\r\n";
  116729. }
  116730. var depCount = 0;
  116731. for (var i = freeVaryingVec2; i < offsets.length; i++) {
  116732. defines += "#define KERNEL_DEP_OFFSET" + depCount + " " + this._glslFloat(offsets[i]) + "\r\n";
  116733. defines += "#define KERNEL_DEP_WEIGHT" + depCount + " " + this._glslFloat(weights[i]) + "\r\n";
  116734. depCount++;
  116735. }
  116736. if (this.packedFloat) {
  116737. defines += "#define PACKEDFLOAT 1";
  116738. }
  116739. this.blockCompilation = false;
  116740. _super.prototype.updateEffect.call(this, defines, null, null, {
  116741. varyingCount: varyingCount,
  116742. depCount: depCount
  116743. }, onCompiled, onError);
  116744. };
  116745. /**
  116746. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  116747. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  116748. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  116749. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  116750. * The gaps between physical kernels are compensated for in the weighting of the samples
  116751. * @param idealKernel Ideal blur kernel.
  116752. * @return Nearest best kernel.
  116753. */
  116754. BlurPostProcess.prototype._nearestBestKernel = function (idealKernel) {
  116755. var v = Math.round(idealKernel);
  116756. for (var _i = 0, _a = [v, v - 1, v + 1, v - 2, v + 2]; _i < _a.length; _i++) {
  116757. var k = _a[_i];
  116758. if (((k % 2) !== 0) && ((Math.floor(k / 2) % 2) === 0) && k > 0) {
  116759. return Math.max(k, 3);
  116760. }
  116761. }
  116762. return Math.max(v, 3);
  116763. };
  116764. /**
  116765. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  116766. * @param x The point on the Gaussian distribution to sample.
  116767. * @return the value of the Gaussian function at x.
  116768. */
  116769. BlurPostProcess.prototype._gaussianWeight = function (x) {
  116770. //reference: Engines/ImageProcessingBlur.cpp #dcc760
  116771. // We are evaluating the Gaussian (normal) distribution over a kernel parameter space of [-1,1],
  116772. // so we truncate at three standard deviations by setting stddev (sigma) to 1/3.
  116773. // The choice of 3-sigma truncation is common but arbitrary, and means that the signal is
  116774. // truncated at around 1.3% of peak strength.
  116775. //the distribution is scaled to account for the difference between the actual kernel size and the requested kernel size
  116776. var sigma = (1 / 3);
  116777. var denominator = Math.sqrt(2.0 * Math.PI) * sigma;
  116778. var exponent = -((x * x) / (2.0 * sigma * sigma));
  116779. var weight = (1.0 / denominator) * Math.exp(exponent);
  116780. return weight;
  116781. };
  116782. /**
  116783. * Generates a string that can be used as a floating point number in GLSL.
  116784. * @param x Value to print.
  116785. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  116786. * @return GLSL float string.
  116787. */
  116788. BlurPostProcess.prototype._glslFloat = function (x, decimalFigures) {
  116789. if (decimalFigures === void 0) { decimalFigures = 8; }
  116790. return x.toFixed(decimalFigures).replace(/0+$/, '');
  116791. };
  116792. return BlurPostProcess;
  116793. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116794. /***/ }),
  116795. /***/ "./PostProcesses/chromaticAberrationPostProcess.ts":
  116796. /*!*********************************************************!*\
  116797. !*** ./PostProcesses/chromaticAberrationPostProcess.ts ***!
  116798. \*********************************************************/
  116799. /*! exports provided: ChromaticAberrationPostProcess */
  116800. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116801. "use strict";
  116802. __webpack_require__.r(__webpack_exports__);
  116803. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return ChromaticAberrationPostProcess; });
  116804. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116805. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  116806. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116807. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116808. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  116809. /**
  116810. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  116811. */
  116812. var ChromaticAberrationPostProcess = /** @class */ (function (_super) {
  116813. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ChromaticAberrationPostProcess, _super);
  116814. /**
  116815. * Creates a new instance ChromaticAberrationPostProcess
  116816. * @param name The name of the effect.
  116817. * @param screenWidth The width of the screen to apply the effect on.
  116818. * @param screenHeight The height of the screen to apply the effect on.
  116819. * @param options The required width/height ratio to downsize to before computing the render pass.
  116820. * @param camera The camera to apply the render pass to.
  116821. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116822. * @param engine The engine which the post process will be applied. (default: current engine)
  116823. * @param reusable If the post process can be reused on the same frame. (default: false)
  116824. * @param textureType Type of textures used when performing the post process. (default: 0)
  116825. * @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)
  116826. */
  116827. function ChromaticAberrationPostProcess(name, screenWidth, screenHeight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116828. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116829. if (blockCompilation === void 0) { blockCompilation = false; }
  116830. 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;
  116831. /**
  116832. * The amount of seperation of rgb channels (default: 30)
  116833. */
  116834. _this.aberrationAmount = 30;
  116835. /**
  116836. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  116837. */
  116838. _this.radialIntensity = 0;
  116839. /**
  116840. * 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))
  116841. */
  116842. _this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.707, 0.707);
  116843. /**
  116844. * 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))
  116845. */
  116846. _this.centerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.5, 0.5);
  116847. _this.onApplyObservable.add(function (effect) {
  116848. effect.setFloat('chromatic_aberration', _this.aberrationAmount);
  116849. effect.setFloat('screen_width', screenWidth);
  116850. effect.setFloat('screen_height', screenHeight);
  116851. effect.setFloat('radialIntensity', _this.radialIntensity);
  116852. effect.setFloat2('direction', _this.direction.x, _this.direction.y);
  116853. effect.setFloat2('centerPosition', _this.centerPosition.x, _this.centerPosition.y);
  116854. });
  116855. return _this;
  116856. }
  116857. return ChromaticAberrationPostProcess;
  116858. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  116859. /***/ }),
  116860. /***/ "./PostProcesses/circleOfConfusionPostProcess.ts":
  116861. /*!*******************************************************!*\
  116862. !*** ./PostProcesses/circleOfConfusionPostProcess.ts ***!
  116863. \*******************************************************/
  116864. /*! exports provided: CircleOfConfusionPostProcess */
  116865. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116866. "use strict";
  116867. __webpack_require__.r(__webpack_exports__);
  116868. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return CircleOfConfusionPostProcess; });
  116869. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116870. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116871. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  116872. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116873. /* harmony import */ var _Shaders_circleOfConfusion_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/circleOfConfusion.fragment */ "./Shaders/circleOfConfusion.fragment.ts");
  116874. /**
  116875. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  116876. */
  116877. var CircleOfConfusionPostProcess = /** @class */ (function (_super) {
  116878. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleOfConfusionPostProcess, _super);
  116879. /**
  116880. * Creates a new instance CircleOfConfusionPostProcess
  116881. * @param name The name of the effect.
  116882. * @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.
  116883. * @param options The required width/height ratio to downsize to before computing the render pass.
  116884. * @param camera The camera to apply the render pass to.
  116885. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116886. * @param engine The engine which the post process will be applied. (default: current engine)
  116887. * @param reusable If the post process can be reused on the same frame. (default: false)
  116888. * @param textureType Type of textures used when performing the post process. (default: 0)
  116889. * @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)
  116890. */
  116891. function CircleOfConfusionPostProcess(name, depthTexture, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116892. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116893. if (blockCompilation === void 0) { blockCompilation = false; }
  116894. var _this = _super.call(this, name, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  116895. /**
  116896. * 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.
  116897. */
  116898. _this.lensSize = 50;
  116899. /**
  116900. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  116901. */
  116902. _this.fStop = 1.4;
  116903. /**
  116904. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  116905. */
  116906. _this.focusDistance = 2000;
  116907. /**
  116908. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  116909. */
  116910. _this.focalLength = 50;
  116911. _this._depthTexture = null;
  116912. _this._depthTexture = depthTexture;
  116913. _this.onApplyObservable.add(function (effect) {
  116914. if (!_this._depthTexture) {
  116915. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("No depth texture set on CircleOfConfusionPostProcess");
  116916. return;
  116917. }
  116918. effect.setTexture("depthSampler", _this._depthTexture);
  116919. // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html
  116920. var aperture = _this.lensSize / _this.fStop;
  116921. var cocPrecalculation = ((aperture * _this.focalLength) / ((_this.focusDistance - _this.focalLength))); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]
  116922. effect.setFloat('focusDistance', _this.focusDistance);
  116923. effect.setFloat('cocPrecalculation', cocPrecalculation);
  116924. effect.setFloat2('cameraMinMaxZ', _this._depthTexture.activeCamera.minZ, _this._depthTexture.activeCamera.maxZ);
  116925. });
  116926. return _this;
  116927. }
  116928. Object.defineProperty(CircleOfConfusionPostProcess.prototype, "depthTexture", {
  116929. /**
  116930. * 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.
  116931. */
  116932. set: function (value) {
  116933. this._depthTexture = value;
  116934. },
  116935. enumerable: true,
  116936. configurable: true
  116937. });
  116938. return CircleOfConfusionPostProcess;
  116939. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116940. /***/ }),
  116941. /***/ "./PostProcesses/colorCorrectionPostProcess.ts":
  116942. /*!*****************************************************!*\
  116943. !*** ./PostProcesses/colorCorrectionPostProcess.ts ***!
  116944. \*****************************************************/
  116945. /*! exports provided: ColorCorrectionPostProcess */
  116946. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116947. "use strict";
  116948. __webpack_require__.r(__webpack_exports__);
  116949. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return ColorCorrectionPostProcess; });
  116950. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116951. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116952. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116953. /* harmony import */ var _Shaders_colorCorrection_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/colorCorrection.fragment */ "./Shaders/colorCorrection.fragment.ts");
  116954. /**
  116955. *
  116956. * This post-process allows the modification of rendered colors by using
  116957. * a 'look-up table' (LUT). This effect is also called Color Grading.
  116958. *
  116959. * The object needs to be provided an url to a texture containing the color
  116960. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  116961. * Use an image editing software to tweak the LUT to match your needs.
  116962. *
  116963. * For an example of a color LUT, see here:
  116964. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  116965. * For explanations on color grading, see here:
  116966. * @see http://udn.epicgames.com/Three/ColorGrading.html
  116967. *
  116968. */
  116969. var ColorCorrectionPostProcess = /** @class */ (function (_super) {
  116970. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorCorrectionPostProcess, _super);
  116971. function ColorCorrectionPostProcess(name, colorTableUrl, options, camera, samplingMode, engine, reusable) {
  116972. var _this = _super.call(this, name, 'colorCorrection', null, ['colorTable'], options, camera, samplingMode, engine, reusable) || this;
  116973. _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);
  116974. _this._colorTableTexture.anisotropicFilteringLevel = 1;
  116975. _this._colorTableTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  116976. _this._colorTableTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  116977. _this.onApply = function (effect) {
  116978. effect.setTexture("colorTable", _this._colorTableTexture);
  116979. };
  116980. return _this;
  116981. }
  116982. return ColorCorrectionPostProcess;
  116983. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116984. /***/ }),
  116985. /***/ "./PostProcesses/convolutionPostProcess.ts":
  116986. /*!*************************************************!*\
  116987. !*** ./PostProcesses/convolutionPostProcess.ts ***!
  116988. \*************************************************/
  116989. /*! exports provided: ConvolutionPostProcess */
  116990. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116991. "use strict";
  116992. __webpack_require__.r(__webpack_exports__);
  116993. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return ConvolutionPostProcess; });
  116994. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116995. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116996. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116997. /* harmony import */ var _Shaders_convolution_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/convolution.fragment */ "./Shaders/convolution.fragment.ts");
  116998. /**
  116999. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  117000. * input texture to perform effects such as edge detection or sharpening
  117001. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  117002. */
  117003. var ConvolutionPostProcess = /** @class */ (function (_super) {
  117004. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ConvolutionPostProcess, _super);
  117005. /**
  117006. * Creates a new instance ConvolutionPostProcess
  117007. * @param name The name of the effect.
  117008. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  117009. * @param options The required width/height ratio to downsize to before computing the render pass.
  117010. * @param camera The camera to apply the render pass to.
  117011. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117012. * @param engine The engine which the post process will be applied. (default: current engine)
  117013. * @param reusable If the post process can be reused on the same frame. (default: false)
  117014. * @param textureType Type of textures used when performing the post process. (default: 0)
  117015. */
  117016. function ConvolutionPostProcess(name,
  117017. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  117018. kernel, options, camera, samplingMode, engine, reusable, textureType) {
  117019. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117020. var _this = _super.call(this, name, "convolution", ["kernel", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  117021. _this.kernel = kernel;
  117022. _this.onApply = function (effect) {
  117023. effect.setFloat2("screenSize", _this.width, _this.height);
  117024. effect.setArray("kernel", _this.kernel);
  117025. };
  117026. return _this;
  117027. }
  117028. // Statics
  117029. /**
  117030. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117031. */
  117032. ConvolutionPostProcess.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1];
  117033. /**
  117034. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117035. */
  117036. ConvolutionPostProcess.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0];
  117037. /**
  117038. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117039. */
  117040. ConvolutionPostProcess.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1];
  117041. /**
  117042. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117043. */
  117044. ConvolutionPostProcess.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0];
  117045. /**
  117046. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117047. */
  117048. ConvolutionPostProcess.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2];
  117049. /**
  117050. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117051. */
  117052. ConvolutionPostProcess.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0];
  117053. return ConvolutionPostProcess;
  117054. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117055. /***/ }),
  117056. /***/ "./PostProcesses/depthOfFieldBlurPostProcess.ts":
  117057. /*!******************************************************!*\
  117058. !*** ./PostProcesses/depthOfFieldBlurPostProcess.ts ***!
  117059. \******************************************************/
  117060. /*! exports provided: DepthOfFieldBlurPostProcess */
  117061. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117062. "use strict";
  117063. __webpack_require__.r(__webpack_exports__);
  117064. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return DepthOfFieldBlurPostProcess; });
  117065. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117066. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  117067. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  117068. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117069. /**
  117070. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  117071. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  117072. * based on samples that have a large difference in distance than the center pixel.
  117073. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  117074. */
  117075. var DepthOfFieldBlurPostProcess = /** @class */ (function (_super) {
  117076. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldBlurPostProcess, _super);
  117077. /**
  117078. * Creates a new instance CircleOfConfusionPostProcess
  117079. * @param name The name of the effect.
  117080. * @param scene The scene the effect belongs to.
  117081. * @param direction The direction the blur should be applied.
  117082. * @param kernel The size of the kernel used to blur.
  117083. * @param options The required width/height ratio to downsize to before computing the render pass.
  117084. * @param camera The camera to apply the render pass to.
  117085. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  117086. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  117087. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117088. * @param engine The engine which the post process will be applied. (default: current engine)
  117089. * @param reusable If the post process can be reused on the same frame. (default: false)
  117090. * @param textureType Type of textures used when performing the post process. (default: 0)
  117091. * @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)
  117092. */
  117093. function DepthOfFieldBlurPostProcess(name, scene, direction, kernel, options, camera, circleOfConfusion, imageToBlur, samplingMode, engine, reusable, textureType, blockCompilation) {
  117094. if (imageToBlur === void 0) { imageToBlur = null; }
  117095. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  117096. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117097. if (blockCompilation === void 0) { blockCompilation = false; }
  117098. 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;
  117099. _this.direction = direction;
  117100. _this.onApplyObservable.add(function (effect) {
  117101. if (imageToBlur != null) {
  117102. effect.setTextureFromPostProcess("textureSampler", imageToBlur);
  117103. }
  117104. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  117105. if (scene.activeCamera) {
  117106. effect.setFloat2('cameraMinMaxZ', scene.activeCamera.minZ, scene.activeCamera.maxZ);
  117107. }
  117108. });
  117109. return _this;
  117110. }
  117111. return DepthOfFieldBlurPostProcess;
  117112. }(_blurPostProcess__WEBPACK_IMPORTED_MODULE_2__["BlurPostProcess"]));
  117113. /***/ }),
  117114. /***/ "./PostProcesses/depthOfFieldEffect.ts":
  117115. /*!*********************************************!*\
  117116. !*** ./PostProcesses/depthOfFieldEffect.ts ***!
  117117. \*********************************************/
  117118. /*! exports provided: DepthOfFieldEffectBlurLevel, DepthOfFieldEffect */
  117119. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117120. "use strict";
  117121. __webpack_require__.r(__webpack_exports__);
  117122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return DepthOfFieldEffectBlurLevel; });
  117123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return DepthOfFieldEffect; });
  117124. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117125. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  117126. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  117127. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  117128. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  117129. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  117130. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  117131. /**
  117132. * Specifies the level of max blur that should be applied when using the depth of field effect
  117133. */
  117134. var DepthOfFieldEffectBlurLevel;
  117135. (function (DepthOfFieldEffectBlurLevel) {
  117136. /**
  117137. * Subtle blur
  117138. */
  117139. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Low"] = 0] = "Low";
  117140. /**
  117141. * Medium blur
  117142. */
  117143. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Medium"] = 1] = "Medium";
  117144. /**
  117145. * Large blur
  117146. */
  117147. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["High"] = 2] = "High";
  117148. })(DepthOfFieldEffectBlurLevel || (DepthOfFieldEffectBlurLevel = {}));
  117149. /**
  117150. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  117151. */
  117152. var DepthOfFieldEffect = /** @class */ (function (_super) {
  117153. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldEffect, _super);
  117154. /**
  117155. * Creates a new instance DepthOfFieldEffect
  117156. * @param scene The scene the effect belongs to.
  117157. * @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.
  117158. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  117159. * @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)
  117160. */
  117161. function DepthOfFieldEffect(scene, depthTexture, blurLevel, pipelineTextureType, blockCompilation) {
  117162. if (blurLevel === void 0) { blurLevel = DepthOfFieldEffectBlurLevel.Low; }
  117163. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  117164. if (blockCompilation === void 0) { blockCompilation = false; }
  117165. var _this = _super.call(this, scene.getEngine(), "depth of field", function () {
  117166. return _this._effects;
  117167. }, true) || this;
  117168. /**
  117169. * @hidden Internal post processes in depth of field effect
  117170. */
  117171. _this._effects = [];
  117172. // Circle of confusion value for each pixel is used to determine how much to blur that pixel
  117173. _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);
  117174. // 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)
  117175. // Blur the image but do not blur on sharp far to near distance changes to avoid bleeding artifacts
  117176. // See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  117177. _this._depthOfFieldBlurY = [];
  117178. _this._depthOfFieldBlurX = [];
  117179. var blurCount = 1;
  117180. var kernelSize = 15;
  117181. switch (blurLevel) {
  117182. case DepthOfFieldEffectBlurLevel.High: {
  117183. blurCount = 3;
  117184. kernelSize = 51;
  117185. break;
  117186. }
  117187. case DepthOfFieldEffectBlurLevel.Medium: {
  117188. blurCount = 2;
  117189. kernelSize = 31;
  117190. break;
  117191. }
  117192. default: {
  117193. kernelSize = 15;
  117194. blurCount = 1;
  117195. break;
  117196. }
  117197. }
  117198. var adjustedKernelSize = kernelSize / Math.pow(2, blurCount - 1);
  117199. var ratio = 1.0;
  117200. for (var i = 0; i < blurCount; i++) {
  117201. 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);
  117202. blurY.autoClear = false;
  117203. ratio = 0.75 / Math.pow(2, i);
  117204. 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);
  117205. blurX.autoClear = false;
  117206. _this._depthOfFieldBlurY.push(blurY);
  117207. _this._depthOfFieldBlurX.push(blurX);
  117208. }
  117209. // Set all post processes on the effect.
  117210. _this._effects = [_this._circleOfConfusion];
  117211. for (var i = 0; i < _this._depthOfFieldBlurX.length; i++) {
  117212. _this._effects.push(_this._depthOfFieldBlurY[i]);
  117213. _this._effects.push(_this._depthOfFieldBlurX[i]);
  117214. }
  117215. // Merge blurred images with original image based on circleOfConfusion
  117216. _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);
  117217. _this._dofMerge.autoClear = false;
  117218. _this._effects.push(_this._dofMerge);
  117219. return _this;
  117220. }
  117221. Object.defineProperty(DepthOfFieldEffect.prototype, "focalLength", {
  117222. get: function () {
  117223. return this._circleOfConfusion.focalLength;
  117224. },
  117225. /**
  117226. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  117227. */
  117228. set: function (value) {
  117229. this._circleOfConfusion.focalLength = value;
  117230. },
  117231. enumerable: true,
  117232. configurable: true
  117233. });
  117234. Object.defineProperty(DepthOfFieldEffect.prototype, "fStop", {
  117235. get: function () {
  117236. return this._circleOfConfusion.fStop;
  117237. },
  117238. /**
  117239. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  117240. */
  117241. set: function (value) {
  117242. this._circleOfConfusion.fStop = value;
  117243. },
  117244. enumerable: true,
  117245. configurable: true
  117246. });
  117247. Object.defineProperty(DepthOfFieldEffect.prototype, "focusDistance", {
  117248. get: function () {
  117249. return this._circleOfConfusion.focusDistance;
  117250. },
  117251. /**
  117252. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  117253. */
  117254. set: function (value) {
  117255. this._circleOfConfusion.focusDistance = value;
  117256. },
  117257. enumerable: true,
  117258. configurable: true
  117259. });
  117260. Object.defineProperty(DepthOfFieldEffect.prototype, "lensSize", {
  117261. get: function () {
  117262. return this._circleOfConfusion.lensSize;
  117263. },
  117264. /**
  117265. * 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.
  117266. */
  117267. set: function (value) {
  117268. this._circleOfConfusion.lensSize = value;
  117269. },
  117270. enumerable: true,
  117271. configurable: true
  117272. });
  117273. Object.defineProperty(DepthOfFieldEffect.prototype, "depthTexture", {
  117274. /**
  117275. * 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.
  117276. */
  117277. set: function (value) {
  117278. this._circleOfConfusion.depthTexture = value;
  117279. },
  117280. enumerable: true,
  117281. configurable: true
  117282. });
  117283. /**
  117284. * Disposes each of the internal effects for a given camera.
  117285. * @param camera The camera to dispose the effect on.
  117286. */
  117287. DepthOfFieldEffect.prototype.disposeEffects = function (camera) {
  117288. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  117289. this._effects[effectIndex].dispose(camera);
  117290. }
  117291. };
  117292. /**
  117293. * @hidden Internal
  117294. */
  117295. DepthOfFieldEffect.prototype._updateEffects = function () {
  117296. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  117297. this._effects[effectIndex].updateEffect();
  117298. }
  117299. };
  117300. /**
  117301. * Internal
  117302. * @returns if all the contained post processes are ready.
  117303. * @hidden
  117304. */
  117305. DepthOfFieldEffect.prototype._isReady = function () {
  117306. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  117307. if (!this._effects[effectIndex].isReady()) {
  117308. return false;
  117309. }
  117310. }
  117311. return true;
  117312. };
  117313. return DepthOfFieldEffect;
  117314. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderEffect"]));
  117315. /***/ }),
  117316. /***/ "./PostProcesses/depthOfFieldMergePostProcess.ts":
  117317. /*!*******************************************************!*\
  117318. !*** ./PostProcesses/depthOfFieldMergePostProcess.ts ***!
  117319. \*******************************************************/
  117320. /*! exports provided: DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess */
  117321. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117322. "use strict";
  117323. __webpack_require__.r(__webpack_exports__);
  117324. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return DepthOfFieldMergePostProcessOptions; });
  117325. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return DepthOfFieldMergePostProcess; });
  117326. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117327. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117328. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117329. /* harmony import */ var _Shaders_depthOfFieldMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/depthOfFieldMerge.fragment */ "./Shaders/depthOfFieldMerge.fragment.ts");
  117330. /**
  117331. * Options to be set when merging outputs from the default pipeline.
  117332. */
  117333. var DepthOfFieldMergePostProcessOptions = /** @class */ (function () {
  117334. function DepthOfFieldMergePostProcessOptions() {
  117335. }
  117336. return DepthOfFieldMergePostProcessOptions;
  117337. }());
  117338. /**
  117339. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  117340. */
  117341. var DepthOfFieldMergePostProcess = /** @class */ (function (_super) {
  117342. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldMergePostProcess, _super);
  117343. /**
  117344. * Creates a new instance of DepthOfFieldMergePostProcess
  117345. * @param name The name of the effect.
  117346. * @param originalFromInput Post process which's input will be used for the merge.
  117347. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  117348. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  117349. * @param options The required width/height ratio to downsize to before computing the render pass.
  117350. * @param camera The camera to apply the render pass to.
  117351. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117352. * @param engine The engine which the post process will be applied. (default: current engine)
  117353. * @param reusable If the post process can be reused on the same frame. (default: false)
  117354. * @param textureType Type of textures used when performing the post process. (default: 0)
  117355. * @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)
  117356. */
  117357. function DepthOfFieldMergePostProcess(name, originalFromInput, circleOfConfusion, blurSteps, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117358. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117359. if (blockCompilation === void 0) { blockCompilation = false; }
  117360. var _this = _super.call(this, name, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  117361. _this.blurSteps = blurSteps;
  117362. _this.onApplyObservable.add(function (effect) {
  117363. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  117364. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  117365. blurSteps.forEach(function (step, index) {
  117366. effect.setTextureFromPostProcessOutput("blurStep" + (blurSteps.length - index - 1), step);
  117367. });
  117368. });
  117369. if (!blockCompilation) {
  117370. _this.updateEffect();
  117371. }
  117372. return _this;
  117373. }
  117374. /**
  117375. * Updates the effect with the current post process compile time values and recompiles the shader.
  117376. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  117377. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  117378. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  117379. * @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
  117380. * @param onCompiled Called when the shader has been compiled.
  117381. * @param onError Called if there is an error when compiling a shader.
  117382. */
  117383. DepthOfFieldMergePostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  117384. if (defines === void 0) { defines = null; }
  117385. if (uniforms === void 0) { uniforms = null; }
  117386. if (samplers === void 0) { samplers = null; }
  117387. if (!defines) {
  117388. defines = "";
  117389. defines += "#define BLUR_LEVEL " + (this.blurSteps.length - 1) + "\n";
  117390. }
  117391. _super.prototype.updateEffect.call(this, defines, uniforms, samplers, indexParameters, onCompiled, onError);
  117392. };
  117393. return DepthOfFieldMergePostProcess;
  117394. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117395. /***/ }),
  117396. /***/ "./PostProcesses/displayPassPostProcess.ts":
  117397. /*!*************************************************!*\
  117398. !*** ./PostProcesses/displayPassPostProcess.ts ***!
  117399. \*************************************************/
  117400. /*! exports provided: DisplayPassPostProcess */
  117401. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117402. "use strict";
  117403. __webpack_require__.r(__webpack_exports__);
  117404. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return DisplayPassPostProcess; });
  117405. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117406. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117407. /* harmony import */ var _Shaders_displayPass_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/displayPass.fragment */ "./Shaders/displayPass.fragment.ts");
  117408. /**
  117409. * DisplayPassPostProcess which produces an output the same as it's input
  117410. */
  117411. var DisplayPassPostProcess = /** @class */ (function (_super) {
  117412. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayPassPostProcess, _super);
  117413. /**
  117414. * Creates the DisplayPassPostProcess
  117415. * @param name The name of the effect.
  117416. * @param options The required width/height ratio to downsize to before computing the render pass.
  117417. * @param camera The camera to apply the render pass to.
  117418. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117419. * @param engine The engine which the post process will be applied. (default: current engine)
  117420. * @param reusable If the post process can be reused on the same frame. (default: false)
  117421. */
  117422. function DisplayPassPostProcess(name, options, camera, samplingMode, engine, reusable) {
  117423. return _super.call(this, name, "displayPass", ["passSampler"], ["passSampler"], options, camera, samplingMode, engine, reusable) || this;
  117424. }
  117425. return DisplayPassPostProcess;
  117426. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117427. /***/ }),
  117428. /***/ "./PostProcesses/extractHighlightsPostProcess.ts":
  117429. /*!*******************************************************!*\
  117430. !*** ./PostProcesses/extractHighlightsPostProcess.ts ***!
  117431. \*******************************************************/
  117432. /*! exports provided: ExtractHighlightsPostProcess */
  117433. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117434. "use strict";
  117435. __webpack_require__.r(__webpack_exports__);
  117436. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return ExtractHighlightsPostProcess; });
  117437. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117438. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117439. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  117440. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117441. /* harmony import */ var _Shaders_extractHighlights_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/extractHighlights.fragment */ "./Shaders/extractHighlights.fragment.ts");
  117442. /**
  117443. * 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.
  117444. */
  117445. var ExtractHighlightsPostProcess = /** @class */ (function (_super) {
  117446. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExtractHighlightsPostProcess, _super);
  117447. function ExtractHighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117448. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117449. if (blockCompilation === void 0) { blockCompilation = false; }
  117450. var _this = _super.call(this, name, "extractHighlights", ["threshold", "exposure"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  117451. /**
  117452. * The luminance threshold, pixels below this value will be set to black.
  117453. */
  117454. _this.threshold = 0.9;
  117455. /** @hidden */
  117456. _this._exposure = 1;
  117457. /**
  117458. * Post process which has the input texture to be used when performing highlight extraction
  117459. * @hidden
  117460. */
  117461. _this._inputPostProcess = null;
  117462. _this.onApplyObservable.add(function (effect) {
  117463. if (_this._inputPostProcess) {
  117464. effect.setTextureFromPostProcess("textureSampler", _this._inputPostProcess);
  117465. }
  117466. effect.setFloat('threshold', Math.pow(_this.threshold, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["ToGammaSpace"]));
  117467. effect.setFloat('exposure', _this._exposure);
  117468. });
  117469. return _this;
  117470. }
  117471. return ExtractHighlightsPostProcess;
  117472. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117473. /***/ }),
  117474. /***/ "./PostProcesses/filterPostProcess.ts":
  117475. /*!********************************************!*\
  117476. !*** ./PostProcesses/filterPostProcess.ts ***!
  117477. \********************************************/
  117478. /*! exports provided: FilterPostProcess */
  117479. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117480. "use strict";
  117481. __webpack_require__.r(__webpack_exports__);
  117482. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return FilterPostProcess; });
  117483. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117484. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117485. /* harmony import */ var _Shaders_filter_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/filter.fragment */ "./Shaders/filter.fragment.ts");
  117486. /**
  117487. * Applies a kernel filter to the image
  117488. */
  117489. var FilterPostProcess = /** @class */ (function (_super) {
  117490. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FilterPostProcess, _super);
  117491. /**
  117492. *
  117493. * @param name The name of the effect.
  117494. * @param kernelMatrix The matrix to be applied to the image
  117495. * @param options The required width/height ratio to downsize to before computing the render pass.
  117496. * @param camera The camera to apply the render pass to.
  117497. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117498. * @param engine The engine which the post process will be applied. (default: current engine)
  117499. * @param reusable If the post process can be reused on the same frame. (default: false)
  117500. */
  117501. function FilterPostProcess(name,
  117502. /** The matrix to be applied to the image */
  117503. kernelMatrix, options, camera, samplingMode, engine, reusable) {
  117504. var _this = _super.call(this, name, "filter", ["kernelMatrix"], null, options, camera, samplingMode, engine, reusable) || this;
  117505. _this.kernelMatrix = kernelMatrix;
  117506. _this.onApply = function (effect) {
  117507. effect.setMatrix("kernelMatrix", _this.kernelMatrix);
  117508. };
  117509. return _this;
  117510. }
  117511. return FilterPostProcess;
  117512. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117513. /***/ }),
  117514. /***/ "./PostProcesses/fxaaPostProcess.ts":
  117515. /*!******************************************!*\
  117516. !*** ./PostProcesses/fxaaPostProcess.ts ***!
  117517. \******************************************/
  117518. /*! exports provided: FxaaPostProcess */
  117519. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117520. "use strict";
  117521. __webpack_require__.r(__webpack_exports__);
  117522. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return FxaaPostProcess; });
  117523. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117524. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  117525. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117526. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117527. /* harmony import */ var _Shaders_fxaa_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/fxaa.fragment */ "./Shaders/fxaa.fragment.ts");
  117528. /* harmony import */ var _Shaders_fxaa_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/fxaa.vertex */ "./Shaders/fxaa.vertex.ts");
  117529. /**
  117530. * Fxaa post process
  117531. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  117532. */
  117533. var FxaaPostProcess = /** @class */ (function (_super) {
  117534. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FxaaPostProcess, _super);
  117535. function FxaaPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  117536. if (camera === void 0) { camera = null; }
  117537. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117538. 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;
  117539. var defines = _this._getDefines();
  117540. _this.updateEffect(defines);
  117541. _this.onApplyObservable.add(function (effect) {
  117542. var texelSize = _this.texelSize;
  117543. effect.setFloat2("texelSize", texelSize.x, texelSize.y);
  117544. });
  117545. return _this;
  117546. }
  117547. FxaaPostProcess.prototype._getDefines = function () {
  117548. var engine = this.getEngine();
  117549. if (!engine) {
  117550. return null;
  117551. }
  117552. var glInfo = engine.getGlInfo();
  117553. if (glInfo && glInfo.renderer && glInfo.renderer.toLowerCase().indexOf("mali") > -1) {
  117554. return "#define MALI 1\n";
  117555. }
  117556. return null;
  117557. };
  117558. return FxaaPostProcess;
  117559. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  117560. /***/ }),
  117561. /***/ "./PostProcesses/grainPostProcess.ts":
  117562. /*!*******************************************!*\
  117563. !*** ./PostProcesses/grainPostProcess.ts ***!
  117564. \*******************************************/
  117565. /*! exports provided: GrainPostProcess */
  117566. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117567. "use strict";
  117568. __webpack_require__.r(__webpack_exports__);
  117569. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return GrainPostProcess; });
  117570. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117571. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117572. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117573. /* harmony import */ var _Shaders_grain_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/grain.fragment */ "./Shaders/grain.fragment.ts");
  117574. /**
  117575. * The GrainPostProcess adds noise to the image at mid luminance levels
  117576. */
  117577. var GrainPostProcess = /** @class */ (function (_super) {
  117578. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GrainPostProcess, _super);
  117579. /**
  117580. * Creates a new instance of @see GrainPostProcess
  117581. * @param name The name of the effect.
  117582. * @param options The required width/height ratio to downsize to before computing the render pass.
  117583. * @param camera The camera to apply the render pass to.
  117584. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117585. * @param engine The engine which the post process will be applied. (default: current engine)
  117586. * @param reusable If the post process can be reused on the same frame. (default: false)
  117587. * @param textureType Type of textures used when performing the post process. (default: 0)
  117588. * @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)
  117589. */
  117590. function GrainPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117591. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117592. if (blockCompilation === void 0) { blockCompilation = false; }
  117593. var _this = _super.call(this, name, "grain", ["intensity", "animatedSeed"], [], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  117594. /**
  117595. * The intensity of the grain added (default: 30)
  117596. */
  117597. _this.intensity = 30;
  117598. /**
  117599. * If the grain should be randomized on every frame
  117600. */
  117601. _this.animated = false;
  117602. _this.onApplyObservable.add(function (effect) {
  117603. effect.setFloat('intensity', _this.intensity);
  117604. effect.setFloat('animatedSeed', _this.animated ? Math.random() + 1 : 1);
  117605. });
  117606. return _this;
  117607. }
  117608. return GrainPostProcess;
  117609. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117610. /***/ }),
  117611. /***/ "./PostProcesses/highlightsPostProcess.ts":
  117612. /*!************************************************!*\
  117613. !*** ./PostProcesses/highlightsPostProcess.ts ***!
  117614. \************************************************/
  117615. /*! exports provided: HighlightsPostProcess */
  117616. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117617. "use strict";
  117618. __webpack_require__.r(__webpack_exports__);
  117619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return HighlightsPostProcess; });
  117620. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117621. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117622. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117623. /* harmony import */ var _Shaders_highlights_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/highlights.fragment */ "./Shaders/highlights.fragment.ts");
  117624. /**
  117625. * Extracts highlights from the image
  117626. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117627. */
  117628. var HighlightsPostProcess = /** @class */ (function (_super) {
  117629. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightsPostProcess, _super);
  117630. /**
  117631. * Extracts highlights from the image
  117632. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117633. * @param name The name of the effect.
  117634. * @param options The required width/height ratio to downsize to before computing the render pass.
  117635. * @param camera The camera to apply the render pass to.
  117636. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117637. * @param engine The engine which the post process will be applied. (default: current engine)
  117638. * @param reusable If the post process can be reused on the same frame. (default: false)
  117639. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  117640. */
  117641. function HighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  117642. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117643. return _super.call(this, name, "highlights", null, null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  117644. }
  117645. return HighlightsPostProcess;
  117646. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117647. /***/ }),
  117648. /***/ "./PostProcesses/imageProcessingPostProcess.ts":
  117649. /*!*****************************************************!*\
  117650. !*** ./PostProcesses/imageProcessingPostProcess.ts ***!
  117651. \*****************************************************/
  117652. /*! exports provided: ImageProcessingPostProcess */
  117653. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117654. "use strict";
  117655. __webpack_require__.r(__webpack_exports__);
  117656. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return ImageProcessingPostProcess; });
  117657. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117658. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  117659. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  117660. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117661. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  117662. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117663. /* harmony import */ var _Shaders_imageProcessing_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/imageProcessing.fragment */ "./Shaders/imageProcessing.fragment.ts");
  117664. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  117665. /**
  117666. * ImageProcessingPostProcess
  117667. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  117668. */
  117669. var ImageProcessingPostProcess = /** @class */ (function (_super) {
  117670. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingPostProcess, _super);
  117671. function ImageProcessingPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, imageProcessingConfiguration) {
  117672. if (camera === void 0) { camera = null; }
  117673. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117674. var _this = _super.call(this, name, "imageProcessing", [], [], options, camera, samplingMode, engine, reusable, null, textureType, "postprocess", null, true) || this;
  117675. _this._fromLinearSpace = true;
  117676. /**
  117677. * Defines cache preventing GC.
  117678. */
  117679. _this._defines = {
  117680. IMAGEPROCESSING: false,
  117681. VIGNETTE: false,
  117682. VIGNETTEBLENDMODEMULTIPLY: false,
  117683. VIGNETTEBLENDMODEOPAQUE: false,
  117684. TONEMAPPING: false,
  117685. TONEMAPPING_ACES: false,
  117686. CONTRAST: false,
  117687. COLORCURVES: false,
  117688. COLORGRADING: false,
  117689. COLORGRADING3D: false,
  117690. FROMLINEARSPACE: false,
  117691. SAMPLER3DGREENDEPTH: false,
  117692. SAMPLER3DBGRMAP: false,
  117693. IMAGEPROCESSINGPOSTPROCESS: false,
  117694. EXPOSURE: false,
  117695. };
  117696. // Setup the configuration as forced by the constructor. This would then not force the
  117697. // scene materials output in linear space and let untouched the default forward pass.
  117698. if (imageProcessingConfiguration) {
  117699. imageProcessingConfiguration.applyByPostProcess = true;
  117700. _this._attachImageProcessingConfiguration(imageProcessingConfiguration, true);
  117701. // This will cause the shader to be compiled
  117702. _this.fromLinearSpace = false;
  117703. }
  117704. // Setup the default processing configuration to the scene.
  117705. else {
  117706. _this._attachImageProcessingConfiguration(null, true);
  117707. _this.imageProcessingConfiguration.applyByPostProcess = true;
  117708. }
  117709. _this.onApply = function (effect) {
  117710. _this.imageProcessingConfiguration.bind(effect, _this.aspectRatio);
  117711. };
  117712. return _this;
  117713. }
  117714. Object.defineProperty(ImageProcessingPostProcess.prototype, "imageProcessingConfiguration", {
  117715. /**
  117716. * Gets the image processing configuration used either in this material.
  117717. */
  117718. get: function () {
  117719. return this._imageProcessingConfiguration;
  117720. },
  117721. /**
  117722. * Sets the Default image processing configuration used either in the this material.
  117723. *
  117724. * If sets to null, the scene one is in use.
  117725. */
  117726. set: function (value) {
  117727. this._attachImageProcessingConfiguration(value);
  117728. },
  117729. enumerable: true,
  117730. configurable: true
  117731. });
  117732. /**
  117733. * Attaches a new image processing configuration to the PBR Material.
  117734. * @param configuration
  117735. */
  117736. ImageProcessingPostProcess.prototype._attachImageProcessingConfiguration = function (configuration, doNotBuild) {
  117737. var _this = this;
  117738. if (doNotBuild === void 0) { doNotBuild = false; }
  117739. if (configuration === this._imageProcessingConfiguration) {
  117740. return;
  117741. }
  117742. // Detaches observer.
  117743. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  117744. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  117745. }
  117746. // Pick the scene configuration if needed.
  117747. if (!configuration) {
  117748. var scene = null;
  117749. var engine = this.getEngine();
  117750. var camera = this.getCamera();
  117751. if (camera) {
  117752. scene = camera.getScene();
  117753. }
  117754. else if (engine && engine.scenes) {
  117755. var scenes = engine.scenes;
  117756. scene = scenes[scenes.length - 1];
  117757. }
  117758. else {
  117759. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  117760. }
  117761. this._imageProcessingConfiguration = scene.imageProcessingConfiguration;
  117762. }
  117763. else {
  117764. this._imageProcessingConfiguration = configuration;
  117765. }
  117766. // Attaches observer.
  117767. if (this._imageProcessingConfiguration) {
  117768. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  117769. _this._updateParameters();
  117770. });
  117771. }
  117772. // Ensure the effect will be rebuilt.
  117773. if (!doNotBuild) {
  117774. this._updateParameters();
  117775. }
  117776. };
  117777. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurves", {
  117778. /**
  117779. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  117780. */
  117781. get: function () {
  117782. return this.imageProcessingConfiguration.colorCurves;
  117783. },
  117784. /**
  117785. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  117786. */
  117787. set: function (value) {
  117788. this.imageProcessingConfiguration.colorCurves = value;
  117789. },
  117790. enumerable: true,
  117791. configurable: true
  117792. });
  117793. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurvesEnabled", {
  117794. /**
  117795. * Gets wether the color curves effect is enabled.
  117796. */
  117797. get: function () {
  117798. return this.imageProcessingConfiguration.colorCurvesEnabled;
  117799. },
  117800. /**
  117801. * Sets wether the color curves effect is enabled.
  117802. */
  117803. set: function (value) {
  117804. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  117805. },
  117806. enumerable: true,
  117807. configurable: true
  117808. });
  117809. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingTexture", {
  117810. /**
  117811. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  117812. */
  117813. get: function () {
  117814. return this.imageProcessingConfiguration.colorGradingTexture;
  117815. },
  117816. /**
  117817. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  117818. */
  117819. set: function (value) {
  117820. this.imageProcessingConfiguration.colorGradingTexture = value;
  117821. },
  117822. enumerable: true,
  117823. configurable: true
  117824. });
  117825. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingEnabled", {
  117826. /**
  117827. * Gets wether the color grading effect is enabled.
  117828. */
  117829. get: function () {
  117830. return this.imageProcessingConfiguration.colorGradingEnabled;
  117831. },
  117832. /**
  117833. * Gets wether the color grading effect is enabled.
  117834. */
  117835. set: function (value) {
  117836. this.imageProcessingConfiguration.colorGradingEnabled = value;
  117837. },
  117838. enumerable: true,
  117839. configurable: true
  117840. });
  117841. Object.defineProperty(ImageProcessingPostProcess.prototype, "exposure", {
  117842. /**
  117843. * Gets exposure used in the effect.
  117844. */
  117845. get: function () {
  117846. return this.imageProcessingConfiguration.exposure;
  117847. },
  117848. /**
  117849. * Sets exposure used in the effect.
  117850. */
  117851. set: function (value) {
  117852. this.imageProcessingConfiguration.exposure = value;
  117853. },
  117854. enumerable: true,
  117855. configurable: true
  117856. });
  117857. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingEnabled", {
  117858. /**
  117859. * Gets wether tonemapping is enabled or not.
  117860. */
  117861. get: function () {
  117862. return this._imageProcessingConfiguration.toneMappingEnabled;
  117863. },
  117864. /**
  117865. * Sets wether tonemapping is enabled or not
  117866. */
  117867. set: function (value) {
  117868. this._imageProcessingConfiguration.toneMappingEnabled = value;
  117869. },
  117870. enumerable: true,
  117871. configurable: true
  117872. });
  117873. Object.defineProperty(ImageProcessingPostProcess.prototype, "contrast", {
  117874. /**
  117875. * Gets contrast used in the effect.
  117876. */
  117877. get: function () {
  117878. return this.imageProcessingConfiguration.contrast;
  117879. },
  117880. /**
  117881. * Sets contrast used in the effect.
  117882. */
  117883. set: function (value) {
  117884. this.imageProcessingConfiguration.contrast = value;
  117885. },
  117886. enumerable: true,
  117887. configurable: true
  117888. });
  117889. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteStretch", {
  117890. /**
  117891. * Gets Vignette stretch size.
  117892. */
  117893. get: function () {
  117894. return this.imageProcessingConfiguration.vignetteStretch;
  117895. },
  117896. /**
  117897. * Sets Vignette stretch size.
  117898. */
  117899. set: function (value) {
  117900. this.imageProcessingConfiguration.vignetteStretch = value;
  117901. },
  117902. enumerable: true,
  117903. configurable: true
  117904. });
  117905. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreX", {
  117906. /**
  117907. * Gets Vignette centre X Offset.
  117908. */
  117909. get: function () {
  117910. return this.imageProcessingConfiguration.vignetteCentreX;
  117911. },
  117912. /**
  117913. * Sets Vignette centre X Offset.
  117914. */
  117915. set: function (value) {
  117916. this.imageProcessingConfiguration.vignetteCentreX = value;
  117917. },
  117918. enumerable: true,
  117919. configurable: true
  117920. });
  117921. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreY", {
  117922. /**
  117923. * Gets Vignette centre Y Offset.
  117924. */
  117925. get: function () {
  117926. return this.imageProcessingConfiguration.vignetteCentreY;
  117927. },
  117928. /**
  117929. * Sets Vignette centre Y Offset.
  117930. */
  117931. set: function (value) {
  117932. this.imageProcessingConfiguration.vignetteCentreY = value;
  117933. },
  117934. enumerable: true,
  117935. configurable: true
  117936. });
  117937. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteWeight", {
  117938. /**
  117939. * Gets Vignette weight or intensity of the vignette effect.
  117940. */
  117941. get: function () {
  117942. return this.imageProcessingConfiguration.vignetteWeight;
  117943. },
  117944. /**
  117945. * Sets Vignette weight or intensity of the vignette effect.
  117946. */
  117947. set: function (value) {
  117948. this.imageProcessingConfiguration.vignetteWeight = value;
  117949. },
  117950. enumerable: true,
  117951. configurable: true
  117952. });
  117953. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteColor", {
  117954. /**
  117955. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  117956. * if vignetteEnabled is set to true.
  117957. */
  117958. get: function () {
  117959. return this.imageProcessingConfiguration.vignetteColor;
  117960. },
  117961. /**
  117962. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  117963. * if vignetteEnabled is set to true.
  117964. */
  117965. set: function (value) {
  117966. this.imageProcessingConfiguration.vignetteColor = value;
  117967. },
  117968. enumerable: true,
  117969. configurable: true
  117970. });
  117971. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCameraFov", {
  117972. /**
  117973. * Gets Camera field of view used by the Vignette effect.
  117974. */
  117975. get: function () {
  117976. return this.imageProcessingConfiguration.vignetteCameraFov;
  117977. },
  117978. /**
  117979. * Sets Camera field of view used by the Vignette effect.
  117980. */
  117981. set: function (value) {
  117982. this.imageProcessingConfiguration.vignetteCameraFov = value;
  117983. },
  117984. enumerable: true,
  117985. configurable: true
  117986. });
  117987. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteBlendMode", {
  117988. /**
  117989. * Gets the vignette blend mode allowing different kind of effect.
  117990. */
  117991. get: function () {
  117992. return this.imageProcessingConfiguration.vignetteBlendMode;
  117993. },
  117994. /**
  117995. * Sets the vignette blend mode allowing different kind of effect.
  117996. */
  117997. set: function (value) {
  117998. this.imageProcessingConfiguration.vignetteBlendMode = value;
  117999. },
  118000. enumerable: true,
  118001. configurable: true
  118002. });
  118003. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteEnabled", {
  118004. /**
  118005. * Gets wether the vignette effect is enabled.
  118006. */
  118007. get: function () {
  118008. return this.imageProcessingConfiguration.vignetteEnabled;
  118009. },
  118010. /**
  118011. * Sets wether the vignette effect is enabled.
  118012. */
  118013. set: function (value) {
  118014. this.imageProcessingConfiguration.vignetteEnabled = value;
  118015. },
  118016. enumerable: true,
  118017. configurable: true
  118018. });
  118019. Object.defineProperty(ImageProcessingPostProcess.prototype, "fromLinearSpace", {
  118020. /**
  118021. * Gets wether the input of the processing is in Gamma or Linear Space.
  118022. */
  118023. get: function () {
  118024. return this._fromLinearSpace;
  118025. },
  118026. /**
  118027. * Sets wether the input of the processing is in Gamma or Linear Space.
  118028. */
  118029. set: function (value) {
  118030. if (this._fromLinearSpace === value) {
  118031. return;
  118032. }
  118033. this._fromLinearSpace = value;
  118034. this._updateParameters();
  118035. },
  118036. enumerable: true,
  118037. configurable: true
  118038. });
  118039. /**
  118040. * "ImageProcessingPostProcess"
  118041. * @returns "ImageProcessingPostProcess"
  118042. */
  118043. ImageProcessingPostProcess.prototype.getClassName = function () {
  118044. return "ImageProcessingPostProcess";
  118045. };
  118046. ImageProcessingPostProcess.prototype._updateParameters = function () {
  118047. this._defines.FROMLINEARSPACE = this._fromLinearSpace;
  118048. this.imageProcessingConfiguration.prepareDefines(this._defines, true);
  118049. var defines = "";
  118050. for (var define in this._defines) {
  118051. if (this._defines[define]) {
  118052. defines += "#define " + define + ";\r\n";
  118053. }
  118054. }
  118055. var samplers = ["textureSampler"];
  118056. var uniforms = ["scale"];
  118057. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"]) {
  118058. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._defines);
  118059. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._defines);
  118060. }
  118061. this.updateEffect(defines, uniforms, samplers);
  118062. };
  118063. ImageProcessingPostProcess.prototype.dispose = function (camera) {
  118064. _super.prototype.dispose.call(this, camera);
  118065. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  118066. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  118067. }
  118068. if (this._imageProcessingConfiguration) {
  118069. this.imageProcessingConfiguration.applyByPostProcess = false;
  118070. }
  118071. };
  118072. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118073. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118074. ], ImageProcessingPostProcess.prototype, "_fromLinearSpace", void 0);
  118075. return ImageProcessingPostProcess;
  118076. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  118077. /***/ }),
  118078. /***/ "./PostProcesses/index.ts":
  118079. /*!********************************!*\
  118080. !*** ./PostProcesses/index.ts ***!
  118081. \********************************/
  118082. /*! 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 */
  118083. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118084. "use strict";
  118085. __webpack_require__.r(__webpack_exports__);
  118086. /* harmony import */ var _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  118087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  118088. /* harmony import */ var _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./blackAndWhitePostProcess */ "./PostProcesses/blackAndWhitePostProcess.ts");
  118089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__["BlackAndWhitePostProcess"]; });
  118090. /* harmony import */ var _bloomEffect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bloomEffect */ "./PostProcesses/bloomEffect.ts");
  118091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _bloomEffect__WEBPACK_IMPORTED_MODULE_2__["BloomEffect"]; });
  118092. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  118093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__["BloomMergePostProcess"]; });
  118094. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  118095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__["BlurPostProcess"]; });
  118096. /* harmony import */ var _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  118097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__["ChromaticAberrationPostProcess"]; });
  118098. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  118099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__["CircleOfConfusionPostProcess"]; });
  118100. /* harmony import */ var _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./colorCorrectionPostProcess */ "./PostProcesses/colorCorrectionPostProcess.ts");
  118101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__["ColorCorrectionPostProcess"]; });
  118102. /* harmony import */ var _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./convolutionPostProcess */ "./PostProcesses/convolutionPostProcess.ts");
  118103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__["ConvolutionPostProcess"]; });
  118104. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  118105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__["DepthOfFieldBlurPostProcess"]; });
  118106. /* harmony import */ var _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  118107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffectBlurLevel"]; });
  118108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffect"]; });
  118109. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  118110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcessOptions"]; });
  118111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcess"]; });
  118112. /* harmony import */ var _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./displayPassPostProcess */ "./PostProcesses/displayPassPostProcess.ts");
  118113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__["DisplayPassPostProcess"]; });
  118114. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  118115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__["ExtractHighlightsPostProcess"]; });
  118116. /* harmony import */ var _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./filterPostProcess */ "./PostProcesses/filterPostProcess.ts");
  118117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__["FilterPostProcess"]; });
  118118. /* harmony import */ var _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  118119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__["FxaaPostProcess"]; });
  118120. /* harmony import */ var _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  118121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__["GrainPostProcess"]; });
  118122. /* harmony import */ var _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./highlightsPostProcess */ "./PostProcesses/highlightsPostProcess.ts");
  118123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__["HighlightsPostProcess"]; });
  118124. /* harmony import */ var _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  118125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__["ImageProcessingPostProcess"]; });
  118126. /* harmony import */ var _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./motionBlurPostProcess */ "./PostProcesses/motionBlurPostProcess.ts");
  118127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__["MotionBlurPostProcess"]; });
  118128. /* harmony import */ var _passPostProcess__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./passPostProcess */ "./PostProcesses/passPostProcess.ts");
  118129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassPostProcess"]; });
  118130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassCubePostProcess"]; });
  118131. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _postProcess__WEBPACK_IMPORTED_MODULE_21__["PostProcess"]; });
  118133. /* harmony import */ var _postProcessManager__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./postProcessManager */ "./PostProcesses/postProcessManager.ts");
  118134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _postProcessManager__WEBPACK_IMPORTED_MODULE_22__["PostProcessManager"]; });
  118135. /* harmony import */ var _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./refractionPostProcess */ "./PostProcesses/refractionPostProcess.ts");
  118136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__["RefractionPostProcess"]; });
  118137. /* harmony import */ var _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./RenderPipeline/index */ "./PostProcesses/RenderPipeline/index.ts");
  118138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderEffect"]; });
  118139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipeline"]; });
  118140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManager"]; });
  118141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManagerSceneComponent"]; });
  118142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["DefaultRenderingPipeline"]; });
  118143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["LensRenderingPipeline"]; });
  118144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAO2RenderingPipeline"]; });
  118145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAORenderingPipeline"]; });
  118146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["StandardRenderingPipeline"]; });
  118147. /* harmony import */ var _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  118148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__["SharpenPostProcess"]; });
  118149. /* harmony import */ var _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  118150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__["StereoscopicInterlacePostProcess"]; });
  118151. /* harmony import */ var _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./tonemapPostProcess */ "./PostProcesses/tonemapPostProcess.ts");
  118152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemappingOperator"]; });
  118153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemapPostProcess"]; });
  118154. /* harmony import */ var _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./volumetricLightScatteringPostProcess */ "./PostProcesses/volumetricLightScatteringPostProcess.ts");
  118155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__["VolumetricLightScatteringPostProcess"]; });
  118156. /* harmony import */ var _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  118157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  118158. /***/ }),
  118159. /***/ "./PostProcesses/motionBlurPostProcess.ts":
  118160. /*!************************************************!*\
  118161. !*** ./PostProcesses/motionBlurPostProcess.ts ***!
  118162. \************************************************/
  118163. /*! exports provided: MotionBlurPostProcess */
  118164. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118165. "use strict";
  118166. __webpack_require__.r(__webpack_exports__);
  118167. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return MotionBlurPostProcess; });
  118168. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118169. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  118170. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118171. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118172. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118173. /* harmony import */ var _Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Rendering/geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  118174. /* harmony import */ var _Shaders_motionBlur_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/motionBlur.fragment */ "./Shaders/motionBlur.fragment.ts");
  118175. /**
  118176. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  118177. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  118178. * As an example, all you have to do is to create the post-process:
  118179. * var mb = new BABYLON.MotionBlurPostProcess(
  118180. * 'mb', // The name of the effect.
  118181. * scene, // The scene containing the objects to blur according to their velocity.
  118182. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  118183. * camera // The camera to apply the render pass to.
  118184. * );
  118185. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  118186. */
  118187. var MotionBlurPostProcess = /** @class */ (function (_super) {
  118188. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotionBlurPostProcess, _super);
  118189. /**
  118190. * Creates a new instance MotionBlurPostProcess
  118191. * @param name The name of the effect.
  118192. * @param scene The scene containing the objects to blur according to their velocity.
  118193. * @param options The required width/height ratio to downsize to before computing the render pass.
  118194. * @param camera The camera to apply the render pass to.
  118195. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118196. * @param engine The engine which the post process will be applied. (default: current engine)
  118197. * @param reusable If the post process can be reused on the same frame. (default: false)
  118198. * @param textureType Type of textures used when performing the post process. (default: 0)
  118199. * @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)
  118200. */
  118201. function MotionBlurPostProcess(name, scene, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  118202. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118203. if (blockCompilation === void 0) { blockCompilation = false; }
  118204. 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;
  118205. /**
  118206. * Defines how much the image is blurred by the movement. Default value is equal to 1
  118207. */
  118208. _this.motionStrength = 1;
  118209. _this._motionBlurSamples = 32;
  118210. _this._geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  118211. if (!_this._geometryBufferRenderer) {
  118212. // Geometry buffer renderer is not supported. So, work as a passthrough.
  118213. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Multiple Render Target support needed to compute object based motion blur");
  118214. _this.updateEffect();
  118215. }
  118216. else {
  118217. // Geometry buffer renderer is supported.
  118218. _this._geometryBufferRenderer.enableVelocity = true;
  118219. _this.onApply = function (effect) {
  118220. effect.setVector2("screenSize", new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](_this.width, _this.height));
  118221. effect.setFloat("motionScale", scene.getAnimationRatio());
  118222. effect.setFloat("motionStrength", _this.motionStrength);
  118223. if (_this._geometryBufferRenderer) {
  118224. var velocityIndex = _this._geometryBufferRenderer.getTextureIndex(_Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRenderer"].VELOCITY_TEXTURE_TYPE);
  118225. effect.setTexture("velocitySampler", _this._geometryBufferRenderer.getGBuffer().textures[velocityIndex]);
  118226. }
  118227. };
  118228. }
  118229. return _this;
  118230. }
  118231. Object.defineProperty(MotionBlurPostProcess.prototype, "motionBlurSamples", {
  118232. /**
  118233. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  118234. */
  118235. get: function () {
  118236. return this._motionBlurSamples;
  118237. },
  118238. /**
  118239. * Sets the number of iterations to be used for motion blur quality
  118240. */
  118241. set: function (samples) {
  118242. this._motionBlurSamples = samples;
  118243. if (this._geometryBufferRenderer) {
  118244. this.updateEffect("#define GEOMETRY_SUPPORTED\n#define SAMPLES " + samples.toFixed(1));
  118245. }
  118246. },
  118247. enumerable: true,
  118248. configurable: true
  118249. });
  118250. /**
  118251. * Disposes the post process.
  118252. * @param camera The camera to dispose the post process on.
  118253. */
  118254. MotionBlurPostProcess.prototype.dispose = function (camera) {
  118255. if (this._geometryBufferRenderer) {
  118256. // Clear previous transformation matrices dictionary used to compute objects velocities
  118257. this._geometryBufferRenderer._previousTransformationMatrices = {};
  118258. }
  118259. _super.prototype.dispose.call(this, camera);
  118260. };
  118261. return MotionBlurPostProcess;
  118262. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  118263. /***/ }),
  118264. /***/ "./PostProcesses/passPostProcess.ts":
  118265. /*!******************************************!*\
  118266. !*** ./PostProcesses/passPostProcess.ts ***!
  118267. \******************************************/
  118268. /*! exports provided: PassPostProcess, PassCubePostProcess */
  118269. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118270. "use strict";
  118271. __webpack_require__.r(__webpack_exports__);
  118272. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return PassPostProcess; });
  118273. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return PassCubePostProcess; });
  118274. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118275. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118276. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118277. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  118278. /* harmony import */ var _Shaders_pass_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/pass.fragment */ "./Shaders/pass.fragment.ts");
  118279. /* harmony import */ var _Shaders_passCube_fragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/passCube.fragment */ "./Shaders/passCube.fragment.ts");
  118280. /**
  118281. * PassPostProcess which produces an output the same as it's input
  118282. */
  118283. var PassPostProcess = /** @class */ (function (_super) {
  118284. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassPostProcess, _super);
  118285. /**
  118286. * Creates the PassPostProcess
  118287. * @param name The name of the effect.
  118288. * @param options The required width/height ratio to downsize to before computing the render pass.
  118289. * @param camera The camera to apply the render pass to.
  118290. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118291. * @param engine The engine which the post process will be applied. (default: current engine)
  118292. * @param reusable If the post process can be reused on the same frame. (default: false)
  118293. * @param textureType The type of texture to be used when performing the post processing.
  118294. * @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)
  118295. */
  118296. function PassPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  118297. if (camera === void 0) { camera = null; }
  118298. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118299. if (blockCompilation === void 0) { blockCompilation = false; }
  118300. return _super.call(this, name, "pass", null, null, options, camera, samplingMode, engine, reusable, undefined, textureType, undefined, null, blockCompilation) || this;
  118301. }
  118302. return PassPostProcess;
  118303. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  118304. /**
  118305. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  118306. */
  118307. var PassCubePostProcess = /** @class */ (function (_super) {
  118308. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassCubePostProcess, _super);
  118309. /**
  118310. * Creates the PassCubePostProcess
  118311. * @param name The name of the effect.
  118312. * @param options The required width/height ratio to downsize to before computing the render pass.
  118313. * @param camera The camera to apply the render pass to.
  118314. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118315. * @param engine The engine which the post process will be applied. (default: current engine)
  118316. * @param reusable If the post process can be reused on the same frame. (default: false)
  118317. * @param textureType The type of texture to be used when performing the post processing.
  118318. * @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)
  118319. */
  118320. function PassCubePostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  118321. if (camera === void 0) { camera = null; }
  118322. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118323. if (blockCompilation === void 0) { blockCompilation = false; }
  118324. var _this = _super.call(this, name, "passCube", null, null, options, camera, samplingMode, engine, reusable, "#define POSITIVEX", textureType, undefined, null, blockCompilation) || this;
  118325. _this._face = 0;
  118326. return _this;
  118327. }
  118328. Object.defineProperty(PassCubePostProcess.prototype, "face", {
  118329. /**
  118330. * Gets or sets the cube face to display.
  118331. * * 0 is +X
  118332. * * 1 is -X
  118333. * * 2 is +Y
  118334. * * 3 is -Y
  118335. * * 4 is +Z
  118336. * * 5 is -Z
  118337. */
  118338. get: function () {
  118339. return this._face;
  118340. },
  118341. set: function (value) {
  118342. if (value < 0 || value > 5) {
  118343. return;
  118344. }
  118345. this._face = value;
  118346. switch (this._face) {
  118347. case 0:
  118348. this.updateEffect("#define POSITIVEX");
  118349. break;
  118350. case 1:
  118351. this.updateEffect("#define NEGATIVEX");
  118352. break;
  118353. case 2:
  118354. this.updateEffect("#define POSITIVEY");
  118355. break;
  118356. case 3:
  118357. this.updateEffect("#define NEGATIVEY");
  118358. break;
  118359. case 4:
  118360. this.updateEffect("#define POSITIVEZ");
  118361. break;
  118362. case 5:
  118363. this.updateEffect("#define NEGATIVEZ");
  118364. break;
  118365. }
  118366. },
  118367. enumerable: true,
  118368. configurable: true
  118369. });
  118370. return PassCubePostProcess;
  118371. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  118372. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"]._RescalePostProcessFactory = function (engine) {
  118373. 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);
  118374. };
  118375. /***/ }),
  118376. /***/ "./PostProcesses/postProcess.ts":
  118377. /*!**************************************!*\
  118378. !*** ./PostProcesses/postProcess.ts ***!
  118379. \**************************************/
  118380. /*! exports provided: PostProcess */
  118381. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118382. "use strict";
  118383. __webpack_require__.r(__webpack_exports__);
  118384. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return PostProcess; });
  118385. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  118386. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  118387. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  118388. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118389. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118390. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  118391. /**
  118392. * PostProcess can be used to apply a shader to a texture after it has been rendered
  118393. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118394. */
  118395. var PostProcess = /** @class */ (function () {
  118396. /**
  118397. * Creates a new instance PostProcess
  118398. * @param name The name of the PostProcess.
  118399. * @param fragmentUrl The url of the fragment shader to be used.
  118400. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  118401. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  118402. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  118403. * @param camera The camera to apply the render pass to.
  118404. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118405. * @param engine The engine which the post process will be applied. (default: current engine)
  118406. * @param reusable If the post process can be reused on the same frame. (default: false)
  118407. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  118408. * @param textureType Type of textures used when performing the post process. (default: 0)
  118409. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  118410. * @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
  118411. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  118412. */
  118413. function PostProcess(
  118414. /** Name of the PostProcess. */
  118415. name, fragmentUrl, parameters, samplers, options, camera, samplingMode, engine, reusable, defines, textureType, vertexUrl, indexParameters, blockCompilation) {
  118416. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE; }
  118417. if (defines === void 0) { defines = null; }
  118418. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118419. if (vertexUrl === void 0) { vertexUrl = "postprocess"; }
  118420. if (blockCompilation === void 0) { blockCompilation = false; }
  118421. this.name = name;
  118422. /**
  118423. * Width of the texture to apply the post process on
  118424. */
  118425. this.width = -1;
  118426. /**
  118427. * Height of the texture to apply the post process on
  118428. */
  118429. this.height = -1;
  118430. /**
  118431. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  118432. * @hidden
  118433. */
  118434. this._outputTexture = null;
  118435. /**
  118436. * If the buffer needs to be cleared before applying the post process. (default: true)
  118437. * Should be set to false if shader will overwrite all previous pixels.
  118438. */
  118439. this.autoClear = true;
  118440. /**
  118441. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  118442. */
  118443. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE;
  118444. /**
  118445. * Animations to be used for the post processing
  118446. */
  118447. this.animations = new Array();
  118448. /**
  118449. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  118450. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  118451. */
  118452. this.enablePixelPerfectMode = false;
  118453. /**
  118454. * Force the postprocess to be applied without taking in account viewport
  118455. */
  118456. this.forceFullscreenViewport = true;
  118457. /**
  118458. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  118459. *
  118460. * | Value | Type | Description |
  118461. * | ----- | ----------------------------------- | ----------- |
  118462. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  118463. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  118464. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  118465. *
  118466. */
  118467. this.scaleMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].SCALEMODE_FLOOR;
  118468. /**
  118469. * Force textures to be a power of two (default: false)
  118470. */
  118471. this.alwaysForcePOT = false;
  118472. this._samples = 1;
  118473. /**
  118474. * Modify the scale of the post process to be the same as the viewport (default: false)
  118475. */
  118476. this.adaptScaleToCurrentViewport = false;
  118477. this._reusable = false;
  118478. /**
  118479. * Smart array of input and output textures for the post process.
  118480. * @hidden
  118481. */
  118482. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  118483. /**
  118484. * The index in _textures that corresponds to the output texture.
  118485. * @hidden
  118486. */
  118487. this._currentRenderTextureInd = 0;
  118488. this._scaleRatio = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 1);
  118489. this._texelSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  118490. // Events
  118491. /**
  118492. * An event triggered when the postprocess is activated.
  118493. */
  118494. this.onActivateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  118495. /**
  118496. * An event triggered when the postprocess changes its size.
  118497. */
  118498. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  118499. /**
  118500. * An event triggered when the postprocess applies its effect.
  118501. */
  118502. this.onApplyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  118503. /**
  118504. * An event triggered before rendering the postprocess
  118505. */
  118506. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  118507. /**
  118508. * An event triggered after rendering the postprocess
  118509. */
  118510. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  118511. if (camera != null) {
  118512. this._camera = camera;
  118513. this._scene = camera.getScene();
  118514. camera.attachPostProcess(this);
  118515. this._engine = this._scene.getEngine();
  118516. this._scene.postProcesses.push(this);
  118517. this.uniqueId = this._scene.getUniqueId();
  118518. }
  118519. else if (engine) {
  118520. this._engine = engine;
  118521. this._engine.postProcesses.push(this);
  118522. }
  118523. this._options = options;
  118524. this.renderTargetSamplingMode = samplingMode ? samplingMode : _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  118525. this._reusable = reusable || false;
  118526. this._textureType = textureType;
  118527. this._samplers = samplers || [];
  118528. this._samplers.push("textureSampler");
  118529. this._fragmentUrl = fragmentUrl;
  118530. this._vertexUrl = vertexUrl;
  118531. this._parameters = parameters || [];
  118532. this._parameters.push("scale");
  118533. this._indexParameters = indexParameters;
  118534. if (!blockCompilation) {
  118535. this.updateEffect(defines);
  118536. }
  118537. }
  118538. Object.defineProperty(PostProcess.prototype, "samples", {
  118539. /**
  118540. * Number of sample textures (default: 1)
  118541. */
  118542. get: function () {
  118543. return this._samples;
  118544. },
  118545. set: function (n) {
  118546. var _this = this;
  118547. this._samples = n;
  118548. this._textures.forEach(function (texture) {
  118549. if (texture.samples !== _this._samples) {
  118550. _this._engine.updateRenderTargetTextureSampleCount(texture, _this._samples);
  118551. }
  118552. });
  118553. },
  118554. enumerable: true,
  118555. configurable: true
  118556. });
  118557. /**
  118558. * Returns the fragment url or shader name used in the post process.
  118559. * @returns the fragment url or name in the shader store.
  118560. */
  118561. PostProcess.prototype.getEffectName = function () {
  118562. return this._fragmentUrl;
  118563. };
  118564. Object.defineProperty(PostProcess.prototype, "onActivate", {
  118565. /**
  118566. * A function that is added to the onActivateObservable
  118567. */
  118568. set: function (callback) {
  118569. if (this._onActivateObserver) {
  118570. this.onActivateObservable.remove(this._onActivateObserver);
  118571. }
  118572. if (callback) {
  118573. this._onActivateObserver = this.onActivateObservable.add(callback);
  118574. }
  118575. },
  118576. enumerable: true,
  118577. configurable: true
  118578. });
  118579. Object.defineProperty(PostProcess.prototype, "onSizeChanged", {
  118580. /**
  118581. * A function that is added to the onSizeChangedObservable
  118582. */
  118583. set: function (callback) {
  118584. if (this._onSizeChangedObserver) {
  118585. this.onSizeChangedObservable.remove(this._onSizeChangedObserver);
  118586. }
  118587. this._onSizeChangedObserver = this.onSizeChangedObservable.add(callback);
  118588. },
  118589. enumerable: true,
  118590. configurable: true
  118591. });
  118592. Object.defineProperty(PostProcess.prototype, "onApply", {
  118593. /**
  118594. * A function that is added to the onApplyObservable
  118595. */
  118596. set: function (callback) {
  118597. if (this._onApplyObserver) {
  118598. this.onApplyObservable.remove(this._onApplyObserver);
  118599. }
  118600. this._onApplyObserver = this.onApplyObservable.add(callback);
  118601. },
  118602. enumerable: true,
  118603. configurable: true
  118604. });
  118605. Object.defineProperty(PostProcess.prototype, "onBeforeRender", {
  118606. /**
  118607. * A function that is added to the onBeforeRenderObservable
  118608. */
  118609. set: function (callback) {
  118610. if (this._onBeforeRenderObserver) {
  118611. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  118612. }
  118613. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  118614. },
  118615. enumerable: true,
  118616. configurable: true
  118617. });
  118618. Object.defineProperty(PostProcess.prototype, "onAfterRender", {
  118619. /**
  118620. * A function that is added to the onAfterRenderObservable
  118621. */
  118622. set: function (callback) {
  118623. if (this._onAfterRenderObserver) {
  118624. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  118625. }
  118626. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  118627. },
  118628. enumerable: true,
  118629. configurable: true
  118630. });
  118631. Object.defineProperty(PostProcess.prototype, "inputTexture", {
  118632. /**
  118633. * 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
  118634. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  118635. */
  118636. get: function () {
  118637. return this._textures.data[this._currentRenderTextureInd];
  118638. },
  118639. set: function (value) {
  118640. this._forcedOutputTexture = value;
  118641. },
  118642. enumerable: true,
  118643. configurable: true
  118644. });
  118645. /**
  118646. * Gets the camera which post process is applied to.
  118647. * @returns The camera the post process is applied to.
  118648. */
  118649. PostProcess.prototype.getCamera = function () {
  118650. return this._camera;
  118651. };
  118652. Object.defineProperty(PostProcess.prototype, "texelSize", {
  118653. /**
  118654. * Gets the texel size of the postprocess.
  118655. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  118656. */
  118657. get: function () {
  118658. if (this._shareOutputWithPostProcess) {
  118659. return this._shareOutputWithPostProcess.texelSize;
  118660. }
  118661. if (this._forcedOutputTexture) {
  118662. this._texelSize.copyFromFloats(1.0 / this._forcedOutputTexture.width, 1.0 / this._forcedOutputTexture.height);
  118663. }
  118664. return this._texelSize;
  118665. },
  118666. enumerable: true,
  118667. configurable: true
  118668. });
  118669. /**
  118670. * Gets a string idenfifying the name of the class
  118671. * @returns "PostProcess" string
  118672. */
  118673. PostProcess.prototype.getClassName = function () {
  118674. return "PostProcess";
  118675. };
  118676. /**
  118677. * Gets the engine which this post process belongs to.
  118678. * @returns The engine the post process was enabled with.
  118679. */
  118680. PostProcess.prototype.getEngine = function () {
  118681. return this._engine;
  118682. };
  118683. /**
  118684. * The effect that is created when initializing the post process.
  118685. * @returns The created effect corrisponding the the postprocess.
  118686. */
  118687. PostProcess.prototype.getEffect = function () {
  118688. return this._effect;
  118689. };
  118690. /**
  118691. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  118692. * @param postProcess The post process to share the output with.
  118693. * @returns This post process.
  118694. */
  118695. PostProcess.prototype.shareOutputWith = function (postProcess) {
  118696. this._disposeTextures();
  118697. this._shareOutputWithPostProcess = postProcess;
  118698. return this;
  118699. };
  118700. /**
  118701. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  118702. * This should be called if the post process that shares output with this post process is disabled/disposed.
  118703. */
  118704. PostProcess.prototype.useOwnOutput = function () {
  118705. if (this._textures.length == 0) {
  118706. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  118707. }
  118708. this._shareOutputWithPostProcess = null;
  118709. };
  118710. /**
  118711. * Updates the effect with the current post process compile time values and recompiles the shader.
  118712. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  118713. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  118714. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  118715. * @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
  118716. * @param onCompiled Called when the shader has been compiled.
  118717. * @param onError Called if there is an error when compiling a shader.
  118718. */
  118719. PostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  118720. if (defines === void 0) { defines = null; }
  118721. if (uniforms === void 0) { uniforms = null; }
  118722. if (samplers === void 0) { samplers = null; }
  118723. 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);
  118724. };
  118725. /**
  118726. * The post process is reusable if it can be used multiple times within one frame.
  118727. * @returns If the post process is reusable
  118728. */
  118729. PostProcess.prototype.isReusable = function () {
  118730. return this._reusable;
  118731. };
  118732. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  118733. PostProcess.prototype.markTextureDirty = function () {
  118734. this.width = -1;
  118735. };
  118736. /**
  118737. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  118738. * 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.
  118739. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  118740. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  118741. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  118742. * @returns The target texture that was bound to be written to.
  118743. */
  118744. PostProcess.prototype.activate = function (camera, sourceTexture, forceDepthStencil) {
  118745. var _this = this;
  118746. if (sourceTexture === void 0) { sourceTexture = null; }
  118747. camera = camera || this._camera;
  118748. var scene = camera.getScene();
  118749. var engine = scene.getEngine();
  118750. var maxSize = engine.getCaps().maxTextureSize;
  118751. var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderWidth(true)) * this._options) | 0;
  118752. var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderHeight(true)) * this._options) | 0;
  118753. // 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
  118754. var webVRCamera = camera.parent;
  118755. if (webVRCamera && (webVRCamera.leftCamera == camera || webVRCamera.rightCamera == camera)) {
  118756. requiredWidth /= 2;
  118757. }
  118758. var desiredWidth = (this._options.width || requiredWidth);
  118759. var desiredHeight = this._options.height || requiredHeight;
  118760. if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
  118761. if (this.adaptScaleToCurrentViewport) {
  118762. var currentViewport = engine.currentViewport;
  118763. if (currentViewport) {
  118764. desiredWidth *= currentViewport.width;
  118765. desiredHeight *= currentViewport.height;
  118766. }
  118767. }
  118768. if (this.renderTargetSamplingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE || this.alwaysForcePOT) {
  118769. if (!this._options.width) {
  118770. desiredWidth = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredWidth, maxSize, this.scaleMode) : desiredWidth;
  118771. }
  118772. if (!this._options.height) {
  118773. desiredHeight = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredHeight, maxSize, this.scaleMode) : desiredHeight;
  118774. }
  118775. }
  118776. if (this.width !== desiredWidth || this.height !== desiredHeight) {
  118777. if (this._textures.length > 0) {
  118778. for (var i = 0; i < this._textures.length; i++) {
  118779. this._engine._releaseTexture(this._textures.data[i]);
  118780. }
  118781. this._textures.reset();
  118782. }
  118783. this.width = desiredWidth;
  118784. this.height = desiredHeight;
  118785. var textureSize = { width: this.width, height: this.height };
  118786. var textureOptions = {
  118787. generateMipMaps: false,
  118788. generateDepthBuffer: forceDepthStencil || camera._postProcesses.indexOf(this) === 0,
  118789. generateStencilBuffer: (forceDepthStencil || camera._postProcesses.indexOf(this) === 0) && this._engine.isStencilEnable,
  118790. samplingMode: this.renderTargetSamplingMode,
  118791. type: this._textureType
  118792. };
  118793. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  118794. if (this._reusable) {
  118795. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  118796. }
  118797. this._texelSize.copyFromFloats(1.0 / this.width, 1.0 / this.height);
  118798. this.onSizeChangedObservable.notifyObservers(this);
  118799. }
  118800. this._textures.forEach(function (texture) {
  118801. if (texture.samples !== _this.samples) {
  118802. _this._engine.updateRenderTargetTextureSampleCount(texture, _this.samples);
  118803. }
  118804. });
  118805. }
  118806. var target;
  118807. if (this._shareOutputWithPostProcess) {
  118808. target = this._shareOutputWithPostProcess.inputTexture;
  118809. }
  118810. else if (this._forcedOutputTexture) {
  118811. target = this._forcedOutputTexture;
  118812. this.width = this._forcedOutputTexture.width;
  118813. this.height = this._forcedOutputTexture.height;
  118814. }
  118815. else {
  118816. target = this.inputTexture;
  118817. }
  118818. // Bind the input of this post process to be used as the output of the previous post process.
  118819. if (this.enablePixelPerfectMode) {
  118820. this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
  118821. this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight, this.forceFullscreenViewport);
  118822. }
  118823. else {
  118824. this._scaleRatio.copyFromFloats(1, 1);
  118825. this._engine.bindFramebuffer(target, 0, undefined, undefined, this.forceFullscreenViewport);
  118826. }
  118827. this.onActivateObservable.notifyObservers(camera);
  118828. // Clear
  118829. if (this.autoClear && this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE) {
  118830. this._engine.clear(this.clearColor ? this.clearColor : scene.clearColor, scene._allowPostProcessClearColor, true, true);
  118831. }
  118832. if (this._reusable) {
  118833. this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
  118834. }
  118835. return target;
  118836. };
  118837. Object.defineProperty(PostProcess.prototype, "isSupported", {
  118838. /**
  118839. * If the post process is supported.
  118840. */
  118841. get: function () {
  118842. return this._effect.isSupported;
  118843. },
  118844. enumerable: true,
  118845. configurable: true
  118846. });
  118847. Object.defineProperty(PostProcess.prototype, "aspectRatio", {
  118848. /**
  118849. * The aspect ratio of the output texture.
  118850. */
  118851. get: function () {
  118852. if (this._shareOutputWithPostProcess) {
  118853. return this._shareOutputWithPostProcess.aspectRatio;
  118854. }
  118855. if (this._forcedOutputTexture) {
  118856. return this._forcedOutputTexture.width / this._forcedOutputTexture.height;
  118857. }
  118858. return this.width / this.height;
  118859. },
  118860. enumerable: true,
  118861. configurable: true
  118862. });
  118863. /**
  118864. * Get a value indicating if the post-process is ready to be used
  118865. * @returns true if the post-process is ready (shader is compiled)
  118866. */
  118867. PostProcess.prototype.isReady = function () {
  118868. return this._effect && this._effect.isReady();
  118869. };
  118870. /**
  118871. * Binds all textures and uniforms to the shader, this will be run on every pass.
  118872. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  118873. */
  118874. PostProcess.prototype.apply = function () {
  118875. // Check
  118876. if (!this._effect || !this._effect.isReady()) {
  118877. return null;
  118878. }
  118879. // States
  118880. this._engine.enableEffect(this._effect);
  118881. this._engine.setState(false);
  118882. this._engine.setDepthBuffer(false);
  118883. this._engine.setDepthWrite(false);
  118884. // Alpha
  118885. this._engine.setAlphaMode(this.alphaMode);
  118886. if (this.alphaConstants) {
  118887. this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
  118888. }
  118889. // Bind the output texture of the preivous post process as the input to this post process.
  118890. var source;
  118891. if (this._shareOutputWithPostProcess) {
  118892. source = this._shareOutputWithPostProcess.inputTexture;
  118893. }
  118894. else if (this._forcedOutputTexture) {
  118895. source = this._forcedOutputTexture;
  118896. }
  118897. else {
  118898. source = this.inputTexture;
  118899. }
  118900. this._effect._bindTexture("textureSampler", source);
  118901. // Parameters
  118902. this._effect.setVector2("scale", this._scaleRatio);
  118903. this.onApplyObservable.notifyObservers(this._effect);
  118904. return this._effect;
  118905. };
  118906. PostProcess.prototype._disposeTextures = function () {
  118907. if (this._shareOutputWithPostProcess || this._forcedOutputTexture) {
  118908. return;
  118909. }
  118910. if (this._textures.length > 0) {
  118911. for (var i = 0; i < this._textures.length; i++) {
  118912. this._engine._releaseTexture(this._textures.data[i]);
  118913. }
  118914. }
  118915. this._textures.dispose();
  118916. };
  118917. /**
  118918. * Disposes the post process.
  118919. * @param camera The camera to dispose the post process on.
  118920. */
  118921. PostProcess.prototype.dispose = function (camera) {
  118922. camera = camera || this._camera;
  118923. this._disposeTextures();
  118924. if (this._scene) {
  118925. var index_1 = this._scene.postProcesses.indexOf(this);
  118926. if (index_1 !== -1) {
  118927. this._scene.postProcesses.splice(index_1, 1);
  118928. }
  118929. }
  118930. else {
  118931. var index_2 = this._engine.postProcesses.indexOf(this);
  118932. if (index_2 !== -1) {
  118933. this._engine.postProcesses.splice(index_2, 1);
  118934. }
  118935. }
  118936. if (!camera) {
  118937. return;
  118938. }
  118939. camera.detachPostProcess(this);
  118940. var index = camera._postProcesses.indexOf(this);
  118941. if (index === 0 && camera._postProcesses.length > 0) {
  118942. var firstPostProcess = this._camera._getFirstPostProcess();
  118943. if (firstPostProcess) {
  118944. firstPostProcess.markTextureDirty();
  118945. }
  118946. }
  118947. this.onActivateObservable.clear();
  118948. this.onAfterRenderObservable.clear();
  118949. this.onApplyObservable.clear();
  118950. this.onBeforeRenderObservable.clear();
  118951. this.onSizeChangedObservable.clear();
  118952. };
  118953. return PostProcess;
  118954. }());
  118955. /***/ }),
  118956. /***/ "./PostProcesses/postProcessManager.ts":
  118957. /*!*********************************************!*\
  118958. !*** ./PostProcesses/postProcessManager.ts ***!
  118959. \*********************************************/
  118960. /*! exports provided: PostProcessManager */
  118961. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118962. "use strict";
  118963. __webpack_require__.r(__webpack_exports__);
  118964. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return PostProcessManager; });
  118965. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  118966. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  118967. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118968. /**
  118969. * PostProcessManager is used to manage one or more post processes or post process pipelines
  118970. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118971. */
  118972. var PostProcessManager = /** @class */ (function () {
  118973. /**
  118974. * Creates a new instance PostProcess
  118975. * @param scene The scene that the post process is associated with.
  118976. */
  118977. function PostProcessManager(scene) {
  118978. this._vertexBuffers = {};
  118979. this._scene = scene;
  118980. }
  118981. PostProcessManager.prototype._prepareBuffers = function () {
  118982. if (this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind]) {
  118983. return;
  118984. }
  118985. // VBO
  118986. var vertices = [];
  118987. vertices.push(1, 1);
  118988. vertices.push(-1, 1);
  118989. vertices.push(-1, -1);
  118990. vertices.push(1, -1);
  118991. 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);
  118992. this._buildIndexBuffer();
  118993. };
  118994. PostProcessManager.prototype._buildIndexBuffer = function () {
  118995. // Indices
  118996. var indices = [];
  118997. indices.push(0);
  118998. indices.push(1);
  118999. indices.push(2);
  119000. indices.push(0);
  119001. indices.push(2);
  119002. indices.push(3);
  119003. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  119004. };
  119005. /**
  119006. * Rebuilds the vertex buffers of the manager.
  119007. * @hidden
  119008. */
  119009. PostProcessManager.prototype._rebuild = function () {
  119010. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  119011. if (!vb) {
  119012. return;
  119013. }
  119014. vb._rebuild();
  119015. this._buildIndexBuffer();
  119016. };
  119017. // Methods
  119018. /**
  119019. * Prepares a frame to be run through a post process.
  119020. * @param sourceTexture The input texture to the post procesess. (default: null)
  119021. * @param postProcesses An array of post processes to be run. (default: null)
  119022. * @returns True if the post processes were able to be run.
  119023. * @hidden
  119024. */
  119025. PostProcessManager.prototype._prepareFrame = function (sourceTexture, postProcesses) {
  119026. if (sourceTexture === void 0) { sourceTexture = null; }
  119027. if (postProcesses === void 0) { postProcesses = null; }
  119028. var camera = this._scene.activeCamera;
  119029. if (!camera) {
  119030. return false;
  119031. }
  119032. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  119033. if (!postProcesses || postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  119034. return false;
  119035. }
  119036. postProcesses[0].activate(camera, sourceTexture, postProcesses !== null && postProcesses !== undefined);
  119037. return true;
  119038. };
  119039. /**
  119040. * Manually render a set of post processes to a texture.
  119041. * @param postProcesses An array of post processes to be run.
  119042. * @param targetTexture The target texture to render to.
  119043. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  119044. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  119045. * @param lodLevel defines which lod of the texture to render to
  119046. */
  119047. PostProcessManager.prototype.directRender = function (postProcesses, targetTexture, forceFullscreenViewport, faceIndex, lodLevel) {
  119048. if (targetTexture === void 0) { targetTexture = null; }
  119049. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  119050. if (faceIndex === void 0) { faceIndex = 0; }
  119051. if (lodLevel === void 0) { lodLevel = 0; }
  119052. var engine = this._scene.getEngine();
  119053. for (var index = 0; index < postProcesses.length; index++) {
  119054. if (index < postProcesses.length - 1) {
  119055. postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture);
  119056. }
  119057. else {
  119058. if (targetTexture) {
  119059. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport, undefined, lodLevel);
  119060. }
  119061. else {
  119062. engine.restoreDefaultFramebuffer();
  119063. }
  119064. }
  119065. var pp = postProcesses[index];
  119066. var effect = pp.apply();
  119067. if (effect) {
  119068. pp.onBeforeRenderObservable.notifyObservers(effect);
  119069. // VBOs
  119070. this._prepareBuffers();
  119071. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  119072. // Draw order
  119073. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  119074. pp.onAfterRenderObservable.notifyObservers(effect);
  119075. }
  119076. }
  119077. // Restore depth buffer
  119078. engine.setDepthBuffer(true);
  119079. engine.setDepthWrite(true);
  119080. };
  119081. /**
  119082. * Finalize the result of the output of the postprocesses.
  119083. * @param doNotPresent If true the result will not be displayed to the screen.
  119084. * @param targetTexture The target texture to render to.
  119085. * @param faceIndex The index of the face to bind the target texture to.
  119086. * @param postProcesses The array of post processes to render.
  119087. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  119088. * @hidden
  119089. */
  119090. PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, faceIndex, postProcesses, forceFullscreenViewport) {
  119091. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  119092. var camera = this._scene.activeCamera;
  119093. if (!camera) {
  119094. return;
  119095. }
  119096. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  119097. if (postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  119098. return;
  119099. }
  119100. var engine = this._scene.getEngine();
  119101. for (var index = 0, len = postProcesses.length; index < len; index++) {
  119102. var pp = postProcesses[index];
  119103. if (index < len - 1) {
  119104. pp._outputTexture = postProcesses[index + 1].activate(camera, targetTexture);
  119105. }
  119106. else {
  119107. if (targetTexture) {
  119108. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport);
  119109. pp._outputTexture = targetTexture;
  119110. }
  119111. else {
  119112. engine.restoreDefaultFramebuffer();
  119113. pp._outputTexture = null;
  119114. }
  119115. }
  119116. if (doNotPresent) {
  119117. break;
  119118. }
  119119. var effect = pp.apply();
  119120. if (effect) {
  119121. pp.onBeforeRenderObservable.notifyObservers(effect);
  119122. // VBOs
  119123. this._prepareBuffers();
  119124. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  119125. // Draw order
  119126. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  119127. pp.onAfterRenderObservable.notifyObservers(effect);
  119128. }
  119129. }
  119130. // Restore states
  119131. engine.setDepthBuffer(true);
  119132. engine.setDepthWrite(true);
  119133. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  119134. };
  119135. /**
  119136. * Disposes of the post process manager.
  119137. */
  119138. PostProcessManager.prototype.dispose = function () {
  119139. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  119140. if (buffer) {
  119141. buffer.dispose();
  119142. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  119143. }
  119144. if (this._indexBuffer) {
  119145. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  119146. this._indexBuffer = null;
  119147. }
  119148. };
  119149. return PostProcessManager;
  119150. }());
  119151. /***/ }),
  119152. /***/ "./PostProcesses/refractionPostProcess.ts":
  119153. /*!************************************************!*\
  119154. !*** ./PostProcesses/refractionPostProcess.ts ***!
  119155. \************************************************/
  119156. /*! exports provided: RefractionPostProcess */
  119157. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119158. "use strict";
  119159. __webpack_require__.r(__webpack_exports__);
  119160. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return RefractionPostProcess; });
  119161. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119162. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119163. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119164. /* harmony import */ var _Shaders_refraction_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/refraction.fragment */ "./Shaders/refraction.fragment.ts");
  119165. /**
  119166. * Post process which applies a refractin texture
  119167. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  119168. */
  119169. var RefractionPostProcess = /** @class */ (function (_super) {
  119170. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionPostProcess, _super);
  119171. /**
  119172. * Initializes the RefractionPostProcess
  119173. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  119174. * @param name The name of the effect.
  119175. * @param refractionTextureUrl Url of the refraction texture to use
  119176. * @param color the base color of the refraction (used to taint the rendering)
  119177. * @param depth simulated refraction depth
  119178. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  119179. * @param camera The camera to apply the render pass to.
  119180. * @param options The required width/height ratio to downsize to before computing the render pass.
  119181. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119182. * @param engine The engine which the post process will be applied. (default: current engine)
  119183. * @param reusable If the post process can be reused on the same frame. (default: false)
  119184. */
  119185. function RefractionPostProcess(name, refractionTextureUrl,
  119186. /** the base color of the refraction (used to taint the rendering) */
  119187. color,
  119188. /** simulated refraction depth */
  119189. depth,
  119190. /** the coefficient of the base color (0 to remove base color tainting) */
  119191. colorLevel, options, camera, samplingMode, engine, reusable) {
  119192. var _this = _super.call(this, name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], options, camera, samplingMode, engine, reusable) || this;
  119193. _this.color = color;
  119194. _this.depth = depth;
  119195. _this.colorLevel = colorLevel;
  119196. _this._ownRefractionTexture = true;
  119197. _this.onActivateObservable.add(function (cam) {
  119198. _this._refTexture = _this._refTexture || new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](refractionTextureUrl, cam.getScene());
  119199. });
  119200. _this.onApplyObservable.add(function (effect) {
  119201. effect.setColor3("baseColor", _this.color);
  119202. effect.setFloat("depth", _this.depth);
  119203. effect.setFloat("colorLevel", _this.colorLevel);
  119204. effect.setTexture("refractionSampler", _this._refTexture);
  119205. });
  119206. return _this;
  119207. }
  119208. Object.defineProperty(RefractionPostProcess.prototype, "refractionTexture", {
  119209. /**
  119210. * Gets or sets the refraction texture
  119211. * Please note that you are responsible for disposing the texture if you set it manually
  119212. */
  119213. get: function () {
  119214. return this._refTexture;
  119215. },
  119216. set: function (value) {
  119217. if (this._refTexture && this._ownRefractionTexture) {
  119218. this._refTexture.dispose();
  119219. }
  119220. this._refTexture = value;
  119221. this._ownRefractionTexture = false;
  119222. },
  119223. enumerable: true,
  119224. configurable: true
  119225. });
  119226. // Methods
  119227. /**
  119228. * Disposes of the post process
  119229. * @param camera Camera to dispose post process on
  119230. */
  119231. RefractionPostProcess.prototype.dispose = function (camera) {
  119232. if (this._refTexture && this._ownRefractionTexture) {
  119233. this._refTexture.dispose();
  119234. this._refTexture = null;
  119235. }
  119236. _super.prototype.dispose.call(this, camera);
  119237. };
  119238. return RefractionPostProcess;
  119239. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  119240. /***/ }),
  119241. /***/ "./PostProcesses/sharpenPostProcess.ts":
  119242. /*!*********************************************!*\
  119243. !*** ./PostProcesses/sharpenPostProcess.ts ***!
  119244. \*********************************************/
  119245. /*! exports provided: SharpenPostProcess */
  119246. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119247. "use strict";
  119248. __webpack_require__.r(__webpack_exports__);
  119249. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return SharpenPostProcess; });
  119250. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119251. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119252. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119253. /* harmony import */ var _Shaders_sharpen_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/sharpen.fragment */ "./Shaders/sharpen.fragment.ts");
  119254. /**
  119255. * The SharpenPostProcess applies a sharpen kernel to every pixel
  119256. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  119257. */
  119258. var SharpenPostProcess = /** @class */ (function (_super) {
  119259. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SharpenPostProcess, _super);
  119260. /**
  119261. * Creates a new instance ConvolutionPostProcess
  119262. * @param name The name of the effect.
  119263. * @param options The required width/height ratio to downsize to before computing the render pass.
  119264. * @param camera The camera to apply the render pass to.
  119265. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119266. * @param engine The engine which the post process will be applied. (default: current engine)
  119267. * @param reusable If the post process can be reused on the same frame. (default: false)
  119268. * @param textureType Type of textures used when performing the post process. (default: 0)
  119269. * @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)
  119270. */
  119271. function SharpenPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  119272. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119273. if (blockCompilation === void 0) { blockCompilation = false; }
  119274. var _this = _super.call(this, name, "sharpen", ["sharpnessAmounts", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  119275. /**
  119276. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  119277. */
  119278. _this.colorAmount = 1.0;
  119279. /**
  119280. * How much sharpness should be applied (default: 0.3)
  119281. */
  119282. _this.edgeAmount = 0.3;
  119283. _this.onApply = function (effect) {
  119284. effect.setFloat2("screenSize", _this.width, _this.height);
  119285. effect.setFloat2("sharpnessAmounts", _this.edgeAmount, _this.colorAmount);
  119286. };
  119287. return _this;
  119288. }
  119289. return SharpenPostProcess;
  119290. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  119291. /***/ }),
  119292. /***/ "./PostProcesses/stereoscopicInterlacePostProcess.ts":
  119293. /*!***********************************************************!*\
  119294. !*** ./PostProcesses/stereoscopicInterlacePostProcess.ts ***!
  119295. \***********************************************************/
  119296. /*! exports provided: StereoscopicInterlacePostProcess */
  119297. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119298. "use strict";
  119299. __webpack_require__.r(__webpack_exports__);
  119300. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return StereoscopicInterlacePostProcess; });
  119301. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119302. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119303. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119304. /* harmony import */ var _Shaders_stereoscopicInterlace_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/stereoscopicInterlace.fragment */ "./Shaders/stereoscopicInterlace.fragment.ts");
  119305. /**
  119306. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  119307. */
  119308. var StereoscopicInterlacePostProcess = /** @class */ (function (_super) {
  119309. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicInterlacePostProcess, _super);
  119310. /**
  119311. * Initializes a StereoscopicInterlacePostProcess
  119312. * @param name The name of the effect.
  119313. * @param rigCameras The rig cameras to be appled to the post process
  119314. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  119315. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119316. * @param engine The engine which the post process will be applied. (default: current engine)
  119317. * @param reusable If the post process can be reused on the same frame. (default: false)
  119318. */
  119319. function StereoscopicInterlacePostProcess(name, rigCameras, isStereoscopicHoriz, samplingMode, engine, reusable) {
  119320. var _this = _super.call(this, name, "stereoscopicInterlace", ['stepSize'], ['camASampler'], 1, rigCameras[1], samplingMode, engine, reusable, isStereoscopicHoriz ? "#define IS_STEREOSCOPIC_HORIZ 1" : undefined) || this;
  119321. _this._passedProcess = rigCameras[0]._rigPostProcess;
  119322. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  119323. _this.onSizeChangedObservable.add(function () {
  119324. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  119325. });
  119326. _this.onApplyObservable.add(function (effect) {
  119327. effect.setTextureFromPostProcess("camASampler", _this._passedProcess);
  119328. effect.setFloat2("stepSize", _this._stepSize.x, _this._stepSize.y);
  119329. });
  119330. return _this;
  119331. }
  119332. return StereoscopicInterlacePostProcess;
  119333. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  119334. /***/ }),
  119335. /***/ "./PostProcesses/tonemapPostProcess.ts":
  119336. /*!*********************************************!*\
  119337. !*** ./PostProcesses/tonemapPostProcess.ts ***!
  119338. \*********************************************/
  119339. /*! exports provided: TonemappingOperator, TonemapPostProcess */
  119340. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119341. "use strict";
  119342. __webpack_require__.r(__webpack_exports__);
  119343. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return TonemappingOperator; });
  119344. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return TonemapPostProcess; });
  119345. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119346. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119347. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119348. /* harmony import */ var _Shaders_tonemap_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/tonemap.fragment */ "./Shaders/tonemap.fragment.ts");
  119349. /** Defines operator used for tonemapping */
  119350. var TonemappingOperator;
  119351. (function (TonemappingOperator) {
  119352. /** Hable */
  119353. TonemappingOperator[TonemappingOperator["Hable"] = 0] = "Hable";
  119354. /** Reinhard */
  119355. TonemappingOperator[TonemappingOperator["Reinhard"] = 1] = "Reinhard";
  119356. /** HejiDawson */
  119357. TonemappingOperator[TonemappingOperator["HejiDawson"] = 2] = "HejiDawson";
  119358. /** Photographic */
  119359. TonemappingOperator[TonemappingOperator["Photographic"] = 3] = "Photographic";
  119360. })(TonemappingOperator || (TonemappingOperator = {}));
  119361. /**
  119362. * Defines a post process to apply tone mapping
  119363. */
  119364. var TonemapPostProcess = /** @class */ (function (_super) {
  119365. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TonemapPostProcess, _super);
  119366. /**
  119367. * Creates a new TonemapPostProcess
  119368. * @param name defines the name of the postprocess
  119369. * @param _operator defines the operator to use
  119370. * @param exposureAdjustment defines the required exposure adjustement
  119371. * @param camera defines the camera to use (can be null)
  119372. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  119373. * @param engine defines the hosting engine (can be ignore if camera is set)
  119374. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119375. */
  119376. function TonemapPostProcess(name, _operator,
  119377. /** Defines the required exposure adjustement */
  119378. exposureAdjustment, camera, samplingMode, engine, textureFormat) {
  119379. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE; }
  119380. if (textureFormat === void 0) { textureFormat = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119381. var _this = _super.call(this, name, "tonemap", ["_ExposureAdjustment"], null, 1.0, camera, samplingMode, engine, true, null, textureFormat) || this;
  119382. _this._operator = _operator;
  119383. _this.exposureAdjustment = exposureAdjustment;
  119384. var defines = "#define ";
  119385. if (_this._operator === TonemappingOperator.Hable) {
  119386. defines += "HABLE_TONEMAPPING";
  119387. }
  119388. else if (_this._operator === TonemappingOperator.Reinhard) {
  119389. defines += "REINHARD_TONEMAPPING";
  119390. }
  119391. else if (_this._operator === TonemappingOperator.HejiDawson) {
  119392. defines += "OPTIMIZED_HEJIDAWSON_TONEMAPPING";
  119393. }
  119394. else if (_this._operator === TonemappingOperator.Photographic) {
  119395. defines += "PHOTOGRAPHIC_TONEMAPPING";
  119396. }
  119397. //sadly a second call to create the effect.
  119398. _this.updateEffect(defines);
  119399. _this.onApply = function (effect) {
  119400. effect.setFloat("_ExposureAdjustment", _this.exposureAdjustment);
  119401. };
  119402. return _this;
  119403. }
  119404. return TonemapPostProcess;
  119405. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  119406. /***/ }),
  119407. /***/ "./PostProcesses/volumetricLightScatteringPostProcess.ts":
  119408. /*!***************************************************************!*\
  119409. !*** ./PostProcesses/volumetricLightScatteringPostProcess.ts ***!
  119410. \***************************************************************/
  119411. /*! exports provided: VolumetricLightScatteringPostProcess */
  119412. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119413. "use strict";
  119414. __webpack_require__.r(__webpack_exports__);
  119415. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return VolumetricLightScatteringPostProcess; });
  119416. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119417. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  119418. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  119419. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119420. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  119421. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  119422. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  119423. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  119424. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  119425. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119426. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  119427. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119428. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119429. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  119430. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  119431. /* harmony import */ var _Shaders_volumetricLightScattering_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/volumetricLightScattering.fragment */ "./Shaders/volumetricLightScattering.fragment.ts");
  119432. /* harmony import */ var _Shaders_volumetricLightScatteringPass_fragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Shaders/volumetricLightScatteringPass.fragment */ "./Shaders/volumetricLightScatteringPass.fragment.ts");
  119433. /**
  119434. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  119435. */
  119436. var VolumetricLightScatteringPostProcess = /** @class */ (function (_super) {
  119437. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumetricLightScatteringPostProcess, _super);
  119438. /**
  119439. * @constructor
  119440. * @param name The post-process name
  119441. * @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)
  119442. * @param camera The camera that the post-process will be attached to
  119443. * @param mesh The mesh used to create the light scattering
  119444. * @param samples The post-process quality, default 100
  119445. * @param samplingModeThe post-process filtering mode
  119446. * @param engine The babylon engine
  119447. * @param reusable If the post-process is reusable
  119448. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  119449. */
  119450. function VolumetricLightScatteringPostProcess(name, ratio, camera, mesh, samples, samplingMode, engine, reusable, scene) {
  119451. if (samples === void 0) { samples = 100; }
  119452. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].BILINEAR_SAMPLINGMODE; }
  119453. 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;
  119454. _this._screenCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  119455. /**
  119456. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  119457. */
  119458. _this.customMeshPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  119459. /**
  119460. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  119461. */
  119462. _this.useCustomMeshPosition = false;
  119463. /**
  119464. * If the post-process should inverse the light scattering direction
  119465. */
  119466. _this.invert = true;
  119467. /**
  119468. * Array containing the excluded meshes not rendered in the internal pass
  119469. */
  119470. _this.excludedMeshes = new Array();
  119471. /**
  119472. * Controls the overall intensity of the post-process
  119473. */
  119474. _this.exposure = 0.3;
  119475. /**
  119476. * Dissipates each sample's contribution in range [0, 1]
  119477. */
  119478. _this.decay = 0.96815;
  119479. /**
  119480. * Controls the overall intensity of each sample
  119481. */
  119482. _this.weight = 0.58767;
  119483. /**
  119484. * Controls the density of each sample
  119485. */
  119486. _this.density = 0.926;
  119487. scene = ((camera === null) ? scene : camera.getScene()); // parameter "scene" can be null.
  119488. engine = scene.getEngine();
  119489. _this._viewPort = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Viewport"](0, 0, 1, 1).toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  119490. // Configure mesh
  119491. _this.mesh = ((mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene));
  119492. // Configure
  119493. _this._createPass(scene, ratio.passRatio || ratio);
  119494. _this.onActivate = function (camera) {
  119495. if (!_this.isSupported) {
  119496. _this.dispose(camera);
  119497. }
  119498. _this.onActivate = null;
  119499. };
  119500. _this.onApplyObservable.add(function (effect) {
  119501. _this._updateMeshScreenCoordinates(scene);
  119502. effect.setTexture("lightScatteringSampler", _this._volumetricLightScatteringRTT);
  119503. effect.setFloat("exposure", _this.exposure);
  119504. effect.setFloat("decay", _this.decay);
  119505. effect.setFloat("weight", _this.weight);
  119506. effect.setFloat("density", _this.density);
  119507. effect.setVector2("meshPositionOnScreen", _this._screenCoordinates);
  119508. });
  119509. return _this;
  119510. }
  119511. Object.defineProperty(VolumetricLightScatteringPostProcess.prototype, "useDiffuseColor", {
  119512. /**
  119513. * @hidden
  119514. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  119515. */
  119516. get: function () {
  119517. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  119518. return false;
  119519. },
  119520. set: function (useDiffuseColor) {
  119521. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  119522. },
  119523. enumerable: true,
  119524. configurable: true
  119525. });
  119526. /**
  119527. * Returns the string "VolumetricLightScatteringPostProcess"
  119528. * @returns "VolumetricLightScatteringPostProcess"
  119529. */
  119530. VolumetricLightScatteringPostProcess.prototype.getClassName = function () {
  119531. return "VolumetricLightScatteringPostProcess";
  119532. };
  119533. VolumetricLightScatteringPostProcess.prototype._isReady = function (subMesh, useInstances) {
  119534. var mesh = subMesh.getMesh();
  119535. // Render this.mesh as default
  119536. if (mesh === this.mesh && mesh.material) {
  119537. return mesh.material.isReady(mesh);
  119538. }
  119539. var defines = [];
  119540. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  119541. var material = subMesh.getMaterial();
  119542. // Alpha test
  119543. if (material) {
  119544. if (material.needAlphaTesting()) {
  119545. defines.push("#define ALPHATEST");
  119546. }
  119547. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind)) {
  119548. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  119549. defines.push("#define UV1");
  119550. }
  119551. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind)) {
  119552. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  119553. defines.push("#define UV2");
  119554. }
  119555. }
  119556. // Bones
  119557. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  119558. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  119559. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  119560. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  119561. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  119562. }
  119563. else {
  119564. defines.push("#define NUM_BONE_INFLUENCERS 0");
  119565. }
  119566. // Instances
  119567. if (useInstances) {
  119568. defines.push("#define INSTANCES");
  119569. attribs.push("world0");
  119570. attribs.push("world1");
  119571. attribs.push("world2");
  119572. attribs.push("world3");
  119573. }
  119574. // Get correct effect
  119575. var join = defines.join("\n");
  119576. if (this._cachedDefines !== join) {
  119577. this._cachedDefines = join;
  119578. this._volumetricLightScatteringPass = mesh.getScene().getEngine().createEffect({ vertexElement: "depth", fragmentElement: "volumetricLightScatteringPass" }, attribs, ["world", "mBones", "viewProjection", "diffuseMatrix"], ["diffuseSampler"], join);
  119579. }
  119580. return this._volumetricLightScatteringPass.isReady();
  119581. };
  119582. /**
  119583. * Sets the new light position for light scattering effect
  119584. * @param position The new custom light position
  119585. */
  119586. VolumetricLightScatteringPostProcess.prototype.setCustomMeshPosition = function (position) {
  119587. this.customMeshPosition = position;
  119588. };
  119589. /**
  119590. * Returns the light position for light scattering effect
  119591. * @return Vector3 The custom light position
  119592. */
  119593. VolumetricLightScatteringPostProcess.prototype.getCustomMeshPosition = function () {
  119594. return this.customMeshPosition;
  119595. };
  119596. /**
  119597. * Disposes the internal assets and detaches the post-process from the camera
  119598. */
  119599. VolumetricLightScatteringPostProcess.prototype.dispose = function (camera) {
  119600. var rttIndex = camera.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);
  119601. if (rttIndex !== -1) {
  119602. camera.getScene().customRenderTargets.splice(rttIndex, 1);
  119603. }
  119604. this._volumetricLightScatteringRTT.dispose();
  119605. _super.prototype.dispose.call(this, camera);
  119606. };
  119607. /**
  119608. * Returns the render target texture used by the post-process
  119609. * @return the render target texture used by the post-process
  119610. */
  119611. VolumetricLightScatteringPostProcess.prototype.getPass = function () {
  119612. return this._volumetricLightScatteringRTT;
  119613. };
  119614. // Private methods
  119615. VolumetricLightScatteringPostProcess.prototype._meshExcluded = function (mesh) {
  119616. if (this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  119617. return true;
  119618. }
  119619. return false;
  119620. };
  119621. VolumetricLightScatteringPostProcess.prototype._createPass = function (scene, ratio) {
  119622. var _this = this;
  119623. var engine = scene.getEngine();
  119624. 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);
  119625. this._volumetricLightScatteringRTT.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  119626. this._volumetricLightScatteringRTT.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  119627. this._volumetricLightScatteringRTT.renderList = null;
  119628. this._volumetricLightScatteringRTT.renderParticles = false;
  119629. this._volumetricLightScatteringRTT.ignoreCameraViewport = true;
  119630. var camera = this.getCamera();
  119631. if (camera) {
  119632. camera.customRenderTargets.push(this._volumetricLightScatteringRTT);
  119633. }
  119634. else {
  119635. scene.customRenderTargets.push(this._volumetricLightScatteringRTT);
  119636. }
  119637. // Custom render function for submeshes
  119638. var renderSubMesh = function (subMesh) {
  119639. var mesh = subMesh.getRenderingMesh();
  119640. if (_this._meshExcluded(mesh)) {
  119641. return;
  119642. }
  119643. var material = subMesh.getMaterial();
  119644. if (!material) {
  119645. return;
  119646. }
  119647. var scene = mesh.getScene();
  119648. var engine = scene.getEngine();
  119649. // Culling
  119650. engine.setState(material.backFaceCulling);
  119651. // Managing instances
  119652. var batch = mesh._getInstancesRenderList(subMesh._id);
  119653. if (batch.mustReturn) {
  119654. return;
  119655. }
  119656. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  119657. if (_this._isReady(subMesh, hardwareInstancedRendering)) {
  119658. var effect = _this._volumetricLightScatteringPass;
  119659. if (mesh === _this.mesh) {
  119660. if (subMesh.effect) {
  119661. effect = subMesh.effect;
  119662. }
  119663. else {
  119664. effect = material.getEffect();
  119665. }
  119666. }
  119667. engine.enableEffect(effect);
  119668. mesh._bind(subMesh, effect, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode);
  119669. if (mesh === _this.mesh) {
  119670. material.bind(mesh.getWorldMatrix(), mesh);
  119671. }
  119672. else {
  119673. _this._volumetricLightScatteringPass.setMatrix("viewProjection", scene.getTransformMatrix());
  119674. // Alpha test
  119675. if (material && material.needAlphaTesting()) {
  119676. var alphaTexture = material.getAlphaTestTexture();
  119677. _this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
  119678. if (alphaTexture) {
  119679. _this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  119680. }
  119681. }
  119682. // Bones
  119683. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  119684. _this._volumetricLightScatteringPass.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  119685. }
  119686. }
  119687. // Draw
  119688. mesh._processRendering(subMesh, _this._volumetricLightScatteringPass, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return effect.setMatrix("world", world); });
  119689. }
  119690. };
  119691. // Render target texture callbacks
  119692. var savedSceneClearColor;
  119693. var sceneClearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0.0, 0.0, 0.0, 1.0);
  119694. this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function () {
  119695. savedSceneClearColor = scene.clearColor;
  119696. scene.clearColor = sceneClearColor;
  119697. });
  119698. this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function () {
  119699. scene.clearColor = savedSceneClearColor;
  119700. });
  119701. this._volumetricLightScatteringRTT.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  119702. var engine = scene.getEngine();
  119703. var index;
  119704. if (depthOnlySubMeshes.length) {
  119705. engine.setColorWrite(false);
  119706. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  119707. renderSubMesh(depthOnlySubMeshes.data[index]);
  119708. }
  119709. engine.setColorWrite(true);
  119710. }
  119711. for (index = 0; index < opaqueSubMeshes.length; index++) {
  119712. renderSubMesh(opaqueSubMeshes.data[index]);
  119713. }
  119714. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  119715. renderSubMesh(alphaTestSubMeshes.data[index]);
  119716. }
  119717. if (transparentSubMeshes.length) {
  119718. // Sort sub meshes
  119719. for (index = 0; index < transparentSubMeshes.length; index++) {
  119720. var submesh = transparentSubMeshes.data[index];
  119721. var boundingInfo = submesh.getBoundingInfo();
  119722. if (boundingInfo && scene.activeCamera) {
  119723. submesh._alphaIndex = submesh.getMesh().alphaIndex;
  119724. submesh._distanceToCamera = boundingInfo.boundingSphere.centerWorld.subtract(scene.activeCamera.position).length();
  119725. }
  119726. }
  119727. var sortedArray = transparentSubMeshes.data.slice(0, transparentSubMeshes.length);
  119728. sortedArray.sort(function (a, b) {
  119729. // Alpha index first
  119730. if (a._alphaIndex > b._alphaIndex) {
  119731. return 1;
  119732. }
  119733. if (a._alphaIndex < b._alphaIndex) {
  119734. return -1;
  119735. }
  119736. // Then distance to camera
  119737. if (a._distanceToCamera < b._distanceToCamera) {
  119738. return 1;
  119739. }
  119740. if (a._distanceToCamera > b._distanceToCamera) {
  119741. return -1;
  119742. }
  119743. return 0;
  119744. });
  119745. // Render sub meshes
  119746. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_COMBINE);
  119747. for (index = 0; index < sortedArray.length; index++) {
  119748. renderSubMesh(sortedArray[index]);
  119749. }
  119750. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_DISABLE);
  119751. }
  119752. };
  119753. };
  119754. VolumetricLightScatteringPostProcess.prototype._updateMeshScreenCoordinates = function (scene) {
  119755. var transform = scene.getTransformMatrix();
  119756. var meshPosition;
  119757. if (this.useCustomMeshPosition) {
  119758. meshPosition = this.customMeshPosition;
  119759. }
  119760. else if (this.attachedNode) {
  119761. meshPosition = this.attachedNode.position;
  119762. }
  119763. else {
  119764. meshPosition = this.mesh.parent ? this.mesh.getAbsolutePosition() : this.mesh.position;
  119765. }
  119766. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Project(meshPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity(), transform, this._viewPort);
  119767. this._screenCoordinates.x = pos.x / this._viewPort.width;
  119768. this._screenCoordinates.y = pos.y / this._viewPort.height;
  119769. if (this.invert) {
  119770. this._screenCoordinates.y = 1.0 - this._screenCoordinates.y;
  119771. }
  119772. };
  119773. // Static methods
  119774. /**
  119775. * Creates a default mesh for the Volumeric Light Scattering post-process
  119776. * @param name The mesh name
  119777. * @param scene The scene where to create the mesh
  119778. * @return the default mesh
  119779. */
  119780. VolumetricLightScatteringPostProcess.CreateDefaultMesh = function (name, scene) {
  119781. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__["Mesh"].CreatePlane(name, 1, scene);
  119782. mesh.billboardMode = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__["AbstractMesh"].BILLBOARDMODE_ALL;
  119783. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"](name + "Material", scene);
  119784. material.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  119785. mesh.material = material;
  119786. return mesh;
  119787. };
  119788. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119789. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  119790. ], VolumetricLightScatteringPostProcess.prototype, "customMeshPosition", void 0);
  119791. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119792. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119793. ], VolumetricLightScatteringPostProcess.prototype, "useCustomMeshPosition", void 0);
  119794. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119795. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119796. ], VolumetricLightScatteringPostProcess.prototype, "invert", void 0);
  119797. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119798. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  119799. ], VolumetricLightScatteringPostProcess.prototype, "mesh", void 0);
  119800. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119801. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119802. ], VolumetricLightScatteringPostProcess.prototype, "excludedMeshes", void 0);
  119803. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119804. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119805. ], VolumetricLightScatteringPostProcess.prototype, "exposure", void 0);
  119806. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119807. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119808. ], VolumetricLightScatteringPostProcess.prototype, "decay", void 0);
  119809. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119810. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119811. ], VolumetricLightScatteringPostProcess.prototype, "weight", void 0);
  119812. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119813. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119814. ], VolumetricLightScatteringPostProcess.prototype, "density", void 0);
  119815. return VolumetricLightScatteringPostProcess;
  119816. }(_postProcess__WEBPACK_IMPORTED_MODULE_11__["PostProcess"]));
  119817. /***/ }),
  119818. /***/ "./PostProcesses/vrDistortionCorrectionPostProcess.ts":
  119819. /*!************************************************************!*\
  119820. !*** ./PostProcesses/vrDistortionCorrectionPostProcess.ts ***!
  119821. \************************************************************/
  119822. /*! exports provided: VRDistortionCorrectionPostProcess */
  119823. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119824. "use strict";
  119825. __webpack_require__.r(__webpack_exports__);
  119826. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return VRDistortionCorrectionPostProcess; });
  119827. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119828. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119829. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119830. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119831. /* harmony import */ var _Shaders_vrDistortionCorrection_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/vrDistortionCorrection.fragment */ "./Shaders/vrDistortionCorrection.fragment.ts");
  119832. /**
  119833. * VRDistortionCorrectionPostProcess used for mobile VR
  119834. */
  119835. var VRDistortionCorrectionPostProcess = /** @class */ (function (_super) {
  119836. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDistortionCorrectionPostProcess, _super);
  119837. /**
  119838. * Initializes the VRDistortionCorrectionPostProcess
  119839. * @param name The name of the effect.
  119840. * @param camera The camera to apply the render pass to.
  119841. * @param isRightEye If this is for the right eye distortion
  119842. * @param vrMetrics All the required metrics for the VR camera
  119843. */
  119844. function VRDistortionCorrectionPostProcess(name, camera, isRightEye, vrMetrics) {
  119845. var _this = _super.call(this, name, "vrDistortionCorrection", [
  119846. 'LensCenter',
  119847. 'Scale',
  119848. 'ScaleIn',
  119849. 'HmdWarpParam'
  119850. ], null, vrMetrics.postProcessScaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  119851. _this._isRightEye = isRightEye;
  119852. _this._distortionFactors = vrMetrics.distortionK;
  119853. _this._postProcessScaleFactor = vrMetrics.postProcessScaleFactor;
  119854. _this._lensCenterOffset = vrMetrics.lensCenterOffset;
  119855. _this.adaptScaleToCurrentViewport = true;
  119856. _this.onSizeChangedObservable.add(function () {
  119857. _this._scaleIn = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](2, 2 / _this.aspectRatio);
  119858. _this._scaleFactor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](.5 * (1 / _this._postProcessScaleFactor), .5 * (1 / _this._postProcessScaleFactor) * _this.aspectRatio);
  119859. _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);
  119860. });
  119861. _this.onApplyObservable.add(function (effect) {
  119862. effect.setFloat2("LensCenter", _this._lensCenter.x, _this._lensCenter.y);
  119863. effect.setFloat2("Scale", _this._scaleFactor.x, _this._scaleFactor.y);
  119864. effect.setFloat2("ScaleIn", _this._scaleIn.x, _this._scaleIn.y);
  119865. effect.setFloat4("HmdWarpParam", _this._distortionFactors[0], _this._distortionFactors[1], _this._distortionFactors[2], _this._distortionFactors[3]);
  119866. });
  119867. return _this;
  119868. }
  119869. return VRDistortionCorrectionPostProcess;
  119870. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  119871. /***/ }),
  119872. /***/ "./Probes/index.ts":
  119873. /*!*************************!*\
  119874. !*** ./Probes/index.ts ***!
  119875. \*************************/
  119876. /*! exports provided: ReflectionProbe */
  119877. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119878. "use strict";
  119879. __webpack_require__.r(__webpack_exports__);
  119880. /* harmony import */ var _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./reflectionProbe */ "./Probes/reflectionProbe.ts");
  119881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  119882. /***/ }),
  119883. /***/ "./Probes/reflectionProbe.ts":
  119884. /*!***********************************!*\
  119885. !*** ./Probes/reflectionProbe.ts ***!
  119886. \***********************************/
  119887. /*! exports provided: ReflectionProbe */
  119888. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119889. "use strict";
  119890. __webpack_require__.r(__webpack_exports__);
  119891. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return ReflectionProbe; });
  119892. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119893. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  119894. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  119895. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119896. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  119897. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119898. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.removeReflectionProbe = function (toRemove) {
  119899. if (!this.reflectionProbes) {
  119900. return -1;
  119901. }
  119902. var index = this.reflectionProbes.indexOf(toRemove);
  119903. if (index !== -1) {
  119904. this.reflectionProbes.splice(index, 1);
  119905. }
  119906. return index;
  119907. };
  119908. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.addReflectionProbe = function (newReflectionProbe) {
  119909. if (!this.reflectionProbes) {
  119910. this.reflectionProbes = [];
  119911. }
  119912. this.reflectionProbes.push(newReflectionProbe);
  119913. };
  119914. /**
  119915. * Class used to generate realtime reflection / refraction cube textures
  119916. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  119917. */
  119918. var ReflectionProbe = /** @class */ (function () {
  119919. /**
  119920. * Creates a new reflection probe
  119921. * @param name defines the name of the probe
  119922. * @param size defines the texture resolution (for each face)
  119923. * @param scene defines the hosting scene
  119924. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  119925. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  119926. */
  119927. function ReflectionProbe(
  119928. /** defines the name of the probe */
  119929. name, size, scene, generateMipMaps, useFloat) {
  119930. if (generateMipMaps === void 0) { generateMipMaps = true; }
  119931. if (useFloat === void 0) { useFloat = false; }
  119932. var _this = this;
  119933. this.name = name;
  119934. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  119935. this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  119936. this._add = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  119937. this._invertYAxis = false;
  119938. /** Gets or sets probe position (center of the cube map) */
  119939. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  119940. this._scene = scene;
  119941. // Create the scene field if not exist.
  119942. if (!this._scene.reflectionProbes) {
  119943. this._scene.reflectionProbes = new Array();
  119944. }
  119945. this._scene.reflectionProbes.push(this);
  119946. 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);
  119947. this._renderTargetTexture.onBeforeRenderObservable.add(function (faceIndex) {
  119948. switch (faceIndex) {
  119949. case 0:
  119950. _this._add.copyFromFloats(1, 0, 0);
  119951. break;
  119952. case 1:
  119953. _this._add.copyFromFloats(-1, 0, 0);
  119954. break;
  119955. case 2:
  119956. _this._add.copyFromFloats(0, _this._invertYAxis ? 1 : -1, 0);
  119957. break;
  119958. case 3:
  119959. _this._add.copyFromFloats(0, _this._invertYAxis ? -1 : 1, 0);
  119960. break;
  119961. case 4:
  119962. _this._add.copyFromFloats(0, 0, 1);
  119963. break;
  119964. case 5:
  119965. _this._add.copyFromFloats(0, 0, -1);
  119966. break;
  119967. }
  119968. if (_this._attachedMesh) {
  119969. _this.position.copyFrom(_this._attachedMesh.getAbsolutePosition());
  119970. }
  119971. _this.position.addToRef(_this._add, _this._target);
  119972. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(_this.position, _this._target, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), _this._viewMatrix);
  119973. if (scene.activeCamera) {
  119974. _this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
  119975. scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
  119976. }
  119977. scene._forcedViewPosition = _this.position;
  119978. });
  119979. this._renderTargetTexture.onAfterUnbindObservable.add(function () {
  119980. scene._forcedViewPosition = null;
  119981. scene.updateTransformMatrix(true);
  119982. });
  119983. }
  119984. Object.defineProperty(ReflectionProbe.prototype, "samples", {
  119985. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  119986. get: function () {
  119987. return this._renderTargetTexture.samples;
  119988. },
  119989. set: function (value) {
  119990. this._renderTargetTexture.samples = value;
  119991. },
  119992. enumerable: true,
  119993. configurable: true
  119994. });
  119995. Object.defineProperty(ReflectionProbe.prototype, "refreshRate", {
  119996. /** Gets or sets the refresh rate to use (on every frame by default) */
  119997. get: function () {
  119998. return this._renderTargetTexture.refreshRate;
  119999. },
  120000. set: function (value) {
  120001. this._renderTargetTexture.refreshRate = value;
  120002. },
  120003. enumerable: true,
  120004. configurable: true
  120005. });
  120006. /**
  120007. * Gets the hosting scene
  120008. * @returns a Scene
  120009. */
  120010. ReflectionProbe.prototype.getScene = function () {
  120011. return this._scene;
  120012. };
  120013. Object.defineProperty(ReflectionProbe.prototype, "cubeTexture", {
  120014. /** Gets the internal CubeTexture used to render to */
  120015. get: function () {
  120016. return this._renderTargetTexture;
  120017. },
  120018. enumerable: true,
  120019. configurable: true
  120020. });
  120021. Object.defineProperty(ReflectionProbe.prototype, "renderList", {
  120022. /** Gets the list of meshes to render */
  120023. get: function () {
  120024. return this._renderTargetTexture.renderList;
  120025. },
  120026. enumerable: true,
  120027. configurable: true
  120028. });
  120029. /**
  120030. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  120031. * @param mesh defines the mesh to attach to
  120032. */
  120033. ReflectionProbe.prototype.attachToMesh = function (mesh) {
  120034. this._attachedMesh = mesh;
  120035. };
  120036. /**
  120037. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  120038. * @param renderingGroupId The rendering group id corresponding to its index
  120039. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  120040. */
  120041. ReflectionProbe.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  120042. this._renderTargetTexture.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  120043. };
  120044. /**
  120045. * Clean all associated resources
  120046. */
  120047. ReflectionProbe.prototype.dispose = function () {
  120048. var index = this._scene.reflectionProbes.indexOf(this);
  120049. if (index !== -1) {
  120050. // Remove from the scene if found
  120051. this._scene.reflectionProbes.splice(index, 1);
  120052. }
  120053. if (this._renderTargetTexture) {
  120054. this._renderTargetTexture.dispose();
  120055. this._renderTargetTexture = null;
  120056. }
  120057. };
  120058. /**
  120059. * Converts the reflection probe information to a readable string for debug purpose.
  120060. * @param fullDetails Supports for multiple levels of logging within scene loading
  120061. * @returns the human readable reflection probe info
  120062. */
  120063. ReflectionProbe.prototype.toString = function (fullDetails) {
  120064. var ret = "Name: " + this.name;
  120065. if (fullDetails) {
  120066. ret += ", position: " + this.position.toString();
  120067. if (this._attachedMesh) {
  120068. ret += ", attached mesh: " + this._attachedMesh.name;
  120069. }
  120070. }
  120071. return ret;
  120072. };
  120073. /**
  120074. * Get the class name of the relfection probe.
  120075. * @returns "ReflectionProbe"
  120076. */
  120077. ReflectionProbe.prototype.getClassName = function () {
  120078. return "ReflectionProbe";
  120079. };
  120080. /**
  120081. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  120082. * @returns The JSON representation of the texture
  120083. */
  120084. ReflectionProbe.prototype.serialize = function () {
  120085. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, this._renderTargetTexture.serialize());
  120086. serializationObject.isReflectionProbe = true;
  120087. return serializationObject;
  120088. };
  120089. /**
  120090. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  120091. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  120092. * @param scene Define the scene the parsed reflection probe should be instantiated in
  120093. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  120094. * @returns The parsed reflection probe if successful
  120095. */
  120096. ReflectionProbe.Parse = function (parsedReflectionProbe, scene, rootUrl) {
  120097. var reflectionProbe = null;
  120098. if (scene.reflectionProbes) {
  120099. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  120100. var rp = scene.reflectionProbes[index];
  120101. if (rp.name === parsedReflectionProbe.name) {
  120102. reflectionProbe = rp;
  120103. break;
  120104. }
  120105. }
  120106. }
  120107. reflectionProbe = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return reflectionProbe || new ReflectionProbe(parsedReflectionProbe.name, parsedReflectionProbe.renderTargetSize, scene, parsedReflectionProbe._generateMipMaps); }, parsedReflectionProbe, scene, rootUrl);
  120108. reflectionProbe.cubeTexture._waitingRenderList = parsedReflectionProbe.renderList;
  120109. if (parsedReflectionProbe._attachedMesh) {
  120110. reflectionProbe.attachToMesh(scene.getMeshByID(parsedReflectionProbe._attachedMesh));
  120111. }
  120112. return reflectionProbe;
  120113. };
  120114. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120115. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  120116. ], ReflectionProbe.prototype, "_attachedMesh", void 0);
  120117. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120118. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  120119. ], ReflectionProbe.prototype, "position", void 0);
  120120. return ReflectionProbe;
  120121. }());
  120122. /***/ }),
  120123. /***/ "./Rendering/boundingBoxRenderer.ts":
  120124. /*!******************************************!*\
  120125. !*** ./Rendering/boundingBoxRenderer.ts ***!
  120126. \******************************************/
  120127. /*! exports provided: BoundingBoxRenderer */
  120128. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120129. "use strict";
  120130. __webpack_require__.r(__webpack_exports__);
  120131. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return BoundingBoxRenderer; });
  120132. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  120133. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  120134. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  120135. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  120136. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120137. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  120138. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  120139. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  120140. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  120141. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  120142. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  120143. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  120144. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "forceShowBoundingBoxes", {
  120145. get: function () {
  120146. return this._forceShowBoundingBoxes || false;
  120147. },
  120148. set: function (value) {
  120149. this._forceShowBoundingBoxes = value;
  120150. // Lazyly creates a BB renderer if needed.
  120151. if (value) {
  120152. this.getBoundingBoxRenderer();
  120153. }
  120154. },
  120155. enumerable: true,
  120156. configurable: true
  120157. });
  120158. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.getBoundingBoxRenderer = function () {
  120159. if (!this._boundingBoxRenderer) {
  120160. this._boundingBoxRenderer = new BoundingBoxRenderer(this);
  120161. }
  120162. return this._boundingBoxRenderer;
  120163. };
  120164. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "showBoundingBox", {
  120165. get: function () {
  120166. return this._showBoundingBox || false;
  120167. },
  120168. set: function (value) {
  120169. this._showBoundingBox = value;
  120170. // Lazyly creates a BB renderer if needed.
  120171. if (value) {
  120172. this.getScene().getBoundingBoxRenderer();
  120173. }
  120174. },
  120175. enumerable: true,
  120176. configurable: true
  120177. });
  120178. /**
  120179. * Component responsible of rendering the bounding box of the meshes in a scene.
  120180. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  120181. */
  120182. var BoundingBoxRenderer = /** @class */ (function () {
  120183. /**
  120184. * Instantiates a new bounding box renderer in a scene.
  120185. * @param scene the scene the renderer renders in
  120186. */
  120187. function BoundingBoxRenderer(scene) {
  120188. /**
  120189. * The component name helpfull to identify the component in the list of scene components.
  120190. */
  120191. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_BOUNDINGBOXRENDERER;
  120192. /**
  120193. * Color of the bounding box lines placed in front of an object
  120194. */
  120195. this.frontColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  120196. /**
  120197. * Color of the bounding box lines placed behind an object
  120198. */
  120199. this.backColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0.1, 0.1, 0.1);
  120200. /**
  120201. * Defines if the renderer should show the back lines or not
  120202. */
  120203. this.showBackLines = true;
  120204. /**
  120205. * @hidden
  120206. */
  120207. this.renderList = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__["SmartArray"](32);
  120208. this._vertexBuffers = {};
  120209. this.scene = scene;
  120210. scene._addComponent(this);
  120211. }
  120212. /**
  120213. * Registers the component in a given scene
  120214. */
  120215. BoundingBoxRenderer.prototype.register = function () {
  120216. this.scene._beforeEvaluateActiveMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset);
  120217. this.scene._activeMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_ACTIVEMESH_BOUNDINGBOXRENDERER, this, this._activeMesh);
  120218. this.scene._evaluateSubMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh);
  120219. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render);
  120220. };
  120221. BoundingBoxRenderer.prototype._evaluateSubMesh = function (mesh, subMesh) {
  120222. if (mesh.showSubMeshesBoundingBox) {
  120223. var boundingInfo = subMesh.getBoundingInfo();
  120224. if (boundingInfo !== null && boundingInfo !== undefined) {
  120225. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  120226. this.renderList.push(boundingInfo.boundingBox);
  120227. }
  120228. }
  120229. };
  120230. BoundingBoxRenderer.prototype._activeMesh = function (sourceMesh, mesh) {
  120231. if (sourceMesh.showBoundingBox || this.scene.forceShowBoundingBoxes) {
  120232. var boundingInfo = sourceMesh.getBoundingInfo();
  120233. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  120234. this.renderList.push(boundingInfo.boundingBox);
  120235. }
  120236. };
  120237. BoundingBoxRenderer.prototype._prepareRessources = function () {
  120238. if (this._colorShader) {
  120239. return;
  120240. }
  120241. this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__["ShaderMaterial"]("colorShader", this.scene, "color", {
  120242. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind],
  120243. uniforms: ["world", "viewProjection", "color"]
  120244. });
  120245. var engine = this.scene.getEngine();
  120246. var boxdata = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateBox({ size: 1.0 });
  120247. 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);
  120248. this._createIndexBuffer();
  120249. };
  120250. BoundingBoxRenderer.prototype._createIndexBuffer = function () {
  120251. var engine = this.scene.getEngine();
  120252. 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]);
  120253. };
  120254. /**
  120255. * Rebuilds the elements related to this component in case of
  120256. * context lost for instance.
  120257. */
  120258. BoundingBoxRenderer.prototype.rebuild = function () {
  120259. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120260. if (vb) {
  120261. vb._rebuild();
  120262. }
  120263. this._createIndexBuffer();
  120264. };
  120265. /**
  120266. * @hidden
  120267. */
  120268. BoundingBoxRenderer.prototype.reset = function () {
  120269. this.renderList.reset();
  120270. };
  120271. /**
  120272. * Render the bounding boxes of a specific rendering group
  120273. * @param renderingGroupId defines the rendering group to render
  120274. */
  120275. BoundingBoxRenderer.prototype.render = function (renderingGroupId) {
  120276. if (this.renderList.length === 0) {
  120277. return;
  120278. }
  120279. this._prepareRessources();
  120280. if (!this._colorShader.isReady()) {
  120281. return;
  120282. }
  120283. var engine = this.scene.getEngine();
  120284. engine.setDepthWrite(false);
  120285. this._colorShader._preBind();
  120286. for (var boundingBoxIndex = 0; boundingBoxIndex < this.renderList.length; boundingBoxIndex++) {
  120287. var boundingBox = this.renderList.data[boundingBoxIndex];
  120288. if (boundingBox._tag !== renderingGroupId) {
  120289. continue;
  120290. }
  120291. var min = boundingBox.minimum;
  120292. var max = boundingBox.maximum;
  120293. var diff = max.subtract(min);
  120294. var median = min.add(diff.scale(0.5));
  120295. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  120296. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  120297. .multiply(boundingBox.getWorldMatrix());
  120298. // VBOs
  120299. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  120300. if (this.showBackLines) {
  120301. // Back
  120302. engine.setDepthFunctionToGreaterOrEqual();
  120303. this.scene.resetCachedMaterial();
  120304. this._colorShader.setColor4("color", this.backColor.toColor4());
  120305. this._colorShader.bind(worldMatrix);
  120306. // Draw order
  120307. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  120308. }
  120309. // Front
  120310. engine.setDepthFunctionToLess();
  120311. this.scene.resetCachedMaterial();
  120312. this._colorShader.setColor4("color", this.frontColor.toColor4());
  120313. this._colorShader.bind(worldMatrix);
  120314. // Draw order
  120315. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  120316. }
  120317. this._colorShader.unbind();
  120318. engine.setDepthFunctionToLessOrEqual();
  120319. engine.setDepthWrite(true);
  120320. };
  120321. /**
  120322. * In case of occlusion queries, we can render the occlusion bounding box through this method
  120323. * @param mesh Define the mesh to render the occlusion bounding box for
  120324. */
  120325. BoundingBoxRenderer.prototype.renderOcclusionBoundingBox = function (mesh) {
  120326. this._prepareRessources();
  120327. if (!this._colorShader.isReady() || !mesh._boundingInfo) {
  120328. return;
  120329. }
  120330. var engine = this.scene.getEngine();
  120331. engine.setDepthWrite(false);
  120332. engine.setColorWrite(false);
  120333. this._colorShader._preBind();
  120334. var boundingBox = mesh._boundingInfo.boundingBox;
  120335. var min = boundingBox.minimum;
  120336. var max = boundingBox.maximum;
  120337. var diff = max.subtract(min);
  120338. var median = min.add(diff.scale(0.5));
  120339. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  120340. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  120341. .multiply(boundingBox.getWorldMatrix());
  120342. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  120343. engine.setDepthFunctionToLess();
  120344. this.scene.resetCachedMaterial();
  120345. this._colorShader.bind(worldMatrix);
  120346. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  120347. this._colorShader.unbind();
  120348. engine.setDepthFunctionToLessOrEqual();
  120349. engine.setDepthWrite(true);
  120350. engine.setColorWrite(true);
  120351. };
  120352. /**
  120353. * Dispose and release the resources attached to this renderer.
  120354. */
  120355. BoundingBoxRenderer.prototype.dispose = function () {
  120356. if (!this._colorShader) {
  120357. return;
  120358. }
  120359. this.renderList.dispose();
  120360. this._colorShader.dispose();
  120361. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120362. if (buffer) {
  120363. buffer.dispose();
  120364. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  120365. }
  120366. this.scene.getEngine()._releaseBuffer(this._indexBuffer);
  120367. };
  120368. return BoundingBoxRenderer;
  120369. }());
  120370. /***/ }),
  120371. /***/ "./Rendering/depthRenderer.ts":
  120372. /*!************************************!*\
  120373. !*** ./Rendering/depthRenderer.ts ***!
  120374. \************************************/
  120375. /*! exports provided: DepthRenderer */
  120376. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120377. "use strict";
  120378. __webpack_require__.r(__webpack_exports__);
  120379. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return DepthRenderer; });
  120380. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120381. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  120382. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  120383. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  120384. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  120385. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120386. /* harmony import */ var _Shaders_depth_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/depth.fragment */ "./Shaders/depth.fragment.ts");
  120387. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  120388. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  120389. /**
  120390. * This represents a depth renderer in Babylon.
  120391. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  120392. */
  120393. var DepthRenderer = /** @class */ (function () {
  120394. /**
  120395. * Instantiates a depth renderer
  120396. * @param scene The scene the renderer belongs to
  120397. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  120398. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  120399. */
  120400. function DepthRenderer(scene, type, camera) {
  120401. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT; }
  120402. if (camera === void 0) { camera = null; }
  120403. var _this = this;
  120404. /**
  120405. * Specifiess that the depth renderer will only be used within
  120406. * the camera it is created for.
  120407. * This can help forcing its rendering during the camera processing.
  120408. */
  120409. this.useOnlyInActiveCamera = false;
  120410. this._scene = scene;
  120411. DepthRenderer._SceneComponentInitialization(this._scene);
  120412. this._camera = camera;
  120413. var engine = scene.getEngine();
  120414. // Render target
  120415. this._depthMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]("depthMap", { width: engine.getRenderWidth(), height: engine.getRenderHeight() }, this._scene, false, true, type);
  120416. this._depthMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  120417. this._depthMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  120418. this._depthMap.refreshRate = 1;
  120419. this._depthMap.renderParticles = false;
  120420. this._depthMap.renderList = null;
  120421. // Camera to get depth map from to support multiple concurrent cameras
  120422. this._depthMap.activeCamera = this._camera;
  120423. this._depthMap.ignoreCameraViewport = true;
  120424. this._depthMap.useCameraPostProcesses = false;
  120425. // set default depth value to 1.0 (far away)
  120426. this._depthMap.onClearObservable.add(function (engine) {
  120427. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0), true, true, true);
  120428. });
  120429. // Custom render function
  120430. var renderSubMesh = function (subMesh) {
  120431. var mesh = subMesh.getRenderingMesh();
  120432. var scene = _this._scene;
  120433. var engine = scene.getEngine();
  120434. var material = subMesh.getMaterial();
  120435. if (!material) {
  120436. return;
  120437. }
  120438. // Culling and reverse (right handed system)
  120439. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  120440. // Managing instances
  120441. var batch = mesh._getInstancesRenderList(subMesh._id);
  120442. if (batch.mustReturn) {
  120443. return;
  120444. }
  120445. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  120446. var camera = _this._camera || scene.activeCamera;
  120447. if (_this.isReady(subMesh, hardwareInstancedRendering) && camera) {
  120448. engine.enableEffect(_this._effect);
  120449. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  120450. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  120451. _this._effect.setFloat2("depthValues", camera.minZ, camera.minZ + camera.maxZ);
  120452. // Alpha test
  120453. if (material && material.needAlphaTesting()) {
  120454. var alphaTexture = material.getAlphaTestTexture();
  120455. if (alphaTexture) {
  120456. _this._effect.setTexture("diffuseSampler", alphaTexture);
  120457. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  120458. }
  120459. }
  120460. // Bones
  120461. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  120462. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  120463. }
  120464. // Draw
  120465. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  120466. }
  120467. };
  120468. this._depthMap.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  120469. var index;
  120470. if (depthOnlySubMeshes.length) {
  120471. engine.setColorWrite(false);
  120472. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  120473. renderSubMesh(depthOnlySubMeshes.data[index]);
  120474. }
  120475. engine.setColorWrite(true);
  120476. }
  120477. for (index = 0; index < opaqueSubMeshes.length; index++) {
  120478. renderSubMesh(opaqueSubMeshes.data[index]);
  120479. }
  120480. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  120481. renderSubMesh(alphaTestSubMeshes.data[index]);
  120482. }
  120483. };
  120484. }
  120485. /**
  120486. * Creates the depth rendering effect and checks if the effect is ready.
  120487. * @param subMesh The submesh to be used to render the depth map of
  120488. * @param useInstances If multiple world instances should be used
  120489. * @returns if the depth renderer is ready to render the depth map
  120490. */
  120491. DepthRenderer.prototype.isReady = function (subMesh, useInstances) {
  120492. var material = subMesh.getMaterial();
  120493. if (material.disableDepthWrite) {
  120494. return false;
  120495. }
  120496. var defines = [];
  120497. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120498. var mesh = subMesh.getMesh();
  120499. // Alpha test
  120500. if (material && material.needAlphaTesting() && material.getAlphaTestTexture()) {
  120501. defines.push("#define ALPHATEST");
  120502. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  120503. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  120504. defines.push("#define UV1");
  120505. }
  120506. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  120507. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  120508. defines.push("#define UV2");
  120509. }
  120510. }
  120511. // Bones
  120512. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  120513. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  120514. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  120515. if (mesh.numBoneInfluencers > 4) {
  120516. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  120517. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  120518. }
  120519. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  120520. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  120521. }
  120522. else {
  120523. defines.push("#define NUM_BONE_INFLUENCERS 0");
  120524. }
  120525. // Instances
  120526. if (useInstances) {
  120527. defines.push("#define INSTANCES");
  120528. attribs.push("world0");
  120529. attribs.push("world1");
  120530. attribs.push("world2");
  120531. attribs.push("world3");
  120532. }
  120533. // Get correct effect
  120534. var join = defines.join("\n");
  120535. if (this._cachedDefines !== join) {
  120536. this._cachedDefines = join;
  120537. this._effect = this._scene.getEngine().createEffect("depth", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "depthValues"], ["diffuseSampler"], join);
  120538. }
  120539. return this._effect.isReady();
  120540. };
  120541. /**
  120542. * Gets the texture which the depth map will be written to.
  120543. * @returns The depth map texture
  120544. */
  120545. DepthRenderer.prototype.getDepthMap = function () {
  120546. return this._depthMap;
  120547. };
  120548. /**
  120549. * Disposes of the depth renderer.
  120550. */
  120551. DepthRenderer.prototype.dispose = function () {
  120552. this._depthMap.dispose();
  120553. };
  120554. /** @hidden */
  120555. DepthRenderer._SceneComponentInitialization = function (_) {
  120556. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("DepthRendererSceneComponent");
  120557. };
  120558. return DepthRenderer;
  120559. }());
  120560. /***/ }),
  120561. /***/ "./Rendering/depthRendererSceneComponent.ts":
  120562. /*!**************************************************!*\
  120563. !*** ./Rendering/depthRendererSceneComponent.ts ***!
  120564. \**************************************************/
  120565. /*! exports provided: DepthRendererSceneComponent */
  120566. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120567. "use strict";
  120568. __webpack_require__.r(__webpack_exports__);
  120569. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return DepthRendererSceneComponent; });
  120570. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  120571. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  120572. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120573. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  120574. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableDepthRenderer = function (camera) {
  120575. camera = camera || this.activeCamera;
  120576. if (!camera) {
  120577. throw "No camera available to enable depth renderer";
  120578. }
  120579. if (!this._depthRenderer) {
  120580. this._depthRenderer = {};
  120581. }
  120582. if (!this._depthRenderer[camera.id]) {
  120583. var textureType = 0;
  120584. if (this.getEngine().getCaps().textureHalfFloatRender) {
  120585. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  120586. }
  120587. else if (this.getEngine().getCaps().textureFloatRender) {
  120588. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  120589. }
  120590. else {
  120591. throw "Depth renderer does not support int texture type";
  120592. }
  120593. this._depthRenderer[camera.id] = new _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"](this, textureType, camera);
  120594. }
  120595. return this._depthRenderer[camera.id];
  120596. };
  120597. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableDepthRenderer = function (camera) {
  120598. camera = camera || this.activeCamera;
  120599. if (!camera || !this._depthRenderer || !this._depthRenderer[camera.id]) {
  120600. return;
  120601. }
  120602. this._depthRenderer[camera.id].dispose();
  120603. delete this._depthRenderer[camera.id];
  120604. };
  120605. /**
  120606. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  120607. * in several rendering techniques.
  120608. */
  120609. var DepthRendererSceneComponent = /** @class */ (function () {
  120610. /**
  120611. * Creates a new instance of the component for the given scene
  120612. * @param scene Defines the scene to register the component in
  120613. */
  120614. function DepthRendererSceneComponent(scene) {
  120615. /**
  120616. * The component name helpfull to identify the component in the list of scene components.
  120617. */
  120618. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER;
  120619. this.scene = scene;
  120620. }
  120621. /**
  120622. * Registers the component in a given scene
  120623. */
  120624. DepthRendererSceneComponent.prototype.register = function () {
  120625. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets);
  120626. this.scene._gatherActiveCameraRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets);
  120627. };
  120628. /**
  120629. * Rebuilds the elements related to this component in case of
  120630. * context lost for instance.
  120631. */
  120632. DepthRendererSceneComponent.prototype.rebuild = function () {
  120633. // Nothing to do for this component
  120634. };
  120635. /**
  120636. * Disposes the component and the associated ressources
  120637. */
  120638. DepthRendererSceneComponent.prototype.dispose = function () {
  120639. for (var key in this.scene._depthRenderer) {
  120640. this.scene._depthRenderer[key].dispose();
  120641. }
  120642. };
  120643. DepthRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  120644. if (this.scene._depthRenderer) {
  120645. for (var key in this.scene._depthRenderer) {
  120646. var depthRenderer = this.scene._depthRenderer[key];
  120647. if (!depthRenderer.useOnlyInActiveCamera) {
  120648. renderTargets.push(depthRenderer.getDepthMap());
  120649. }
  120650. }
  120651. }
  120652. };
  120653. DepthRendererSceneComponent.prototype._gatherActiveCameraRenderTargets = function (renderTargets) {
  120654. if (this.scene._depthRenderer) {
  120655. for (var key in this.scene._depthRenderer) {
  120656. var depthRenderer = this.scene._depthRenderer[key];
  120657. if (depthRenderer.useOnlyInActiveCamera && this.scene.activeCamera.id === key) {
  120658. renderTargets.push(depthRenderer.getDepthMap());
  120659. }
  120660. }
  120661. }
  120662. };
  120663. return DepthRendererSceneComponent;
  120664. }());
  120665. _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]._SceneComponentInitialization = function (scene) {
  120666. // Register the G Buffer component to the scene.
  120667. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER);
  120668. if (!component) {
  120669. component = new DepthRendererSceneComponent(scene);
  120670. scene._addComponent(component);
  120671. }
  120672. };
  120673. /***/ }),
  120674. /***/ "./Rendering/edgesRenderer.ts":
  120675. /*!************************************!*\
  120676. !*** ./Rendering/edgesRenderer.ts ***!
  120677. \************************************/
  120678. /*! exports provided: EdgesRenderer, LineEdgesRenderer */
  120679. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120680. "use strict";
  120681. __webpack_require__.r(__webpack_exports__);
  120682. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return EdgesRenderer; });
  120683. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return LineEdgesRenderer; });
  120684. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120685. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  120686. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  120687. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  120688. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120689. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  120690. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  120691. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  120692. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120693. /* harmony import */ var _Shaders_line_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/line.fragment */ "./Shaders/line.fragment.ts");
  120694. /* harmony import */ var _Shaders_line_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/line.vertex */ "./Shaders/line.vertex.ts");
  120695. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.disableEdgesRendering = function () {
  120696. if (this._edgesRenderer) {
  120697. this._edgesRenderer.dispose();
  120698. this._edgesRenderer = null;
  120699. }
  120700. return this;
  120701. };
  120702. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  120703. if (epsilon === void 0) { epsilon = 0.95; }
  120704. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  120705. this.disableEdgesRendering();
  120706. this._edgesRenderer = new EdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  120707. return this;
  120708. };
  120709. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "edgesRenderer", {
  120710. get: function () {
  120711. return this._edgesRenderer;
  120712. },
  120713. enumerable: true,
  120714. configurable: true
  120715. });
  120716. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  120717. if (epsilon === void 0) { epsilon = 0.95; }
  120718. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  120719. this.disableEdgesRendering();
  120720. this._edgesRenderer = new LineEdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  120721. return this;
  120722. };
  120723. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["InstancedLinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  120724. if (epsilon === void 0) { epsilon = 0.95; }
  120725. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  120726. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering.apply(this, arguments);
  120727. return this;
  120728. };
  120729. /**
  120730. * FaceAdjacencies Helper class to generate edges
  120731. */
  120732. var FaceAdjacencies = /** @class */ (function () {
  120733. function FaceAdjacencies() {
  120734. this.edges = new Array();
  120735. this.edgesConnectedCount = 0;
  120736. }
  120737. return FaceAdjacencies;
  120738. }());
  120739. /**
  120740. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  120741. */
  120742. var EdgesRenderer = /** @class */ (function () {
  120743. /**
  120744. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  120745. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  120746. * @param source Mesh used to create edges
  120747. * @param epsilon sum of angles in adjacency to check for edge
  120748. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  120749. * @param generateEdgesLines - should generate Lines or only prepare resources.
  120750. */
  120751. function EdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices, generateEdgesLines) {
  120752. if (epsilon === void 0) { epsilon = 0.95; }
  120753. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  120754. if (generateEdgesLines === void 0) { generateEdgesLines = true; }
  120755. var _this = this;
  120756. /**
  120757. * Define the size of the edges with an orthographic camera
  120758. */
  120759. this.edgesWidthScalerForOrthographic = 1000.0;
  120760. /**
  120761. * Define the size of the edges with a perspective camera
  120762. */
  120763. this.edgesWidthScalerForPerspective = 50.0;
  120764. this._linesPositions = new Array();
  120765. this._linesNormals = new Array();
  120766. this._linesIndices = new Array();
  120767. this._buffers = {};
  120768. this._checkVerticesInsteadOfIndices = false;
  120769. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  120770. this.isEnabled = true;
  120771. this._source = source;
  120772. this._checkVerticesInsteadOfIndices = checkVerticesInsteadOfIndices;
  120773. this._epsilon = epsilon;
  120774. this._prepareRessources();
  120775. if (generateEdgesLines) {
  120776. this._generateEdgesLines();
  120777. }
  120778. this._meshRebuildObserver = this._source.onRebuildObservable.add(function () {
  120779. _this._rebuild();
  120780. });
  120781. this._meshDisposeObserver = this._source.onDisposeObservable.add(function () {
  120782. _this.dispose();
  120783. });
  120784. }
  120785. EdgesRenderer.prototype._prepareRessources = function () {
  120786. if (this._lineShader) {
  120787. return;
  120788. }
  120789. this._lineShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("lineShader", this._source.getScene(), "line", {
  120790. attributes: ["position", "normal"],
  120791. uniforms: ["worldViewProjection", "color", "width", "aspectRatio"]
  120792. });
  120793. this._lineShader.disableDepthWrite = true;
  120794. this._lineShader.backFaceCulling = false;
  120795. };
  120796. /** @hidden */
  120797. EdgesRenderer.prototype._rebuild = function () {
  120798. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120799. if (buffer) {
  120800. buffer._rebuild();
  120801. }
  120802. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  120803. if (buffer) {
  120804. buffer._rebuild();
  120805. }
  120806. var scene = this._source.getScene();
  120807. var engine = scene.getEngine();
  120808. this._ib = engine.createIndexBuffer(this._linesIndices);
  120809. };
  120810. /**
  120811. * Releases the required resources for the edges renderer
  120812. */
  120813. EdgesRenderer.prototype.dispose = function () {
  120814. this._source.onRebuildObservable.remove(this._meshRebuildObserver);
  120815. this._source.onDisposeObservable.remove(this._meshDisposeObserver);
  120816. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120817. if (buffer) {
  120818. buffer.dispose();
  120819. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  120820. }
  120821. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  120822. if (buffer) {
  120823. buffer.dispose();
  120824. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind] = null;
  120825. }
  120826. this._source.getScene().getEngine()._releaseBuffer(this._ib);
  120827. this._lineShader.dispose();
  120828. };
  120829. EdgesRenderer.prototype._processEdgeForAdjacencies = function (pa, pb, p0, p1, p2) {
  120830. if (pa === p0 && pb === p1 || pa === p1 && pb === p0) {
  120831. return 0;
  120832. }
  120833. if (pa === p1 && pb === p2 || pa === p2 && pb === p1) {
  120834. return 1;
  120835. }
  120836. if (pa === p2 && pb === p0 || pa === p0 && pb === p2) {
  120837. return 2;
  120838. }
  120839. return -1;
  120840. };
  120841. EdgesRenderer.prototype._processEdgeForAdjacenciesWithVertices = function (pa, pb, p0, p1, p2) {
  120842. if (pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p1) || pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p0)) {
  120843. return 0;
  120844. }
  120845. if (pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p2) || pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p1)) {
  120846. return 1;
  120847. }
  120848. if (pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p0) || pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p2)) {
  120849. return 2;
  120850. }
  120851. return -1;
  120852. };
  120853. /**
  120854. * Checks if the pair of p0 and p1 is en edge
  120855. * @param faceIndex
  120856. * @param edge
  120857. * @param faceNormals
  120858. * @param p0
  120859. * @param p1
  120860. * @private
  120861. */
  120862. EdgesRenderer.prototype._checkEdge = function (faceIndex, edge, faceNormals, p0, p1) {
  120863. var needToCreateLine;
  120864. if (edge === undefined) {
  120865. needToCreateLine = true;
  120866. }
  120867. else {
  120868. var dotProduct = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Dot(faceNormals[faceIndex], faceNormals[edge]);
  120869. needToCreateLine = dotProduct < this._epsilon;
  120870. }
  120871. if (needToCreateLine) {
  120872. this.createLine(p0, p1, this._linesPositions.length / 3);
  120873. }
  120874. };
  120875. /**
  120876. * push line into the position, normal and index buffer
  120877. * @protected
  120878. */
  120879. EdgesRenderer.prototype.createLine = function (p0, p1, offset) {
  120880. // Positions
  120881. 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);
  120882. // Normals
  120883. 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);
  120884. // Indices
  120885. this._linesIndices.push(offset, offset + 1, offset + 2, offset, offset + 2, offset + 3);
  120886. };
  120887. /**
  120888. * Generates lines edges from adjacencjes
  120889. * @private
  120890. */
  120891. EdgesRenderer.prototype._generateEdgesLines = function () {
  120892. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  120893. var indices = this._source.getIndices();
  120894. if (!indices || !positions) {
  120895. return;
  120896. }
  120897. // First let's find adjacencies
  120898. var adjacencies = new Array();
  120899. var faceNormals = new Array();
  120900. var index;
  120901. var faceAdjacencies;
  120902. // Prepare faces
  120903. for (index = 0; index < indices.length; index += 3) {
  120904. faceAdjacencies = new FaceAdjacencies();
  120905. var p0Index = indices[index];
  120906. var p1Index = indices[index + 1];
  120907. var p2Index = indices[index + 2];
  120908. faceAdjacencies.p0 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p0Index * 3], positions[p0Index * 3 + 1], positions[p0Index * 3 + 2]);
  120909. faceAdjacencies.p1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p1Index * 3], positions[p1Index * 3 + 1], positions[p1Index * 3 + 2]);
  120910. faceAdjacencies.p2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p2Index * 3], positions[p2Index * 3 + 1], positions[p2Index * 3 + 2]);
  120911. var faceNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Cross(faceAdjacencies.p1.subtract(faceAdjacencies.p0), faceAdjacencies.p2.subtract(faceAdjacencies.p1));
  120912. faceNormal.normalize();
  120913. faceNormals.push(faceNormal);
  120914. adjacencies.push(faceAdjacencies);
  120915. }
  120916. // Scan
  120917. for (index = 0; index < adjacencies.length; index++) {
  120918. faceAdjacencies = adjacencies[index];
  120919. for (var otherIndex = index + 1; otherIndex < adjacencies.length; otherIndex++) {
  120920. var otherFaceAdjacencies = adjacencies[otherIndex];
  120921. if (faceAdjacencies.edgesConnectedCount === 3) { // Full
  120922. break;
  120923. }
  120924. if (otherFaceAdjacencies.edgesConnectedCount === 3) { // Full
  120925. continue;
  120926. }
  120927. var otherP0 = indices[otherIndex * 3];
  120928. var otherP1 = indices[otherIndex * 3 + 1];
  120929. var otherP2 = indices[otherIndex * 3 + 2];
  120930. for (var edgeIndex = 0; edgeIndex < 3; edgeIndex++) {
  120931. var otherEdgeIndex = 0;
  120932. if (faceAdjacencies.edges[edgeIndex] !== undefined) {
  120933. continue;
  120934. }
  120935. switch (edgeIndex) {
  120936. case 0:
  120937. if (this._checkVerticesInsteadOfIndices) {
  120938. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p0, faceAdjacencies.p1, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  120939. }
  120940. else {
  120941. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3], indices[index * 3 + 1], otherP0, otherP1, otherP2);
  120942. }
  120943. break;
  120944. case 1:
  120945. if (this._checkVerticesInsteadOfIndices) {
  120946. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p1, faceAdjacencies.p2, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  120947. }
  120948. else {
  120949. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 1], indices[index * 3 + 2], otherP0, otherP1, otherP2);
  120950. }
  120951. break;
  120952. case 2:
  120953. if (this._checkVerticesInsteadOfIndices) {
  120954. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p2, faceAdjacencies.p0, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  120955. }
  120956. else {
  120957. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 2], indices[index * 3], otherP0, otherP1, otherP2);
  120958. }
  120959. break;
  120960. }
  120961. if (otherEdgeIndex === -1) {
  120962. continue;
  120963. }
  120964. faceAdjacencies.edges[edgeIndex] = otherIndex;
  120965. otherFaceAdjacencies.edges[otherEdgeIndex] = index;
  120966. faceAdjacencies.edgesConnectedCount++;
  120967. otherFaceAdjacencies.edgesConnectedCount++;
  120968. if (faceAdjacencies.edgesConnectedCount === 3) {
  120969. break;
  120970. }
  120971. }
  120972. }
  120973. }
  120974. // Create lines
  120975. for (index = 0; index < adjacencies.length; index++) {
  120976. // 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
  120977. var current = adjacencies[index];
  120978. this._checkEdge(index, current.edges[0], faceNormals, current.p0, current.p1);
  120979. this._checkEdge(index, current.edges[1], faceNormals, current.p1, current.p2);
  120980. this._checkEdge(index, current.edges[2], faceNormals, current.p2, current.p0);
  120981. }
  120982. // Merge into a single mesh
  120983. var engine = this._source.getScene().getEngine();
  120984. 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);
  120985. 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);
  120986. this._ib = engine.createIndexBuffer(this._linesIndices);
  120987. this._indicesCount = this._linesIndices.length;
  120988. };
  120989. /**
  120990. * Checks wether or not the edges renderer is ready to render.
  120991. * @return true if ready, otherwise false.
  120992. */
  120993. EdgesRenderer.prototype.isReady = function () {
  120994. return this._lineShader.isReady();
  120995. };
  120996. /**
  120997. * Renders the edges of the attached mesh,
  120998. */
  120999. EdgesRenderer.prototype.render = function () {
  121000. var scene = this._source.getScene();
  121001. if (!this.isReady() || !scene.activeCamera) {
  121002. return;
  121003. }
  121004. var engine = scene.getEngine();
  121005. this._lineShader._preBind();
  121006. if (this._source.edgesColor.a !== 1) {
  121007. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE);
  121008. }
  121009. else {
  121010. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  121011. }
  121012. // VBOs
  121013. engine.bindBuffers(this._buffers, this._ib, this._lineShader.getEffect());
  121014. scene.resetCachedMaterial();
  121015. this._lineShader.setColor4("color", this._source.edgesColor);
  121016. if (scene.activeCamera.mode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__["Camera"].ORTHOGRAPHIC_CAMERA) {
  121017. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForOrthographic);
  121018. }
  121019. else {
  121020. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForPerspective);
  121021. }
  121022. this._lineShader.setFloat("aspectRatio", engine.getAspectRatio(scene.activeCamera));
  121023. this._lineShader.bind(this._source.getWorldMatrix());
  121024. // Draw order
  121025. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, this._indicesCount);
  121026. this._lineShader.unbind();
  121027. };
  121028. return EdgesRenderer;
  121029. }());
  121030. /**
  121031. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  121032. */
  121033. var LineEdgesRenderer = /** @class */ (function (_super) {
  121034. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LineEdgesRenderer, _super);
  121035. /**
  121036. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  121037. * @param source LineMesh used to generate edges
  121038. * @param epsilon not important (specified angle for edge detection)
  121039. * @param checkVerticesInsteadOfIndices not important for LineMesh
  121040. */
  121041. function LineEdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices) {
  121042. if (epsilon === void 0) { epsilon = 0.95; }
  121043. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  121044. var _this = _super.call(this, source, epsilon, checkVerticesInsteadOfIndices, false) || this;
  121045. _this._generateEdgesLines();
  121046. return _this;
  121047. }
  121048. /**
  121049. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  121050. */
  121051. LineEdgesRenderer.prototype._generateEdgesLines = function () {
  121052. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  121053. var indices = this._source.getIndices();
  121054. if (!indices || !positions) {
  121055. return;
  121056. }
  121057. var p0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  121058. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  121059. var len = indices.length - 1;
  121060. for (var i = 0, offset = 0; i < len; i += 2, offset += 4) {
  121061. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i], p0);
  121062. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i + 1], p1);
  121063. this.createLine(p0, p1, offset);
  121064. }
  121065. // Merge into a single mesh
  121066. var engine = this._source.getScene().getEngine();
  121067. 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);
  121068. 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);
  121069. this._ib = engine.createIndexBuffer(this._linesIndices);
  121070. this._indicesCount = this._linesIndices.length;
  121071. };
  121072. return LineEdgesRenderer;
  121073. }(EdgesRenderer));
  121074. /***/ }),
  121075. /***/ "./Rendering/geometryBufferRenderer.ts":
  121076. /*!*********************************************!*\
  121077. !*** ./Rendering/geometryBufferRenderer.ts ***!
  121078. \*********************************************/
  121079. /*! exports provided: GeometryBufferRenderer */
  121080. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121081. "use strict";
  121082. __webpack_require__.r(__webpack_exports__);
  121083. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return GeometryBufferRenderer; });
  121084. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  121085. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  121086. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121087. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  121088. /* harmony import */ var _Materials_Textures_multiRenderTarget__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  121089. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  121090. /* harmony import */ var _Shaders_geometry_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/geometry.fragment */ "./Shaders/geometry.fragment.ts");
  121091. /* harmony import */ var _Shaders_geometry_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/geometry.vertex */ "./Shaders/geometry.vertex.ts");
  121092. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  121093. /**
  121094. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  121095. */
  121096. var GeometryBufferRenderer = /** @class */ (function () {
  121097. /**
  121098. * Creates a new G Buffer for the scene
  121099. * @param scene The scene the buffer belongs to
  121100. * @param ratio How big is the buffer related to the main canvas.
  121101. */
  121102. function GeometryBufferRenderer(scene, ratio) {
  121103. if (ratio === void 0) { ratio = 1; }
  121104. /**
  121105. * Dictionary used to store the previous transformation matrices of each rendered mesh
  121106. * in order to compute objects velocities when enableVelocity is set to "true"
  121107. * @hidden
  121108. */
  121109. this._previousTransformationMatrices = {};
  121110. this._enablePosition = false;
  121111. this._enableVelocity = false;
  121112. this._positionIndex = -1;
  121113. this._velocityIndex = -1;
  121114. this._scene = scene;
  121115. this._ratio = ratio;
  121116. GeometryBufferRenderer._SceneComponentInitialization(this._scene);
  121117. // Render target
  121118. this._createRenderTargets();
  121119. }
  121120. Object.defineProperty(GeometryBufferRenderer.prototype, "renderList", {
  121121. /**
  121122. * Set the render list (meshes to be rendered) used in the G buffer.
  121123. */
  121124. set: function (meshes) {
  121125. this._multiRenderTarget.renderList = meshes;
  121126. },
  121127. enumerable: true,
  121128. configurable: true
  121129. });
  121130. Object.defineProperty(GeometryBufferRenderer.prototype, "isSupported", {
  121131. /**
  121132. * Gets wether or not G buffer are supported by the running hardware.
  121133. * This requires draw buffer supports
  121134. */
  121135. get: function () {
  121136. return this._multiRenderTarget.isSupported;
  121137. },
  121138. enumerable: true,
  121139. configurable: true
  121140. });
  121141. /**
  121142. * Returns the index of the given texture type in the G-Buffer textures array
  121143. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  121144. * @returns the index of the given texture type in the G-Buffer textures array
  121145. */
  121146. GeometryBufferRenderer.prototype.getTextureIndex = function (textureType) {
  121147. switch (textureType) {
  121148. case GeometryBufferRenderer.POSITION_TEXTURE_TYPE: return this._positionIndex;
  121149. case GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE: return this._velocityIndex;
  121150. default: return -1;
  121151. }
  121152. };
  121153. Object.defineProperty(GeometryBufferRenderer.prototype, "enablePosition", {
  121154. /**
  121155. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  121156. */
  121157. get: function () {
  121158. return this._enablePosition;
  121159. },
  121160. /**
  121161. * Sets whether or not objects positions are enabled for the G buffer.
  121162. */
  121163. set: function (enable) {
  121164. this._enablePosition = enable;
  121165. this.dispose();
  121166. this._createRenderTargets();
  121167. },
  121168. enumerable: true,
  121169. configurable: true
  121170. });
  121171. Object.defineProperty(GeometryBufferRenderer.prototype, "enableVelocity", {
  121172. /**
  121173. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  121174. */
  121175. get: function () {
  121176. return this._enableVelocity;
  121177. },
  121178. /**
  121179. * Sets wether or not objects velocities are enabled for the G buffer.
  121180. */
  121181. set: function (enable) {
  121182. this._enableVelocity = enable;
  121183. this.dispose();
  121184. this._createRenderTargets();
  121185. },
  121186. enumerable: true,
  121187. configurable: true
  121188. });
  121189. Object.defineProperty(GeometryBufferRenderer.prototype, "scene", {
  121190. /**
  121191. * Gets the scene associated with the buffer.
  121192. */
  121193. get: function () {
  121194. return this._scene;
  121195. },
  121196. enumerable: true,
  121197. configurable: true
  121198. });
  121199. Object.defineProperty(GeometryBufferRenderer.prototype, "ratio", {
  121200. /**
  121201. * Gets the ratio used by the buffer during its creation.
  121202. * How big is the buffer related to the main canvas.
  121203. */
  121204. get: function () {
  121205. return this._ratio;
  121206. },
  121207. enumerable: true,
  121208. configurable: true
  121209. });
  121210. /**
  121211. * Checks wether everything is ready to render a submesh to the G buffer.
  121212. * @param subMesh the submesh to check readiness for
  121213. * @param useInstances is the mesh drawn using instance or not
  121214. * @returns true if ready otherwise false
  121215. */
  121216. GeometryBufferRenderer.prototype.isReady = function (subMesh, useInstances) {
  121217. var material = subMesh.getMaterial();
  121218. if (material && material.disableDepthWrite) {
  121219. return false;
  121220. }
  121221. var defines = [];
  121222. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  121223. var mesh = subMesh.getMesh();
  121224. // Alpha test
  121225. if (material && material.needAlphaTesting()) {
  121226. defines.push("#define ALPHATEST");
  121227. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  121228. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  121229. defines.push("#define UV1");
  121230. }
  121231. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  121232. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  121233. defines.push("#define UV2");
  121234. }
  121235. }
  121236. // Buffers
  121237. if (this._enablePosition) {
  121238. defines.push("#define POSITION");
  121239. defines.push("#define POSITION_INDEX " + this._positionIndex);
  121240. }
  121241. if (this._enableVelocity) {
  121242. defines.push("#define VELOCITY");
  121243. defines.push("#define VELOCITY_INDEX " + this._velocityIndex);
  121244. }
  121245. // Bones
  121246. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  121247. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  121248. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  121249. if (mesh.numBoneInfluencers > 4) {
  121250. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  121251. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  121252. }
  121253. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  121254. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  121255. }
  121256. else {
  121257. defines.push("#define NUM_BONE_INFLUENCERS 0");
  121258. }
  121259. // Instances
  121260. if (useInstances) {
  121261. defines.push("#define INSTANCES");
  121262. attribs.push("world0");
  121263. attribs.push("world1");
  121264. attribs.push("world2");
  121265. attribs.push("world3");
  121266. }
  121267. // Setup textures count
  121268. defines.push("#define RENDER_TARGET_COUNT " + this._multiRenderTarget.textures.length);
  121269. // Get correct effect
  121270. var join = defines.join("\n");
  121271. if (this._cachedDefines !== join) {
  121272. this._cachedDefines = join;
  121273. this._effect = this._scene.getEngine().createEffect("geometry", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "view", "previousWorldViewProjection"], ["diffuseSampler"], join, undefined, undefined, undefined, { buffersCount: this._enablePosition ? 3 : 2 });
  121274. }
  121275. return this._effect.isReady();
  121276. };
  121277. /**
  121278. * Gets the current underlying G Buffer.
  121279. * @returns the buffer
  121280. */
  121281. GeometryBufferRenderer.prototype.getGBuffer = function () {
  121282. return this._multiRenderTarget;
  121283. };
  121284. Object.defineProperty(GeometryBufferRenderer.prototype, "samples", {
  121285. /**
  121286. * Gets the number of samples used to render the buffer (anti aliasing).
  121287. */
  121288. get: function () {
  121289. return this._multiRenderTarget.samples;
  121290. },
  121291. /**
  121292. * Sets the number of samples used to render the buffer (anti aliasing).
  121293. */
  121294. set: function (value) {
  121295. this._multiRenderTarget.samples = value;
  121296. },
  121297. enumerable: true,
  121298. configurable: true
  121299. });
  121300. /**
  121301. * Disposes the renderer and frees up associated resources.
  121302. */
  121303. GeometryBufferRenderer.prototype.dispose = function () {
  121304. this.getGBuffer().dispose();
  121305. };
  121306. GeometryBufferRenderer.prototype._createRenderTargets = function () {
  121307. var _this = this;
  121308. var engine = this._scene.getEngine();
  121309. var count = 2;
  121310. if (this._enablePosition) {
  121311. this._positionIndex = count;
  121312. count++;
  121313. }
  121314. if (this._enableVelocity) {
  121315. this._velocityIndex = count;
  121316. count++;
  121317. }
  121318. 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 });
  121319. if (!this.isSupported) {
  121320. return;
  121321. }
  121322. this._multiRenderTarget.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  121323. this._multiRenderTarget.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  121324. this._multiRenderTarget.refreshRate = 1;
  121325. this._multiRenderTarget.renderParticles = false;
  121326. this._multiRenderTarget.renderList = null;
  121327. // set default depth value to 1.0 (far away)
  121328. this._multiRenderTarget.onClearObservable.add(function (engine) {
  121329. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0.0, 0.0, 0.0, 1.0), true, true, true);
  121330. });
  121331. // Custom render function
  121332. var renderSubMesh = function (subMesh) {
  121333. var mesh = subMesh.getRenderingMesh();
  121334. var scene = _this._scene;
  121335. var engine = scene.getEngine();
  121336. var material = subMesh.getMaterial();
  121337. if (!material) {
  121338. return;
  121339. }
  121340. // Velocity
  121341. if (!_this._previousTransformationMatrices[mesh.uniqueId]) {
  121342. _this._previousTransformationMatrices[mesh.uniqueId] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  121343. }
  121344. // Culling
  121345. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  121346. // Managing instances
  121347. var batch = mesh._getInstancesRenderList(subMesh._id);
  121348. if (batch.mustReturn) {
  121349. return;
  121350. }
  121351. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  121352. if (_this.isReady(subMesh, hardwareInstancedRendering)) {
  121353. engine.enableEffect(_this._effect);
  121354. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  121355. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  121356. _this._effect.setMatrix("view", scene.getViewMatrix());
  121357. // Alpha test
  121358. if (material && material.needAlphaTesting()) {
  121359. var alphaTexture = material.getAlphaTestTexture();
  121360. if (alphaTexture) {
  121361. _this._effect.setTexture("diffuseSampler", alphaTexture);
  121362. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  121363. }
  121364. }
  121365. // Bones
  121366. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  121367. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  121368. }
  121369. // Velocity
  121370. _this._effect.setMatrix("previousWorldViewProjection", _this._previousTransformationMatrices[mesh.uniqueId]);
  121371. // Draw
  121372. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  121373. }
  121374. // Velocity
  121375. _this._previousTransformationMatrices[mesh.uniqueId] = mesh.getWorldMatrix().multiply(_this._scene.getTransformMatrix());
  121376. };
  121377. this._multiRenderTarget.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  121378. var index;
  121379. if (depthOnlySubMeshes.length) {
  121380. engine.setColorWrite(false);
  121381. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  121382. renderSubMesh(depthOnlySubMeshes.data[index]);
  121383. }
  121384. engine.setColorWrite(true);
  121385. }
  121386. for (index = 0; index < opaqueSubMeshes.length; index++) {
  121387. renderSubMesh(opaqueSubMeshes.data[index]);
  121388. }
  121389. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  121390. renderSubMesh(alphaTestSubMeshes.data[index]);
  121391. }
  121392. };
  121393. };
  121394. /**
  121395. * Constant used to retrieve the position texture index in the G-Buffer textures array
  121396. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  121397. */
  121398. GeometryBufferRenderer.POSITION_TEXTURE_TYPE = 1;
  121399. /**
  121400. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  121401. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  121402. */
  121403. GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE = 2;
  121404. /** @hidden */
  121405. GeometryBufferRenderer._SceneComponentInitialization = function (_) {
  121406. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("GeometryBufferRendererSceneComponent");
  121407. };
  121408. return GeometryBufferRenderer;
  121409. }());
  121410. /***/ }),
  121411. /***/ "./Rendering/geometryBufferRendererSceneComponent.ts":
  121412. /*!***********************************************************!*\
  121413. !*** ./Rendering/geometryBufferRendererSceneComponent.ts ***!
  121414. \***********************************************************/
  121415. /*! exports provided: GeometryBufferRendererSceneComponent */
  121416. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121417. "use strict";
  121418. __webpack_require__.r(__webpack_exports__);
  121419. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return GeometryBufferRendererSceneComponent; });
  121420. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  121421. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  121422. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  121423. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "geometryBufferRenderer", {
  121424. get: function () {
  121425. this._geometryBufferRenderer;
  121426. },
  121427. set: function (value) {
  121428. if (value && value.isSupported) {
  121429. this._geometryBufferRenderer = value;
  121430. }
  121431. },
  121432. enumerable: true,
  121433. configurable: true
  121434. });
  121435. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableGeometryBufferRenderer = function (ratio) {
  121436. if (ratio === void 0) { ratio = 1; }
  121437. if (this._geometryBufferRenderer) {
  121438. return this._geometryBufferRenderer;
  121439. }
  121440. this._geometryBufferRenderer = new _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"](this, ratio);
  121441. if (!this._geometryBufferRenderer.isSupported) {
  121442. this._geometryBufferRenderer = null;
  121443. }
  121444. return this._geometryBufferRenderer;
  121445. };
  121446. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableGeometryBufferRenderer = function () {
  121447. if (!this._geometryBufferRenderer) {
  121448. return;
  121449. }
  121450. this._geometryBufferRenderer.dispose();
  121451. this._geometryBufferRenderer = null;
  121452. };
  121453. /**
  121454. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  121455. * in several rendering techniques.
  121456. */
  121457. var GeometryBufferRendererSceneComponent = /** @class */ (function () {
  121458. /**
  121459. * Creates a new instance of the component for the given scene
  121460. * @param scene Defines the scene to register the component in
  121461. */
  121462. function GeometryBufferRendererSceneComponent(scene) {
  121463. /**
  121464. * The component name helpful to identify the component in the list of scene components.
  121465. */
  121466. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER;
  121467. this.scene = scene;
  121468. }
  121469. /**
  121470. * Registers the component in a given scene
  121471. */
  121472. GeometryBufferRendererSceneComponent.prototype.register = function () {
  121473. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER, this, this._gatherRenderTargets);
  121474. };
  121475. /**
  121476. * Rebuilds the elements related to this component in case of
  121477. * context lost for instance.
  121478. */
  121479. GeometryBufferRendererSceneComponent.prototype.rebuild = function () {
  121480. // Nothing to do for this component
  121481. };
  121482. /**
  121483. * Disposes the component and the associated ressources
  121484. */
  121485. GeometryBufferRendererSceneComponent.prototype.dispose = function () {
  121486. // Nothing to do for this component
  121487. };
  121488. GeometryBufferRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  121489. if (this.scene._geometryBufferRenderer) {
  121490. renderTargets.push(this.scene._geometryBufferRenderer.getGBuffer());
  121491. }
  121492. };
  121493. return GeometryBufferRendererSceneComponent;
  121494. }());
  121495. _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"]._SceneComponentInitialization = function (scene) {
  121496. // Register the G Buffer component to the scene.
  121497. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER);
  121498. if (!component) {
  121499. component = new GeometryBufferRendererSceneComponent(scene);
  121500. scene._addComponent(component);
  121501. }
  121502. };
  121503. /***/ }),
  121504. /***/ "./Rendering/index.ts":
  121505. /*!****************************!*\
  121506. !*** ./Rendering/index.ts ***!
  121507. \****************************/
  121508. /*! exports provided: BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer */
  121509. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121510. "use strict";
  121511. __webpack_require__.r(__webpack_exports__);
  121512. /* harmony import */ var _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBoxRenderer */ "./Rendering/boundingBoxRenderer.ts");
  121513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  121514. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  121515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]; });
  121516. /* harmony import */ var _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./depthRendererSceneComponent */ "./Rendering/depthRendererSceneComponent.ts");
  121517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__["DepthRendererSceneComponent"]; });
  121518. /* harmony import */ var _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./edgesRenderer */ "./Rendering/edgesRenderer.ts");
  121519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["EdgesRenderer"]; });
  121520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["LineEdgesRenderer"]; });
  121521. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  121522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__["GeometryBufferRenderer"]; });
  121523. /* harmony import */ var _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  121524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRendererSceneComponent"]; });
  121525. /* harmony import */ var _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./outlineRenderer */ "./Rendering/outlineRenderer.ts");
  121526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__["OutlineRenderer"]; });
  121527. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  121528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _renderingGroup__WEBPACK_IMPORTED_MODULE_7__["RenderingGroup"]; });
  121529. /* harmony import */ var _renderingManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./renderingManager */ "./Rendering/renderingManager.ts");
  121530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingGroupInfo"]; });
  121531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingManager"]; });
  121532. /* harmony import */ var _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  121533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"]; });
  121534. /***/ }),
  121535. /***/ "./Rendering/outlineRenderer.ts":
  121536. /*!**************************************!*\
  121537. !*** ./Rendering/outlineRenderer.ts ***!
  121538. \**************************************/
  121539. /*! exports provided: OutlineRenderer */
  121540. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121541. "use strict";
  121542. __webpack_require__.r(__webpack_exports__);
  121543. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return OutlineRenderer; });
  121544. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  121545. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  121546. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  121547. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121548. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  121549. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  121550. /* harmony import */ var _Shaders_outline_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/outline.fragment */ "./Shaders/outline.fragment.ts");
  121551. /* harmony import */ var _Shaders_outline_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/outline.vertex */ "./Shaders/outline.vertex.ts");
  121552. /**
  121553. * Gets the outline renderer associated with the scene
  121554. * @returns a OutlineRenderer
  121555. */
  121556. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype.getOutlineRenderer = function () {
  121557. if (!this._outlineRenderer) {
  121558. this._outlineRenderer = new OutlineRenderer(this);
  121559. }
  121560. return this._outlineRenderer;
  121561. };
  121562. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOutline", {
  121563. get: function () {
  121564. return this._renderOutline;
  121565. },
  121566. set: function (value) {
  121567. if (value) {
  121568. // Lazy Load the component.
  121569. this.getScene().getOutlineRenderer();
  121570. }
  121571. this._renderOutline = value;
  121572. },
  121573. enumerable: true,
  121574. configurable: true
  121575. });
  121576. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOverlay", {
  121577. get: function () {
  121578. return this._renderOverlay;
  121579. },
  121580. set: function (value) {
  121581. if (value) {
  121582. // Lazy Load the component.
  121583. this.getScene().getOutlineRenderer();
  121584. }
  121585. this._renderOverlay = value;
  121586. },
  121587. enumerable: true,
  121588. configurable: true
  121589. });
  121590. /**
  121591. * This class is responsible to draw bothe outline/overlay of meshes.
  121592. * It should not be used directly but through the available method on mesh.
  121593. */
  121594. var OutlineRenderer = /** @class */ (function () {
  121595. /**
  121596. * Instantiates a new outline renderer. (There could be only one per scene).
  121597. * @param scene Defines the scene it belongs to
  121598. */
  121599. function OutlineRenderer(scene) {
  121600. /**
  121601. * The name of the component. Each component must have a unique name.
  121602. */
  121603. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OUTLINERENDERER;
  121604. /**
  121605. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  121606. */
  121607. this.zOffset = 1;
  121608. this.scene = scene;
  121609. this._engine = scene.getEngine();
  121610. this.scene._addComponent(this);
  121611. }
  121612. /**
  121613. * Register the component to one instance of a scene.
  121614. */
  121615. OutlineRenderer.prototype.register = function () {
  121616. this.scene._beforeRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_BEFORERENDERINGMESH_OUTLINE, this, this._beforeRenderingMesh);
  121617. this.scene._afterRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDERINGMESH_OUTLINE, this, this._afterRenderingMesh);
  121618. };
  121619. /**
  121620. * Rebuilds the elements related to this component in case of
  121621. * context lost for instance.
  121622. */
  121623. OutlineRenderer.prototype.rebuild = function () {
  121624. // Nothing to do here.
  121625. };
  121626. /**
  121627. * Disposes the component and the associated ressources.
  121628. */
  121629. OutlineRenderer.prototype.dispose = function () {
  121630. // Nothing to do here.
  121631. };
  121632. /**
  121633. * Renders the outline in the canvas.
  121634. * @param subMesh Defines the sumesh to render
  121635. * @param batch Defines the batch of meshes in case of instances
  121636. * @param useOverlay Defines if the rendering is for the overlay or the outline
  121637. */
  121638. OutlineRenderer.prototype.render = function (subMesh, batch, useOverlay) {
  121639. var _this = this;
  121640. if (useOverlay === void 0) { useOverlay = false; }
  121641. var scene = this.scene;
  121642. var engine = scene.getEngine();
  121643. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  121644. if (!this.isReady(subMesh, hardwareInstancedRendering)) {
  121645. return;
  121646. }
  121647. var mesh = subMesh.getRenderingMesh();
  121648. var material = subMesh.getMaterial();
  121649. if (!material || !scene.activeCamera) {
  121650. return;
  121651. }
  121652. engine.enableEffect(this._effect);
  121653. // Logarithmic depth
  121654. if (material.useLogarithmicDepth) {
  121655. this._effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  121656. }
  121657. this._effect.setFloat("offset", useOverlay ? 0 : mesh.outlineWidth);
  121658. this._effect.setColor4("color", useOverlay ? mesh.overlayColor : mesh.outlineColor, useOverlay ? mesh.overlayAlpha : material.alpha);
  121659. this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  121660. // Bones
  121661. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  121662. this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  121663. }
  121664. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  121665. // Alpha test
  121666. if (material && material.needAlphaTesting()) {
  121667. var alphaTexture = material.getAlphaTestTexture();
  121668. if (alphaTexture) {
  121669. this._effect.setTexture("diffuseSampler", alphaTexture);
  121670. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  121671. }
  121672. }
  121673. engine.setZOffset(-this.zOffset);
  121674. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { _this._effect.setMatrix("world", world); });
  121675. engine.setZOffset(0);
  121676. };
  121677. /**
  121678. * Returns whether or not the outline renderer is ready for a given submesh.
  121679. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  121680. * @param subMesh Defines the submesh to check readyness for
  121681. * @param useInstances Defines wheter wee are trying to render instances or not
  121682. * @returns true if ready otherwise false
  121683. */
  121684. OutlineRenderer.prototype.isReady = function (subMesh, useInstances) {
  121685. var defines = [];
  121686. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].NormalKind];
  121687. var mesh = subMesh.getMesh();
  121688. var material = subMesh.getMaterial();
  121689. if (material) {
  121690. // Alpha test
  121691. if (material.needAlphaTesting()) {
  121692. defines.push("#define ALPHATEST");
  121693. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind)) {
  121694. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind);
  121695. defines.push("#define UV1");
  121696. }
  121697. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind)) {
  121698. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind);
  121699. defines.push("#define UV2");
  121700. }
  121701. }
  121702. //Logarithmic depth
  121703. if (material.useLogarithmicDepth) {
  121704. defines.push("#define LOGARITHMICDEPTH");
  121705. }
  121706. }
  121707. // Bones
  121708. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  121709. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesKind);
  121710. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsKind);
  121711. if (mesh.numBoneInfluencers > 4) {
  121712. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesExtraKind);
  121713. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsExtraKind);
  121714. }
  121715. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  121716. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  121717. }
  121718. else {
  121719. defines.push("#define NUM_BONE_INFLUENCERS 0");
  121720. }
  121721. // Instances
  121722. if (useInstances) {
  121723. defines.push("#define INSTANCES");
  121724. attribs.push("world0");
  121725. attribs.push("world1");
  121726. attribs.push("world2");
  121727. attribs.push("world3");
  121728. }
  121729. // Get correct effect
  121730. var join = defines.join("\n");
  121731. if (this._cachedDefines !== join) {
  121732. this._cachedDefines = join;
  121733. this._effect = this.scene.getEngine().createEffect("outline", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "offset", "color", "logarithmicDepthConstant"], ["diffuseSampler"], join);
  121734. }
  121735. return this._effect.isReady();
  121736. };
  121737. OutlineRenderer.prototype._beforeRenderingMesh = function (mesh, subMesh, batch) {
  121738. // Outline - step 1
  121739. this._savedDepthWrite = this._engine.getDepthWrite();
  121740. if (mesh.renderOutline) {
  121741. this._engine.setDepthWrite(false);
  121742. this.render(subMesh, batch);
  121743. this._engine.setDepthWrite(this._savedDepthWrite);
  121744. }
  121745. };
  121746. OutlineRenderer.prototype._afterRenderingMesh = function (mesh, subMesh, batch) {
  121747. // Outline - step 2
  121748. if (mesh.renderOutline && this._savedDepthWrite) {
  121749. this._engine.setDepthWrite(true);
  121750. this._engine.setColorWrite(false);
  121751. this.render(subMesh, batch);
  121752. this._engine.setColorWrite(true);
  121753. }
  121754. // Overlay
  121755. if (mesh.renderOverlay) {
  121756. var currentMode = this._engine.getAlphaMode();
  121757. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALPHA_COMBINE);
  121758. this.render(subMesh, batch, true);
  121759. this._engine.setAlphaMode(currentMode);
  121760. }
  121761. };
  121762. return OutlineRenderer;
  121763. }());
  121764. /***/ }),
  121765. /***/ "./Rendering/renderingGroup.ts":
  121766. /*!*************************************!*\
  121767. !*** ./Rendering/renderingGroup.ts ***!
  121768. \*************************************/
  121769. /*! exports provided: RenderingGroup */
  121770. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121771. "use strict";
  121772. __webpack_require__.r(__webpack_exports__);
  121773. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return RenderingGroup; });
  121774. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  121775. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  121776. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121777. /**
  121778. * This represents the object necessary to create a rendering group.
  121779. * This is exclusively used and created by the rendering manager.
  121780. * To modify the behavior, you use the available helpers in your scene or meshes.
  121781. * @hidden
  121782. */
  121783. var RenderingGroup = /** @class */ (function () {
  121784. /**
  121785. * Creates a new rendering group.
  121786. * @param index The rendering group index
  121787. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  121788. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  121789. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  121790. */
  121791. function RenderingGroup(index, scene, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  121792. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  121793. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  121794. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  121795. this.index = index;
  121796. this._opaqueSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121797. this._transparentSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121798. this._alphaTestSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121799. this._depthOnlySubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121800. this._particleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121801. this._spriteManagers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121802. this._edgesRenderers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  121803. this._scene = scene;
  121804. this.opaqueSortCompareFn = opaqueSortCompareFn;
  121805. this.alphaTestSortCompareFn = alphaTestSortCompareFn;
  121806. this.transparentSortCompareFn = transparentSortCompareFn;
  121807. }
  121808. Object.defineProperty(RenderingGroup.prototype, "opaqueSortCompareFn", {
  121809. /**
  121810. * Set the opaque sort comparison function.
  121811. * If null the sub meshes will be render in the order they were created
  121812. */
  121813. set: function (value) {
  121814. this._opaqueSortCompareFn = value;
  121815. if (value) {
  121816. this._renderOpaque = this.renderOpaqueSorted;
  121817. }
  121818. else {
  121819. this._renderOpaque = RenderingGroup.renderUnsorted;
  121820. }
  121821. },
  121822. enumerable: true,
  121823. configurable: true
  121824. });
  121825. Object.defineProperty(RenderingGroup.prototype, "alphaTestSortCompareFn", {
  121826. /**
  121827. * Set the alpha test sort comparison function.
  121828. * If null the sub meshes will be render in the order they were created
  121829. */
  121830. set: function (value) {
  121831. this._alphaTestSortCompareFn = value;
  121832. if (value) {
  121833. this._renderAlphaTest = this.renderAlphaTestSorted;
  121834. }
  121835. else {
  121836. this._renderAlphaTest = RenderingGroup.renderUnsorted;
  121837. }
  121838. },
  121839. enumerable: true,
  121840. configurable: true
  121841. });
  121842. Object.defineProperty(RenderingGroup.prototype, "transparentSortCompareFn", {
  121843. /**
  121844. * Set the transparent sort comparison function.
  121845. * If null the sub meshes will be render in the order they were created
  121846. */
  121847. set: function (value) {
  121848. if (value) {
  121849. this._transparentSortCompareFn = value;
  121850. }
  121851. else {
  121852. this._transparentSortCompareFn = RenderingGroup.defaultTransparentSortCompare;
  121853. }
  121854. this._renderTransparent = this.renderTransparentSorted;
  121855. },
  121856. enumerable: true,
  121857. configurable: true
  121858. });
  121859. /**
  121860. * Render all the sub meshes contained in the group.
  121861. * @param customRenderFunction Used to override the default render behaviour of the group.
  121862. * @returns true if rendered some submeshes.
  121863. */
  121864. RenderingGroup.prototype.render = function (customRenderFunction, renderSprites, renderParticles, activeMeshes) {
  121865. if (customRenderFunction) {
  121866. customRenderFunction(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
  121867. return;
  121868. }
  121869. var engine = this._scene.getEngine();
  121870. // Depth only
  121871. if (this._depthOnlySubMeshes.length !== 0) {
  121872. engine.setColorWrite(false);
  121873. this._renderAlphaTest(this._depthOnlySubMeshes);
  121874. engine.setColorWrite(true);
  121875. }
  121876. // Opaque
  121877. if (this._opaqueSubMeshes.length !== 0) {
  121878. this._renderOpaque(this._opaqueSubMeshes);
  121879. }
  121880. // Alpha test
  121881. if (this._alphaTestSubMeshes.length !== 0) {
  121882. this._renderAlphaTest(this._alphaTestSubMeshes);
  121883. }
  121884. var stencilState = engine.getStencilBuffer();
  121885. engine.setStencilBuffer(false);
  121886. // Sprites
  121887. if (renderSprites) {
  121888. this._renderSprites();
  121889. }
  121890. // Particles
  121891. if (renderParticles) {
  121892. this._renderParticles(activeMeshes);
  121893. }
  121894. if (this.onBeforeTransparentRendering) {
  121895. this.onBeforeTransparentRendering();
  121896. }
  121897. // Transparent
  121898. if (this._transparentSubMeshes.length !== 0) {
  121899. this._renderTransparent(this._transparentSubMeshes);
  121900. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  121901. }
  121902. // Set back stencil to false in case it changes before the edge renderer.
  121903. engine.setStencilBuffer(false);
  121904. // Edges
  121905. if (this._edgesRenderers.length) {
  121906. for (var edgesRendererIndex = 0; edgesRendererIndex < this._edgesRenderers.length; edgesRendererIndex++) {
  121907. this._edgesRenderers.data[edgesRendererIndex].render();
  121908. }
  121909. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  121910. }
  121911. // Restore Stencil state.
  121912. engine.setStencilBuffer(stencilState);
  121913. };
  121914. /**
  121915. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  121916. * @param subMeshes The submeshes to render
  121917. */
  121918. RenderingGroup.prototype.renderOpaqueSorted = function (subMeshes) {
  121919. return RenderingGroup.renderSorted(subMeshes, this._opaqueSortCompareFn, this._scene.activeCamera, false);
  121920. };
  121921. /**
  121922. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  121923. * @param subMeshes The submeshes to render
  121924. */
  121925. RenderingGroup.prototype.renderAlphaTestSorted = function (subMeshes) {
  121926. return RenderingGroup.renderSorted(subMeshes, this._alphaTestSortCompareFn, this._scene.activeCamera, false);
  121927. };
  121928. /**
  121929. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  121930. * @param subMeshes The submeshes to render
  121931. */
  121932. RenderingGroup.prototype.renderTransparentSorted = function (subMeshes) {
  121933. return RenderingGroup.renderSorted(subMeshes, this._transparentSortCompareFn, this._scene.activeCamera, true);
  121934. };
  121935. /**
  121936. * Renders the submeshes in a specified order.
  121937. * @param subMeshes The submeshes to sort before render
  121938. * @param sortCompareFn The comparison function use to sort
  121939. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  121940. * @param transparent Specifies to activate blending if true
  121941. */
  121942. RenderingGroup.renderSorted = function (subMeshes, sortCompareFn, camera, transparent) {
  121943. var subIndex = 0;
  121944. var subMesh;
  121945. var cameraPosition = camera ? camera.globalPosition : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  121946. for (; subIndex < subMeshes.length; subIndex++) {
  121947. subMesh = subMeshes.data[subIndex];
  121948. subMesh._alphaIndex = subMesh.getMesh().alphaIndex;
  121949. subMesh._distanceToCamera = subMesh.getBoundingInfo().boundingSphere.centerWorld.subtract(cameraPosition).length();
  121950. }
  121951. var sortedArray = subMeshes.data.slice(0, subMeshes.length);
  121952. if (sortCompareFn) {
  121953. sortedArray.sort(sortCompareFn);
  121954. }
  121955. for (subIndex = 0; subIndex < sortedArray.length; subIndex++) {
  121956. subMesh = sortedArray[subIndex];
  121957. if (transparent) {
  121958. var material = subMesh.getMaterial();
  121959. if (material && material.needDepthPrePass) {
  121960. var engine = material.getScene().getEngine();
  121961. engine.setColorWrite(false);
  121962. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  121963. subMesh.render(false);
  121964. engine.setColorWrite(true);
  121965. }
  121966. }
  121967. subMesh.render(transparent);
  121968. }
  121969. };
  121970. /**
  121971. * Renders the submeshes in the order they were dispatched (no sort applied).
  121972. * @param subMeshes The submeshes to render
  121973. */
  121974. RenderingGroup.renderUnsorted = function (subMeshes) {
  121975. for (var subIndex = 0; subIndex < subMeshes.length; subIndex++) {
  121976. var submesh = subMeshes.data[subIndex];
  121977. submesh.render(false);
  121978. }
  121979. };
  121980. /**
  121981. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  121982. * are rendered back to front if in the same alpha index.
  121983. *
  121984. * @param a The first submesh
  121985. * @param b The second submesh
  121986. * @returns The result of the comparison
  121987. */
  121988. RenderingGroup.defaultTransparentSortCompare = function (a, b) {
  121989. // Alpha index first
  121990. if (a._alphaIndex > b._alphaIndex) {
  121991. return 1;
  121992. }
  121993. if (a._alphaIndex < b._alphaIndex) {
  121994. return -1;
  121995. }
  121996. // Then distance to camera
  121997. return RenderingGroup.backToFrontSortCompare(a, b);
  121998. };
  121999. /**
  122000. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  122001. * are rendered back to front.
  122002. *
  122003. * @param a The first submesh
  122004. * @param b The second submesh
  122005. * @returns The result of the comparison
  122006. */
  122007. RenderingGroup.backToFrontSortCompare = function (a, b) {
  122008. // Then distance to camera
  122009. if (a._distanceToCamera < b._distanceToCamera) {
  122010. return 1;
  122011. }
  122012. if (a._distanceToCamera > b._distanceToCamera) {
  122013. return -1;
  122014. }
  122015. return 0;
  122016. };
  122017. /**
  122018. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  122019. * are rendered front to back (prevent overdraw).
  122020. *
  122021. * @param a The first submesh
  122022. * @param b The second submesh
  122023. * @returns The result of the comparison
  122024. */
  122025. RenderingGroup.frontToBackSortCompare = function (a, b) {
  122026. // Then distance to camera
  122027. if (a._distanceToCamera < b._distanceToCamera) {
  122028. return -1;
  122029. }
  122030. if (a._distanceToCamera > b._distanceToCamera) {
  122031. return 1;
  122032. }
  122033. return 0;
  122034. };
  122035. /**
  122036. * Resets the different lists of submeshes to prepare a new frame.
  122037. */
  122038. RenderingGroup.prototype.prepare = function () {
  122039. this._opaqueSubMeshes.reset();
  122040. this._transparentSubMeshes.reset();
  122041. this._alphaTestSubMeshes.reset();
  122042. this._depthOnlySubMeshes.reset();
  122043. this._particleSystems.reset();
  122044. this._spriteManagers.reset();
  122045. this._edgesRenderers.reset();
  122046. };
  122047. RenderingGroup.prototype.dispose = function () {
  122048. this._opaqueSubMeshes.dispose();
  122049. this._transparentSubMeshes.dispose();
  122050. this._alphaTestSubMeshes.dispose();
  122051. this._depthOnlySubMeshes.dispose();
  122052. this._particleSystems.dispose();
  122053. this._spriteManagers.dispose();
  122054. this._edgesRenderers.dispose();
  122055. };
  122056. /**
  122057. * Inserts the submesh in its correct queue depending on its material.
  122058. * @param subMesh The submesh to dispatch
  122059. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  122060. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  122061. */
  122062. RenderingGroup.prototype.dispatch = function (subMesh, mesh, material) {
  122063. // Get mesh and materials if not provided
  122064. if (mesh === undefined) {
  122065. mesh = subMesh.getMesh();
  122066. }
  122067. if (material === undefined) {
  122068. material = subMesh.getMaterial();
  122069. }
  122070. if (material === null || material === undefined) {
  122071. return;
  122072. }
  122073. if (material.needAlphaBlendingForMesh(mesh)) { // Transparent
  122074. this._transparentSubMeshes.push(subMesh);
  122075. }
  122076. else if (material.needAlphaTesting()) { // Alpha test
  122077. if (material.needDepthPrePass) {
  122078. this._depthOnlySubMeshes.push(subMesh);
  122079. }
  122080. this._alphaTestSubMeshes.push(subMesh);
  122081. }
  122082. else {
  122083. if (material.needDepthPrePass) {
  122084. this._depthOnlySubMeshes.push(subMesh);
  122085. }
  122086. this._opaqueSubMeshes.push(subMesh); // Opaque
  122087. }
  122088. if (mesh._edgesRenderer && mesh._edgesRenderer.isEnabled) {
  122089. this._edgesRenderers.push(mesh._edgesRenderer);
  122090. }
  122091. };
  122092. RenderingGroup.prototype.dispatchSprites = function (spriteManager) {
  122093. this._spriteManagers.push(spriteManager);
  122094. };
  122095. RenderingGroup.prototype.dispatchParticles = function (particleSystem) {
  122096. this._particleSystems.push(particleSystem);
  122097. };
  122098. RenderingGroup.prototype._renderParticles = function (activeMeshes) {
  122099. if (this._particleSystems.length === 0) {
  122100. return;
  122101. }
  122102. // Particles
  122103. var activeCamera = this._scene.activeCamera;
  122104. this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);
  122105. for (var particleIndex = 0; particleIndex < this._particleSystems.length; particleIndex++) {
  122106. var particleSystem = this._particleSystems.data[particleIndex];
  122107. if ((activeCamera && activeCamera.layerMask & particleSystem.layerMask) === 0) {
  122108. continue;
  122109. }
  122110. var emitter = particleSystem.emitter;
  122111. if (!emitter.position || !activeMeshes || activeMeshes.indexOf(emitter) !== -1) {
  122112. this._scene._activeParticles.addCount(particleSystem.render(), false);
  122113. }
  122114. }
  122115. this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene);
  122116. };
  122117. RenderingGroup.prototype._renderSprites = function () {
  122118. if (!this._scene.spritesEnabled || this._spriteManagers.length === 0) {
  122119. return;
  122120. }
  122121. // Sprites
  122122. var activeCamera = this._scene.activeCamera;
  122123. this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);
  122124. for (var id = 0; id < this._spriteManagers.length; id++) {
  122125. var spriteManager = this._spriteManagers.data[id];
  122126. if (((activeCamera && activeCamera.layerMask & spriteManager.layerMask) !== 0)) {
  122127. spriteManager.render();
  122128. }
  122129. }
  122130. this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene);
  122131. };
  122132. return RenderingGroup;
  122133. }());
  122134. /***/ }),
  122135. /***/ "./Rendering/renderingManager.ts":
  122136. /*!***************************************!*\
  122137. !*** ./Rendering/renderingManager.ts ***!
  122138. \***************************************/
  122139. /*! exports provided: RenderingGroupInfo, RenderingManager */
  122140. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122141. "use strict";
  122142. __webpack_require__.r(__webpack_exports__);
  122143. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return RenderingGroupInfo; });
  122144. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return RenderingManager; });
  122145. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  122146. /**
  122147. * This class is used by the onRenderingGroupObservable
  122148. */
  122149. var RenderingGroupInfo = /** @class */ (function () {
  122150. function RenderingGroupInfo() {
  122151. }
  122152. return RenderingGroupInfo;
  122153. }());
  122154. /**
  122155. * This is the manager responsible of all the rendering for meshes sprites and particles.
  122156. * It is enable to manage the different groups as well as the different necessary sort functions.
  122157. * This should not be used directly aside of the few static configurations
  122158. */
  122159. var RenderingManager = /** @class */ (function () {
  122160. /**
  122161. * Instantiates a new rendering group for a particular scene
  122162. * @param scene Defines the scene the groups belongs to
  122163. */
  122164. function RenderingManager(scene) {
  122165. /**
  122166. * @hidden
  122167. */
  122168. this._useSceneAutoClearSetup = false;
  122169. this._renderingGroups = new Array();
  122170. this._autoClearDepthStencil = {};
  122171. this._customOpaqueSortCompareFn = {};
  122172. this._customAlphaTestSortCompareFn = {};
  122173. this._customTransparentSortCompareFn = {};
  122174. this._renderingGroupInfo = new RenderingGroupInfo();
  122175. this._scene = scene;
  122176. for (var i = RenderingManager.MIN_RENDERINGGROUPS; i < RenderingManager.MAX_RENDERINGGROUPS; i++) {
  122177. this._autoClearDepthStencil[i] = { autoClear: true, depth: true, stencil: true };
  122178. }
  122179. }
  122180. RenderingManager.prototype._clearDepthStencilBuffer = function (depth, stencil) {
  122181. if (depth === void 0) { depth = true; }
  122182. if (stencil === void 0) { stencil = true; }
  122183. if (this._depthStencilBufferAlreadyCleaned) {
  122184. return;
  122185. }
  122186. this._scene.getEngine().clear(null, false, depth, stencil);
  122187. this._depthStencilBufferAlreadyCleaned = true;
  122188. };
  122189. /**
  122190. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  122191. * @hidden
  122192. */
  122193. RenderingManager.prototype.render = function (customRenderFunction, activeMeshes, renderParticles, renderSprites) {
  122194. // Update the observable context (not null as it only goes away on dispose)
  122195. var info = this._renderingGroupInfo;
  122196. info.scene = this._scene;
  122197. info.camera = this._scene.activeCamera;
  122198. // Dispatch sprites
  122199. if (this._scene.spriteManagers && renderSprites) {
  122200. for (var index = 0; index < this._scene.spriteManagers.length; index++) {
  122201. var manager = this._scene.spriteManagers[index];
  122202. this.dispatchSprites(manager);
  122203. }
  122204. }
  122205. // Render
  122206. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  122207. this._depthStencilBufferAlreadyCleaned = index === RenderingManager.MIN_RENDERINGGROUPS;
  122208. var renderingGroup = this._renderingGroups[index];
  122209. if (!renderingGroup) {
  122210. continue;
  122211. }
  122212. var renderingGroupMask = Math.pow(2, index);
  122213. info.renderingGroupId = index;
  122214. // Before Observable
  122215. this._scene.onBeforeRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  122216. // Clear depth/stencil if needed
  122217. if (RenderingManager.AUTOCLEAR) {
  122218. var autoClear = this._useSceneAutoClearSetup ?
  122219. this._scene.getAutoClearDepthStencilSetup(index) :
  122220. this._autoClearDepthStencil[index];
  122221. if (autoClear && autoClear.autoClear) {
  122222. this._clearDepthStencilBuffer(autoClear.depth, autoClear.stencil);
  122223. }
  122224. }
  122225. // Render
  122226. for (var _i = 0, _a = this._scene._beforeRenderingGroupDrawStage; _i < _a.length; _i++) {
  122227. var step = _a[_i];
  122228. step.action(index);
  122229. }
  122230. renderingGroup.render(customRenderFunction, renderSprites, renderParticles, activeMeshes);
  122231. for (var _b = 0, _c = this._scene._afterRenderingGroupDrawStage; _b < _c.length; _b++) {
  122232. var step = _c[_b];
  122233. step.action(index);
  122234. }
  122235. // After Observable
  122236. this._scene.onAfterRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  122237. }
  122238. };
  122239. /**
  122240. * Resets the different information of the group to prepare a new frame
  122241. * @hidden
  122242. */
  122243. RenderingManager.prototype.reset = function () {
  122244. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  122245. var renderingGroup = this._renderingGroups[index];
  122246. if (renderingGroup) {
  122247. renderingGroup.prepare();
  122248. }
  122249. }
  122250. };
  122251. /**
  122252. * Dispose and release the group and its associated resources.
  122253. * @hidden
  122254. */
  122255. RenderingManager.prototype.dispose = function () {
  122256. this.freeRenderingGroups();
  122257. this._renderingGroups.length = 0;
  122258. this._renderingGroupInfo = null;
  122259. };
  122260. /**
  122261. * Clear the info related to rendering groups preventing retention points during dispose.
  122262. */
  122263. RenderingManager.prototype.freeRenderingGroups = function () {
  122264. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  122265. var renderingGroup = this._renderingGroups[index];
  122266. if (renderingGroup) {
  122267. renderingGroup.dispose();
  122268. }
  122269. }
  122270. };
  122271. RenderingManager.prototype._prepareRenderingGroup = function (renderingGroupId) {
  122272. if (this._renderingGroups[renderingGroupId] === undefined) {
  122273. this._renderingGroups[renderingGroupId] = new _renderingGroup__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"](renderingGroupId, this._scene, this._customOpaqueSortCompareFn[renderingGroupId], this._customAlphaTestSortCompareFn[renderingGroupId], this._customTransparentSortCompareFn[renderingGroupId]);
  122274. }
  122275. };
  122276. /**
  122277. * Add a sprite manager to the rendering manager in order to render it this frame.
  122278. * @param spriteManager Define the sprite manager to render
  122279. */
  122280. RenderingManager.prototype.dispatchSprites = function (spriteManager) {
  122281. var renderingGroupId = spriteManager.renderingGroupId || 0;
  122282. this._prepareRenderingGroup(renderingGroupId);
  122283. this._renderingGroups[renderingGroupId].dispatchSprites(spriteManager);
  122284. };
  122285. /**
  122286. * Add a particle system to the rendering manager in order to render it this frame.
  122287. * @param particleSystem Define the particle system to render
  122288. */
  122289. RenderingManager.prototype.dispatchParticles = function (particleSystem) {
  122290. var renderingGroupId = particleSystem.renderingGroupId || 0;
  122291. this._prepareRenderingGroup(renderingGroupId);
  122292. this._renderingGroups[renderingGroupId].dispatchParticles(particleSystem);
  122293. };
  122294. /**
  122295. * Add a submesh to the manager in order to render it this frame
  122296. * @param subMesh The submesh to dispatch
  122297. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  122298. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  122299. */
  122300. RenderingManager.prototype.dispatch = function (subMesh, mesh, material) {
  122301. if (mesh === undefined) {
  122302. mesh = subMesh.getMesh();
  122303. }
  122304. var renderingGroupId = mesh.renderingGroupId || 0;
  122305. this._prepareRenderingGroup(renderingGroupId);
  122306. this._renderingGroups[renderingGroupId].dispatch(subMesh, mesh, material);
  122307. };
  122308. /**
  122309. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  122310. * This allowed control for front to back rendering or reversly depending of the special needs.
  122311. *
  122312. * @param renderingGroupId The rendering group id corresponding to its index
  122313. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  122314. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  122315. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  122316. */
  122317. RenderingManager.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  122318. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  122319. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  122320. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  122321. this._customOpaqueSortCompareFn[renderingGroupId] = opaqueSortCompareFn;
  122322. this._customAlphaTestSortCompareFn[renderingGroupId] = alphaTestSortCompareFn;
  122323. this._customTransparentSortCompareFn[renderingGroupId] = transparentSortCompareFn;
  122324. if (this._renderingGroups[renderingGroupId]) {
  122325. var group = this._renderingGroups[renderingGroupId];
  122326. group.opaqueSortCompareFn = this._customOpaqueSortCompareFn[renderingGroupId];
  122327. group.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[renderingGroupId];
  122328. group.transparentSortCompareFn = this._customTransparentSortCompareFn[renderingGroupId];
  122329. }
  122330. };
  122331. /**
  122332. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  122333. *
  122334. * @param renderingGroupId The rendering group id corresponding to its index
  122335. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  122336. * @param depth Automatically clears depth between groups if true and autoClear is true.
  122337. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  122338. */
  122339. RenderingManager.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  122340. if (depth === void 0) { depth = true; }
  122341. if (stencil === void 0) { stencil = true; }
  122342. this._autoClearDepthStencil[renderingGroupId] = {
  122343. autoClear: autoClearDepthStencil,
  122344. depth: depth,
  122345. stencil: stencil
  122346. };
  122347. };
  122348. /**
  122349. * Gets the current auto clear configuration for one rendering group of the rendering
  122350. * manager.
  122351. * @param index the rendering group index to get the information for
  122352. * @returns The auto clear setup for the requested rendering group
  122353. */
  122354. RenderingManager.prototype.getAutoClearDepthStencilSetup = function (index) {
  122355. return this._autoClearDepthStencil[index];
  122356. };
  122357. /**
  122358. * The max id used for rendering groups (not included)
  122359. */
  122360. RenderingManager.MAX_RENDERINGGROUPS = 4;
  122361. /**
  122362. * The min id used for rendering groups (included)
  122363. */
  122364. RenderingManager.MIN_RENDERINGGROUPS = 0;
  122365. /**
  122366. * Used to globally prevent autoclearing scenes.
  122367. */
  122368. RenderingManager.AUTOCLEAR = true;
  122369. return RenderingManager;
  122370. }());
  122371. /***/ }),
  122372. /***/ "./Rendering/utilityLayerRenderer.ts":
  122373. /*!*******************************************!*\
  122374. !*** ./Rendering/utilityLayerRenderer.ts ***!
  122375. \*******************************************/
  122376. /*! exports provided: UtilityLayerRenderer */
  122377. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122378. "use strict";
  122379. __webpack_require__.r(__webpack_exports__);
  122380. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return UtilityLayerRenderer; });
  122381. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  122382. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  122383. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  122384. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  122385. /**
  122386. * Renders a layer on top of an existing scene
  122387. */
  122388. var UtilityLayerRenderer = /** @class */ (function () {
  122389. /**
  122390. * Instantiates a UtilityLayerRenderer
  122391. * @param originalScene the original scene that will be rendered on top of
  122392. * @param handleEvents boolean indicating if the utility layer should handle events
  122393. */
  122394. function UtilityLayerRenderer(
  122395. /** the original scene that will be rendered on top of */
  122396. originalScene, handleEvents) {
  122397. if (handleEvents === void 0) { handleEvents = true; }
  122398. var _this = this;
  122399. this.originalScene = originalScene;
  122400. this._pointerCaptures = {};
  122401. this._lastPointerEvents = {};
  122402. /**
  122403. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  122404. */
  122405. this.pickUtilitySceneFirst = true;
  122406. /**
  122407. * If the utility layer should automatically be rendered on top of existing scene
  122408. */
  122409. this.shouldRender = true;
  122410. /**
  122411. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  122412. */
  122413. this.onlyCheckPointerDownEvents = true;
  122414. /**
  122415. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  122416. */
  122417. this.processAllEvents = false;
  122418. /**
  122419. * Observable raised when the pointer move from the utility layer scene to the main scene
  122420. */
  122421. this.onPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  122422. // Create scene which will be rendered in the foreground and remove it from being referenced by engine to avoid interfering with existing app
  122423. this.utilityLayerScene = new _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"](originalScene.getEngine());
  122424. this.utilityLayerScene.useRightHandedSystem = originalScene.useRightHandedSystem;
  122425. this.utilityLayerScene._allowPostProcessClearColor = false;
  122426. originalScene.getEngine().scenes.pop();
  122427. // Detach controls on utility scene, events will be fired by logic below to handle picking priority
  122428. this.utilityLayerScene.detachControl();
  122429. if (handleEvents) {
  122430. this._originalPointerObserver = originalScene.onPrePointerObservable.add(function (prePointerInfo, eventState) {
  122431. if (!_this.utilityLayerScene.activeCamera) {
  122432. return;
  122433. }
  122434. if (!_this.processAllEvents) {
  122435. if (prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE
  122436. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP
  122437. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  122438. return;
  122439. }
  122440. }
  122441. _this.utilityLayerScene.pointerX = originalScene.pointerX;
  122442. _this.utilityLayerScene.pointerY = originalScene.pointerY;
  122443. var pointerEvent = (prePointerInfo.event);
  122444. if (originalScene.isPointerCaptured(pointerEvent.pointerId)) {
  122445. _this._pointerCaptures[pointerEvent.pointerId] = false;
  122446. return;
  122447. }
  122448. var utilityScenePick = prePointerInfo.ray ? _this.utilityLayerScene.pickWithRay(prePointerInfo.ray) : _this.utilityLayerScene.pick(originalScene.pointerX, originalScene.pointerY);
  122449. if (!prePointerInfo.ray && utilityScenePick) {
  122450. prePointerInfo.ray = utilityScenePick.ray;
  122451. }
  122452. // always fire the prepointer oversvable
  122453. _this.utilityLayerScene.onPrePointerObservable.notifyObservers(prePointerInfo);
  122454. // allow every non pointer down event to flow to the utility layer
  122455. if (_this.onlyCheckPointerDownEvents && prePointerInfo.type != _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  122456. if (!prePointerInfo.skipOnPointerObservable) {
  122457. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  122458. }
  122459. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent.pointerId]) {
  122460. _this._pointerCaptures[pointerEvent.pointerId] = false;
  122461. }
  122462. return;
  122463. }
  122464. if (_this.utilityLayerScene.autoClearDepthAndStencil || _this.pickUtilitySceneFirst) {
  122465. // If this layer is an overlay, check if this layer was hit and if so, skip pointer events for the main scene
  122466. if (utilityScenePick && utilityScenePick.hit) {
  122467. if (!prePointerInfo.skipOnPointerObservable) {
  122468. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  122469. }
  122470. prePointerInfo.skipOnPointerObservable = true;
  122471. }
  122472. }
  122473. else {
  122474. var originalScenePick = prePointerInfo.ray ? originalScene.pickWithRay(prePointerInfo.ray) : originalScene.pick(originalScene.pointerX, originalScene.pointerY);
  122475. var pointerEvent_1 = (prePointerInfo.event);
  122476. // If the layer can be occluded by the original scene, only fire pointer events to the first layer that hit they ray
  122477. if (originalScenePick && utilityScenePick) {
  122478. // No pick in utility scene
  122479. if (utilityScenePick.distance === 0 && originalScenePick.pickedMesh) {
  122480. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  122481. // We touched an utility mesh present in the main scene
  122482. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  122483. prePointerInfo.skipOnPointerObservable = true;
  122484. }
  122485. else if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  122486. _this._pointerCaptures[pointerEvent_1.pointerId] = true;
  122487. }
  122488. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  122489. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  122490. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  122491. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  122492. }
  122493. }
  122494. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance < originalScenePick.distance || originalScenePick.distance === 0)) {
  122495. // We pick something in utility scene or the pick in utility is closer than the one in main scene
  122496. _this._notifyObservers(prePointerInfo, utilityScenePick, pointerEvent_1);
  122497. // If a previous utility layer set this, do not unset this
  122498. if (!prePointerInfo.skipOnPointerObservable) {
  122499. prePointerInfo.skipOnPointerObservable = utilityScenePick.distance > 0;
  122500. }
  122501. }
  122502. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance > originalScenePick.distance)) {
  122503. // We have a pick in both scenes but main is closer than utility
  122504. // We touched an utility mesh present in the main scene
  122505. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  122506. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  122507. prePointerInfo.skipOnPointerObservable = true;
  122508. }
  122509. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  122510. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  122511. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  122512. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  122513. }
  122514. }
  122515. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent_1.pointerId]) {
  122516. _this._pointerCaptures[pointerEvent_1.pointerId] = false;
  122517. }
  122518. }
  122519. }
  122520. });
  122521. }
  122522. // Render directly on top of existing scene without clearing
  122523. this.utilityLayerScene.autoClear = false;
  122524. this._afterRenderObserver = this.originalScene.onAfterRenderObservable.add(function () {
  122525. if (_this.shouldRender) {
  122526. _this.render();
  122527. }
  122528. });
  122529. this._sceneDisposeObserver = this.originalScene.onDisposeObservable.add(function () {
  122530. _this.dispose();
  122531. });
  122532. this._updateCamera();
  122533. }
  122534. Object.defineProperty(UtilityLayerRenderer, "DefaultUtilityLayer", {
  122535. /**
  122536. * 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)
  122537. */
  122538. get: function () {
  122539. if (UtilityLayerRenderer._DefaultUtilityLayer == null) {
  122540. UtilityLayerRenderer._DefaultUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  122541. UtilityLayerRenderer._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  122542. UtilityLayerRenderer._DefaultUtilityLayer = null;
  122543. });
  122544. }
  122545. return UtilityLayerRenderer._DefaultUtilityLayer;
  122546. },
  122547. enumerable: true,
  122548. configurable: true
  122549. });
  122550. Object.defineProperty(UtilityLayerRenderer, "DefaultKeepDepthUtilityLayer", {
  122551. /**
  122552. * 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)
  122553. */
  122554. get: function () {
  122555. if (UtilityLayerRenderer._DefaultKeepDepthUtilityLayer == null) {
  122556. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  122557. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  122558. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  122559. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  122560. });
  122561. }
  122562. return UtilityLayerRenderer._DefaultKeepDepthUtilityLayer;
  122563. },
  122564. enumerable: true,
  122565. configurable: true
  122566. });
  122567. UtilityLayerRenderer.prototype._notifyObservers = function (prePointerInfo, pickInfo, pointerEvent) {
  122568. if (!prePointerInfo.skipOnPointerObservable) {
  122569. this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, pickInfo));
  122570. this._lastPointerEvents[pointerEvent.pointerId] = true;
  122571. }
  122572. };
  122573. /**
  122574. * Renders the utility layers scene on top of the original scene
  122575. */
  122576. UtilityLayerRenderer.prototype.render = function () {
  122577. this._updateCamera();
  122578. if (this.utilityLayerScene.activeCamera) {
  122579. // Set the camera's scene to utility layers scene
  122580. var oldScene = this.utilityLayerScene.activeCamera.getScene();
  122581. var camera = this.utilityLayerScene.activeCamera;
  122582. camera._scene = this.utilityLayerScene;
  122583. if (camera.leftCamera) {
  122584. camera.leftCamera._scene = this.utilityLayerScene;
  122585. }
  122586. if (camera.rightCamera) {
  122587. camera.rightCamera._scene = this.utilityLayerScene;
  122588. }
  122589. this.utilityLayerScene.render(false);
  122590. // Reset camera's scene back to original
  122591. camera._scene = oldScene;
  122592. if (camera.leftCamera) {
  122593. camera.leftCamera._scene = oldScene;
  122594. }
  122595. if (camera.rightCamera) {
  122596. camera.rightCamera._scene = oldScene;
  122597. }
  122598. }
  122599. };
  122600. /**
  122601. * Disposes of the renderer
  122602. */
  122603. UtilityLayerRenderer.prototype.dispose = function () {
  122604. this.onPointerOutObservable.clear();
  122605. if (this._afterRenderObserver) {
  122606. this.originalScene.onAfterRenderObservable.remove(this._afterRenderObserver);
  122607. }
  122608. if (this._sceneDisposeObserver) {
  122609. this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver);
  122610. }
  122611. if (this._originalPointerObserver) {
  122612. this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver);
  122613. }
  122614. this.utilityLayerScene.dispose();
  122615. };
  122616. UtilityLayerRenderer.prototype._updateCamera = function () {
  122617. if (this.originalScene.activeCameras.length > 1) {
  122618. this.utilityLayerScene.activeCamera = this.originalScene.activeCameras[this.originalScene.activeCameras.length - 1];
  122619. }
  122620. else {
  122621. this.utilityLayerScene.activeCamera = this.originalScene.activeCamera;
  122622. }
  122623. };
  122624. UtilityLayerRenderer._DefaultUtilityLayer = null;
  122625. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  122626. return UtilityLayerRenderer;
  122627. }());
  122628. /***/ }),
  122629. /***/ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts":
  122630. /*!*****************************************************************!*\
  122631. !*** ./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts ***!
  122632. \*****************************************************************/
  122633. /*! exports provided: backgroundFragmentDeclaration */
  122634. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122635. "use strict";
  122636. __webpack_require__.r(__webpack_exports__);
  122637. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundFragmentDeclaration", function() { return backgroundFragmentDeclaration; });
  122638. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122639. var name = 'backgroundFragmentDeclaration';
  122640. 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";
  122641. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122642. /** @hidden */
  122643. var backgroundFragmentDeclaration = { name: name, shader: shader };
  122644. /***/ }),
  122645. /***/ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts":
  122646. /*!************************************************************!*\
  122647. !*** ./Shaders/ShadersInclude/backgroundUboDeclaration.ts ***!
  122648. \************************************************************/
  122649. /*! exports provided: backgroundUboDeclaration */
  122650. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122651. "use strict";
  122652. __webpack_require__.r(__webpack_exports__);
  122653. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundUboDeclaration", function() { return backgroundUboDeclaration; });
  122654. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122655. var name = 'backgroundUboDeclaration';
  122656. 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};";
  122657. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122658. /** @hidden */
  122659. var backgroundUboDeclaration = { name: name, shader: shader };
  122660. /***/ }),
  122661. /***/ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts":
  122662. /*!***************************************************************!*\
  122663. !*** ./Shaders/ShadersInclude/backgroundVertexDeclaration.ts ***!
  122664. \***************************************************************/
  122665. /*! exports provided: backgroundVertexDeclaration */
  122666. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122667. "use strict";
  122668. __webpack_require__.r(__webpack_exports__);
  122669. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexDeclaration", function() { return backgroundVertexDeclaration; });
  122670. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122671. var name = 'backgroundVertexDeclaration';
  122672. 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";
  122673. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122674. /** @hidden */
  122675. var backgroundVertexDeclaration = { name: name, shader: shader };
  122676. /***/ }),
  122677. /***/ "./Shaders/ShadersInclude/bonesDeclaration.ts":
  122678. /*!****************************************************!*\
  122679. !*** ./Shaders/ShadersInclude/bonesDeclaration.ts ***!
  122680. \****************************************************/
  122681. /*! exports provided: bonesDeclaration */
  122682. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122683. "use strict";
  122684. __webpack_require__.r(__webpack_exports__);
  122685. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesDeclaration", function() { return bonesDeclaration; });
  122686. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122687. var name = 'bonesDeclaration';
  122688. 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";
  122689. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122690. /** @hidden */
  122691. var bonesDeclaration = { name: name, shader: shader };
  122692. /***/ }),
  122693. /***/ "./Shaders/ShadersInclude/bonesVertex.ts":
  122694. /*!***********************************************!*\
  122695. !*** ./Shaders/ShadersInclude/bonesVertex.ts ***!
  122696. \***********************************************/
  122697. /*! exports provided: bonesVertex */
  122698. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122699. "use strict";
  122700. __webpack_require__.r(__webpack_exports__);
  122701. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesVertex", function() { return bonesVertex; });
  122702. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122703. var name = 'bonesVertex';
  122704. 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";
  122705. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122706. /** @hidden */
  122707. var bonesVertex = { name: name, shader: shader };
  122708. /***/ }),
  122709. /***/ "./Shaders/ShadersInclude/bumpFragment.ts":
  122710. /*!************************************************!*\
  122711. !*** ./Shaders/ShadersInclude/bumpFragment.ts ***!
  122712. \************************************************/
  122713. /*! exports provided: bumpFragment */
  122714. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122715. "use strict";
  122716. __webpack_require__.r(__webpack_exports__);
  122717. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragment", function() { return bumpFragment; });
  122718. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122719. var name = 'bumpFragment';
  122720. 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";
  122721. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122722. /** @hidden */
  122723. var bumpFragment = { name: name, shader: shader };
  122724. /***/ }),
  122725. /***/ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts":
  122726. /*!*********************************************************!*\
  122727. !*** ./Shaders/ShadersInclude/bumpFragmentFunctions.ts ***!
  122728. \*********************************************************/
  122729. /*! exports provided: bumpFragmentFunctions */
  122730. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122731. "use strict";
  122732. __webpack_require__.r(__webpack_exports__);
  122733. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragmentFunctions", function() { return bumpFragmentFunctions; });
  122734. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122735. var name = 'bumpFragmentFunctions';
  122736. 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";
  122737. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122738. /** @hidden */
  122739. var bumpFragmentFunctions = { name: name, shader: shader };
  122740. /***/ }),
  122741. /***/ "./Shaders/ShadersInclude/bumpVertex.ts":
  122742. /*!**********************************************!*\
  122743. !*** ./Shaders/ShadersInclude/bumpVertex.ts ***!
  122744. \**********************************************/
  122745. /*! exports provided: bumpVertex */
  122746. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122747. "use strict";
  122748. __webpack_require__.r(__webpack_exports__);
  122749. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertex", function() { return bumpVertex; });
  122750. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122751. var name = 'bumpVertex';
  122752. 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";
  122753. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122754. /** @hidden */
  122755. var bumpVertex = { name: name, shader: shader };
  122756. /***/ }),
  122757. /***/ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts":
  122758. /*!*********************************************************!*\
  122759. !*** ./Shaders/ShadersInclude/bumpVertexDeclaration.ts ***!
  122760. \*********************************************************/
  122761. /*! exports provided: bumpVertexDeclaration */
  122762. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122763. "use strict";
  122764. __webpack_require__.r(__webpack_exports__);
  122765. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertexDeclaration", function() { return bumpVertexDeclaration; });
  122766. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122767. var name = 'bumpVertexDeclaration';
  122768. var shader = "#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#endif\n";
  122769. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122770. /** @hidden */
  122771. var bumpVertexDeclaration = { name: name, shader: shader };
  122772. /***/ }),
  122773. /***/ "./Shaders/ShadersInclude/clipPlaneFragment.ts":
  122774. /*!*****************************************************!*\
  122775. !*** ./Shaders/ShadersInclude/clipPlaneFragment.ts ***!
  122776. \*****************************************************/
  122777. /*! exports provided: clipPlaneFragment */
  122778. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122779. "use strict";
  122780. __webpack_require__.r(__webpack_exports__);
  122781. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragment", function() { return clipPlaneFragment; });
  122782. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122783. var name = 'clipPlaneFragment';
  122784. 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";
  122785. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122786. /** @hidden */
  122787. var clipPlaneFragment = { name: name, shader: shader };
  122788. /***/ }),
  122789. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts":
  122790. /*!****************************************************************!*\
  122791. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts ***!
  122792. \****************************************************************/
  122793. /*! exports provided: clipPlaneFragmentDeclaration */
  122794. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122795. "use strict";
  122796. __webpack_require__.r(__webpack_exports__);
  122797. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration", function() { return clipPlaneFragmentDeclaration; });
  122798. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122799. var name = 'clipPlaneFragmentDeclaration';
  122800. 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";
  122801. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122802. /** @hidden */
  122803. var clipPlaneFragmentDeclaration = { name: name, shader: shader };
  122804. /***/ }),
  122805. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts":
  122806. /*!*****************************************************************!*\
  122807. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts ***!
  122808. \*****************************************************************/
  122809. /*! exports provided: clipPlaneFragmentDeclaration2 */
  122810. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122811. "use strict";
  122812. __webpack_require__.r(__webpack_exports__);
  122813. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration2", function() { return clipPlaneFragmentDeclaration2; });
  122814. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122815. var name = 'clipPlaneFragmentDeclaration2';
  122816. 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";
  122817. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122818. /** @hidden */
  122819. var clipPlaneFragmentDeclaration2 = { name: name, shader: shader };
  122820. /***/ }),
  122821. /***/ "./Shaders/ShadersInclude/clipPlaneVertex.ts":
  122822. /*!***************************************************!*\
  122823. !*** ./Shaders/ShadersInclude/clipPlaneVertex.ts ***!
  122824. \***************************************************/
  122825. /*! exports provided: clipPlaneVertex */
  122826. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122827. "use strict";
  122828. __webpack_require__.r(__webpack_exports__);
  122829. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertex", function() { return clipPlaneVertex; });
  122830. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122831. var name = 'clipPlaneVertex';
  122832. 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";
  122833. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122834. /** @hidden */
  122835. var clipPlaneVertex = { name: name, shader: shader };
  122836. /***/ }),
  122837. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts":
  122838. /*!**************************************************************!*\
  122839. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts ***!
  122840. \**************************************************************/
  122841. /*! exports provided: clipPlaneVertexDeclaration */
  122842. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122843. "use strict";
  122844. __webpack_require__.r(__webpack_exports__);
  122845. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration", function() { return clipPlaneVertexDeclaration; });
  122846. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122847. var name = 'clipPlaneVertexDeclaration';
  122848. 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";
  122849. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122850. /** @hidden */
  122851. var clipPlaneVertexDeclaration = { name: name, shader: shader };
  122852. /***/ }),
  122853. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts":
  122854. /*!***************************************************************!*\
  122855. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts ***!
  122856. \***************************************************************/
  122857. /*! exports provided: clipPlaneVertexDeclaration2 */
  122858. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122859. "use strict";
  122860. __webpack_require__.r(__webpack_exports__);
  122861. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration2", function() { return clipPlaneVertexDeclaration2; });
  122862. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122863. var name = 'clipPlaneVertexDeclaration2';
  122864. 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";
  122865. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122866. /** @hidden */
  122867. var clipPlaneVertexDeclaration2 = { name: name, shader: shader };
  122868. /***/ }),
  122869. /***/ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts":
  122870. /*!**************************************************************!*\
  122871. !*** ./Shaders/ShadersInclude/defaultFragmentDeclaration.ts ***!
  122872. \**************************************************************/
  122873. /*! exports provided: defaultFragmentDeclaration */
  122874. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122875. "use strict";
  122876. __webpack_require__.r(__webpack_exports__);
  122877. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultFragmentDeclaration", function() { return defaultFragmentDeclaration; });
  122878. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122879. var name = 'defaultFragmentDeclaration';
  122880. 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";
  122881. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122882. /** @hidden */
  122883. var defaultFragmentDeclaration = { name: name, shader: shader };
  122884. /***/ }),
  122885. /***/ "./Shaders/ShadersInclude/defaultUboDeclaration.ts":
  122886. /*!*********************************************************!*\
  122887. !*** ./Shaders/ShadersInclude/defaultUboDeclaration.ts ***!
  122888. \*********************************************************/
  122889. /*! exports provided: defaultUboDeclaration */
  122890. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122891. "use strict";
  122892. __webpack_require__.r(__webpack_exports__);
  122893. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultUboDeclaration", function() { return defaultUboDeclaration; });
  122894. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122895. var name = 'defaultUboDeclaration';
  122896. 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};";
  122897. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122898. /** @hidden */
  122899. var defaultUboDeclaration = { name: name, shader: shader };
  122900. /***/ }),
  122901. /***/ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts":
  122902. /*!************************************************************!*\
  122903. !*** ./Shaders/ShadersInclude/defaultVertexDeclaration.ts ***!
  122904. \************************************************************/
  122905. /*! exports provided: defaultVertexDeclaration */
  122906. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122907. "use strict";
  122908. __webpack_require__.r(__webpack_exports__);
  122909. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexDeclaration", function() { return defaultVertexDeclaration; });
  122910. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122911. var name = 'defaultVertexDeclaration';
  122912. 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";
  122913. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122914. /** @hidden */
  122915. var defaultVertexDeclaration = { name: name, shader: shader };
  122916. /***/ }),
  122917. /***/ "./Shaders/ShadersInclude/depthPrePass.ts":
  122918. /*!************************************************!*\
  122919. !*** ./Shaders/ShadersInclude/depthPrePass.ts ***!
  122920. \************************************************/
  122921. /*! exports provided: depthPrePass */
  122922. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122923. "use strict";
  122924. __webpack_require__.r(__webpack_exports__);
  122925. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPrePass", function() { return depthPrePass; });
  122926. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122927. var name = 'depthPrePass';
  122928. var shader = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";
  122929. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122930. /** @hidden */
  122931. var depthPrePass = { name: name, shader: shader };
  122932. /***/ }),
  122933. /***/ "./Shaders/ShadersInclude/fogFragment.ts":
  122934. /*!***********************************************!*\
  122935. !*** ./Shaders/ShadersInclude/fogFragment.ts ***!
  122936. \***********************************************/
  122937. /*! exports provided: fogFragment */
  122938. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122939. "use strict";
  122940. __webpack_require__.r(__webpack_exports__);
  122941. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragment", function() { return fogFragment; });
  122942. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122943. var name = 'fogFragment';
  122944. var shader = "#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";
  122945. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122946. /** @hidden */
  122947. var fogFragment = { name: name, shader: shader };
  122948. /***/ }),
  122949. /***/ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts":
  122950. /*!**********************************************************!*\
  122951. !*** ./Shaders/ShadersInclude/fogFragmentDeclaration.ts ***!
  122952. \**********************************************************/
  122953. /*! exports provided: fogFragmentDeclaration */
  122954. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122955. "use strict";
  122956. __webpack_require__.r(__webpack_exports__);
  122957. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragmentDeclaration", function() { return fogFragmentDeclaration; });
  122958. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122959. var name = 'fogFragmentDeclaration';
  122960. 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";
  122961. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122962. /** @hidden */
  122963. var fogFragmentDeclaration = { name: name, shader: shader };
  122964. /***/ }),
  122965. /***/ "./Shaders/ShadersInclude/fogVertex.ts":
  122966. /*!*********************************************!*\
  122967. !*** ./Shaders/ShadersInclude/fogVertex.ts ***!
  122968. \*********************************************/
  122969. /*! exports provided: fogVertex */
  122970. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122971. "use strict";
  122972. __webpack_require__.r(__webpack_exports__);
  122973. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertex", function() { return fogVertex; });
  122974. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122975. var name = 'fogVertex';
  122976. var shader = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";
  122977. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122978. /** @hidden */
  122979. var fogVertex = { name: name, shader: shader };
  122980. /***/ }),
  122981. /***/ "./Shaders/ShadersInclude/fogVertexDeclaration.ts":
  122982. /*!********************************************************!*\
  122983. !*** ./Shaders/ShadersInclude/fogVertexDeclaration.ts ***!
  122984. \********************************************************/
  122985. /*! exports provided: fogVertexDeclaration */
  122986. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122987. "use strict";
  122988. __webpack_require__.r(__webpack_exports__);
  122989. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertexDeclaration", function() { return fogVertexDeclaration; });
  122990. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122991. var name = 'fogVertexDeclaration';
  122992. var shader = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";
  122993. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122994. /** @hidden */
  122995. var fogVertexDeclaration = { name: name, shader: shader };
  122996. /***/ }),
  122997. /***/ "./Shaders/ShadersInclude/fresnelFunction.ts":
  122998. /*!***************************************************!*\
  122999. !*** ./Shaders/ShadersInclude/fresnelFunction.ts ***!
  123000. \***************************************************/
  123001. /*! exports provided: fresnelFunction */
  123002. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123003. "use strict";
  123004. __webpack_require__.r(__webpack_exports__);
  123005. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fresnelFunction", function() { return fresnelFunction; });
  123006. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123007. var name = 'fresnelFunction';
  123008. 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";
  123009. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123010. /** @hidden */
  123011. var fresnelFunction = { name: name, shader: shader };
  123012. /***/ }),
  123013. /***/ "./Shaders/ShadersInclude/harmonicsFunctions.ts":
  123014. /*!******************************************************!*\
  123015. !*** ./Shaders/ShadersInclude/harmonicsFunctions.ts ***!
  123016. \******************************************************/
  123017. /*! exports provided: harmonicsFunctions */
  123018. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123019. "use strict";
  123020. __webpack_require__.r(__webpack_exports__);
  123021. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "harmonicsFunctions", function() { return harmonicsFunctions; });
  123022. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123023. var name = 'harmonicsFunctions';
  123024. 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";
  123025. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123026. /** @hidden */
  123027. var harmonicsFunctions = { name: name, shader: shader };
  123028. /***/ }),
  123029. /***/ "./Shaders/ShadersInclude/helperFunctions.ts":
  123030. /*!***************************************************!*\
  123031. !*** ./Shaders/ShadersInclude/helperFunctions.ts ***!
  123032. \***************************************************/
  123033. /*! exports provided: helperFunctions */
  123034. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123035. "use strict";
  123036. __webpack_require__.r(__webpack_exports__);
  123037. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "helperFunctions", function() { return helperFunctions; });
  123038. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123039. var name = 'helperFunctions';
  123040. 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}";
  123041. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123042. /** @hidden */
  123043. var helperFunctions = { name: name, shader: shader };
  123044. /***/ }),
  123045. /***/ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts":
  123046. /*!**************************************************************!*\
  123047. !*** ./Shaders/ShadersInclude/imageProcessingDeclaration.ts ***!
  123048. \**************************************************************/
  123049. /*! exports provided: imageProcessingDeclaration */
  123050. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123051. "use strict";
  123052. __webpack_require__.r(__webpack_exports__);
  123053. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingDeclaration", function() { return imageProcessingDeclaration; });
  123054. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123055. var name = 'imageProcessingDeclaration';
  123056. 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";
  123057. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123058. /** @hidden */
  123059. var imageProcessingDeclaration = { name: name, shader: shader };
  123060. /***/ }),
  123061. /***/ "./Shaders/ShadersInclude/imageProcessingFunctions.ts":
  123062. /*!************************************************************!*\
  123063. !*** ./Shaders/ShadersInclude/imageProcessingFunctions.ts ***!
  123064. \************************************************************/
  123065. /*! exports provided: imageProcessingFunctions */
  123066. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123067. "use strict";
  123068. __webpack_require__.r(__webpack_exports__);
  123069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingFunctions", function() { return imageProcessingFunctions; });
  123070. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123071. var name = 'imageProcessingFunctions';
  123072. 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}";
  123073. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123074. /** @hidden */
  123075. var imageProcessingFunctions = { name: name, shader: shader };
  123076. /***/ }),
  123077. /***/ "./Shaders/ShadersInclude/instancesDeclaration.ts":
  123078. /*!********************************************************!*\
  123079. !*** ./Shaders/ShadersInclude/instancesDeclaration.ts ***!
  123080. \********************************************************/
  123081. /*! exports provided: instancesDeclaration */
  123082. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123083. "use strict";
  123084. __webpack_require__.r(__webpack_exports__);
  123085. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesDeclaration", function() { return instancesDeclaration; });
  123086. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123087. var name = 'instancesDeclaration';
  123088. var shader = "#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif";
  123089. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123090. /** @hidden */
  123091. var instancesDeclaration = { name: name, shader: shader };
  123092. /***/ }),
  123093. /***/ "./Shaders/ShadersInclude/instancesVertex.ts":
  123094. /*!***************************************************!*\
  123095. !*** ./Shaders/ShadersInclude/instancesVertex.ts ***!
  123096. \***************************************************/
  123097. /*! exports provided: instancesVertex */
  123098. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123099. "use strict";
  123100. __webpack_require__.r(__webpack_exports__);
  123101. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesVertex", function() { return instancesVertex; });
  123102. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123103. var name = 'instancesVertex';
  123104. var shader = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";
  123105. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123106. /** @hidden */
  123107. var instancesVertex = { name: name, shader: shader };
  123108. /***/ }),
  123109. /***/ "./Shaders/ShadersInclude/kernelBlurFragment.ts":
  123110. /*!******************************************************!*\
  123111. !*** ./Shaders/ShadersInclude/kernelBlurFragment.ts ***!
  123112. \******************************************************/
  123113. /*! exports provided: kernelBlurFragment */
  123114. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123115. "use strict";
  123116. __webpack_require__.r(__webpack_exports__);
  123117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment", function() { return kernelBlurFragment; });
  123118. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123119. var name = 'kernelBlurFragment';
  123120. 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";
  123121. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123122. /** @hidden */
  123123. var kernelBlurFragment = { name: name, shader: shader };
  123124. /***/ }),
  123125. /***/ "./Shaders/ShadersInclude/kernelBlurFragment2.ts":
  123126. /*!*******************************************************!*\
  123127. !*** ./Shaders/ShadersInclude/kernelBlurFragment2.ts ***!
  123128. \*******************************************************/
  123129. /*! exports provided: kernelBlurFragment2 */
  123130. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123131. "use strict";
  123132. __webpack_require__.r(__webpack_exports__);
  123133. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment2", function() { return kernelBlurFragment2; });
  123134. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123135. var name = 'kernelBlurFragment2';
  123136. 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";
  123137. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123138. /** @hidden */
  123139. var kernelBlurFragment2 = { name: name, shader: shader };
  123140. /***/ }),
  123141. /***/ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts":
  123142. /*!****************************************************************!*\
  123143. !*** ./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts ***!
  123144. \****************************************************************/
  123145. /*! exports provided: kernelBlurVaryingDeclaration */
  123146. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123147. "use strict";
  123148. __webpack_require__.r(__webpack_exports__);
  123149. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVaryingDeclaration", function() { return kernelBlurVaryingDeclaration; });
  123150. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123151. var name = 'kernelBlurVaryingDeclaration';
  123152. var shader = "varying vec2 sampleCoord{X};";
  123153. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123154. /** @hidden */
  123155. var kernelBlurVaryingDeclaration = { name: name, shader: shader };
  123156. /***/ }),
  123157. /***/ "./Shaders/ShadersInclude/kernelBlurVertex.ts":
  123158. /*!****************************************************!*\
  123159. !*** ./Shaders/ShadersInclude/kernelBlurVertex.ts ***!
  123160. \****************************************************/
  123161. /*! exports provided: kernelBlurVertex */
  123162. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123163. "use strict";
  123164. __webpack_require__.r(__webpack_exports__);
  123165. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertex", function() { return kernelBlurVertex; });
  123166. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123167. var name = 'kernelBlurVertex';
  123168. var shader = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
  123169. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123170. /** @hidden */
  123171. var kernelBlurVertex = { name: name, shader: shader };
  123172. /***/ }),
  123173. /***/ "./Shaders/ShadersInclude/lightFragment.ts":
  123174. /*!*************************************************!*\
  123175. !*** ./Shaders/ShadersInclude/lightFragment.ts ***!
  123176. \*************************************************/
  123177. /*! exports provided: lightFragment */
  123178. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123179. "use strict";
  123180. __webpack_require__.r(__webpack_exports__);
  123181. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragment", function() { return lightFragment; });
  123182. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123183. var name = 'lightFragment';
  123184. 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";
  123185. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123186. /** @hidden */
  123187. var lightFragment = { name: name, shader: shader };
  123188. /***/ }),
  123189. /***/ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts":
  123190. /*!************************************************************!*\
  123191. !*** ./Shaders/ShadersInclude/lightFragmentDeclaration.ts ***!
  123192. \************************************************************/
  123193. /*! exports provided: lightFragmentDeclaration */
  123194. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123195. "use strict";
  123196. __webpack_require__.r(__webpack_exports__);
  123197. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragmentDeclaration", function() { return lightFragmentDeclaration; });
  123198. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123199. var name = 'lightFragmentDeclaration';
  123200. 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";
  123201. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123202. /** @hidden */
  123203. var lightFragmentDeclaration = { name: name, shader: shader };
  123204. /***/ }),
  123205. /***/ "./Shaders/ShadersInclude/lightUboDeclaration.ts":
  123206. /*!*******************************************************!*\
  123207. !*** ./Shaders/ShadersInclude/lightUboDeclaration.ts ***!
  123208. \*******************************************************/
  123209. /*! exports provided: lightUboDeclaration */
  123210. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123211. "use strict";
  123212. __webpack_require__.r(__webpack_exports__);
  123213. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightUboDeclaration", function() { return lightUboDeclaration; });
  123214. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123215. var name = 'lightUboDeclaration';
  123216. 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";
  123217. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123218. /** @hidden */
  123219. var lightUboDeclaration = { name: name, shader: shader };
  123220. /***/ }),
  123221. /***/ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts":
  123222. /*!***********************************************************!*\
  123223. !*** ./Shaders/ShadersInclude/lightsFragmentFunctions.ts ***!
  123224. \***********************************************************/
  123225. /*! exports provided: lightsFragmentFunctions */
  123226. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123227. "use strict";
  123228. __webpack_require__.r(__webpack_exports__);
  123229. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightsFragmentFunctions", function() { return lightsFragmentFunctions; });
  123230. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123231. var name = 'lightsFragmentFunctions';
  123232. 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}";
  123233. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123234. /** @hidden */
  123235. var lightsFragmentFunctions = { name: name, shader: shader };
  123236. /***/ }),
  123237. /***/ "./Shaders/ShadersInclude/logDepthDeclaration.ts":
  123238. /*!*******************************************************!*\
  123239. !*** ./Shaders/ShadersInclude/logDepthDeclaration.ts ***!
  123240. \*******************************************************/
  123241. /*! exports provided: logDepthDeclaration */
  123242. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123243. "use strict";
  123244. __webpack_require__.r(__webpack_exports__);
  123245. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthDeclaration", function() { return logDepthDeclaration; });
  123246. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123247. var name = 'logDepthDeclaration';
  123248. var shader = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";
  123249. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123250. /** @hidden */
  123251. var logDepthDeclaration = { name: name, shader: shader };
  123252. /***/ }),
  123253. /***/ "./Shaders/ShadersInclude/logDepthFragment.ts":
  123254. /*!****************************************************!*\
  123255. !*** ./Shaders/ShadersInclude/logDepthFragment.ts ***!
  123256. \****************************************************/
  123257. /*! exports provided: logDepthFragment */
  123258. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123259. "use strict";
  123260. __webpack_require__.r(__webpack_exports__);
  123261. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthFragment", function() { return logDepthFragment; });
  123262. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123263. var name = 'logDepthFragment';
  123264. var shader = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";
  123265. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123266. /** @hidden */
  123267. var logDepthFragment = { name: name, shader: shader };
  123268. /***/ }),
  123269. /***/ "./Shaders/ShadersInclude/logDepthVertex.ts":
  123270. /*!**************************************************!*\
  123271. !*** ./Shaders/ShadersInclude/logDepthVertex.ts ***!
  123272. \**************************************************/
  123273. /*! exports provided: logDepthVertex */
  123274. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123275. "use strict";
  123276. __webpack_require__.r(__webpack_exports__);
  123277. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthVertex", function() { return logDepthVertex; });
  123278. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123279. var name = 'logDepthVertex';
  123280. var shader = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";
  123281. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123282. /** @hidden */
  123283. var logDepthVertex = { name: name, shader: shader };
  123284. /***/ }),
  123285. /***/ "./Shaders/ShadersInclude/morphTargetsVertex.ts":
  123286. /*!******************************************************!*\
  123287. !*** ./Shaders/ShadersInclude/morphTargetsVertex.ts ***!
  123288. \******************************************************/
  123289. /*! exports provided: morphTargetsVertex */
  123290. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123291. "use strict";
  123292. __webpack_require__.r(__webpack_exports__);
  123293. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertex", function() { return morphTargetsVertex; });
  123294. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123295. var name = 'morphTargetsVertex';
  123296. 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";
  123297. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123298. /** @hidden */
  123299. var morphTargetsVertex = { name: name, shader: shader };
  123300. /***/ }),
  123301. /***/ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts":
  123302. /*!*****************************************************************!*\
  123303. !*** ./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts ***!
  123304. \*****************************************************************/
  123305. /*! exports provided: morphTargetsVertexDeclaration */
  123306. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123307. "use strict";
  123308. __webpack_require__.r(__webpack_exports__);
  123309. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexDeclaration", function() { return morphTargetsVertexDeclaration; });
  123310. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123311. var name = 'morphTargetsVertexDeclaration';
  123312. 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";
  123313. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123314. /** @hidden */
  123315. var morphTargetsVertexDeclaration = { name: name, shader: shader };
  123316. /***/ }),
  123317. /***/ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts":
  123318. /*!***********************************************************************!*\
  123319. !*** ./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts ***!
  123320. \***********************************************************************/
  123321. /*! exports provided: morphTargetsVertexGlobalDeclaration */
  123322. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123323. "use strict";
  123324. __webpack_require__.r(__webpack_exports__);
  123325. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexGlobalDeclaration", function() { return morphTargetsVertexGlobalDeclaration; });
  123326. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123327. var name = 'morphTargetsVertexGlobalDeclaration';
  123328. var shader = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";
  123329. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123330. /** @hidden */
  123331. var morphTargetsVertexGlobalDeclaration = { name: name, shader: shader };
  123332. /***/ }),
  123333. /***/ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts":
  123334. /*!**********************************************************!*\
  123335. !*** ./Shaders/ShadersInclude/mrtFragmentDeclaration.ts ***!
  123336. \**********************************************************/
  123337. /*! exports provided: mrtFragmentDeclaration */
  123338. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123339. "use strict";
  123340. __webpack_require__.r(__webpack_exports__);
  123341. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mrtFragmentDeclaration", function() { return mrtFragmentDeclaration; });
  123342. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123343. var name = 'mrtFragmentDeclaration';
  123344. var shader = "#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";
  123345. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123346. /** @hidden */
  123347. var mrtFragmentDeclaration = { name: name, shader: shader };
  123348. /***/ }),
  123349. /***/ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts":
  123350. /*!**********************************************************!*\
  123351. !*** ./Shaders/ShadersInclude/pbrFragmentDeclaration.ts ***!
  123352. \**********************************************************/
  123353. /*! exports provided: pbrFragmentDeclaration */
  123354. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123355. "use strict";
  123356. __webpack_require__.r(__webpack_exports__);
  123357. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentDeclaration", function() { return pbrFragmentDeclaration; });
  123358. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123359. var name = 'pbrFragmentDeclaration';
  123360. 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";
  123361. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123362. /** @hidden */
  123363. var pbrFragmentDeclaration = { name: name, shader: shader };
  123364. /***/ }),
  123365. /***/ "./Shaders/ShadersInclude/pbrFunctions.ts":
  123366. /*!************************************************!*\
  123367. !*** ./Shaders/ShadersInclude/pbrFunctions.ts ***!
  123368. \************************************************/
  123369. /*! exports provided: pbrFunctions */
  123370. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123371. "use strict";
  123372. __webpack_require__.r(__webpack_exports__);
  123373. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFunctions", function() { return pbrFunctions; });
  123374. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123375. var name = 'pbrFunctions';
  123376. 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}";
  123377. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123378. /** @hidden */
  123379. var pbrFunctions = { name: name, shader: shader };
  123380. /***/ }),
  123381. /***/ "./Shaders/ShadersInclude/pbrLightFunctions.ts":
  123382. /*!*****************************************************!*\
  123383. !*** ./Shaders/ShadersInclude/pbrLightFunctions.ts ***!
  123384. \*****************************************************/
  123385. /*! exports provided: pbrLightFunctions */
  123386. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123387. "use strict";
  123388. __webpack_require__.r(__webpack_exports__);
  123389. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrLightFunctions", function() { return pbrLightFunctions; });
  123390. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123391. var name = 'pbrLightFunctions';
  123392. 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}";
  123393. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123394. /** @hidden */
  123395. var pbrLightFunctions = { name: name, shader: shader };
  123396. /***/ }),
  123397. /***/ "./Shaders/ShadersInclude/pbrUboDeclaration.ts":
  123398. /*!*****************************************************!*\
  123399. !*** ./Shaders/ShadersInclude/pbrUboDeclaration.ts ***!
  123400. \*****************************************************/
  123401. /*! exports provided: pbrUboDeclaration */
  123402. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123403. "use strict";
  123404. __webpack_require__.r(__webpack_exports__);
  123405. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrUboDeclaration", function() { return pbrUboDeclaration; });
  123406. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123407. var name = 'pbrUboDeclaration';
  123408. 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};";
  123409. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123410. /** @hidden */
  123411. var pbrUboDeclaration = { name: name, shader: shader };
  123412. /***/ }),
  123413. /***/ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts":
  123414. /*!********************************************************!*\
  123415. !*** ./Shaders/ShadersInclude/pbrVertexDeclaration.ts ***!
  123416. \********************************************************/
  123417. /*! exports provided: pbrVertexDeclaration */
  123418. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123419. "use strict";
  123420. __webpack_require__.r(__webpack_exports__);
  123421. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexDeclaration", function() { return pbrVertexDeclaration; });
  123422. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123423. var name = 'pbrVertexDeclaration';
  123424. 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";
  123425. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123426. /** @hidden */
  123427. var pbrVertexDeclaration = { name: name, shader: shader };
  123428. /***/ }),
  123429. /***/ "./Shaders/ShadersInclude/pointCloudVertex.ts":
  123430. /*!****************************************************!*\
  123431. !*** ./Shaders/ShadersInclude/pointCloudVertex.ts ***!
  123432. \****************************************************/
  123433. /*! exports provided: pointCloudVertex */
  123434. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123435. "use strict";
  123436. __webpack_require__.r(__webpack_exports__);
  123437. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pointCloudVertex", function() { return pointCloudVertex; });
  123438. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123439. var name = 'pointCloudVertex';
  123440. var shader = "#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";
  123441. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123442. /** @hidden */
  123443. var pointCloudVertex = { name: name, shader: shader };
  123444. /***/ }),
  123445. /***/ "./Shaders/ShadersInclude/reflectionFunction.ts":
  123446. /*!******************************************************!*\
  123447. !*** ./Shaders/ShadersInclude/reflectionFunction.ts ***!
  123448. \******************************************************/
  123449. /*! exports provided: reflectionFunction */
  123450. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123451. "use strict";
  123452. __webpack_require__.r(__webpack_exports__);
  123453. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reflectionFunction", function() { return reflectionFunction; });
  123454. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123455. var name = 'reflectionFunction';
  123456. 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}";
  123457. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123458. /** @hidden */
  123459. var reflectionFunction = { name: name, shader: shader };
  123460. /***/ }),
  123461. /***/ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts":
  123462. /*!************************************************************!*\
  123463. !*** ./Shaders/ShadersInclude/shadowsFragmentFunctions.ts ***!
  123464. \************************************************************/
  123465. /*! exports provided: shadowsFragmentFunctions */
  123466. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123467. "use strict";
  123468. __webpack_require__.r(__webpack_exports__);
  123469. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsFragmentFunctions", function() { return shadowsFragmentFunctions; });
  123470. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123471. var name = 'shadowsFragmentFunctions';
  123472. 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";
  123473. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123474. /** @hidden */
  123475. var shadowsFragmentFunctions = { name: name, shader: shader };
  123476. /***/ }),
  123477. /***/ "./Shaders/ShadersInclude/shadowsVertex.ts":
  123478. /*!*************************************************!*\
  123479. !*** ./Shaders/ShadersInclude/shadowsVertex.ts ***!
  123480. \*************************************************/
  123481. /*! exports provided: shadowsVertex */
  123482. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123483. "use strict";
  123484. __webpack_require__.r(__webpack_exports__);
  123485. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsVertex", function() { return shadowsVertex; });
  123486. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123487. var name = 'shadowsVertex';
  123488. 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";
  123489. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123490. /** @hidden */
  123491. var shadowsVertex = { name: name, shader: shader };
  123492. /***/ }),
  123493. /***/ "./Shaders/anaglyph.fragment.ts":
  123494. /*!**************************************!*\
  123495. !*** ./Shaders/anaglyph.fragment.ts ***!
  123496. \**************************************/
  123497. /*! exports provided: anaglyphPixelShader */
  123498. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123499. "use strict";
  123500. __webpack_require__.r(__webpack_exports__);
  123501. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "anaglyphPixelShader", function() { return anaglyphPixelShader; });
  123502. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123503. var name = 'anaglyphPixelShader';
  123504. 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}";
  123505. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123506. /** @hidden */
  123507. var anaglyphPixelShader = { name: name, shader: shader };
  123508. /***/ }),
  123509. /***/ "./Shaders/background.fragment.ts":
  123510. /*!****************************************!*\
  123511. !*** ./Shaders/background.fragment.ts ***!
  123512. \****************************************/
  123513. /*! exports provided: backgroundPixelShader */
  123514. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123515. "use strict";
  123516. __webpack_require__.r(__webpack_exports__);
  123517. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundPixelShader", function() { return backgroundPixelShader; });
  123518. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123519. /* harmony import */ var _ShadersInclude_backgroundFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundFragmentDeclaration */ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts");
  123520. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  123521. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  123522. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  123523. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123524. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123525. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123526. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  123527. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  123528. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  123529. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  123530. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  123531. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  123532. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  123533. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  123534. var name = 'backgroundPixelShader';
  123535. 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";
  123536. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123537. /** @hidden */
  123538. var backgroundPixelShader = { name: name, shader: shader };
  123539. /***/ }),
  123540. /***/ "./Shaders/background.vertex.ts":
  123541. /*!**************************************!*\
  123542. !*** ./Shaders/background.vertex.ts ***!
  123543. \**************************************/
  123544. /*! exports provided: backgroundVertexShader */
  123545. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123546. "use strict";
  123547. __webpack_require__.r(__webpack_exports__);
  123548. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexShader", function() { return backgroundVertexShader; });
  123549. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123550. /* harmony import */ var _ShadersInclude_backgroundVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundVertexDeclaration */ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts");
  123551. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  123552. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123553. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123554. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123555. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  123556. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  123557. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123558. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123559. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123560. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123561. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  123562. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  123563. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  123564. var name = 'backgroundVertexShader';
  123565. 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";
  123566. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123567. /** @hidden */
  123568. var backgroundVertexShader = { name: name, shader: shader };
  123569. /***/ }),
  123570. /***/ "./Shaders/blackAndWhite.fragment.ts":
  123571. /*!*******************************************!*\
  123572. !*** ./Shaders/blackAndWhite.fragment.ts ***!
  123573. \*******************************************/
  123574. /*! exports provided: blackAndWhitePixelShader */
  123575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123576. "use strict";
  123577. __webpack_require__.r(__webpack_exports__);
  123578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "blackAndWhitePixelShader", function() { return blackAndWhitePixelShader; });
  123579. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123580. var name = 'blackAndWhitePixelShader';
  123581. 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}";
  123582. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123583. /** @hidden */
  123584. var blackAndWhitePixelShader = { name: name, shader: shader };
  123585. /***/ }),
  123586. /***/ "./Shaders/bloomMerge.fragment.ts":
  123587. /*!****************************************!*\
  123588. !*** ./Shaders/bloomMerge.fragment.ts ***!
  123589. \****************************************/
  123590. /*! exports provided: bloomMergePixelShader */
  123591. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123592. "use strict";
  123593. __webpack_require__.r(__webpack_exports__);
  123594. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bloomMergePixelShader", function() { return bloomMergePixelShader; });
  123595. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123596. var name = 'bloomMergePixelShader';
  123597. 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";
  123598. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123599. /** @hidden */
  123600. var bloomMergePixelShader = { name: name, shader: shader };
  123601. /***/ }),
  123602. /***/ "./Shaders/chromaticAberration.fragment.ts":
  123603. /*!*************************************************!*\
  123604. !*** ./Shaders/chromaticAberration.fragment.ts ***!
  123605. \*************************************************/
  123606. /*! exports provided: chromaticAberrationPixelShader */
  123607. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123608. "use strict";
  123609. __webpack_require__.r(__webpack_exports__);
  123610. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "chromaticAberrationPixelShader", function() { return chromaticAberrationPixelShader; });
  123611. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123612. var name = 'chromaticAberrationPixelShader';
  123613. 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}";
  123614. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123615. /** @hidden */
  123616. var chromaticAberrationPixelShader = { name: name, shader: shader };
  123617. /***/ }),
  123618. /***/ "./Shaders/circleOfConfusion.fragment.ts":
  123619. /*!***********************************************!*\
  123620. !*** ./Shaders/circleOfConfusion.fragment.ts ***!
  123621. \***********************************************/
  123622. /*! exports provided: circleOfConfusionPixelShader */
  123623. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123624. "use strict";
  123625. __webpack_require__.r(__webpack_exports__);
  123626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "circleOfConfusionPixelShader", function() { return circleOfConfusionPixelShader; });
  123627. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123628. var name = 'circleOfConfusionPixelShader';
  123629. 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";
  123630. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123631. /** @hidden */
  123632. var circleOfConfusionPixelShader = { name: name, shader: shader };
  123633. /***/ }),
  123634. /***/ "./Shaders/color.fragment.ts":
  123635. /*!***********************************!*\
  123636. !*** ./Shaders/color.fragment.ts ***!
  123637. \***********************************/
  123638. /*! exports provided: colorPixelShader */
  123639. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123640. "use strict";
  123641. __webpack_require__.r(__webpack_exports__);
  123642. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorPixelShader", function() { return colorPixelShader; });
  123643. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123644. var name = 'colorPixelShader';
  123645. 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}";
  123646. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123647. /** @hidden */
  123648. var colorPixelShader = { name: name, shader: shader };
  123649. /***/ }),
  123650. /***/ "./Shaders/color.vertex.ts":
  123651. /*!*********************************!*\
  123652. !*** ./Shaders/color.vertex.ts ***!
  123653. \*********************************/
  123654. /*! exports provided: colorVertexShader */
  123655. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123656. "use strict";
  123657. __webpack_require__.r(__webpack_exports__);
  123658. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorVertexShader", function() { return colorVertexShader; });
  123659. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123660. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123661. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123662. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123663. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123664. var name = 'colorVertexShader';
  123665. 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}";
  123666. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123667. /** @hidden */
  123668. var colorVertexShader = { name: name, shader: shader };
  123669. /***/ }),
  123670. /***/ "./Shaders/colorCorrection.fragment.ts":
  123671. /*!*********************************************!*\
  123672. !*** ./Shaders/colorCorrection.fragment.ts ***!
  123673. \*********************************************/
  123674. /*! exports provided: colorCorrectionPixelShader */
  123675. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123676. "use strict";
  123677. __webpack_require__.r(__webpack_exports__);
  123678. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorCorrectionPixelShader", function() { return colorCorrectionPixelShader; });
  123679. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123680. var name = 'colorCorrectionPixelShader';
  123681. 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}";
  123682. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123683. /** @hidden */
  123684. var colorCorrectionPixelShader = { name: name, shader: shader };
  123685. /***/ }),
  123686. /***/ "./Shaders/convolution.fragment.ts":
  123687. /*!*****************************************!*\
  123688. !*** ./Shaders/convolution.fragment.ts ***!
  123689. \*****************************************/
  123690. /*! exports provided: convolutionPixelShader */
  123691. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123692. "use strict";
  123693. __webpack_require__.r(__webpack_exports__);
  123694. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convolutionPixelShader", function() { return convolutionPixelShader; });
  123695. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123696. var name = 'convolutionPixelShader';
  123697. 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}";
  123698. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123699. /** @hidden */
  123700. var convolutionPixelShader = { name: name, shader: shader };
  123701. /***/ }),
  123702. /***/ "./Shaders/default.fragment.ts":
  123703. /*!*************************************!*\
  123704. !*** ./Shaders/default.fragment.ts ***!
  123705. \*************************************/
  123706. /*! exports provided: defaultPixelShader */
  123707. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123708. "use strict";
  123709. __webpack_require__.r(__webpack_exports__);
  123710. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultPixelShader", function() { return defaultPixelShader; });
  123711. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123712. /* harmony import */ var _ShadersInclude_defaultFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultFragmentDeclaration */ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts");
  123713. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  123714. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123715. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123716. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123717. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  123718. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  123719. /* harmony import */ var _ShadersInclude_fresnelFunction__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fresnelFunction */ "./Shaders/ShadersInclude/fresnelFunction.ts");
  123720. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  123721. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  123722. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  123723. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  123724. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  123725. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  123726. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  123727. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  123728. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  123729. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  123730. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  123731. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  123732. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  123733. var name = 'defaultPixelShader';
  123734. 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";
  123735. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123736. /** @hidden */
  123737. var defaultPixelShader = { name: name, shader: shader };
  123738. /***/ }),
  123739. /***/ "./Shaders/default.vertex.ts":
  123740. /*!***********************************!*\
  123741. !*** ./Shaders/default.vertex.ts ***!
  123742. \***********************************/
  123743. /*! exports provided: defaultVertexShader */
  123744. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123745. "use strict";
  123746. __webpack_require__.r(__webpack_exports__);
  123747. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexShader", function() { return defaultVertexShader; });
  123748. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123749. /* harmony import */ var _ShadersInclude_defaultVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultVertexDeclaration */ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts");
  123750. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  123751. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123752. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123753. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123754. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  123755. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  123756. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  123757. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123758. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123759. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  123760. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  123761. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  123762. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  123763. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123764. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123765. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  123766. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  123767. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  123768. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  123769. /* harmony import */ var _ShadersInclude_pointCloudVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/pointCloudVertex */ "./Shaders/ShadersInclude/pointCloudVertex.ts");
  123770. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  123771. var name = 'defaultVertexShader';
  123772. 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";
  123773. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123774. /** @hidden */
  123775. var defaultVertexShader = { name: name, shader: shader };
  123776. /***/ }),
  123777. /***/ "./Shaders/depth.fragment.ts":
  123778. /*!***********************************!*\
  123779. !*** ./Shaders/depth.fragment.ts ***!
  123780. \***********************************/
  123781. /*! exports provided: depthPixelShader */
  123782. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123783. "use strict";
  123784. __webpack_require__.r(__webpack_exports__);
  123785. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPixelShader", function() { return depthPixelShader; });
  123786. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123787. var name = 'depthPixelShader';
  123788. 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}";
  123789. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123790. /** @hidden */
  123791. var depthPixelShader = { name: name, shader: shader };
  123792. /***/ }),
  123793. /***/ "./Shaders/depth.vertex.ts":
  123794. /*!*********************************!*\
  123795. !*** ./Shaders/depth.vertex.ts ***!
  123796. \*********************************/
  123797. /*! exports provided: depthVertexShader */
  123798. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123799. "use strict";
  123800. __webpack_require__.r(__webpack_exports__);
  123801. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthVertexShader", function() { return depthVertexShader; });
  123802. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123803. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123804. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123805. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123806. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123807. var name = 'depthVertexShader';
  123808. 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}";
  123809. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123810. /** @hidden */
  123811. var depthVertexShader = { name: name, shader: shader };
  123812. /***/ }),
  123813. /***/ "./Shaders/depthBoxBlur.fragment.ts":
  123814. /*!******************************************!*\
  123815. !*** ./Shaders/depthBoxBlur.fragment.ts ***!
  123816. \******************************************/
  123817. /*! exports provided: depthBoxBlurPixelShader */
  123818. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123819. "use strict";
  123820. __webpack_require__.r(__webpack_exports__);
  123821. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthBoxBlurPixelShader", function() { return depthBoxBlurPixelShader; });
  123822. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123823. var name = 'depthBoxBlurPixelShader';
  123824. 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}";
  123825. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123826. /** @hidden */
  123827. var depthBoxBlurPixelShader = { name: name, shader: shader };
  123828. /***/ }),
  123829. /***/ "./Shaders/depthOfField.fragment.ts":
  123830. /*!******************************************!*\
  123831. !*** ./Shaders/depthOfField.fragment.ts ***!
  123832. \******************************************/
  123833. /*! exports provided: depthOfFieldPixelShader */
  123834. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123835. "use strict";
  123836. __webpack_require__.r(__webpack_exports__);
  123837. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldPixelShader", function() { return depthOfFieldPixelShader; });
  123838. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123839. var name = 'depthOfFieldPixelShader';
  123840. 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";
  123841. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123842. /** @hidden */
  123843. var depthOfFieldPixelShader = { name: name, shader: shader };
  123844. /***/ }),
  123845. /***/ "./Shaders/depthOfFieldMerge.fragment.ts":
  123846. /*!***********************************************!*\
  123847. !*** ./Shaders/depthOfFieldMerge.fragment.ts ***!
  123848. \***********************************************/
  123849. /*! exports provided: depthOfFieldMergePixelShader */
  123850. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123851. "use strict";
  123852. __webpack_require__.r(__webpack_exports__);
  123853. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldMergePixelShader", function() { return depthOfFieldMergePixelShader; });
  123854. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123855. var name = 'depthOfFieldMergePixelShader';
  123856. 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";
  123857. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123858. /** @hidden */
  123859. var depthOfFieldMergePixelShader = { name: name, shader: shader };
  123860. /***/ }),
  123861. /***/ "./Shaders/displayPass.fragment.ts":
  123862. /*!*****************************************!*\
  123863. !*** ./Shaders/displayPass.fragment.ts ***!
  123864. \*****************************************/
  123865. /*! exports provided: displayPassPixelShader */
  123866. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123867. "use strict";
  123868. __webpack_require__.r(__webpack_exports__);
  123869. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayPassPixelShader", function() { return displayPassPixelShader; });
  123870. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123871. var name = 'displayPassPixelShader';
  123872. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}";
  123873. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123874. /** @hidden */
  123875. var displayPassPixelShader = { name: name, shader: shader };
  123876. /***/ }),
  123877. /***/ "./Shaders/extractHighlights.fragment.ts":
  123878. /*!***********************************************!*\
  123879. !*** ./Shaders/extractHighlights.fragment.ts ***!
  123880. \***********************************************/
  123881. /*! exports provided: extractHighlightsPixelShader */
  123882. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123883. "use strict";
  123884. __webpack_require__.r(__webpack_exports__);
  123885. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractHighlightsPixelShader", function() { return extractHighlightsPixelShader; });
  123886. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123887. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123888. var name = 'extractHighlightsPixelShader';
  123889. 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}";
  123890. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123891. /** @hidden */
  123892. var extractHighlightsPixelShader = { name: name, shader: shader };
  123893. /***/ }),
  123894. /***/ "./Shaders/filter.fragment.ts":
  123895. /*!************************************!*\
  123896. !*** ./Shaders/filter.fragment.ts ***!
  123897. \************************************/
  123898. /*! exports provided: filterPixelShader */
  123899. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123900. "use strict";
  123901. __webpack_require__.r(__webpack_exports__);
  123902. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "filterPixelShader", function() { return filterPixelShader; });
  123903. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123904. var name = 'filterPixelShader';
  123905. 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}";
  123906. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123907. /** @hidden */
  123908. var filterPixelShader = { name: name, shader: shader };
  123909. /***/ }),
  123910. /***/ "./Shaders/fxaa.fragment.ts":
  123911. /*!**********************************!*\
  123912. !*** ./Shaders/fxaa.fragment.ts ***!
  123913. \**********************************/
  123914. /*! exports provided: fxaaPixelShader */
  123915. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123916. "use strict";
  123917. __webpack_require__.r(__webpack_exports__);
  123918. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaPixelShader", function() { return fxaaPixelShader; });
  123919. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123920. var name = 'fxaaPixelShader';
  123921. 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}";
  123922. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123923. /** @hidden */
  123924. var fxaaPixelShader = { name: name, shader: shader };
  123925. /***/ }),
  123926. /***/ "./Shaders/fxaa.vertex.ts":
  123927. /*!********************************!*\
  123928. !*** ./Shaders/fxaa.vertex.ts ***!
  123929. \********************************/
  123930. /*! exports provided: fxaaVertexShader */
  123931. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123932. "use strict";
  123933. __webpack_require__.r(__webpack_exports__);
  123934. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaVertexShader", function() { return fxaaVertexShader; });
  123935. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123936. var name = 'fxaaVertexShader';
  123937. 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}";
  123938. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123939. /** @hidden */
  123940. var fxaaVertexShader = { name: name, shader: shader };
  123941. /***/ }),
  123942. /***/ "./Shaders/geometry.fragment.ts":
  123943. /*!**************************************!*\
  123944. !*** ./Shaders/geometry.fragment.ts ***!
  123945. \**************************************/
  123946. /*! exports provided: geometryPixelShader */
  123947. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123948. "use strict";
  123949. __webpack_require__.r(__webpack_exports__);
  123950. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryPixelShader", function() { return geometryPixelShader; });
  123951. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123952. /* harmony import */ var _ShadersInclude_mrtFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/mrtFragmentDeclaration */ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts");
  123953. var name = 'geometryPixelShader';
  123954. 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}";
  123955. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123956. /** @hidden */
  123957. var geometryPixelShader = { name: name, shader: shader };
  123958. /***/ }),
  123959. /***/ "./Shaders/geometry.vertex.ts":
  123960. /*!************************************!*\
  123961. !*** ./Shaders/geometry.vertex.ts ***!
  123962. \************************************/
  123963. /*! exports provided: geometryVertexShader */
  123964. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123965. "use strict";
  123966. __webpack_require__.r(__webpack_exports__);
  123967. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryVertexShader", function() { return geometryVertexShader; });
  123968. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123969. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123970. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123971. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123972. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123973. var name = 'geometryVertexShader';
  123974. 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}";
  123975. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123976. /** @hidden */
  123977. var geometryVertexShader = { name: name, shader: shader };
  123978. /***/ }),
  123979. /***/ "./Shaders/glowBlurPostProcess.fragment.ts":
  123980. /*!*************************************************!*\
  123981. !*** ./Shaders/glowBlurPostProcess.fragment.ts ***!
  123982. \*************************************************/
  123983. /*! exports provided: glowBlurPostProcessPixelShader */
  123984. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123985. "use strict";
  123986. __webpack_require__.r(__webpack_exports__);
  123987. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowBlurPostProcessPixelShader", function() { return glowBlurPostProcessPixelShader; });
  123988. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123989. var name = 'glowBlurPostProcessPixelShader';
  123990. 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}";
  123991. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123992. /** @hidden */
  123993. var glowBlurPostProcessPixelShader = { name: name, shader: shader };
  123994. /***/ }),
  123995. /***/ "./Shaders/glowMapGeneration.fragment.ts":
  123996. /*!***********************************************!*\
  123997. !*** ./Shaders/glowMapGeneration.fragment.ts ***!
  123998. \***********************************************/
  123999. /*! exports provided: glowMapGenerationPixelShader */
  124000. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124001. "use strict";
  124002. __webpack_require__.r(__webpack_exports__);
  124003. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationPixelShader", function() { return glowMapGenerationPixelShader; });
  124004. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124005. var name = 'glowMapGenerationPixelShader';
  124006. 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}";
  124007. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124008. /** @hidden */
  124009. var glowMapGenerationPixelShader = { name: name, shader: shader };
  124010. /***/ }),
  124011. /***/ "./Shaders/glowMapGeneration.vertex.ts":
  124012. /*!*********************************************!*\
  124013. !*** ./Shaders/glowMapGeneration.vertex.ts ***!
  124014. \*********************************************/
  124015. /*! exports provided: glowMapGenerationVertexShader */
  124016. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124017. "use strict";
  124018. __webpack_require__.r(__webpack_exports__);
  124019. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationVertexShader", function() { return glowMapGenerationVertexShader; });
  124020. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124021. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  124022. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  124023. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  124024. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  124025. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  124026. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  124027. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  124028. var name = 'glowMapGenerationVertexShader';
  124029. 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}";
  124030. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124031. /** @hidden */
  124032. var glowMapGenerationVertexShader = { name: name, shader: shader };
  124033. /***/ }),
  124034. /***/ "./Shaders/glowMapMerge.fragment.ts":
  124035. /*!******************************************!*\
  124036. !*** ./Shaders/glowMapMerge.fragment.ts ***!
  124037. \******************************************/
  124038. /*! exports provided: glowMapMergePixelShader */
  124039. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124040. "use strict";
  124041. __webpack_require__.r(__webpack_exports__);
  124042. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergePixelShader", function() { return glowMapMergePixelShader; });
  124043. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124044. var name = 'glowMapMergePixelShader';
  124045. 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}";
  124046. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124047. /** @hidden */
  124048. var glowMapMergePixelShader = { name: name, shader: shader };
  124049. /***/ }),
  124050. /***/ "./Shaders/glowMapMerge.vertex.ts":
  124051. /*!****************************************!*\
  124052. !*** ./Shaders/glowMapMerge.vertex.ts ***!
  124053. \****************************************/
  124054. /*! exports provided: glowMapMergeVertexShader */
  124055. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124056. "use strict";
  124057. __webpack_require__.r(__webpack_exports__);
  124058. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergeVertexShader", function() { return glowMapMergeVertexShader; });
  124059. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124060. var name = 'glowMapMergeVertexShader';
  124061. 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}";
  124062. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124063. /** @hidden */
  124064. var glowMapMergeVertexShader = { name: name, shader: shader };
  124065. /***/ }),
  124066. /***/ "./Shaders/gpuRenderParticles.fragment.ts":
  124067. /*!************************************************!*\
  124068. !*** ./Shaders/gpuRenderParticles.fragment.ts ***!
  124069. \************************************************/
  124070. /*! exports provided: gpuRenderParticlesPixelShader */
  124071. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124072. "use strict";
  124073. __webpack_require__.r(__webpack_exports__);
  124074. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesPixelShader", function() { return gpuRenderParticlesPixelShader; });
  124075. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124076. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts");
  124077. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  124078. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124079. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  124080. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  124081. var name = 'gpuRenderParticlesPixelShader';
  124082. 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";
  124083. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124084. /** @hidden */
  124085. var gpuRenderParticlesPixelShader = { name: name, shader: shader };
  124086. /***/ }),
  124087. /***/ "./Shaders/gpuRenderParticles.vertex.ts":
  124088. /*!**********************************************!*\
  124089. !*** ./Shaders/gpuRenderParticles.vertex.ts ***!
  124090. \**********************************************/
  124091. /*! exports provided: gpuRenderParticlesVertexShader */
  124092. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124093. "use strict";
  124094. __webpack_require__.r(__webpack_exports__);
  124095. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesVertexShader", function() { return gpuRenderParticlesVertexShader; });
  124096. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124097. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts");
  124098. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  124099. var name = 'gpuRenderParticlesVertexShader';
  124100. 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}";
  124101. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124102. /** @hidden */
  124103. var gpuRenderParticlesVertexShader = { name: name, shader: shader };
  124104. /***/ }),
  124105. /***/ "./Shaders/gpuUpdateParticles.fragment.ts":
  124106. /*!************************************************!*\
  124107. !*** ./Shaders/gpuUpdateParticles.fragment.ts ***!
  124108. \************************************************/
  124109. /*! exports provided: gpuUpdateParticlesPixelShader */
  124110. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124111. "use strict";
  124112. __webpack_require__.r(__webpack_exports__);
  124113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesPixelShader", function() { return gpuUpdateParticlesPixelShader; });
  124114. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124115. var name = 'gpuUpdateParticlesPixelShader';
  124116. var shader = "#version 300 es\nvoid main() {\ndiscard;\n}\n";
  124117. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124118. /** @hidden */
  124119. var gpuUpdateParticlesPixelShader = { name: name, shader: shader };
  124120. /***/ }),
  124121. /***/ "./Shaders/gpuUpdateParticles.vertex.ts":
  124122. /*!**********************************************!*\
  124123. !*** ./Shaders/gpuUpdateParticles.vertex.ts ***!
  124124. \**********************************************/
  124125. /*! exports provided: gpuUpdateParticlesVertexShader */
  124126. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124127. "use strict";
  124128. __webpack_require__.r(__webpack_exports__);
  124129. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesVertexShader", function() { return gpuUpdateParticlesVertexShader; });
  124130. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124131. var name = 'gpuUpdateParticlesVertexShader';
  124132. 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}";
  124133. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124134. /** @hidden */
  124135. var gpuUpdateParticlesVertexShader = { name: name, shader: shader };
  124136. /***/ }),
  124137. /***/ "./Shaders/grain.fragment.ts":
  124138. /*!***********************************!*\
  124139. !*** ./Shaders/grain.fragment.ts ***!
  124140. \***********************************/
  124141. /*! exports provided: grainPixelShader */
  124142. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124143. "use strict";
  124144. __webpack_require__.r(__webpack_exports__);
  124145. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "grainPixelShader", function() { return grainPixelShader; });
  124146. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124147. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124148. var name = 'grainPixelShader';
  124149. 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}";
  124150. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124151. /** @hidden */
  124152. var grainPixelShader = { name: name, shader: shader };
  124153. /***/ }),
  124154. /***/ "./Shaders/highlights.fragment.ts":
  124155. /*!****************************************!*\
  124156. !*** ./Shaders/highlights.fragment.ts ***!
  124157. \****************************************/
  124158. /*! exports provided: highlightsPixelShader */
  124159. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124160. "use strict";
  124161. __webpack_require__.r(__webpack_exports__);
  124162. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "highlightsPixelShader", function() { return highlightsPixelShader; });
  124163. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124164. var name = 'highlightsPixelShader';
  124165. 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}";
  124166. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124167. /** @hidden */
  124168. var highlightsPixelShader = { name: name, shader: shader };
  124169. /***/ }),
  124170. /***/ "./Shaders/imageProcessing.fragment.ts":
  124171. /*!*********************************************!*\
  124172. !*** ./Shaders/imageProcessing.fragment.ts ***!
  124173. \*********************************************/
  124174. /*! exports provided: imageProcessingPixelShader */
  124175. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124176. "use strict";
  124177. __webpack_require__.r(__webpack_exports__);
  124178. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingPixelShader", function() { return imageProcessingPixelShader; });
  124179. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124180. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  124181. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124182. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  124183. var name = 'imageProcessingPixelShader';
  124184. 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}";
  124185. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124186. /** @hidden */
  124187. var imageProcessingPixelShader = { name: name, shader: shader };
  124188. /***/ }),
  124189. /***/ "./Shaders/kernelBlur.fragment.ts":
  124190. /*!****************************************!*\
  124191. !*** ./Shaders/kernelBlur.fragment.ts ***!
  124192. \****************************************/
  124193. /*! exports provided: kernelBlurPixelShader */
  124194. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124195. "use strict";
  124196. __webpack_require__.r(__webpack_exports__);
  124197. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurPixelShader", function() { return kernelBlurPixelShader; });
  124198. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124199. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  124200. /* harmony import */ var _ShadersInclude_kernelBlurFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment */ "./Shaders/ShadersInclude/kernelBlurFragment.ts");
  124201. /* harmony import */ var _ShadersInclude_kernelBlurFragment2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment2 */ "./Shaders/ShadersInclude/kernelBlurFragment2.ts");
  124202. var name = 'kernelBlurPixelShader';
  124203. 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}";
  124204. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124205. /** @hidden */
  124206. var kernelBlurPixelShader = { name: name, shader: shader };
  124207. /***/ }),
  124208. /***/ "./Shaders/kernelBlur.vertex.ts":
  124209. /*!**************************************!*\
  124210. !*** ./Shaders/kernelBlur.vertex.ts ***!
  124211. \**************************************/
  124212. /*! exports provided: kernelBlurVertexShader */
  124213. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124214. "use strict";
  124215. __webpack_require__.r(__webpack_exports__);
  124216. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertexShader", function() { return kernelBlurVertexShader; });
  124217. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124218. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  124219. /* harmony import */ var _ShadersInclude_kernelBlurVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVertex */ "./Shaders/ShadersInclude/kernelBlurVertex.ts");
  124220. var name = 'kernelBlurVertexShader';
  124221. 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}";
  124222. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124223. /** @hidden */
  124224. var kernelBlurVertexShader = { name: name, shader: shader };
  124225. /***/ }),
  124226. /***/ "./Shaders/layer.fragment.ts":
  124227. /*!***********************************!*\
  124228. !*** ./Shaders/layer.fragment.ts ***!
  124229. \***********************************/
  124230. /*! exports provided: layerPixelShader */
  124231. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124232. "use strict";
  124233. __webpack_require__.r(__webpack_exports__);
  124234. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerPixelShader", function() { return layerPixelShader; });
  124235. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124236. var name = 'layerPixelShader';
  124237. 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}";
  124238. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124239. /** @hidden */
  124240. var layerPixelShader = { name: name, shader: shader };
  124241. /***/ }),
  124242. /***/ "./Shaders/layer.vertex.ts":
  124243. /*!*********************************!*\
  124244. !*** ./Shaders/layer.vertex.ts ***!
  124245. \*********************************/
  124246. /*! exports provided: layerVertexShader */
  124247. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124248. "use strict";
  124249. __webpack_require__.r(__webpack_exports__);
  124250. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerVertexShader", function() { return layerVertexShader; });
  124251. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124252. var name = 'layerVertexShader';
  124253. 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}";
  124254. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124255. /** @hidden */
  124256. var layerVertexShader = { name: name, shader: shader };
  124257. /***/ }),
  124258. /***/ "./Shaders/lensFlare.fragment.ts":
  124259. /*!***************************************!*\
  124260. !*** ./Shaders/lensFlare.fragment.ts ***!
  124261. \***************************************/
  124262. /*! exports provided: lensFlarePixelShader */
  124263. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124264. "use strict";
  124265. __webpack_require__.r(__webpack_exports__);
  124266. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlarePixelShader", function() { return lensFlarePixelShader; });
  124267. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124268. var name = 'lensFlarePixelShader';
  124269. 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}";
  124270. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124271. /** @hidden */
  124272. var lensFlarePixelShader = { name: name, shader: shader };
  124273. /***/ }),
  124274. /***/ "./Shaders/lensFlare.vertex.ts":
  124275. /*!*************************************!*\
  124276. !*** ./Shaders/lensFlare.vertex.ts ***!
  124277. \*************************************/
  124278. /*! exports provided: lensFlareVertexShader */
  124279. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124280. "use strict";
  124281. __webpack_require__.r(__webpack_exports__);
  124282. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlareVertexShader", function() { return lensFlareVertexShader; });
  124283. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124284. var name = 'lensFlareVertexShader';
  124285. 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}";
  124286. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124287. /** @hidden */
  124288. var lensFlareVertexShader = { name: name, shader: shader };
  124289. /***/ }),
  124290. /***/ "./Shaders/lensHighlights.fragment.ts":
  124291. /*!********************************************!*\
  124292. !*** ./Shaders/lensHighlights.fragment.ts ***!
  124293. \********************************************/
  124294. /*! exports provided: lensHighlightsPixelShader */
  124295. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124296. "use strict";
  124297. __webpack_require__.r(__webpack_exports__);
  124298. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensHighlightsPixelShader", function() { return lensHighlightsPixelShader; });
  124299. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124300. var name = 'lensHighlightsPixelShader';
  124301. 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}";
  124302. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124303. /** @hidden */
  124304. var lensHighlightsPixelShader = { name: name, shader: shader };
  124305. /***/ }),
  124306. /***/ "./Shaders/line.fragment.ts":
  124307. /*!**********************************!*\
  124308. !*** ./Shaders/line.fragment.ts ***!
  124309. \**********************************/
  124310. /*! exports provided: linePixelShader */
  124311. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124312. "use strict";
  124313. __webpack_require__.r(__webpack_exports__);
  124314. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "linePixelShader", function() { return linePixelShader; });
  124315. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124316. var name = 'linePixelShader';
  124317. var shader = "uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}";
  124318. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124319. /** @hidden */
  124320. var linePixelShader = { name: name, shader: shader };
  124321. /***/ }),
  124322. /***/ "./Shaders/line.vertex.ts":
  124323. /*!********************************!*\
  124324. !*** ./Shaders/line.vertex.ts ***!
  124325. \********************************/
  124326. /*! exports provided: lineVertexShader */
  124327. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124328. "use strict";
  124329. __webpack_require__.r(__webpack_exports__);
  124330. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lineVertexShader", function() { return lineVertexShader; });
  124331. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124332. var name = 'lineVertexShader';
  124333. 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}";
  124334. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124335. /** @hidden */
  124336. var lineVertexShader = { name: name, shader: shader };
  124337. /***/ }),
  124338. /***/ "./Shaders/motionBlur.fragment.ts":
  124339. /*!****************************************!*\
  124340. !*** ./Shaders/motionBlur.fragment.ts ***!
  124341. \****************************************/
  124342. /*! exports provided: motionBlurPixelShader */
  124343. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124344. "use strict";
  124345. __webpack_require__.r(__webpack_exports__);
  124346. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "motionBlurPixelShader", function() { return motionBlurPixelShader; });
  124347. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124348. var name = 'motionBlurPixelShader';
  124349. 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";
  124350. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124351. /** @hidden */
  124352. var motionBlurPixelShader = { name: name, shader: shader };
  124353. /***/ }),
  124354. /***/ "./Shaders/noise.fragment.ts":
  124355. /*!***********************************!*\
  124356. !*** ./Shaders/noise.fragment.ts ***!
  124357. \***********************************/
  124358. /*! exports provided: noisePixelShader */
  124359. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124360. "use strict";
  124361. __webpack_require__.r(__webpack_exports__);
  124362. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "noisePixelShader", function() { return noisePixelShader; });
  124363. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124364. var name = 'noisePixelShader';
  124365. 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";
  124366. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124367. /** @hidden */
  124368. var noisePixelShader = { name: name, shader: shader };
  124369. /***/ }),
  124370. /***/ "./Shaders/outline.fragment.ts":
  124371. /*!*************************************!*\
  124372. !*** ./Shaders/outline.fragment.ts ***!
  124373. \*************************************/
  124374. /*! exports provided: outlinePixelShader */
  124375. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124376. "use strict";
  124377. __webpack_require__.r(__webpack_exports__);
  124378. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlinePixelShader", function() { return outlinePixelShader; });
  124379. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124380. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  124381. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  124382. var name = 'outlinePixelShader';
  124383. 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}";
  124384. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124385. /** @hidden */
  124386. var outlinePixelShader = { name: name, shader: shader };
  124387. /***/ }),
  124388. /***/ "./Shaders/outline.vertex.ts":
  124389. /*!***********************************!*\
  124390. !*** ./Shaders/outline.vertex.ts ***!
  124391. \***********************************/
  124392. /*! exports provided: outlineVertexShader */
  124393. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124394. "use strict";
  124395. __webpack_require__.r(__webpack_exports__);
  124396. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlineVertexShader", function() { return outlineVertexShader; });
  124397. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124398. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  124399. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  124400. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  124401. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  124402. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  124403. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  124404. var name = 'outlineVertexShader';
  124405. 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";
  124406. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124407. /** @hidden */
  124408. var outlineVertexShader = { name: name, shader: shader };
  124409. /***/ }),
  124410. /***/ "./Shaders/particles.fragment.ts":
  124411. /*!***************************************!*\
  124412. !*** ./Shaders/particles.fragment.ts ***!
  124413. \***************************************/
  124414. /*! exports provided: particlesPixelShader */
  124415. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124416. "use strict";
  124417. __webpack_require__.r(__webpack_exports__);
  124418. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesPixelShader", function() { return particlesPixelShader; });
  124419. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124420. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  124421. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  124422. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124423. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  124424. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  124425. var name = 'particlesPixelShader';
  124426. 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}";
  124427. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124428. /** @hidden */
  124429. var particlesPixelShader = { name: name, shader: shader };
  124430. /***/ }),
  124431. /***/ "./Shaders/particles.vertex.ts":
  124432. /*!*************************************!*\
  124433. !*** ./Shaders/particles.vertex.ts ***!
  124434. \*************************************/
  124435. /*! exports provided: particlesVertexShader */
  124436. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124437. "use strict";
  124438. __webpack_require__.r(__webpack_exports__);
  124439. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesVertexShader", function() { return particlesVertexShader; });
  124440. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124441. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  124442. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  124443. var name = 'particlesVertexShader';
  124444. 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}";
  124445. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124446. /** @hidden */
  124447. var particlesVertexShader = { name: name, shader: shader };
  124448. /***/ }),
  124449. /***/ "./Shaders/pass.fragment.ts":
  124450. /*!**********************************!*\
  124451. !*** ./Shaders/pass.fragment.ts ***!
  124452. \**********************************/
  124453. /*! exports provided: passPixelShader */
  124454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124455. "use strict";
  124456. __webpack_require__.r(__webpack_exports__);
  124457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passPixelShader", function() { return passPixelShader; });
  124458. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124459. var name = 'passPixelShader';
  124460. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";
  124461. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124462. /** @hidden */
  124463. var passPixelShader = { name: name, shader: shader };
  124464. /***/ }),
  124465. /***/ "./Shaders/passCube.fragment.ts":
  124466. /*!**************************************!*\
  124467. !*** ./Shaders/passCube.fragment.ts ***!
  124468. \**************************************/
  124469. /*! exports provided: passCubePixelShader */
  124470. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124471. "use strict";
  124472. __webpack_require__.r(__webpack_exports__);
  124473. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passCubePixelShader", function() { return passCubePixelShader; });
  124474. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124475. var name = 'passCubePixelShader';
  124476. 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}";
  124477. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124478. /** @hidden */
  124479. var passCubePixelShader = { name: name, shader: shader };
  124480. /***/ }),
  124481. /***/ "./Shaders/pbr.fragment.ts":
  124482. /*!*********************************!*\
  124483. !*** ./Shaders/pbr.fragment.ts ***!
  124484. \*********************************/
  124485. /*! exports provided: pbrPixelShader */
  124486. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124487. "use strict";
  124488. __webpack_require__.r(__webpack_exports__);
  124489. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrPixelShader", function() { return pbrPixelShader; });
  124490. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124491. /* harmony import */ var _ShadersInclude_pbrFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentDeclaration */ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts");
  124492. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  124493. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  124494. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  124495. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  124496. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  124497. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124498. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  124499. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  124500. /* harmony import */ var _ShadersInclude_pbrFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/pbrFunctions */ "./Shaders/ShadersInclude/pbrFunctions.ts");
  124501. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  124502. /* harmony import */ var _ShadersInclude_pbrLightFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/pbrLightFunctions */ "./Shaders/ShadersInclude/pbrLightFunctions.ts");
  124503. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  124504. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  124505. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  124506. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  124507. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  124508. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  124509. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  124510. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  124511. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  124512. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  124513. var name = 'pbrPixelShader';
  124514. 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";
  124515. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124516. /** @hidden */
  124517. var pbrPixelShader = { name: name, shader: shader };
  124518. /***/ }),
  124519. /***/ "./Shaders/pbr.vertex.ts":
  124520. /*!*******************************!*\
  124521. !*** ./Shaders/pbr.vertex.ts ***!
  124522. \*******************************/
  124523. /*! exports provided: pbrVertexShader */
  124524. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124525. "use strict";
  124526. __webpack_require__.r(__webpack_exports__);
  124527. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexShader", function() { return pbrVertexShader; });
  124528. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124529. /* harmony import */ var _ShadersInclude_pbrVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrVertexDeclaration */ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts");
  124530. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  124531. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124532. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  124533. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  124534. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  124535. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  124536. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  124537. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  124538. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  124539. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  124540. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  124541. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  124542. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  124543. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  124544. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  124545. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  124546. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  124547. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  124548. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  124549. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  124550. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  124551. var name = 'pbrVertexShader';
  124552. 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}";
  124553. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124554. /** @hidden */
  124555. var pbrVertexShader = { name: name, shader: shader };
  124556. /***/ }),
  124557. /***/ "./Shaders/postprocess.vertex.ts":
  124558. /*!***************************************!*\
  124559. !*** ./Shaders/postprocess.vertex.ts ***!
  124560. \***************************************/
  124561. /*! exports provided: postprocessVertexShader */
  124562. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124563. "use strict";
  124564. __webpack_require__.r(__webpack_exports__);
  124565. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "postprocessVertexShader", function() { return postprocessVertexShader; });
  124566. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124567. var name = 'postprocessVertexShader';
  124568. 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}";
  124569. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124570. /** @hidden */
  124571. var postprocessVertexShader = { name: name, shader: shader };
  124572. /***/ }),
  124573. /***/ "./Shaders/procedural.vertex.ts":
  124574. /*!**************************************!*\
  124575. !*** ./Shaders/procedural.vertex.ts ***!
  124576. \**************************************/
  124577. /*! exports provided: proceduralVertexShader */
  124578. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124579. "use strict";
  124580. __webpack_require__.r(__webpack_exports__);
  124581. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "proceduralVertexShader", function() { return proceduralVertexShader; });
  124582. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124583. var name = 'proceduralVertexShader';
  124584. 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}";
  124585. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124586. /** @hidden */
  124587. var proceduralVertexShader = { name: name, shader: shader };
  124588. /***/ }),
  124589. /***/ "./Shaders/refraction.fragment.ts":
  124590. /*!****************************************!*\
  124591. !*** ./Shaders/refraction.fragment.ts ***!
  124592. \****************************************/
  124593. /*! exports provided: refractionPixelShader */
  124594. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124595. "use strict";
  124596. __webpack_require__.r(__webpack_exports__);
  124597. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "refractionPixelShader", function() { return refractionPixelShader; });
  124598. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124599. var name = 'refractionPixelShader';
  124600. 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}";
  124601. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124602. /** @hidden */
  124603. var refractionPixelShader = { name: name, shader: shader };
  124604. /***/ }),
  124605. /***/ "./Shaders/rgbdDecode.fragment.ts":
  124606. /*!****************************************!*\
  124607. !*** ./Shaders/rgbdDecode.fragment.ts ***!
  124608. \****************************************/
  124609. /*! exports provided: rgbdDecodePixelShader */
  124610. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124611. "use strict";
  124612. __webpack_require__.r(__webpack_exports__);
  124613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdDecodePixelShader", function() { return rgbdDecodePixelShader; });
  124614. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124615. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124616. var name = 'rgbdDecodePixelShader';
  124617. 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}";
  124618. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124619. /** @hidden */
  124620. var rgbdDecodePixelShader = { name: name, shader: shader };
  124621. /***/ }),
  124622. /***/ "./Shaders/rgbdEncode.fragment.ts":
  124623. /*!****************************************!*\
  124624. !*** ./Shaders/rgbdEncode.fragment.ts ***!
  124625. \****************************************/
  124626. /*! exports provided: rgbdEncodePixelShader */
  124627. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124628. "use strict";
  124629. __webpack_require__.r(__webpack_exports__);
  124630. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdEncodePixelShader", function() { return rgbdEncodePixelShader; });
  124631. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124632. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124633. var name = 'rgbdEncodePixelShader';
  124634. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void)\n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}";
  124635. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124636. /** @hidden */
  124637. var rgbdEncodePixelShader = { name: name, shader: shader };
  124638. /***/ }),
  124639. /***/ "./Shaders/shadowMap.fragment.ts":
  124640. /*!***************************************!*\
  124641. !*** ./Shaders/shadowMap.fragment.ts ***!
  124642. \***************************************/
  124643. /*! exports provided: shadowMapPixelShader */
  124644. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124645. "use strict";
  124646. __webpack_require__.r(__webpack_exports__);
  124647. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapPixelShader", function() { return shadowMapPixelShader; });
  124648. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124649. var name = 'shadowMapPixelShader';
  124650. 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}";
  124651. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124652. /** @hidden */
  124653. var shadowMapPixelShader = { name: name, shader: shader };
  124654. /***/ }),
  124655. /***/ "./Shaders/shadowMap.vertex.ts":
  124656. /*!*************************************!*\
  124657. !*** ./Shaders/shadowMap.vertex.ts ***!
  124658. \*************************************/
  124659. /*! exports provided: shadowMapVertexShader */
  124660. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124661. "use strict";
  124662. __webpack_require__.r(__webpack_exports__);
  124663. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapVertexShader", function() { return shadowMapVertexShader; });
  124664. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124665. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  124666. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  124667. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  124668. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  124669. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124670. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  124671. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  124672. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  124673. var name = 'shadowMapVertexShader';
  124674. 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}";
  124675. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124676. /** @hidden */
  124677. var shadowMapVertexShader = { name: name, shader: shader };
  124678. /***/ }),
  124679. /***/ "./Shaders/sharpen.fragment.ts":
  124680. /*!*************************************!*\
  124681. !*** ./Shaders/sharpen.fragment.ts ***!
  124682. \*************************************/
  124683. /*! exports provided: sharpenPixelShader */
  124684. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124685. "use strict";
  124686. __webpack_require__.r(__webpack_exports__);
  124687. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sharpenPixelShader", function() { return sharpenPixelShader; });
  124688. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124689. var name = 'sharpenPixelShader';
  124690. 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}";
  124691. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124692. /** @hidden */
  124693. var sharpenPixelShader = { name: name, shader: shader };
  124694. /***/ }),
  124695. /***/ "./Shaders/sprites.fragment.ts":
  124696. /*!*************************************!*\
  124697. !*** ./Shaders/sprites.fragment.ts ***!
  124698. \*************************************/
  124699. /*! exports provided: spritesPixelShader */
  124700. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124701. "use strict";
  124702. __webpack_require__.r(__webpack_exports__);
  124703. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesPixelShader", function() { return spritesPixelShader; });
  124704. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124705. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  124706. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  124707. var name = 'spritesPixelShader';
  124708. 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}";
  124709. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124710. /** @hidden */
  124711. var spritesPixelShader = { name: name, shader: shader };
  124712. /***/ }),
  124713. /***/ "./Shaders/sprites.vertex.ts":
  124714. /*!***********************************!*\
  124715. !*** ./Shaders/sprites.vertex.ts ***!
  124716. \***********************************/
  124717. /*! exports provided: spritesVertexShader */
  124718. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124719. "use strict";
  124720. __webpack_require__.r(__webpack_exports__);
  124721. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesVertexShader", function() { return spritesVertexShader; });
  124722. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124723. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  124724. var name = 'spritesVertexShader';
  124725. 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}";
  124726. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124727. /** @hidden */
  124728. var spritesVertexShader = { name: name, shader: shader };
  124729. /***/ }),
  124730. /***/ "./Shaders/ssao.fragment.ts":
  124731. /*!**********************************!*\
  124732. !*** ./Shaders/ssao.fragment.ts ***!
  124733. \**********************************/
  124734. /*! exports provided: ssaoPixelShader */
  124735. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124736. "use strict";
  124737. __webpack_require__.r(__webpack_exports__);
  124738. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoPixelShader", function() { return ssaoPixelShader; });
  124739. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124740. var name = 'ssaoPixelShader';
  124741. 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";
  124742. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124743. /** @hidden */
  124744. var ssaoPixelShader = { name: name, shader: shader };
  124745. /***/ }),
  124746. /***/ "./Shaders/ssao2.fragment.ts":
  124747. /*!***********************************!*\
  124748. !*** ./Shaders/ssao2.fragment.ts ***!
  124749. \***********************************/
  124750. /*! exports provided: ssao2PixelShader */
  124751. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124752. "use strict";
  124753. __webpack_require__.r(__webpack_exports__);
  124754. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssao2PixelShader", function() { return ssao2PixelShader; });
  124755. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124756. var name = 'ssao2PixelShader';
  124757. 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";
  124758. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124759. /** @hidden */
  124760. var ssao2PixelShader = { name: name, shader: shader };
  124761. /***/ }),
  124762. /***/ "./Shaders/ssaoCombine.fragment.ts":
  124763. /*!*****************************************!*\
  124764. !*** ./Shaders/ssaoCombine.fragment.ts ***!
  124765. \*****************************************/
  124766. /*! exports provided: ssaoCombinePixelShader */
  124767. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124768. "use strict";
  124769. __webpack_require__.r(__webpack_exports__);
  124770. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoCombinePixelShader", function() { return ssaoCombinePixelShader; });
  124771. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124772. var name = 'ssaoCombinePixelShader';
  124773. 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";
  124774. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124775. /** @hidden */
  124776. var ssaoCombinePixelShader = { name: name, shader: shader };
  124777. /***/ }),
  124778. /***/ "./Shaders/standard.fragment.ts":
  124779. /*!**************************************!*\
  124780. !*** ./Shaders/standard.fragment.ts ***!
  124781. \**************************************/
  124782. /*! exports provided: standardPixelShader */
  124783. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124784. "use strict";
  124785. __webpack_require__.r(__webpack_exports__);
  124786. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "standardPixelShader", function() { return standardPixelShader; });
  124787. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124788. var name = 'standardPixelShader';
  124789. 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";
  124790. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124791. /** @hidden */
  124792. var standardPixelShader = { name: name, shader: shader };
  124793. /***/ }),
  124794. /***/ "./Shaders/stereoscopicInterlace.fragment.ts":
  124795. /*!***************************************************!*\
  124796. !*** ./Shaders/stereoscopicInterlace.fragment.ts ***!
  124797. \***************************************************/
  124798. /*! exports provided: stereoscopicInterlacePixelShader */
  124799. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124800. "use strict";
  124801. __webpack_require__.r(__webpack_exports__);
  124802. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stereoscopicInterlacePixelShader", function() { return stereoscopicInterlacePixelShader; });
  124803. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124804. var name = 'stereoscopicInterlacePixelShader';
  124805. 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}";
  124806. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124807. /** @hidden */
  124808. var stereoscopicInterlacePixelShader = { name: name, shader: shader };
  124809. /***/ }),
  124810. /***/ "./Shaders/tonemap.fragment.ts":
  124811. /*!*************************************!*\
  124812. !*** ./Shaders/tonemap.fragment.ts ***!
  124813. \*************************************/
  124814. /*! exports provided: tonemapPixelShader */
  124815. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124816. "use strict";
  124817. __webpack_require__.r(__webpack_exports__);
  124818. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tonemapPixelShader", function() { return tonemapPixelShader; });
  124819. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124820. var name = 'tonemapPixelShader';
  124821. 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}";
  124822. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124823. /** @hidden */
  124824. var tonemapPixelShader = { name: name, shader: shader };
  124825. /***/ }),
  124826. /***/ "./Shaders/volumetricLightScattering.fragment.ts":
  124827. /*!*******************************************************!*\
  124828. !*** ./Shaders/volumetricLightScattering.fragment.ts ***!
  124829. \*******************************************************/
  124830. /*! exports provided: volumetricLightScatteringPixelShader */
  124831. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124832. "use strict";
  124833. __webpack_require__.r(__webpack_exports__);
  124834. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPixelShader", function() { return volumetricLightScatteringPixelShader; });
  124835. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124836. var name = 'volumetricLightScatteringPixelShader';
  124837. 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";
  124838. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124839. /** @hidden */
  124840. var volumetricLightScatteringPixelShader = { name: name, shader: shader };
  124841. /***/ }),
  124842. /***/ "./Shaders/volumetricLightScatteringPass.fragment.ts":
  124843. /*!***********************************************************!*\
  124844. !*** ./Shaders/volumetricLightScatteringPass.fragment.ts ***!
  124845. \***********************************************************/
  124846. /*! exports provided: volumetricLightScatteringPassPixelShader */
  124847. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124848. "use strict";
  124849. __webpack_require__.r(__webpack_exports__);
  124850. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPassPixelShader", function() { return volumetricLightScatteringPassPixelShader; });
  124851. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124852. var name = 'volumetricLightScatteringPassPixelShader';
  124853. 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";
  124854. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124855. /** @hidden */
  124856. var volumetricLightScatteringPassPixelShader = { name: name, shader: shader };
  124857. /***/ }),
  124858. /***/ "./Shaders/vrDistortionCorrection.fragment.ts":
  124859. /*!****************************************************!*\
  124860. !*** ./Shaders/vrDistortionCorrection.fragment.ts ***!
  124861. \****************************************************/
  124862. /*! exports provided: vrDistortionCorrectionPixelShader */
  124863. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124864. "use strict";
  124865. __webpack_require__.r(__webpack_exports__);
  124866. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vrDistortionCorrectionPixelShader", function() { return vrDistortionCorrectionPixelShader; });
  124867. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124868. var name = 'vrDistortionCorrectionPixelShader';
  124869. 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}";
  124870. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124871. /** @hidden */
  124872. var vrDistortionCorrectionPixelShader = { name: name, shader: shader };
  124873. /***/ }),
  124874. /***/ "./Sprites/index.ts":
  124875. /*!**************************!*\
  124876. !*** ./Sprites/index.ts ***!
  124877. \**************************/
  124878. /*! exports provided: Sprite, SpriteManager, SpriteSceneComponent */
  124879. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124880. "use strict";
  124881. __webpack_require__.r(__webpack_exports__);
  124882. /* harmony import */ var _sprite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sprite */ "./Sprites/sprite.ts");
  124883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _sprite__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  124884. /* harmony import */ var _spriteManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./spriteManager */ "./Sprites/spriteManager.ts");
  124885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _spriteManager__WEBPACK_IMPORTED_MODULE_1__["SpriteManager"]; });
  124886. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  124887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__["SpriteSceneComponent"]; });
  124888. /***/ }),
  124889. /***/ "./Sprites/sprite.ts":
  124890. /*!***************************!*\
  124891. !*** ./Sprites/sprite.ts ***!
  124892. \***************************/
  124893. /*! exports provided: Sprite */
  124894. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124895. "use strict";
  124896. __webpack_require__.r(__webpack_exports__);
  124897. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return Sprite; });
  124898. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124899. /**
  124900. * Class used to represent a sprite
  124901. * @see http://doc.babylonjs.com/babylon101/sprites
  124902. */
  124903. var Sprite = /** @class */ (function () {
  124904. /**
  124905. * Creates a new Sprite
  124906. * @param name defines the name
  124907. * @param manager defines the manager
  124908. */
  124909. function Sprite(
  124910. /** defines the name */
  124911. name, manager) {
  124912. this.name = name;
  124913. /** Gets or sets the main color */
  124914. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  124915. /** Gets or sets the width */
  124916. this.width = 1.0;
  124917. /** Gets or sets the height */
  124918. this.height = 1.0;
  124919. /** Gets or sets rotation angle */
  124920. this.angle = 0;
  124921. /** Gets or sets the cell index in the sprite sheet */
  124922. this.cellIndex = 0;
  124923. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  124924. this.invertU = 0;
  124925. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  124926. this.invertV = 0;
  124927. /** Gets the list of attached animations */
  124928. this.animations = new Array();
  124929. /** Gets or sets a boolean indicating if the sprite can be picked */
  124930. this.isPickable = false;
  124931. this._animationStarted = false;
  124932. this._loopAnimation = false;
  124933. this._fromIndex = 0;
  124934. this._toIndex = 0;
  124935. this._delay = 0;
  124936. this._direction = 1;
  124937. this._time = 0;
  124938. /**
  124939. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  124940. */
  124941. this.isVisible = true;
  124942. this._manager = manager;
  124943. this._manager.sprites.push(this);
  124944. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  124945. }
  124946. Object.defineProperty(Sprite.prototype, "size", {
  124947. /**
  124948. * Gets or sets the sprite size
  124949. */
  124950. get: function () {
  124951. return this.width;
  124952. },
  124953. set: function (value) {
  124954. this.width = value;
  124955. this.height = value;
  124956. },
  124957. enumerable: true,
  124958. configurable: true
  124959. });
  124960. /**
  124961. * Starts an animation
  124962. * @param from defines the initial key
  124963. * @param to defines the end key
  124964. * @param loop defines if the animation must loop
  124965. * @param delay defines the start delay (in ms)
  124966. * @param onAnimationEnd defines a callback to call when animation ends
  124967. */
  124968. Sprite.prototype.playAnimation = function (from, to, loop, delay, onAnimationEnd) {
  124969. this._fromIndex = from;
  124970. this._toIndex = to;
  124971. this._loopAnimation = loop;
  124972. this._delay = delay;
  124973. this._animationStarted = true;
  124974. this._direction = from < to ? 1 : -1;
  124975. this.cellIndex = from;
  124976. this._time = 0;
  124977. this._onAnimationEnd = onAnimationEnd;
  124978. };
  124979. /** Stops current animation (if any) */
  124980. Sprite.prototype.stopAnimation = function () {
  124981. this._animationStarted = false;
  124982. };
  124983. /** @hidden */
  124984. Sprite.prototype._animate = function (deltaTime) {
  124985. if (!this._animationStarted) {
  124986. return;
  124987. }
  124988. this._time += deltaTime;
  124989. if (this._time > this._delay) {
  124990. this._time = this._time % this._delay;
  124991. this.cellIndex += this._direction;
  124992. if (this.cellIndex > this._toIndex) {
  124993. if (this._loopAnimation) {
  124994. this.cellIndex = this._fromIndex;
  124995. }
  124996. else {
  124997. this.cellIndex = this._toIndex;
  124998. this._animationStarted = false;
  124999. if (this._onAnimationEnd) {
  125000. this._onAnimationEnd();
  125001. }
  125002. if (this.disposeWhenFinishedAnimating) {
  125003. this.dispose();
  125004. }
  125005. }
  125006. }
  125007. }
  125008. };
  125009. /** Release associated resources */
  125010. Sprite.prototype.dispose = function () {
  125011. for (var i = 0; i < this._manager.sprites.length; i++) {
  125012. if (this._manager.sprites[i] == this) {
  125013. this._manager.sprites.splice(i, 1);
  125014. }
  125015. }
  125016. };
  125017. return Sprite;
  125018. }());
  125019. /***/ }),
  125020. /***/ "./Sprites/spriteManager.ts":
  125021. /*!**********************************!*\
  125022. !*** ./Sprites/spriteManager.ts ***!
  125023. \**********************************/
  125024. /*! exports provided: SpriteManager */
  125025. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125026. "use strict";
  125027. __webpack_require__.r(__webpack_exports__);
  125028. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return SpriteManager; });
  125029. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  125030. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  125031. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  125032. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125033. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  125034. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  125035. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  125036. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  125037. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  125038. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125039. /* harmony import */ var _Shaders_sprites_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/sprites.fragment */ "./Shaders/sprites.fragment.ts");
  125040. /* harmony import */ var _Shaders_sprites_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/sprites.vertex */ "./Shaders/sprites.vertex.ts");
  125041. /**
  125042. * Class used to manage multiple sprites on the same spritesheet
  125043. * @see http://doc.babylonjs.com/babylon101/sprites
  125044. */
  125045. var SpriteManager = /** @class */ (function () {
  125046. /**
  125047. * Creates a new sprite manager
  125048. * @param name defines the manager's name
  125049. * @param imgUrl defines the sprite sheet url
  125050. * @param capacity defines the maximum allowed number of sprites
  125051. * @param cellSize defines the size of a sprite cell
  125052. * @param scene defines the hosting scene
  125053. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  125054. * @param samplingMode defines the smapling mode to use with spritesheet
  125055. */
  125056. function SpriteManager(
  125057. /** defines the manager's name */
  125058. name, imgUrl, capacity, cellSize, scene, epsilon, samplingMode) {
  125059. if (epsilon === void 0) { epsilon = 0.01; }
  125060. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].TRILINEAR_SAMPLINGMODE; }
  125061. this.name = name;
  125062. /** Gets the list of sprites */
  125063. this.sprites = new Array();
  125064. /** Gets or sets the rendering group id (0 by default) */
  125065. this.renderingGroupId = 0;
  125066. /** Gets or sets camera layer mask */
  125067. this.layerMask = 0x0FFFFFFF;
  125068. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  125069. this.fogEnabled = true;
  125070. /** Gets or sets a boolean indicating if the sprites are pickable */
  125071. this.isPickable = false;
  125072. /**
  125073. * An event triggered when the manager is disposed.
  125074. */
  125075. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  125076. this._vertexBuffers = {};
  125077. if (!scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_8__["SceneComponentConstants"].NAME_SPRITE)) {
  125078. scene._addComponent(new _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__["SpriteSceneComponent"](scene));
  125079. }
  125080. this._capacity = capacity;
  125081. this._spriteTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](imgUrl, scene, true, false, samplingMode);
  125082. this._spriteTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  125083. this._spriteTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  125084. if (cellSize.width && cellSize.height) {
  125085. this.cellWidth = cellSize.width;
  125086. this.cellHeight = cellSize.height;
  125087. }
  125088. else if (cellSize !== undefined) {
  125089. this.cellWidth = cellSize;
  125090. this.cellHeight = cellSize;
  125091. }
  125092. else {
  125093. return;
  125094. }
  125095. this._epsilon = epsilon;
  125096. this._scene = scene;
  125097. this._scene.spriteManagers.push(this);
  125098. var indices = [];
  125099. var index = 0;
  125100. for (var count = 0; count < capacity; count++) {
  125101. indices.push(index);
  125102. indices.push(index + 1);
  125103. indices.push(index + 2);
  125104. indices.push(index);
  125105. indices.push(index + 2);
  125106. indices.push(index + 3);
  125107. index += 4;
  125108. }
  125109. this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
  125110. // VBO
  125111. // 16 floats per sprite (x, y, z, angle, sizeX, sizeY, offsetX, offsetY, invertU, invertV, cellIndexX, cellIndexY, color r, color g, color b, color a)
  125112. this._vertexData = new Float32Array(capacity * 16 * 4);
  125113. this._buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["Buffer"](scene.getEngine(), this._vertexData, true, 16);
  125114. var positions = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, 0, 4);
  125115. var options = this._buffer.createVertexBuffer("options", 4, 4);
  125116. var cellInfo = this._buffer.createVertexBuffer("cellInfo", 8, 4);
  125117. var colors = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, 12, 4);
  125118. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind] = positions;
  125119. this._vertexBuffers["options"] = options;
  125120. this._vertexBuffers["cellInfo"] = cellInfo;
  125121. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind] = colors;
  125122. // Effects
  125123. 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"], "");
  125124. 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");
  125125. }
  125126. Object.defineProperty(SpriteManager.prototype, "onDispose", {
  125127. /**
  125128. * Callback called when the manager is disposed
  125129. */
  125130. set: function (callback) {
  125131. if (this._onDisposeObserver) {
  125132. this.onDisposeObservable.remove(this._onDisposeObserver);
  125133. }
  125134. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  125135. },
  125136. enumerable: true,
  125137. configurable: true
  125138. });
  125139. Object.defineProperty(SpriteManager.prototype, "texture", {
  125140. /**
  125141. * Gets or sets the spritesheet texture
  125142. */
  125143. get: function () {
  125144. return this._spriteTexture;
  125145. },
  125146. set: function (value) {
  125147. this._spriteTexture = value;
  125148. },
  125149. enumerable: true,
  125150. configurable: true
  125151. });
  125152. SpriteManager.prototype._appendSpriteVertex = function (index, sprite, offsetX, offsetY, rowSize) {
  125153. var arrayOffset = index * 16;
  125154. if (offsetX === 0) {
  125155. offsetX = this._epsilon;
  125156. }
  125157. else if (offsetX === 1) {
  125158. offsetX = 1 - this._epsilon;
  125159. }
  125160. if (offsetY === 0) {
  125161. offsetY = this._epsilon;
  125162. }
  125163. else if (offsetY === 1) {
  125164. offsetY = 1 - this._epsilon;
  125165. }
  125166. this._vertexData[arrayOffset] = sprite.position.x;
  125167. this._vertexData[arrayOffset + 1] = sprite.position.y;
  125168. this._vertexData[arrayOffset + 2] = sprite.position.z;
  125169. this._vertexData[arrayOffset + 3] = sprite.angle;
  125170. this._vertexData[arrayOffset + 4] = sprite.width;
  125171. this._vertexData[arrayOffset + 5] = sprite.height;
  125172. this._vertexData[arrayOffset + 6] = offsetX;
  125173. this._vertexData[arrayOffset + 7] = offsetY;
  125174. this._vertexData[arrayOffset + 8] = sprite.invertU ? 1 : 0;
  125175. this._vertexData[arrayOffset + 9] = sprite.invertV ? 1 : 0;
  125176. var offset = (sprite.cellIndex / rowSize) >> 0;
  125177. this._vertexData[arrayOffset + 10] = sprite.cellIndex - offset * rowSize;
  125178. this._vertexData[arrayOffset + 11] = offset;
  125179. // Color
  125180. this._vertexData[arrayOffset + 12] = sprite.color.r;
  125181. this._vertexData[arrayOffset + 13] = sprite.color.g;
  125182. this._vertexData[arrayOffset + 14] = sprite.color.b;
  125183. this._vertexData[arrayOffset + 15] = sprite.color.a;
  125184. };
  125185. /**
  125186. * Intersects the sprites with a ray
  125187. * @param ray defines the ray to intersect with
  125188. * @param camera defines the current active camera
  125189. * @param predicate defines a predicate used to select candidate sprites
  125190. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  125191. * @returns null if no hit or a PickingInfo
  125192. */
  125193. SpriteManager.prototype.intersects = function (ray, camera, predicate, fastCheck) {
  125194. var count = Math.min(this._capacity, this.sprites.length);
  125195. var min = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  125196. var max = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  125197. var distance = Number.MAX_VALUE;
  125198. var currentSprite = null;
  125199. var cameraSpacePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  125200. var cameraView = camera.getViewMatrix();
  125201. for (var index = 0; index < count; index++) {
  125202. var sprite = this.sprites[index];
  125203. if (!sprite) {
  125204. continue;
  125205. }
  125206. if (predicate) {
  125207. if (!predicate(sprite)) {
  125208. continue;
  125209. }
  125210. }
  125211. else if (!sprite.isPickable) {
  125212. continue;
  125213. }
  125214. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(sprite.position, cameraView, cameraSpacePosition);
  125215. min.copyFromFloats(cameraSpacePosition.x - sprite.width / 2, cameraSpacePosition.y - sprite.height / 2, cameraSpacePosition.z);
  125216. max.copyFromFloats(cameraSpacePosition.x + sprite.width / 2, cameraSpacePosition.y + sprite.height / 2, cameraSpacePosition.z);
  125217. if (ray.intersectsBoxMinMax(min, max)) {
  125218. var currentDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(cameraSpacePosition, ray.origin);
  125219. if (distance > currentDistance) {
  125220. distance = currentDistance;
  125221. currentSprite = sprite;
  125222. if (fastCheck) {
  125223. break;
  125224. }
  125225. }
  125226. }
  125227. }
  125228. if (currentSprite) {
  125229. var result = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__["PickingInfo"]();
  125230. result.hit = true;
  125231. result.pickedSprite = currentSprite;
  125232. result.distance = distance;
  125233. return result;
  125234. }
  125235. return null;
  125236. };
  125237. /**
  125238. * Render all child sprites
  125239. */
  125240. SpriteManager.prototype.render = function () {
  125241. // Check
  125242. if (!this._effectBase.isReady() || !this._effectFog.isReady() || !this._spriteTexture
  125243. || !this._spriteTexture.isReady() || !this.sprites.length) {
  125244. return;
  125245. }
  125246. var engine = this._scene.getEngine();
  125247. var baseSize = this._spriteTexture.getBaseSize();
  125248. // Sprites
  125249. var deltaTime = engine.getDeltaTime();
  125250. var max = Math.min(this._capacity, this.sprites.length);
  125251. var rowSize = baseSize.width / this.cellWidth;
  125252. var offset = 0;
  125253. for (var index = 0; index < max; index++) {
  125254. var sprite = this.sprites[index];
  125255. if (!sprite || !sprite.isVisible) {
  125256. continue;
  125257. }
  125258. sprite._animate(deltaTime);
  125259. this._appendSpriteVertex(offset++, sprite, 0, 0, rowSize);
  125260. this._appendSpriteVertex(offset++, sprite, 1, 0, rowSize);
  125261. this._appendSpriteVertex(offset++, sprite, 1, 1, rowSize);
  125262. this._appendSpriteVertex(offset++, sprite, 0, 1, rowSize);
  125263. }
  125264. this._buffer.update(this._vertexData);
  125265. // Render
  125266. var effect = this._effectBase;
  125267. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  125268. effect = this._effectFog;
  125269. }
  125270. engine.enableEffect(effect);
  125271. var viewMatrix = this._scene.getViewMatrix();
  125272. effect.setTexture("diffuseSampler", this._spriteTexture);
  125273. effect.setMatrix("view", viewMatrix);
  125274. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  125275. effect.setFloat2("textureInfos", this.cellWidth / baseSize.width, this.cellHeight / baseSize.height);
  125276. // Fog
  125277. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  125278. effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
  125279. effect.setColor3("vFogColor", this._scene.fogColor);
  125280. }
  125281. // VBOs
  125282. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  125283. // Draw order
  125284. engine.setDepthFunctionToLessOrEqual();
  125285. effect.setBool("alphaTest", true);
  125286. engine.setColorWrite(false);
  125287. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  125288. engine.setColorWrite(true);
  125289. effect.setBool("alphaTest", false);
  125290. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_COMBINE);
  125291. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  125292. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_DISABLE);
  125293. };
  125294. /**
  125295. * Release associated resources
  125296. */
  125297. SpriteManager.prototype.dispose = function () {
  125298. if (this._buffer) {
  125299. this._buffer.dispose();
  125300. this._buffer = null;
  125301. }
  125302. if (this._indexBuffer) {
  125303. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  125304. this._indexBuffer = null;
  125305. }
  125306. if (this._spriteTexture) {
  125307. this._spriteTexture.dispose();
  125308. this._spriteTexture = null;
  125309. }
  125310. // Remove from scene
  125311. var index = this._scene.spriteManagers.indexOf(this);
  125312. this._scene.spriteManagers.splice(index, 1);
  125313. // Callback
  125314. this.onDisposeObservable.notifyObservers(this);
  125315. this.onDisposeObservable.clear();
  125316. };
  125317. return SpriteManager;
  125318. }());
  125319. /***/ }),
  125320. /***/ "./Sprites/spriteSceneComponent.ts":
  125321. /*!*****************************************!*\
  125322. !*** ./Sprites/spriteSceneComponent.ts ***!
  125323. \*****************************************/
  125324. /*! exports provided: SpriteSceneComponent */
  125325. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125326. "use strict";
  125327. __webpack_require__.r(__webpack_exports__);
  125328. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return SpriteSceneComponent; });
  125329. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  125330. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  125331. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  125332. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  125333. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  125334. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Actions/actionEvent */ "./Actions/actionEvent.ts");
  125335. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125336. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype._internalPickSprites = function (ray, predicate, fastCheck, camera) {
  125337. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]) {
  125338. return null;
  125339. }
  125340. var pickingInfo = null;
  125341. if (!camera) {
  125342. if (!this.activeCamera) {
  125343. return null;
  125344. }
  125345. camera = this.activeCamera;
  125346. }
  125347. if (this.spriteManagers.length > 0) {
  125348. for (var spriteIndex = 0; spriteIndex < this.spriteManagers.length; spriteIndex++) {
  125349. var spriteManager = this.spriteManagers[spriteIndex];
  125350. if (!spriteManager.isPickable) {
  125351. continue;
  125352. }
  125353. var result = spriteManager.intersects(ray, camera, predicate, fastCheck);
  125354. if (!result || !result.hit) {
  125355. continue;
  125356. }
  125357. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  125358. continue;
  125359. }
  125360. pickingInfo = result;
  125361. if (fastCheck) {
  125362. break;
  125363. }
  125364. }
  125365. }
  125366. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]();
  125367. };
  125368. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSprite = function (x, y, predicate, fastCheck, camera) {
  125369. this.createPickingRayInCameraSpaceToRef(x, y, this._tempSpritePickingRay, camera);
  125370. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  125371. };
  125372. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSpriteWithRay = function (ray, predicate, fastCheck, camera) {
  125373. if (!this._tempSpritePickingRay) {
  125374. return null;
  125375. }
  125376. if (!camera) {
  125377. if (!this.activeCamera) {
  125378. return null;
  125379. }
  125380. camera = this.activeCamera;
  125381. }
  125382. _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].TransformToRef(ray, camera.getViewMatrix(), this._tempSpritePickingRay);
  125383. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  125384. };
  125385. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.setPointerOverSprite = function (sprite) {
  125386. if (this._pointerOverSprite === sprite) {
  125387. return;
  125388. }
  125389. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  125390. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  125391. }
  125392. this._pointerOverSprite = sprite;
  125393. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  125394. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  125395. }
  125396. };
  125397. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.getPointerOverSprite = function () {
  125398. return this._pointerOverSprite;
  125399. };
  125400. /**
  125401. * Defines the sprite scene component responsible to manage sprites
  125402. * in a given scene.
  125403. */
  125404. var SpriteSceneComponent = /** @class */ (function () {
  125405. /**
  125406. * Creates a new instance of the component for the given scene
  125407. * @param scene Defines the scene to register the component in
  125408. */
  125409. function SpriteSceneComponent(scene) {
  125410. /**
  125411. * The component name helpfull to identify the component in the list of scene components.
  125412. */
  125413. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_SPRITE;
  125414. this.scene = scene;
  125415. this.scene.spriteManagers = new Array();
  125416. this.scene._tempSpritePickingRay = _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"] ? _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].Zero() : null;
  125417. this.scene.onBeforeSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  125418. this.scene.onAfterSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  125419. this._spritePredicate = function (sprite) {
  125420. if (!sprite.actionManager) {
  125421. return false;
  125422. }
  125423. return sprite.isPickable && sprite.actionManager.hasPointerTriggers;
  125424. };
  125425. }
  125426. /**
  125427. * Registers the component in a given scene
  125428. */
  125429. SpriteSceneComponent.prototype.register = function () {
  125430. this.scene._pointerMoveStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERMOVE_SPRITE, this, this._pointerMove);
  125431. this.scene._pointerDownStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERDOWN_SPRITE, this, this._pointerDown);
  125432. this.scene._pointerUpStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERUP_SPRITE, this, this._pointerUp);
  125433. };
  125434. /**
  125435. * Rebuilds the elements related to this component in case of
  125436. * context lost for instance.
  125437. */
  125438. SpriteSceneComponent.prototype.rebuild = function () {
  125439. /** Nothing to do for sprites */
  125440. };
  125441. /**
  125442. * Disposes the component and the associated ressources.
  125443. */
  125444. SpriteSceneComponent.prototype.dispose = function () {
  125445. this.scene.onBeforeSpritesRenderingObservable.clear();
  125446. this.scene.onAfterSpritesRenderingObservable.clear();
  125447. var spriteManagers = this.scene.spriteManagers;
  125448. while (spriteManagers.length) {
  125449. spriteManagers[0].dispose();
  125450. }
  125451. };
  125452. SpriteSceneComponent.prototype._pickSpriteButKeepRay = function (originalPointerInfo, x, y, fastCheck, camera) {
  125453. var result = this.scene.pickSprite(x, y, this._spritePredicate, fastCheck, camera);
  125454. if (result) {
  125455. result.ray = originalPointerInfo ? originalPointerInfo.ray : null;
  125456. }
  125457. return result;
  125458. };
  125459. SpriteSceneComponent.prototype._pointerMove = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, isMeshPicked, canvas) {
  125460. var scene = this.scene;
  125461. if (isMeshPicked) {
  125462. scene.setPointerOverSprite(null);
  125463. }
  125464. else {
  125465. pickResult = this._pickSpriteButKeepRay(pickResult, unTranslatedPointerX, unTranslatedPointerY, false, scene.cameraToUseForPointers || undefined);
  125466. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  125467. scene.setPointerOverSprite(pickResult.pickedSprite);
  125468. if (scene._pointerOverSprite && scene._pointerOverSprite.actionManager && scene._pointerOverSprite.actionManager.hoverCursor) {
  125469. canvas.style.cursor = scene._pointerOverSprite.actionManager.hoverCursor;
  125470. }
  125471. else {
  125472. canvas.style.cursor = scene.hoverCursor;
  125473. }
  125474. }
  125475. else {
  125476. scene.setPointerOverSprite(null);
  125477. }
  125478. }
  125479. return pickResult;
  125480. };
  125481. SpriteSceneComponent.prototype._pointerDown = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  125482. var scene = this.scene;
  125483. scene._pickedDownSprite = null;
  125484. if (scene.spriteManagers.length > 0) {
  125485. pickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  125486. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  125487. if (pickResult.pickedSprite.actionManager) {
  125488. scene._pickedDownSprite = pickResult.pickedSprite;
  125489. switch (evt.button) {
  125490. case 0:
  125491. 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));
  125492. break;
  125493. case 1:
  125494. 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));
  125495. break;
  125496. case 2:
  125497. 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));
  125498. break;
  125499. }
  125500. if (pickResult.pickedSprite.actionManager) {
  125501. 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));
  125502. }
  125503. }
  125504. }
  125505. }
  125506. return pickResult;
  125507. };
  125508. SpriteSceneComponent.prototype._pointerUp = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  125509. var scene = this.scene;
  125510. if (scene.spriteManagers.length > 0) {
  125511. var spritePickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  125512. if (spritePickResult) {
  125513. if (spritePickResult.hit && spritePickResult.pickedSprite) {
  125514. if (spritePickResult.pickedSprite.actionManager) {
  125515. 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));
  125516. if (spritePickResult.pickedSprite.actionManager) {
  125517. if (!this.scene._isPointerSwiping()) {
  125518. 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));
  125519. }
  125520. }
  125521. }
  125522. }
  125523. if (scene._pickedDownSprite && scene._pickedDownSprite.actionManager && scene._pickedDownSprite !== spritePickResult.pickedSprite) {
  125524. 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));
  125525. }
  125526. }
  125527. }
  125528. return pickResult;
  125529. };
  125530. return SpriteSceneComponent;
  125531. }());
  125532. /***/ }),
  125533. /***/ "./States/alphaCullingState.ts":
  125534. /*!*************************************!*\
  125535. !*** ./States/alphaCullingState.ts ***!
  125536. \*************************************/
  125537. /*! exports provided: _AlphaState */
  125538. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125539. "use strict";
  125540. __webpack_require__.r(__webpack_exports__);
  125541. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _AlphaState; });
  125542. /**
  125543. * @hidden
  125544. **/
  125545. var _AlphaState = /** @class */ (function () {
  125546. /**
  125547. * Initializes the state.
  125548. */
  125549. function _AlphaState() {
  125550. this._isAlphaBlendDirty = false;
  125551. this._isBlendFunctionParametersDirty = false;
  125552. this._isBlendEquationParametersDirty = false;
  125553. this._isBlendConstantsDirty = false;
  125554. this._alphaBlend = false;
  125555. this._blendFunctionParameters = new Array(4);
  125556. this._blendEquationParameters = new Array(2);
  125557. this._blendConstants = new Array(4);
  125558. this.reset();
  125559. }
  125560. Object.defineProperty(_AlphaState.prototype, "isDirty", {
  125561. get: function () {
  125562. return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty;
  125563. },
  125564. enumerable: true,
  125565. configurable: true
  125566. });
  125567. Object.defineProperty(_AlphaState.prototype, "alphaBlend", {
  125568. get: function () {
  125569. return this._alphaBlend;
  125570. },
  125571. set: function (value) {
  125572. if (this._alphaBlend === value) {
  125573. return;
  125574. }
  125575. this._alphaBlend = value;
  125576. this._isAlphaBlendDirty = true;
  125577. },
  125578. enumerable: true,
  125579. configurable: true
  125580. });
  125581. _AlphaState.prototype.setAlphaBlendConstants = function (r, g, b, a) {
  125582. if (this._blendConstants[0] === r &&
  125583. this._blendConstants[1] === g &&
  125584. this._blendConstants[2] === b &&
  125585. this._blendConstants[3] === a) {
  125586. return;
  125587. }
  125588. this._blendConstants[0] = r;
  125589. this._blendConstants[1] = g;
  125590. this._blendConstants[2] = b;
  125591. this._blendConstants[3] = a;
  125592. this._isBlendConstantsDirty = true;
  125593. };
  125594. _AlphaState.prototype.setAlphaBlendFunctionParameters = function (value0, value1, value2, value3) {
  125595. if (this._blendFunctionParameters[0] === value0 &&
  125596. this._blendFunctionParameters[1] === value1 &&
  125597. this._blendFunctionParameters[2] === value2 &&
  125598. this._blendFunctionParameters[3] === value3) {
  125599. return;
  125600. }
  125601. this._blendFunctionParameters[0] = value0;
  125602. this._blendFunctionParameters[1] = value1;
  125603. this._blendFunctionParameters[2] = value2;
  125604. this._blendFunctionParameters[3] = value3;
  125605. this._isBlendFunctionParametersDirty = true;
  125606. };
  125607. _AlphaState.prototype.setAlphaEquationParameters = function (rgb, alpha) {
  125608. if (this._blendEquationParameters[0] === rgb &&
  125609. this._blendEquationParameters[1] === alpha) {
  125610. return;
  125611. }
  125612. this._blendEquationParameters[0] = rgb;
  125613. this._blendEquationParameters[1] = alpha;
  125614. this._isBlendEquationParametersDirty = true;
  125615. };
  125616. _AlphaState.prototype.reset = function () {
  125617. this._alphaBlend = false;
  125618. this._blendFunctionParameters[0] = null;
  125619. this._blendFunctionParameters[1] = null;
  125620. this._blendFunctionParameters[2] = null;
  125621. this._blendFunctionParameters[3] = null;
  125622. this._blendEquationParameters[0] = null;
  125623. this._blendEquationParameters[1] = null;
  125624. this._blendConstants[0] = null;
  125625. this._blendConstants[1] = null;
  125626. this._blendConstants[2] = null;
  125627. this._blendConstants[3] = null;
  125628. this._isAlphaBlendDirty = true;
  125629. this._isBlendFunctionParametersDirty = false;
  125630. this._isBlendEquationParametersDirty = false;
  125631. this._isBlendConstantsDirty = false;
  125632. };
  125633. _AlphaState.prototype.apply = function (gl) {
  125634. if (!this.isDirty) {
  125635. return;
  125636. }
  125637. // Alpha blend
  125638. if (this._isAlphaBlendDirty) {
  125639. if (this._alphaBlend) {
  125640. gl.enable(gl.BLEND);
  125641. }
  125642. else {
  125643. gl.disable(gl.BLEND);
  125644. }
  125645. this._isAlphaBlendDirty = false;
  125646. }
  125647. // Alpha function
  125648. if (this._isBlendFunctionParametersDirty) {
  125649. gl.blendFuncSeparate(this._blendFunctionParameters[0], this._blendFunctionParameters[1], this._blendFunctionParameters[2], this._blendFunctionParameters[3]);
  125650. this._isBlendFunctionParametersDirty = false;
  125651. }
  125652. // Alpha equation
  125653. if (this._isBlendEquationParametersDirty) {
  125654. gl.blendEquationSeparate(this._blendEquationParameters[0], this._blendEquationParameters[1]);
  125655. this._isBlendEquationParametersDirty = false;
  125656. }
  125657. // Constants
  125658. if (this._isBlendConstantsDirty) {
  125659. gl.blendColor(this._blendConstants[0], this._blendConstants[1], this._blendConstants[2], this._blendConstants[3]);
  125660. this._isBlendConstantsDirty = false;
  125661. }
  125662. };
  125663. return _AlphaState;
  125664. }());
  125665. /***/ }),
  125666. /***/ "./States/depthCullingState.ts":
  125667. /*!*************************************!*\
  125668. !*** ./States/depthCullingState.ts ***!
  125669. \*************************************/
  125670. /*! exports provided: _DepthCullingState */
  125671. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125672. "use strict";
  125673. __webpack_require__.r(__webpack_exports__);
  125674. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _DepthCullingState; });
  125675. /**
  125676. * @hidden
  125677. **/
  125678. var _DepthCullingState = /** @class */ (function () {
  125679. /**
  125680. * Initializes the state.
  125681. */
  125682. function _DepthCullingState() {
  125683. this._isDepthTestDirty = false;
  125684. this._isDepthMaskDirty = false;
  125685. this._isDepthFuncDirty = false;
  125686. this._isCullFaceDirty = false;
  125687. this._isCullDirty = false;
  125688. this._isZOffsetDirty = false;
  125689. this._isFrontFaceDirty = false;
  125690. this.reset();
  125691. }
  125692. Object.defineProperty(_DepthCullingState.prototype, "isDirty", {
  125693. get: function () {
  125694. return this._isDepthFuncDirty || this._isDepthTestDirty || this._isDepthMaskDirty || this._isCullFaceDirty || this._isCullDirty || this._isZOffsetDirty || this._isFrontFaceDirty;
  125695. },
  125696. enumerable: true,
  125697. configurable: true
  125698. });
  125699. Object.defineProperty(_DepthCullingState.prototype, "zOffset", {
  125700. get: function () {
  125701. return this._zOffset;
  125702. },
  125703. set: function (value) {
  125704. if (this._zOffset === value) {
  125705. return;
  125706. }
  125707. this._zOffset = value;
  125708. this._isZOffsetDirty = true;
  125709. },
  125710. enumerable: true,
  125711. configurable: true
  125712. });
  125713. Object.defineProperty(_DepthCullingState.prototype, "cullFace", {
  125714. get: function () {
  125715. return this._cullFace;
  125716. },
  125717. set: function (value) {
  125718. if (this._cullFace === value) {
  125719. return;
  125720. }
  125721. this._cullFace = value;
  125722. this._isCullFaceDirty = true;
  125723. },
  125724. enumerable: true,
  125725. configurable: true
  125726. });
  125727. Object.defineProperty(_DepthCullingState.prototype, "cull", {
  125728. get: function () {
  125729. return this._cull;
  125730. },
  125731. set: function (value) {
  125732. if (this._cull === value) {
  125733. return;
  125734. }
  125735. this._cull = value;
  125736. this._isCullDirty = true;
  125737. },
  125738. enumerable: true,
  125739. configurable: true
  125740. });
  125741. Object.defineProperty(_DepthCullingState.prototype, "depthFunc", {
  125742. get: function () {
  125743. return this._depthFunc;
  125744. },
  125745. set: function (value) {
  125746. if (this._depthFunc === value) {
  125747. return;
  125748. }
  125749. this._depthFunc = value;
  125750. this._isDepthFuncDirty = true;
  125751. },
  125752. enumerable: true,
  125753. configurable: true
  125754. });
  125755. Object.defineProperty(_DepthCullingState.prototype, "depthMask", {
  125756. get: function () {
  125757. return this._depthMask;
  125758. },
  125759. set: function (value) {
  125760. if (this._depthMask === value) {
  125761. return;
  125762. }
  125763. this._depthMask = value;
  125764. this._isDepthMaskDirty = true;
  125765. },
  125766. enumerable: true,
  125767. configurable: true
  125768. });
  125769. Object.defineProperty(_DepthCullingState.prototype, "depthTest", {
  125770. get: function () {
  125771. return this._depthTest;
  125772. },
  125773. set: function (value) {
  125774. if (this._depthTest === value) {
  125775. return;
  125776. }
  125777. this._depthTest = value;
  125778. this._isDepthTestDirty = true;
  125779. },
  125780. enumerable: true,
  125781. configurable: true
  125782. });
  125783. Object.defineProperty(_DepthCullingState.prototype, "frontFace", {
  125784. get: function () {
  125785. return this._frontFace;
  125786. },
  125787. set: function (value) {
  125788. if (this._frontFace === value) {
  125789. return;
  125790. }
  125791. this._frontFace = value;
  125792. this._isFrontFaceDirty = true;
  125793. },
  125794. enumerable: true,
  125795. configurable: true
  125796. });
  125797. _DepthCullingState.prototype.reset = function () {
  125798. this._depthMask = true;
  125799. this._depthTest = true;
  125800. this._depthFunc = null;
  125801. this._cullFace = null;
  125802. this._cull = null;
  125803. this._zOffset = 0;
  125804. this._frontFace = null;
  125805. this._isDepthTestDirty = true;
  125806. this._isDepthMaskDirty = true;
  125807. this._isDepthFuncDirty = false;
  125808. this._isCullFaceDirty = false;
  125809. this._isCullDirty = false;
  125810. this._isZOffsetDirty = false;
  125811. this._isFrontFaceDirty = false;
  125812. };
  125813. _DepthCullingState.prototype.apply = function (gl) {
  125814. if (!this.isDirty) {
  125815. return;
  125816. }
  125817. // Cull
  125818. if (this._isCullDirty) {
  125819. if (this.cull) {
  125820. gl.enable(gl.CULL_FACE);
  125821. }
  125822. else {
  125823. gl.disable(gl.CULL_FACE);
  125824. }
  125825. this._isCullDirty = false;
  125826. }
  125827. // Cull face
  125828. if (this._isCullFaceDirty) {
  125829. gl.cullFace(this.cullFace);
  125830. this._isCullFaceDirty = false;
  125831. }
  125832. // Depth mask
  125833. if (this._isDepthMaskDirty) {
  125834. gl.depthMask(this.depthMask);
  125835. this._isDepthMaskDirty = false;
  125836. }
  125837. // Depth test
  125838. if (this._isDepthTestDirty) {
  125839. if (this.depthTest) {
  125840. gl.enable(gl.DEPTH_TEST);
  125841. }
  125842. else {
  125843. gl.disable(gl.DEPTH_TEST);
  125844. }
  125845. this._isDepthTestDirty = false;
  125846. }
  125847. // Depth func
  125848. if (this._isDepthFuncDirty) {
  125849. gl.depthFunc(this.depthFunc);
  125850. this._isDepthFuncDirty = false;
  125851. }
  125852. // zOffset
  125853. if (this._isZOffsetDirty) {
  125854. if (this.zOffset) {
  125855. gl.enable(gl.POLYGON_OFFSET_FILL);
  125856. gl.polygonOffset(this.zOffset, 0);
  125857. }
  125858. else {
  125859. gl.disable(gl.POLYGON_OFFSET_FILL);
  125860. }
  125861. this._isZOffsetDirty = false;
  125862. }
  125863. // Front face
  125864. if (this._isFrontFaceDirty) {
  125865. gl.frontFace(this.frontFace);
  125866. this._isFrontFaceDirty = false;
  125867. }
  125868. };
  125869. return _DepthCullingState;
  125870. }());
  125871. /***/ }),
  125872. /***/ "./States/index.ts":
  125873. /*!*************************!*\
  125874. !*** ./States/index.ts ***!
  125875. \*************************/
  125876. /*! exports provided: _AlphaState, _DepthCullingState, _StencilState */
  125877. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125878. "use strict";
  125879. __webpack_require__.r(__webpack_exports__);
  125880. /* harmony import */ var _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./alphaCullingState */ "./States/alphaCullingState.ts");
  125881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  125882. /* harmony import */ var _depthCullingState__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthCullingState */ "./States/depthCullingState.ts");
  125883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _depthCullingState__WEBPACK_IMPORTED_MODULE_1__["_DepthCullingState"]; });
  125884. /* harmony import */ var _stencilState__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stencilState */ "./States/stencilState.ts");
  125885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _stencilState__WEBPACK_IMPORTED_MODULE_2__["_StencilState"]; });
  125886. /***/ }),
  125887. /***/ "./States/stencilState.ts":
  125888. /*!********************************!*\
  125889. !*** ./States/stencilState.ts ***!
  125890. \********************************/
  125891. /*! exports provided: _StencilState */
  125892. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125893. "use strict";
  125894. __webpack_require__.r(__webpack_exports__);
  125895. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _StencilState; });
  125896. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125897. /**
  125898. * @hidden
  125899. **/
  125900. var _StencilState = /** @class */ (function () {
  125901. function _StencilState() {
  125902. this._isStencilTestDirty = false;
  125903. this._isStencilMaskDirty = false;
  125904. this._isStencilFuncDirty = false;
  125905. this._isStencilOpDirty = false;
  125906. this.reset();
  125907. }
  125908. Object.defineProperty(_StencilState.prototype, "isDirty", {
  125909. get: function () {
  125910. return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty;
  125911. },
  125912. enumerable: true,
  125913. configurable: true
  125914. });
  125915. Object.defineProperty(_StencilState.prototype, "stencilFunc", {
  125916. get: function () {
  125917. return this._stencilFunc;
  125918. },
  125919. set: function (value) {
  125920. if (this._stencilFunc === value) {
  125921. return;
  125922. }
  125923. this._stencilFunc = value;
  125924. this._isStencilFuncDirty = true;
  125925. },
  125926. enumerable: true,
  125927. configurable: true
  125928. });
  125929. Object.defineProperty(_StencilState.prototype, "stencilFuncRef", {
  125930. get: function () {
  125931. return this._stencilFuncRef;
  125932. },
  125933. set: function (value) {
  125934. if (this._stencilFuncRef === value) {
  125935. return;
  125936. }
  125937. this._stencilFuncRef = value;
  125938. this._isStencilFuncDirty = true;
  125939. },
  125940. enumerable: true,
  125941. configurable: true
  125942. });
  125943. Object.defineProperty(_StencilState.prototype, "stencilFuncMask", {
  125944. get: function () {
  125945. return this._stencilFuncMask;
  125946. },
  125947. set: function (value) {
  125948. if (this._stencilFuncMask === value) {
  125949. return;
  125950. }
  125951. this._stencilFuncMask = value;
  125952. this._isStencilFuncDirty = true;
  125953. },
  125954. enumerable: true,
  125955. configurable: true
  125956. });
  125957. Object.defineProperty(_StencilState.prototype, "stencilOpStencilFail", {
  125958. get: function () {
  125959. return this._stencilOpStencilFail;
  125960. },
  125961. set: function (value) {
  125962. if (this._stencilOpStencilFail === value) {
  125963. return;
  125964. }
  125965. this._stencilOpStencilFail = value;
  125966. this._isStencilOpDirty = true;
  125967. },
  125968. enumerable: true,
  125969. configurable: true
  125970. });
  125971. Object.defineProperty(_StencilState.prototype, "stencilOpDepthFail", {
  125972. get: function () {
  125973. return this._stencilOpDepthFail;
  125974. },
  125975. set: function (value) {
  125976. if (this._stencilOpDepthFail === value) {
  125977. return;
  125978. }
  125979. this._stencilOpDepthFail = value;
  125980. this._isStencilOpDirty = true;
  125981. },
  125982. enumerable: true,
  125983. configurable: true
  125984. });
  125985. Object.defineProperty(_StencilState.prototype, "stencilOpStencilDepthPass", {
  125986. get: function () {
  125987. return this._stencilOpStencilDepthPass;
  125988. },
  125989. set: function (value) {
  125990. if (this._stencilOpStencilDepthPass === value) {
  125991. return;
  125992. }
  125993. this._stencilOpStencilDepthPass = value;
  125994. this._isStencilOpDirty = true;
  125995. },
  125996. enumerable: true,
  125997. configurable: true
  125998. });
  125999. Object.defineProperty(_StencilState.prototype, "stencilMask", {
  126000. get: function () {
  126001. return this._stencilMask;
  126002. },
  126003. set: function (value) {
  126004. if (this._stencilMask === value) {
  126005. return;
  126006. }
  126007. this._stencilMask = value;
  126008. this._isStencilMaskDirty = true;
  126009. },
  126010. enumerable: true,
  126011. configurable: true
  126012. });
  126013. Object.defineProperty(_StencilState.prototype, "stencilTest", {
  126014. get: function () {
  126015. return this._stencilTest;
  126016. },
  126017. set: function (value) {
  126018. if (this._stencilTest === value) {
  126019. return;
  126020. }
  126021. this._stencilTest = value;
  126022. this._isStencilTestDirty = true;
  126023. },
  126024. enumerable: true,
  126025. configurable: true
  126026. });
  126027. _StencilState.prototype.reset = function () {
  126028. this._stencilTest = false;
  126029. this._stencilMask = 0xFF;
  126030. this._stencilFunc = _StencilState.ALWAYS;
  126031. this._stencilFuncRef = 1;
  126032. this._stencilFuncMask = 0xFF;
  126033. this._stencilOpStencilFail = _StencilState.KEEP;
  126034. this._stencilOpDepthFail = _StencilState.KEEP;
  126035. this._stencilOpStencilDepthPass = _StencilState.REPLACE;
  126036. this._isStencilTestDirty = true;
  126037. this._isStencilMaskDirty = true;
  126038. this._isStencilFuncDirty = true;
  126039. this._isStencilOpDirty = true;
  126040. };
  126041. _StencilState.prototype.apply = function (gl) {
  126042. if (!this.isDirty) {
  126043. return;
  126044. }
  126045. // Stencil test
  126046. if (this._isStencilTestDirty) {
  126047. if (this.stencilTest) {
  126048. gl.enable(gl.STENCIL_TEST);
  126049. }
  126050. else {
  126051. gl.disable(gl.STENCIL_TEST);
  126052. }
  126053. this._isStencilTestDirty = false;
  126054. }
  126055. // Stencil mask
  126056. if (this._isStencilMaskDirty) {
  126057. gl.stencilMask(this.stencilMask);
  126058. this._isStencilMaskDirty = false;
  126059. }
  126060. // Stencil func
  126061. if (this._isStencilFuncDirty) {
  126062. gl.stencilFunc(this.stencilFunc, this.stencilFuncRef, this.stencilFuncMask);
  126063. this._isStencilFuncDirty = false;
  126064. }
  126065. // Stencil op
  126066. if (this._isStencilOpDirty) {
  126067. gl.stencilOp(this.stencilOpStencilFail, this.stencilOpDepthFail, this.stencilOpStencilDepthPass);
  126068. this._isStencilOpDirty = false;
  126069. }
  126070. };
  126071. /** 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 */
  126072. _StencilState.ALWAYS = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ALWAYS;
  126073. /** Passed to stencilOperation to specify that stencil value must be kept */
  126074. _StencilState.KEEP = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].KEEP;
  126075. /** Passed to stencilOperation to specify that stencil value must be replaced */
  126076. _StencilState.REPLACE = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].REPLACE;
  126077. return _StencilState;
  126078. }());
  126079. /***/ }),
  126080. /***/ "./abstractScene.ts":
  126081. /*!**************************!*\
  126082. !*** ./abstractScene.ts ***!
  126083. \**************************/
  126084. /*! exports provided: AbstractScene */
  126085. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126086. "use strict";
  126087. __webpack_require__.r(__webpack_exports__);
  126088. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return AbstractScene; });
  126089. /**
  126090. * Base class of the scene acting as a container for the different elements composing a scene.
  126091. * This class is dynamically extended by the different components of the scene increasing
  126092. * flexibility and reducing coupling
  126093. */
  126094. var AbstractScene = /** @class */ (function () {
  126095. function AbstractScene() {
  126096. /**
  126097. * Gets the list of root nodes (ie. nodes with no parent)
  126098. */
  126099. this.rootNodes = new Array();
  126100. /** All of the cameras added to this scene
  126101. * @see http://doc.babylonjs.com/babylon101/cameras
  126102. */
  126103. this.cameras = new Array();
  126104. /**
  126105. * All of the lights added to this scene
  126106. * @see http://doc.babylonjs.com/babylon101/lights
  126107. */
  126108. this.lights = new Array();
  126109. /**
  126110. * All of the (abstract) meshes added to this scene
  126111. */
  126112. this.meshes = new Array();
  126113. /**
  126114. * The list of skeletons added to the scene
  126115. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  126116. */
  126117. this.skeletons = new Array();
  126118. /**
  126119. * All of the particle systems added to this scene
  126120. * @see http://doc.babylonjs.com/babylon101/particles
  126121. */
  126122. this.particleSystems = new Array();
  126123. /**
  126124. * Gets a list of Animations associated with the scene
  126125. */
  126126. this.animations = [];
  126127. /**
  126128. * All of the animation groups added to this scene
  126129. * @see http://doc.babylonjs.com/how_to/group
  126130. */
  126131. this.animationGroups = new Array();
  126132. /**
  126133. * All of the multi-materials added to this scene
  126134. * @see http://doc.babylonjs.com/how_to/multi_materials
  126135. */
  126136. this.multiMaterials = new Array();
  126137. /**
  126138. * All of the materials added to this scene
  126139. * In the context of a Scene, it is not supposed to be modified manually.
  126140. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  126141. * Note also that the order of the Material wihin the array is not significant and might change.
  126142. * @see http://doc.babylonjs.com/babylon101/materials
  126143. */
  126144. this.materials = new Array();
  126145. /**
  126146. * The list of morph target managers added to the scene
  126147. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  126148. */
  126149. this.morphTargetManagers = new Array();
  126150. /**
  126151. * The list of geometries used in the scene.
  126152. */
  126153. this.geometries = new Array();
  126154. /**
  126155. * All of the tranform nodes added to this scene
  126156. * In the context of a Scene, it is not supposed to be modified manually.
  126157. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  126158. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  126159. * @see http://doc.babylonjs.com/how_to/transformnode
  126160. */
  126161. this.transformNodes = new Array();
  126162. /**
  126163. * ActionManagers available on the scene.
  126164. */
  126165. this.actionManagers = new Array();
  126166. /**
  126167. * Textures to keep.
  126168. */
  126169. this.textures = new Array();
  126170. }
  126171. /**
  126172. * Adds a parser in the list of available ones
  126173. * @param name Defines the name of the parser
  126174. * @param parser Defines the parser to add
  126175. */
  126176. AbstractScene.AddParser = function (name, parser) {
  126177. this._BabylonFileParsers[name] = parser;
  126178. };
  126179. /**
  126180. * Gets a general parser from the list of avaialble ones
  126181. * @param name Defines the name of the parser
  126182. * @returns the requested parser or null
  126183. */
  126184. AbstractScene.GetParser = function (name) {
  126185. if (this._BabylonFileParsers[name]) {
  126186. return this._BabylonFileParsers[name];
  126187. }
  126188. return null;
  126189. };
  126190. /**
  126191. * Adds n individual parser in the list of available ones
  126192. * @param name Defines the name of the parser
  126193. * @param parser Defines the parser to add
  126194. */
  126195. AbstractScene.AddIndividualParser = function (name, parser) {
  126196. this._IndividualBabylonFileParsers[name] = parser;
  126197. };
  126198. /**
  126199. * Gets an individual parser from the list of avaialble ones
  126200. * @param name Defines the name of the parser
  126201. * @returns the requested parser or null
  126202. */
  126203. AbstractScene.GetIndividualParser = function (name) {
  126204. if (this._IndividualBabylonFileParsers[name]) {
  126205. return this._IndividualBabylonFileParsers[name];
  126206. }
  126207. return null;
  126208. };
  126209. /**
  126210. * Parser json data and populate both a scene and its associated container object
  126211. * @param jsonData Defines the data to parse
  126212. * @param scene Defines the scene to parse the data for
  126213. * @param container Defines the container attached to the parsing sequence
  126214. * @param rootUrl Defines the root url of the data
  126215. */
  126216. AbstractScene.Parse = function (jsonData, scene, container, rootUrl) {
  126217. for (var parserName in this._BabylonFileParsers) {
  126218. if (this._BabylonFileParsers.hasOwnProperty(parserName)) {
  126219. this._BabylonFileParsers[parserName](jsonData, scene, container, rootUrl);
  126220. }
  126221. }
  126222. };
  126223. /**
  126224. * Stores the list of available parsers in the application.
  126225. */
  126226. AbstractScene._BabylonFileParsers = {};
  126227. /**
  126228. * Stores the list of available individual parsers in the application.
  126229. */
  126230. AbstractScene._IndividualBabylonFileParsers = {};
  126231. return AbstractScene;
  126232. }());
  126233. /***/ }),
  126234. /***/ "./assetContainer.ts":
  126235. /*!***************************!*\
  126236. !*** ./assetContainer.ts ***!
  126237. \***************************/
  126238. /*! exports provided: KeepAssets, AssetContainer */
  126239. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126240. "use strict";
  126241. __webpack_require__.r(__webpack_exports__);
  126242. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return KeepAssets; });
  126243. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return AssetContainer; });
  126244. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  126245. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  126246. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Meshes/mesh */ "./Meshes/mesh.ts");
  126247. /**
  126248. * Set of assets to keep when moving a scene into an asset container.
  126249. */
  126250. var KeepAssets = /** @class */ (function (_super) {
  126251. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeepAssets, _super);
  126252. function KeepAssets() {
  126253. return _super !== null && _super.apply(this, arguments) || this;
  126254. }
  126255. return KeepAssets;
  126256. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  126257. /**
  126258. * Container with a set of assets that can be added or removed from a scene.
  126259. */
  126260. var AssetContainer = /** @class */ (function (_super) {
  126261. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AssetContainer, _super);
  126262. /**
  126263. * Instantiates an AssetContainer.
  126264. * @param scene The scene the AssetContainer belongs to.
  126265. */
  126266. function AssetContainer(scene) {
  126267. var _this = _super.call(this) || this;
  126268. _this.scene = scene;
  126269. _this["sounds"] = [];
  126270. _this["effectLayers"] = [];
  126271. _this["layers"] = [];
  126272. _this["lensFlareSystems"] = [];
  126273. _this["proceduralTextures"] = [];
  126274. _this["reflectionProbes"] = [];
  126275. return _this;
  126276. }
  126277. /**
  126278. * Adds all the assets from the container to the scene.
  126279. */
  126280. AssetContainer.prototype.addAllToScene = function () {
  126281. var _this = this;
  126282. this.cameras.forEach(function (o) {
  126283. _this.scene.addCamera(o);
  126284. });
  126285. this.lights.forEach(function (o) {
  126286. _this.scene.addLight(o);
  126287. });
  126288. this.meshes.forEach(function (o) {
  126289. _this.scene.addMesh(o);
  126290. });
  126291. this.skeletons.forEach(function (o) {
  126292. _this.scene.addSkeleton(o);
  126293. });
  126294. this.animations.forEach(function (o) {
  126295. _this.scene.addAnimation(o);
  126296. });
  126297. this.animationGroups.forEach(function (o) {
  126298. _this.scene.addAnimationGroup(o);
  126299. });
  126300. this.multiMaterials.forEach(function (o) {
  126301. _this.scene.addMultiMaterial(o);
  126302. });
  126303. this.materials.forEach(function (o) {
  126304. _this.scene.addMaterial(o);
  126305. });
  126306. this.morphTargetManagers.forEach(function (o) {
  126307. _this.scene.addMorphTargetManager(o);
  126308. });
  126309. this.geometries.forEach(function (o) {
  126310. _this.scene.addGeometry(o);
  126311. });
  126312. this.transformNodes.forEach(function (o) {
  126313. _this.scene.addTransformNode(o);
  126314. });
  126315. this.actionManagers.forEach(function (o) {
  126316. _this.scene.addActionManager(o);
  126317. });
  126318. this.textures.forEach(function (o) {
  126319. _this.scene.addTexture(o);
  126320. });
  126321. this.reflectionProbes.forEach(function (o) {
  126322. _this.scene.addReflectionProbe(o);
  126323. });
  126324. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  126325. var component = _a[_i];
  126326. component.addFromContainer(this);
  126327. }
  126328. };
  126329. /**
  126330. * Removes all the assets in the container from the scene
  126331. */
  126332. AssetContainer.prototype.removeAllFromScene = function () {
  126333. var _this = this;
  126334. this.cameras.forEach(function (o) {
  126335. _this.scene.removeCamera(o);
  126336. });
  126337. this.lights.forEach(function (o) {
  126338. _this.scene.removeLight(o);
  126339. });
  126340. this.meshes.forEach(function (o) {
  126341. _this.scene.removeMesh(o);
  126342. });
  126343. this.skeletons.forEach(function (o) {
  126344. _this.scene.removeSkeleton(o);
  126345. });
  126346. this.animations.forEach(function (o) {
  126347. _this.scene.removeAnimation(o);
  126348. });
  126349. this.animationGroups.forEach(function (o) {
  126350. _this.scene.removeAnimationGroup(o);
  126351. });
  126352. this.multiMaterials.forEach(function (o) {
  126353. _this.scene.removeMultiMaterial(o);
  126354. });
  126355. this.materials.forEach(function (o) {
  126356. _this.scene.removeMaterial(o);
  126357. });
  126358. this.morphTargetManagers.forEach(function (o) {
  126359. _this.scene.removeMorphTargetManager(o);
  126360. });
  126361. this.geometries.forEach(function (o) {
  126362. _this.scene.removeGeometry(o);
  126363. });
  126364. this.transformNodes.forEach(function (o) {
  126365. _this.scene.removeTransformNode(o);
  126366. });
  126367. this.actionManagers.forEach(function (o) {
  126368. _this.scene.removeActionManager(o);
  126369. });
  126370. this.textures.forEach(function (o) {
  126371. _this.scene.removeTexture(o);
  126372. });
  126373. this.reflectionProbes.forEach(function (o) {
  126374. _this.scene.removeReflectionProbe(o);
  126375. });
  126376. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  126377. var component = _a[_i];
  126378. component.removeFromContainer(this);
  126379. }
  126380. };
  126381. /**
  126382. * Disposes all the assets in the container
  126383. */
  126384. AssetContainer.prototype.dispose = function () {
  126385. this.cameras.forEach(function (o) {
  126386. o.dispose();
  126387. });
  126388. this.lights.forEach(function (o) {
  126389. o.dispose();
  126390. });
  126391. this.meshes.forEach(function (o) {
  126392. o.dispose();
  126393. });
  126394. this.skeletons.forEach(function (o) {
  126395. o.dispose();
  126396. });
  126397. this.animationGroups.forEach(function (o) {
  126398. o.dispose();
  126399. });
  126400. this.multiMaterials.forEach(function (o) {
  126401. o.dispose();
  126402. });
  126403. this.materials.forEach(function (o) {
  126404. o.dispose();
  126405. });
  126406. this.geometries.forEach(function (o) {
  126407. o.dispose();
  126408. });
  126409. this.transformNodes.forEach(function (o) {
  126410. o.dispose();
  126411. });
  126412. this.actionManagers.forEach(function (o) {
  126413. o.dispose();
  126414. });
  126415. this.textures.forEach(function (o) {
  126416. o.dispose();
  126417. });
  126418. this.reflectionProbes.forEach(function (o) {
  126419. o.dispose();
  126420. });
  126421. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  126422. var component = _a[_i];
  126423. component.dispose();
  126424. }
  126425. };
  126426. AssetContainer.prototype._moveAssets = function (sourceAssets, targetAssets, keepAssets) {
  126427. if (!sourceAssets) {
  126428. return;
  126429. }
  126430. for (var _i = 0, sourceAssets_1 = sourceAssets; _i < sourceAssets_1.length; _i++) {
  126431. var asset = sourceAssets_1[_i];
  126432. var move = true;
  126433. if (keepAssets) {
  126434. for (var _a = 0, keepAssets_1 = keepAssets; _a < keepAssets_1.length; _a++) {
  126435. var keepAsset = keepAssets_1[_a];
  126436. if (asset === keepAsset) {
  126437. move = false;
  126438. break;
  126439. }
  126440. }
  126441. }
  126442. if (move) {
  126443. targetAssets.push(asset);
  126444. }
  126445. }
  126446. };
  126447. /**
  126448. * Removes all the assets contained in the scene and adds them to the container.
  126449. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  126450. */
  126451. AssetContainer.prototype.moveAllFromScene = function (keepAssets) {
  126452. if (keepAssets === undefined) {
  126453. keepAssets = new KeepAssets();
  126454. }
  126455. for (var key in this) {
  126456. if (this.hasOwnProperty(key)) {
  126457. this[key] = this[key] || [];
  126458. this._moveAssets(this.scene[key], this[key], keepAssets[key]);
  126459. }
  126460. }
  126461. this.removeAllFromScene();
  126462. };
  126463. /**
  126464. * 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.
  126465. * @returns the root mesh
  126466. */
  126467. AssetContainer.prototype.createRootMesh = function () {
  126468. var rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("assetContainerRootMesh", this.scene);
  126469. this.meshes.forEach(function (m) {
  126470. if (!m.parent) {
  126471. rootMesh.addChild(m);
  126472. }
  126473. });
  126474. this.meshes.unshift(rootMesh);
  126475. return rootMesh;
  126476. };
  126477. return AssetContainer;
  126478. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  126479. /***/ }),
  126480. /***/ "./index.ts":
  126481. /*!******************!*\
  126482. !*** ./index.ts ***!
  126483. \******************/
  126484. /*! 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 */
  126485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126486. "use strict";
  126487. __webpack_require__.r(__webpack_exports__);
  126488. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  126489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _abstractScene__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  126490. /* harmony import */ var _Actions_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Actions/index */ "./Actions/index.ts");
  126491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Action"]; });
  126492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  126493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionManager"]; });
  126494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Condition"]; });
  126495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ValueCondition"]; });
  126496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PredicateCondition"]; });
  126497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StateCondition"]; });
  126498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SwitchBooleanAction"]; });
  126499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetStateAction"]; });
  126500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetValueAction"]; });
  126501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["IncrementValueAction"]; });
  126502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlayAnimationAction"]; });
  126503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopAnimationAction"]; });
  126504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["DoNothingAction"]; });
  126505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["CombineAction"]; });
  126506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ExecuteCodeAction"]; });
  126507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetParentAction"]; });
  126508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlaySoundAction"]; });
  126509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopSoundAction"]; });
  126510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["InterpolateValueAction"]; });
  126511. /* harmony import */ var _Animations_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Animations/index */ "./Animations/index.ts");
  126512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animatable"]; });
  126513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animation"]; });
  126514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  126515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  126516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationPropertiesOverride"]; });
  126517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["EasingFunction"]; });
  126518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CircleEase"]; });
  126519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BackEase"]; });
  126520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BounceEase"]; });
  126521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CubicEase"]; });
  126522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ElasticEase"]; });
  126523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ExponentialEase"]; });
  126524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["PowerEase"]; });
  126525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuadraticEase"]; });
  126526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuarticEase"]; });
  126527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuinticEase"]; });
  126528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["SineEase"]; });
  126529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BezierCurveEase"]; });
  126530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["RuntimeAnimation"]; });
  126531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationEvent"]; });
  126532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationKeyInterpolation"]; });
  126533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationRange"]; });
  126534. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./assetContainer */ "./assetContainer.ts");
  126535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["KeepAssets"]; });
  126536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["AssetContainer"]; });
  126537. /* harmony import */ var _Audio_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Audio/index */ "./Audio/index.ts");
  126538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Analyser"]; });
  126539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioEngine"]; });
  126540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioSceneComponent"]; });
  126541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Sound"]; });
  126542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  126543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["WeightedSound"]; });
  126544. /* harmony import */ var _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Behaviors/index */ "./Behaviors/index.ts");
  126545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AutoRotationBehavior"]; });
  126546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["BouncingBehavior"]; });
  126547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FramingBehavior"]; });
  126548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AttachToBoxBehavior"]; });
  126549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FadeInOutBehavior"]; });
  126550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["MultiPointerScaleBehavior"]; });
  126551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]; });
  126552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]; });
  126553. /* harmony import */ var _Bones_index__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Bones/index */ "./Bones/index.ts");
  126554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Bone"]; });
  126555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneIKController"]; });
  126556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneLookController"]; });
  126557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Skeleton"]; });
  126558. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Cameras/index */ "./Cameras/index.ts");
  126559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputTypes"]; });
  126560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputsManager"]; });
  126561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["Camera"]; });
  126562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TargetCamera"]; });
  126563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCamera"]; });
  126564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraInputsManager"]; });
  126565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TouchCamera"]; });
  126566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  126567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraInputsManager"]; });
  126568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["DeviceOrientationCamera"]; });
  126569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCamera"]; });
  126570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraInputsManager"]; });
  126571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCamera"]; });
  126572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcFollowCamera"]; });
  126573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["GamepadCamera"]; });
  126574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["UniversalCamera"]; });
  126575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VirtualJoysticksCamera"]; });
  126576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraGamepadInput"]; });
  126577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraKeyboardMoveInput"]; });
  126578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraMouseWheelInput"]; });
  126579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraPointersInput"]; });
  126580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraVRDeviceOrientationInput"]; });
  126581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraKeyboardInput"]; });
  126582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraMouseInput"]; });
  126583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  126584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraGamepadInput"]; });
  126585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraKeyboardMoveInput"]; });
  126586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraMouseInput"]; });
  126587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraTouchInput"]; });
  126588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraVirtualJoystickInput"]; });
  126589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphArcRotateCamera"]; });
  126590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphFreeCamera"]; });
  126591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphGamepadCamera"]; });
  126592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphUniversalCamera"]; });
  126593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicArcRotateCamera"]; });
  126594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicFreeCamera"]; });
  126595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicGamepadCamera"]; });
  126596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  126597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRCameraMetrics"]; });
  126598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationArcRotateCamera"]; });
  126599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationFreeCamera"]; });
  126600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationGamepadCamera"]; });
  126601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRExperienceHelper"]; });
  126602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]; });
  126603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRCamera"]; });
  126604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIButton"]; });
  126605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIOptions"]; });
  126606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUI"]; });
  126607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRState"]; });
  126608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRExperienceHelper"]; });
  126609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRController"]; });
  126610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRInput"]; });
  126611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRManagedOutputCanvas"]; });
  126612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRSessionManager"]; });
  126613. /* harmony import */ var _Collisions_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Collisions/index */ "./Collisions/index.ts");
  126614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["Collider"]; });
  126615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["DefaultCollisionCoordinator"]; });
  126616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]; });
  126617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["IntersectionInfo"]; });
  126618. /* harmony import */ var _Culling_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Culling/index */ "./Culling/index.ts");
  126619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingBox"]; });
  126620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"]; });
  126621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingSphere"]; });
  126622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Ray"]; });
  126623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Octree"]; });
  126624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeBlock"]; });
  126625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeSceneComponent"]; });
  126626. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Debug/index */ "./Debug/index.ts");
  126627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["AxesViewer"]; });
  126628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["BoneAxesViewer"]; });
  126629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["DebugLayer"]; });
  126630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["PhysicsViewer"]; });
  126631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["RayHelper"]; });
  126632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["SkeletonViewer"]; });
  126633. /* harmony import */ var _Engines_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Engines/index */ "./Engines/index.ts");
  126634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Constants"]; });
  126635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["InstancingAttributeInfo"]; });
  126636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["DepthTextureCreationOptions"]; });
  126637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineCapabilities"]; });
  126638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Engine"]; });
  126639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineStore"]; });
  126640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngineOptions"]; });
  126641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngine"]; });
  126642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_OcclusionDataStorage"]; });
  126643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_forceTransformFeedbackToBundle"]; });
  126644. /* harmony import */ var _Events_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Events/index */ "./Events/index.ts");
  126645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardEventTypes"]; });
  126646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfo"]; });
  126647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfoPre"]; });
  126648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerEventTypes"]; });
  126649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoBase"]; });
  126650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoPre"]; });
  126651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfo"]; });
  126652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardEventTypes"]; });
  126653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardInfo"]; });
  126654. /* harmony import */ var _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Gamepads/index */ "./Gamepads/index.ts");
  126655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["DaydreamController"]; });
  126656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GearVRController"]; });
  126657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericController"]; });
  126658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["OculusTouchController"]; });
  126659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerType"]; });
  126660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerHelper"]; });
  126661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledController"]; });
  126662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["ViveController"]; });
  126663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WebVRController"]; });
  126664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WindowsMotionController"]; });
  126665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["StickValues"]; });
  126666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Gamepad"]; });
  126667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericPad"]; });
  126668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadManager"]; });
  126669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadSystemSceneComponent"]; });
  126670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"]; });
  126671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Dpad"]; });
  126672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Pad"]; });
  126673. /* harmony import */ var _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Gizmos/index */ "./Gizmos/index.ts");
  126674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisDragGizmo"]; });
  126675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisScaleGizmo"]; });
  126676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["BoundingBoxGizmo"]; });
  126677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["Gizmo"]; });
  126678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["GizmoManager"]; });
  126679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PlaneRotationGizmo"]; });
  126680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PositionGizmo"]; });
  126681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["RotationGizmo"]; });
  126682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["ScaleGizmo"]; });
  126683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["LightGizmo"]; });
  126684. /* harmony import */ var _Helpers_index__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Helpers/index */ "./Helpers/index.ts");
  126685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["EnvironmentHelper"]; });
  126686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["PhotoDome"]; });
  126687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["_forceSceneHelpersToBundle"]; });
  126688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["VideoDome"]; });
  126689. /* harmony import */ var _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Instrumentation/index */ "./Instrumentation/index.ts");
  126690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["EngineInstrumentation"]; });
  126691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["SceneInstrumentation"]; });
  126692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["_TimeToken"]; });
  126693. /* harmony import */ var _Layers_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Layers/index */ "./Layers/index.ts");
  126694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayer"]; });
  126695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayerSceneComponent"]; });
  126696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["GlowLayer"]; });
  126697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["HighlightLayer"]; });
  126698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["Layer"]; });
  126699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["LayerSceneComponent"]; });
  126700. /* harmony import */ var _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./LensFlares/index */ "./LensFlares/index.ts");
  126701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlare"]; });
  126702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystem"]; });
  126703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystemSceneComponent"]; });
  126704. /* harmony import */ var _Lights_index__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Lights/index */ "./Lights/index.ts");
  126705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["Light"]; });
  126706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowLight"]; });
  126707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["DirectionalLight"]; });
  126708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["HemisphericLight"]; });
  126709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["PointLight"]; });
  126710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["SpotLight"]; });
  126711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGenerator"]; });
  126712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGeneratorSceneComponent"]; });
  126713. /* harmony import */ var _Loading_index__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Loading/index */ "./Loading/index.ts");
  126714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["DefaultLoadingScreen"]; });
  126715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderProgressEvent"]; });
  126716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoader"]; });
  126717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderFlags"]; });
  126718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["_BabylonLoaderRegistered"]; });
  126719. /* harmony import */ var _Materials_index__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Materials/index */ "./Materials/index.ts");
  126720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorCurves"]; });
  126721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectFallbacks"]; });
  126722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectCreationOptions"]; });
  126723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Effect"]; });
  126724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["FresnelParameters"]; });
  126725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfigurationDefines"]; });
  126726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfiguration"]; });
  126727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Material"]; });
  126728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialDefines"]; });
  126729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialHelper"]; });
  126730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiMaterial"]; });
  126731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PushMaterial"]; });
  126732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ShaderMaterial"]; });
  126733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterialDefines"]; });
  126734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterial"]; });
  126735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BaseTexture"]; });
  126736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CubeTexture"]; });
  126737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["HDRCubeTexture"]; });
  126738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["InternalTexture"]; });
  126739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DummyInternalTextureTracker"]; });
  126740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MirrorTexture"]; });
  126741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiRenderTarget"]; });
  126742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RenderTargetTexture"]; });
  126743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Texture"]; });
  126744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["UniformBuffer"]; });
  126745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialFlags"]; });
  126746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BackgroundMaterial"]; });
  126747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseMaterial"]; });
  126748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseSimpleMaterial"]; });
  126749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMaterial"]; });
  126750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMetallicRoughnessMaterial"]; });
  126751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRSpecularGlossinessMaterial"]; });
  126752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorGradingTexture"]; });
  126753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DynamicTexture"]; });
  126754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTexture"]; });
  126755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawCubeTexture"]; });
  126756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture"]; });
  126757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture3D"]; });
  126758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RefractionTexture"]; });
  126759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["VideoTexture"]; });
  126760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_DDSTextureLoader"]; });
  126761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_ENVTextureLoader"]; });
  126762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_KTXTextureLoader"]; });
  126763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_TGATextureLoader"]; });
  126764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CustomProceduralTexture"]; });
  126765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NoiseProceduralTexture"]; });
  126766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTextureSceneComponent"]; });
  126767. /* harmony import */ var _Maths_index__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Maths/index */ "./Maths/index.ts");
  126768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Scalar"]; });
  126769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToGammaSpace"]; });
  126770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToLinearSpace"]; });
  126771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Epsilon"]; });
  126772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color3"]; });
  126773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color4"]; });
  126774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector2"]; });
  126775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector3"]; });
  126776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector4"]; });
  126777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Size"]; });
  126778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Quaternion"]; });
  126779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Matrix"]; });
  126780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Plane"]; });
  126781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Viewport"]; });
  126782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Frustum"]; });
  126783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Space"]; });
  126784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Axis"]; });
  126785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["BezierCurve"]; });
  126786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Orientation"]; });
  126787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Angle"]; });
  126788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Arc2"]; });
  126789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path2"]; });
  126790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path3D"]; });
  126791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Curve3"]; });
  126792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalVertex"]; });
  126793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalTextureVertex"]; });
  126794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Tmp"]; });
  126795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalPolynomial"]; });
  126796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalHarmonics"]; });
  126797. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Meshes/index */ "./Meshes/index.ts");
  126798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["AbstractMesh"]; });
  126799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Buffer"]; });
  126800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexBuffer"]; });
  126801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CSG"]; });
  126802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Geometry"]; });
  126803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundMesh"]; });
  126804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedMesh"]; });
  126805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesMesh"]; });
  126806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedLinesMesh"]; });
  126807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshLODLevel"]; });
  126808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_CreationDataStorage"]; });
  126809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_InstancesBatch"]; });
  126810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Mesh"]; });
  126811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexData"]; });
  126812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshBuilder"]; });
  126813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationSettings"]; });
  126814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationQueue"]; });
  126815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationType"]; });
  126816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplicationQueueSceneComponent"]; });
  126817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Polygon"]; });
  126818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonMeshBuilder"]; });
  126819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BaseSubMesh"]; });
  126820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SubMesh"]; });
  126821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TransformNode"]; });
  126822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BoxBuilder"]; });
  126823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SphereBuilder"]; });
  126824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CylinderBuilder"]; });
  126825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesBuilder"]; });
  126826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PlaneBuilder"]; });
  126827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DracoCompression"]; });
  126828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DiscBuilder"]; });
  126829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["RibbonBuilder"]; });
  126830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusBuilder"]; });
  126831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusKnotBuilder"]; });
  126832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonBuilder"]; });
  126833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["ShapeBuilder"]; });
  126834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LatheBuilder"]; });
  126835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundBuilder"]; });
  126836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TubeBuilder"]; });
  126837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolyhedronBuilder"]; });
  126838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["IcoSphereBuilder"]; });
  126839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DecalBuilder"]; });
  126840. /* harmony import */ var _Morph_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Morph/index */ "./Morph/index.ts");
  126841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTarget"]; });
  126842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTargetManager"]; });
  126843. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./node */ "./node.ts");
  126844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _node__WEBPACK_IMPORTED_MODULE_25__["Node"]; });
  126845. /* harmony import */ var _Offline_index__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Offline/index */ "./Offline/index.ts");
  126846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _Offline_index__WEBPACK_IMPORTED_MODULE_26__["Database"]; });
  126847. /* harmony import */ var _Particles_index__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Particles/index */ "./Particles/index.ts");
  126848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BaseParticleSystem"]; });
  126849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["GPUParticleSystem"]; });
  126850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["Particle"]; });
  126851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleHelper"]; });
  126852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystem"]; });
  126853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["_IDoNeedToBeInTheBuild"]; });
  126854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystemSet"]; });
  126855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticle"]; });
  126856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ModelShape"]; });
  126857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["DepthSortedParticle"]; });
  126858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticleSystem"]; });
  126859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitterType"]; });
  126860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitter"]; });
  126861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BoxParticleEmitter"]; });
  126862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ConeParticleEmitter"]; });
  126863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderParticleEmitter"]; });
  126864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderDirectedParticleEmitter"]; });
  126865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["HemisphericParticleEmitter"]; });
  126866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["PointParticleEmitter"]; });
  126867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereParticleEmitter"]; });
  126868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereDirectedParticleEmitter"]; });
  126869. /* harmony import */ var _Physics_index__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./Physics/index */ "./Physics/index.ts");
  126870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngine"]; });
  126871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngineSceneComponent"]; });
  126872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsHelper"]; });
  126873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialExplosionEvent"]; });
  126874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsGravitationalFieldEvent"]; });
  126875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftEvent"]; });
  126876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsVortexEvent"]; });
  126877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialImpulseFalloff"]; });
  126878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftMode"]; });
  126879. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsImpostor"]; });
  126880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsJoint"]; });
  126881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["DistanceJoint"]; });
  126882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["MotorEnabledJoint"]; });
  126883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["HingeJoint"]; });
  126884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["Hinge2Joint"]; });
  126885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["CannonJSPlugin"]; });
  126886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["AmmoJSPlugin"]; });
  126887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["OimoJSPlugin"]; });
  126888. /* harmony import */ var _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./PostProcesses/index */ "./PostProcesses/index.ts");
  126889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["AnaglyphPostProcess"]; });
  126890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlackAndWhitePostProcess"]; });
  126891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomEffect"]; });
  126892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomMergePostProcess"]; });
  126893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlurPostProcess"]; });
  126894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ChromaticAberrationPostProcess"]; });
  126895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["CircleOfConfusionPostProcess"]; });
  126896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ColorCorrectionPostProcess"]; });
  126897. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ConvolutionPostProcess"]; });
  126898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldBlurPostProcess"]; });
  126899. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffectBlurLevel"]; });
  126900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffect"]; });
  126901. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcessOptions"]; });
  126902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcess"]; });
  126903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DisplayPassPostProcess"]; });
  126904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ExtractHighlightsPostProcess"]; });
  126905. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FilterPostProcess"]; });
  126906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FxaaPostProcess"]; });
  126907. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["GrainPostProcess"]; });
  126908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["HighlightsPostProcess"]; });
  126909. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ImageProcessingPostProcess"]; });
  126910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["MotionBlurPostProcess"]; });
  126911. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassPostProcess"]; });
  126912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassCubePostProcess"]; });
  126913. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcess"]; });
  126914. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessManager"]; });
  126915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["RefractionPostProcess"]; });
  126916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SharpenPostProcess"]; });
  126917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StereoscopicInterlacePostProcess"]; });
  126918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemappingOperator"]; });
  126919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemapPostProcess"]; });
  126920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VolumetricLightScatteringPostProcess"]; });
  126921. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  126922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderEffect"]; });
  126923. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipeline"]; });
  126924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManager"]; });
  126925. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManagerSceneComponent"]; });
  126926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DefaultRenderingPipeline"]; });
  126927. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["LensRenderingPipeline"]; });
  126928. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAO2RenderingPipeline"]; });
  126929. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAORenderingPipeline"]; });
  126930. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StandardRenderingPipeline"]; });
  126931. /* harmony import */ var _Probes_index__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./Probes/index */ "./Probes/index.ts");
  126932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _Probes_index__WEBPACK_IMPORTED_MODULE_30__["ReflectionProbe"]; });
  126933. /* harmony import */ var _Rendering_index__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./Rendering/index */ "./Rendering/index.ts");
  126934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["BoundingBoxRenderer"]; });
  126935. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRenderer"]; });
  126936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRendererSceneComponent"]; });
  126937. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["EdgesRenderer"]; });
  126938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["LineEdgesRenderer"]; });
  126939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRenderer"]; });
  126940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRendererSceneComponent"]; });
  126941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["OutlineRenderer"]; });
  126942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroup"]; });
  126943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroupInfo"]; });
  126944. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingManager"]; });
  126945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["UtilityLayerRenderer"]; });
  126946. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./scene */ "./scene.ts");
  126947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _scene__WEBPACK_IMPORTED_MODULE_32__["Scene"]; });
  126948. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  126949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["SceneComponentConstants"]; });
  126950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["Stage"]; });
  126951. /* harmony import */ var _Sprites_index__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./Sprites/index */ "./Sprites/index.ts");
  126952. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["Sprite"]; });
  126953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteManager"]; });
  126954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteSceneComponent"]; });
  126955. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./States/index */ "./States/index.ts");
  126956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_AlphaState"]; });
  126957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_DepthCullingState"]; });
  126958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_StencilState"]; });
  126959. /* harmony import */ var _Misc_index__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./Misc/index */ "./Misc/index.ts");
  126960. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AndOrNotEvaluator"]; });
  126961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetTaskState"]; });
  126962. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AbstractAssetTask"]; });
  126963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsProgressEvent"]; });
  126964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MeshAssetTask"]; });
  126965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextFileAssetTask"]; });
  126966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["BinaryFileAssetTask"]; });
  126967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ImageAssetTask"]; });
  126968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureAssetTask"]; });
  126969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeTextureAssetTask"]; });
  126970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRCubeTextureAssetTask"]; });
  126971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsManager"]; });
  126972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DDSTools"]; });
  126973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["expandToProperty"]; });
  126974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serialize"]; });
  126975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsTexture"]; });
  126976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor3"]; });
  126977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsFresnelParameters"]; });
  126978. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector2"]; });
  126979. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector3"]; });
  126980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsMeshReference"]; });
  126981. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColorCurves"]; });
  126982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor4"]; });
  126983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsImageProcessingConfiguration"]; });
  126984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsQuaternion"]; });
  126985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsCameraReference"]; });
  126986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SerializationHelper"]; });
  126987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Deferred"]; });
  126988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EnvironmentTextureTools"]; });
  126989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInput"]; });
  126990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["KhronosTextureContainer"]; });
  126991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EventState"]; });
  126992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observer"]; });
  126993. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MultiObserver"]; });
  126994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observable"]; });
  126995. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerformanceMonitor"]; });
  126996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RollingAverage"]; });
  126997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PromisePolyfill"]; });
  126998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimization"]; });
  126999. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureOptimization"]; });
  127000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HardwareScalingOptimization"]; });
  127001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ShadowsOptimization"]; });
  127002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PostProcessesOptimization"]; });
  127003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LensFlaresOptimization"]; });
  127004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CustomOptimization"]; });
  127005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ParticlesOptimization"]; });
  127006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RenderTargetsOptimization"]; });
  127007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MergeMeshesOptimization"]; });
  127008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizerOptions"]; });
  127009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizer"]; });
  127010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneSerializer"]; });
  127011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArray"]; });
  127012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArrayNoDuplicate"]; });
  127013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["StringDictionary"]; });
  127014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tags"]; });
  127015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureTools"]; });
  127016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TGATools"]; });
  127017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ColorGradient"]; });
  127018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Color3Gradient"]; });
  127019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FactorGradient"]; });
  127020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LoadFileError"]; });
  127021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RetryStrategy"]; });
  127022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tools"]; });
  127023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerfCounter"]; });
  127024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["className"]; });
  127025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AsyncLoop"]; });
  127026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VideoRecorder"]; });
  127027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["JoystickAxis"]; });
  127028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VirtualJoystick"]; });
  127029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["WorkerPool"]; });
  127030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Logger"]; });
  127031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["_TypeStore"]; });
  127032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInputStore"]; });
  127033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DeepCopier"]; });
  127034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PivotTools"]; });
  127035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PrecisionDate"]; });
  127036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ScreenshotTools"]; });
  127037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeMapToSphericalPolynomialTools"]; });
  127038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRTools"]; });
  127039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PanoramaToCubeMapTools"]; });
  127040. /***/ }),
  127041. /***/ "./node.ts":
  127042. /*!*****************!*\
  127043. !*** ./node.ts ***!
  127044. \*****************/
  127045. /*! exports provided: Node */
  127046. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127047. "use strict";
  127048. __webpack_require__.r(__webpack_exports__);
  127049. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return Node; });
  127050. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  127051. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  127052. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/decorators */ "./Misc/decorators.ts");
  127053. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  127054. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  127055. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  127056. /**
  127057. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  127058. */
  127059. var Node = /** @class */ (function () {
  127060. /**
  127061. * Creates a new Node
  127062. * @param name the name and id to be given to this node
  127063. * @param scene the scene this node will be added to
  127064. * @param addToRootNodes the node will be added to scene.rootNodes
  127065. */
  127066. function Node(name, scene, addToRootNodes) {
  127067. if (scene === void 0) { scene = null; }
  127068. if (addToRootNodes === void 0) { addToRootNodes = true; }
  127069. /**
  127070. * Gets or sets a string used to store user defined state for the node
  127071. */
  127072. this.state = "";
  127073. /**
  127074. * Gets or sets an object used to store user defined information for the node
  127075. */
  127076. this.metadata = null;
  127077. /**
  127078. * For internal use only. Please do not use.
  127079. */
  127080. this.reservedDataStore = null;
  127081. /**
  127082. * Gets or sets a boolean used to define if the node must be serialized
  127083. */
  127084. this.doNotSerialize = false;
  127085. /** @hidden */
  127086. this._isDisposed = false;
  127087. /**
  127088. * Gets a list of Animations associated with the node
  127089. */
  127090. this.animations = new Array();
  127091. this._ranges = {};
  127092. this._isEnabled = true;
  127093. this._isParentEnabled = true;
  127094. this._isReady = true;
  127095. /** @hidden */
  127096. this._currentRenderId = -1;
  127097. this._parentRenderId = -1;
  127098. this._childRenderId = -1;
  127099. /** @hidden */
  127100. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  127101. /** @hidden */
  127102. this._worldMatrixDeterminant = 0;
  127103. /** @hidden */
  127104. this._sceneRootNodesIndex = -1;
  127105. this._animationPropertiesOverride = null;
  127106. /** @hidden */
  127107. this._isNode = true;
  127108. /**
  127109. * An event triggered when the mesh is disposed
  127110. */
  127111. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127112. // Behaviors
  127113. this._behaviors = new Array();
  127114. this.name = name;
  127115. this.id = name;
  127116. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene);
  127117. this.uniqueId = this._scene.getUniqueId();
  127118. this._initCache();
  127119. if (addToRootNodes) {
  127120. this.addToSceneRootNodes();
  127121. }
  127122. }
  127123. /**
  127124. * Add a new node constructor
  127125. * @param type defines the type name of the node to construct
  127126. * @param constructorFunc defines the constructor function
  127127. */
  127128. Node.AddNodeConstructor = function (type, constructorFunc) {
  127129. this._NodeConstructors[type] = constructorFunc;
  127130. };
  127131. /**
  127132. * Returns a node constructor based on type name
  127133. * @param type defines the type name
  127134. * @param name defines the new node name
  127135. * @param scene defines the hosting scene
  127136. * @param options defines optional options to transmit to constructors
  127137. * @returns the new constructor or null
  127138. */
  127139. Node.Construct = function (type, name, scene, options) {
  127140. var constructorFunc = this._NodeConstructors[type];
  127141. if (!constructorFunc) {
  127142. return null;
  127143. }
  127144. return constructorFunc(name, scene, options);
  127145. };
  127146. /**
  127147. * Gets a boolean indicating if the node has been disposed
  127148. * @returns true if the node was disposed
  127149. */
  127150. Node.prototype.isDisposed = function () {
  127151. return this._isDisposed;
  127152. };
  127153. Object.defineProperty(Node.prototype, "parent", {
  127154. get: function () {
  127155. return this._parentNode;
  127156. },
  127157. /**
  127158. * Gets or sets the parent of the node
  127159. */
  127160. set: function (parent) {
  127161. if (this._parentNode === parent) {
  127162. return;
  127163. }
  127164. var previousParentNode = this._parentNode;
  127165. // Remove self from list of children of parent
  127166. if (this._parentNode && this._parentNode._children !== undefined && this._parentNode._children !== null) {
  127167. var index = this._parentNode._children.indexOf(this);
  127168. if (index !== -1) {
  127169. this._parentNode._children.splice(index, 1);
  127170. }
  127171. if (!parent && !this._isDisposed) {
  127172. this.addToSceneRootNodes();
  127173. }
  127174. }
  127175. // Store new parent
  127176. this._parentNode = parent;
  127177. // Add as child to new parent
  127178. if (this._parentNode) {
  127179. if (this._parentNode._children === undefined || this._parentNode._children === null) {
  127180. this._parentNode._children = new Array();
  127181. }
  127182. this._parentNode._children.push(this);
  127183. if (!previousParentNode) {
  127184. this.removeFromSceneRootNodes();
  127185. }
  127186. }
  127187. // Enabled state
  127188. this._syncParentEnabledState();
  127189. },
  127190. enumerable: true,
  127191. configurable: true
  127192. });
  127193. Node.prototype.addToSceneRootNodes = function () {
  127194. if (this._sceneRootNodesIndex === -1) {
  127195. this._sceneRootNodesIndex = this._scene.rootNodes.length;
  127196. this._scene.rootNodes.push(this);
  127197. }
  127198. };
  127199. Node.prototype.removeFromSceneRootNodes = function () {
  127200. if (this._sceneRootNodesIndex !== -1) {
  127201. var rootNodes = this._scene.rootNodes;
  127202. var lastIdx = rootNodes.length - 1;
  127203. rootNodes[this._sceneRootNodesIndex] = rootNodes[lastIdx];
  127204. rootNodes[this._sceneRootNodesIndex]._sceneRootNodesIndex = this._sceneRootNodesIndex;
  127205. this._scene.rootNodes.pop();
  127206. this._sceneRootNodesIndex = -1;
  127207. }
  127208. };
  127209. Object.defineProperty(Node.prototype, "animationPropertiesOverride", {
  127210. /**
  127211. * Gets or sets the animation properties override
  127212. */
  127213. get: function () {
  127214. if (!this._animationPropertiesOverride) {
  127215. return this._scene.animationPropertiesOverride;
  127216. }
  127217. return this._animationPropertiesOverride;
  127218. },
  127219. set: function (value) {
  127220. this._animationPropertiesOverride = value;
  127221. },
  127222. enumerable: true,
  127223. configurable: true
  127224. });
  127225. /**
  127226. * Gets a string idenfifying the name of the class
  127227. * @returns "Node" string
  127228. */
  127229. Node.prototype.getClassName = function () {
  127230. return "Node";
  127231. };
  127232. Object.defineProperty(Node.prototype, "onDispose", {
  127233. /**
  127234. * Sets a callback that will be raised when the node will be disposed
  127235. */
  127236. set: function (callback) {
  127237. if (this._onDisposeObserver) {
  127238. this.onDisposeObservable.remove(this._onDisposeObserver);
  127239. }
  127240. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  127241. },
  127242. enumerable: true,
  127243. configurable: true
  127244. });
  127245. /**
  127246. * Gets the scene of the node
  127247. * @returns a scene
  127248. */
  127249. Node.prototype.getScene = function () {
  127250. return this._scene;
  127251. };
  127252. /**
  127253. * Gets the engine of the node
  127254. * @returns a Engine
  127255. */
  127256. Node.prototype.getEngine = function () {
  127257. return this._scene.getEngine();
  127258. };
  127259. /**
  127260. * Attach a behavior to the node
  127261. * @see http://doc.babylonjs.com/features/behaviour
  127262. * @param behavior defines the behavior to attach
  127263. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  127264. * @returns the current Node
  127265. */
  127266. Node.prototype.addBehavior = function (behavior, attachImmediately) {
  127267. var _this = this;
  127268. if (attachImmediately === void 0) { attachImmediately = false; }
  127269. var index = this._behaviors.indexOf(behavior);
  127270. if (index !== -1) {
  127271. return this;
  127272. }
  127273. behavior.init();
  127274. if (this._scene.isLoading && !attachImmediately) {
  127275. // We defer the attach when the scene will be loaded
  127276. this._scene.onDataLoadedObservable.addOnce(function () {
  127277. behavior.attach(_this);
  127278. });
  127279. }
  127280. else {
  127281. behavior.attach(this);
  127282. }
  127283. this._behaviors.push(behavior);
  127284. return this;
  127285. };
  127286. /**
  127287. * Remove an attached behavior
  127288. * @see http://doc.babylonjs.com/features/behaviour
  127289. * @param behavior defines the behavior to attach
  127290. * @returns the current Node
  127291. */
  127292. Node.prototype.removeBehavior = function (behavior) {
  127293. var index = this._behaviors.indexOf(behavior);
  127294. if (index === -1) {
  127295. return this;
  127296. }
  127297. this._behaviors[index].detach();
  127298. this._behaviors.splice(index, 1);
  127299. return this;
  127300. };
  127301. Object.defineProperty(Node.prototype, "behaviors", {
  127302. /**
  127303. * Gets the list of attached behaviors
  127304. * @see http://doc.babylonjs.com/features/behaviour
  127305. */
  127306. get: function () {
  127307. return this._behaviors;
  127308. },
  127309. enumerable: true,
  127310. configurable: true
  127311. });
  127312. /**
  127313. * Gets an attached behavior by name
  127314. * @param name defines the name of the behavior to look for
  127315. * @see http://doc.babylonjs.com/features/behaviour
  127316. * @returns null if behavior was not found else the requested behavior
  127317. */
  127318. Node.prototype.getBehaviorByName = function (name) {
  127319. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  127320. var behavior = _a[_i];
  127321. if (behavior.name === name) {
  127322. return behavior;
  127323. }
  127324. }
  127325. return null;
  127326. };
  127327. /**
  127328. * Returns the latest update of the World matrix
  127329. * @returns a Matrix
  127330. */
  127331. Node.prototype.getWorldMatrix = function () {
  127332. if (this._currentRenderId !== this._scene.getRenderId()) {
  127333. this.computeWorldMatrix();
  127334. }
  127335. return this._worldMatrix;
  127336. };
  127337. /** @hidden */
  127338. Node.prototype._getWorldMatrixDeterminant = function () {
  127339. return this._worldMatrixDeterminant;
  127340. };
  127341. Object.defineProperty(Node.prototype, "worldMatrixFromCache", {
  127342. /**
  127343. * Returns directly the latest state of the mesh World matrix.
  127344. * A Matrix is returned.
  127345. */
  127346. get: function () {
  127347. return this._worldMatrix;
  127348. },
  127349. enumerable: true,
  127350. configurable: true
  127351. });
  127352. // override it in derived class if you add new variables to the cache
  127353. // and call the parent class method
  127354. /** @hidden */
  127355. Node.prototype._initCache = function () {
  127356. this._cache = {};
  127357. this._cache.parent = undefined;
  127358. };
  127359. /** @hidden */
  127360. Node.prototype.updateCache = function (force) {
  127361. if (!force && this.isSynchronized()) {
  127362. return;
  127363. }
  127364. this._cache.parent = this.parent;
  127365. this._updateCache();
  127366. };
  127367. // override it in derived class if you add new variables to the cache
  127368. // and call the parent class method if !ignoreParentClass
  127369. /** @hidden */
  127370. Node.prototype._updateCache = function (ignoreParentClass) {
  127371. };
  127372. // override it in derived class if you add new variables to the cache
  127373. /** @hidden */
  127374. Node.prototype._isSynchronized = function () {
  127375. return true;
  127376. };
  127377. /** @hidden */
  127378. Node.prototype._markSyncedWithParent = function () {
  127379. if (this._parentNode) {
  127380. this._parentRenderId = this._parentNode._childRenderId;
  127381. }
  127382. };
  127383. /** @hidden */
  127384. Node.prototype.isSynchronizedWithParent = function () {
  127385. if (!this._parentNode) {
  127386. return true;
  127387. }
  127388. if (this._parentRenderId !== this._parentNode._childRenderId) {
  127389. return false;
  127390. }
  127391. return this._parentNode.isSynchronized();
  127392. };
  127393. /** @hidden */
  127394. Node.prototype.isSynchronized = function () {
  127395. if (this._cache.parent != this._parentNode) {
  127396. this._cache.parent = this._parentNode;
  127397. return false;
  127398. }
  127399. if (this._parentNode && !this.isSynchronizedWithParent()) {
  127400. return false;
  127401. }
  127402. return this._isSynchronized();
  127403. };
  127404. /**
  127405. * Is this node ready to be used/rendered
  127406. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  127407. * @return true if the node is ready
  127408. */
  127409. Node.prototype.isReady = function (completeCheck) {
  127410. if (completeCheck === void 0) { completeCheck = false; }
  127411. return this._isReady;
  127412. };
  127413. /**
  127414. * Is this node enabled?
  127415. * 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
  127416. * @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
  127417. * @return whether this node (and its parent) is enabled
  127418. */
  127419. Node.prototype.isEnabled = function (checkAncestors) {
  127420. if (checkAncestors === void 0) { checkAncestors = true; }
  127421. if (checkAncestors === false) {
  127422. return this._isEnabled;
  127423. }
  127424. if (!this._isEnabled) {
  127425. return false;
  127426. }
  127427. return this._isParentEnabled;
  127428. };
  127429. /** @hidden */
  127430. Node.prototype._syncParentEnabledState = function () {
  127431. this._isParentEnabled = this._parentNode ? this._parentNode.isEnabled() : true;
  127432. if (this._children) {
  127433. this._children.forEach(function (c) {
  127434. c._syncParentEnabledState(); // Force children to update accordingly
  127435. });
  127436. }
  127437. };
  127438. /**
  127439. * Set the enabled state of this node
  127440. * @param value defines the new enabled state
  127441. */
  127442. Node.prototype.setEnabled = function (value) {
  127443. this._isEnabled = value;
  127444. this._syncParentEnabledState();
  127445. };
  127446. /**
  127447. * Is this node a descendant of the given node?
  127448. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  127449. * @param ancestor defines the parent node to inspect
  127450. * @returns a boolean indicating if this node is a descendant of the given node
  127451. */
  127452. Node.prototype.isDescendantOf = function (ancestor) {
  127453. if (this.parent) {
  127454. if (this.parent === ancestor) {
  127455. return true;
  127456. }
  127457. return this.parent.isDescendantOf(ancestor);
  127458. }
  127459. return false;
  127460. };
  127461. /** @hidden */
  127462. Node.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  127463. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  127464. if (!this._children) {
  127465. return;
  127466. }
  127467. for (var index = 0; index < this._children.length; index++) {
  127468. var item = this._children[index];
  127469. if (!predicate || predicate(item)) {
  127470. results.push(item);
  127471. }
  127472. if (!directDescendantsOnly) {
  127473. item._getDescendants(results, false, predicate);
  127474. }
  127475. }
  127476. };
  127477. /**
  127478. * Will return all nodes that have this node as ascendant
  127479. * @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
  127480. * @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
  127481. * @return all children nodes of all types
  127482. */
  127483. Node.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  127484. var results = new Array();
  127485. this._getDescendants(results, directDescendantsOnly, predicate);
  127486. return results;
  127487. };
  127488. /**
  127489. * Get all child-meshes of this node
  127490. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  127491. * @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
  127492. * @returns an array of AbstractMesh
  127493. */
  127494. Node.prototype.getChildMeshes = function (directDescendantsOnly, predicate) {
  127495. var results = [];
  127496. this._getDescendants(results, directDescendantsOnly, function (node) {
  127497. return ((!predicate || predicate(node)) && (node.cullingStrategy !== undefined));
  127498. });
  127499. return results;
  127500. };
  127501. /**
  127502. * Get all direct children of this node
  127503. * @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
  127504. * @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)
  127505. * @returns an array of Node
  127506. */
  127507. Node.prototype.getChildren = function (predicate, directDescendantsOnly) {
  127508. if (directDescendantsOnly === void 0) { directDescendantsOnly = true; }
  127509. return this.getDescendants(directDescendantsOnly, predicate);
  127510. };
  127511. /** @hidden */
  127512. Node.prototype._setReady = function (state) {
  127513. if (state === this._isReady) {
  127514. return;
  127515. }
  127516. if (!state) {
  127517. this._isReady = false;
  127518. return;
  127519. }
  127520. if (this.onReady) {
  127521. this.onReady(this);
  127522. }
  127523. this._isReady = true;
  127524. };
  127525. /**
  127526. * Get an animation by name
  127527. * @param name defines the name of the animation to look for
  127528. * @returns null if not found else the requested animation
  127529. */
  127530. Node.prototype.getAnimationByName = function (name) {
  127531. for (var i = 0; i < this.animations.length; i++) {
  127532. var animation = this.animations[i];
  127533. if (animation.name === name) {
  127534. return animation;
  127535. }
  127536. }
  127537. return null;
  127538. };
  127539. /**
  127540. * Creates an animation range for this node
  127541. * @param name defines the name of the range
  127542. * @param from defines the starting key
  127543. * @param to defines the end key
  127544. */
  127545. Node.prototype.createAnimationRange = function (name, from, to) {
  127546. // check name not already in use
  127547. if (!this._ranges[name]) {
  127548. this._ranges[name] = Node._AnimationRangeFactory(name, from, to);
  127549. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  127550. if (this.animations[i]) {
  127551. this.animations[i].createRange(name, from, to);
  127552. }
  127553. }
  127554. }
  127555. };
  127556. /**
  127557. * Delete a specific animation range
  127558. * @param name defines the name of the range to delete
  127559. * @param deleteFrames defines if animation frames from the range must be deleted as well
  127560. */
  127561. Node.prototype.deleteAnimationRange = function (name, deleteFrames) {
  127562. if (deleteFrames === void 0) { deleteFrames = true; }
  127563. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  127564. if (this.animations[i]) {
  127565. this.animations[i].deleteRange(name, deleteFrames);
  127566. }
  127567. }
  127568. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  127569. };
  127570. /**
  127571. * Get an animation range by name
  127572. * @param name defines the name of the animation range to look for
  127573. * @returns null if not found else the requested animation range
  127574. */
  127575. Node.prototype.getAnimationRange = function (name) {
  127576. return this._ranges[name];
  127577. };
  127578. /**
  127579. * Will start the animation sequence
  127580. * @param name defines the range frames for animation sequence
  127581. * @param loop defines if the animation should loop (false by default)
  127582. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  127583. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  127584. * @returns the object created for this animation. If range does not exist, it will return null
  127585. */
  127586. Node.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  127587. var range = this.getAnimationRange(name);
  127588. if (!range) {
  127589. return null;
  127590. }
  127591. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  127592. };
  127593. /**
  127594. * Serialize animation ranges into a JSON compatible object
  127595. * @returns serialization object
  127596. */
  127597. Node.prototype.serializeAnimationRanges = function () {
  127598. var serializationRanges = [];
  127599. for (var name in this._ranges) {
  127600. var localRange = this._ranges[name];
  127601. if (!localRange) {
  127602. continue;
  127603. }
  127604. var range = {};
  127605. range.name = name;
  127606. range.from = localRange.from;
  127607. range.to = localRange.to;
  127608. serializationRanges.push(range);
  127609. }
  127610. return serializationRanges;
  127611. };
  127612. /**
  127613. * Computes the world matrix of the node
  127614. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  127615. * @returns the world matrix
  127616. */
  127617. Node.prototype.computeWorldMatrix = function (force) {
  127618. if (!this._worldMatrix) {
  127619. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  127620. }
  127621. return this._worldMatrix;
  127622. };
  127623. /**
  127624. * Releases resources associated with this node.
  127625. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  127626. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  127627. */
  127628. Node.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  127629. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  127630. this._isDisposed = true;
  127631. if (!doNotRecurse) {
  127632. var nodes = this.getDescendants(true);
  127633. for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
  127634. var node = nodes_1[_i];
  127635. node.dispose(doNotRecurse, disposeMaterialAndTextures);
  127636. }
  127637. }
  127638. if (!this.parent) {
  127639. this.removeFromSceneRootNodes();
  127640. }
  127641. else {
  127642. this.parent = null;
  127643. }
  127644. // Callback
  127645. this.onDisposeObservable.notifyObservers(this);
  127646. this.onDisposeObservable.clear();
  127647. // Behaviors
  127648. for (var _a = 0, _b = this._behaviors; _a < _b.length; _a++) {
  127649. var behavior = _b[_a];
  127650. behavior.detach();
  127651. }
  127652. this._behaviors = [];
  127653. };
  127654. /**
  127655. * Parse animation range data from a serialization object and store them into a given node
  127656. * @param node defines where to store the animation ranges
  127657. * @param parsedNode defines the serialization object to read data from
  127658. * @param scene defines the hosting scene
  127659. */
  127660. Node.ParseAnimationRanges = function (node, parsedNode, scene) {
  127661. if (parsedNode.ranges) {
  127662. for (var index = 0; index < parsedNode.ranges.length; index++) {
  127663. var data = parsedNode.ranges[index];
  127664. node.createAnimationRange(data.name, data.from, data.to);
  127665. }
  127666. }
  127667. };
  127668. /** @hidden */
  127669. Node._AnimationRangeFactory = function (name, from, to) {
  127670. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AnimationRange");
  127671. };
  127672. Node._NodeConstructors = {};
  127673. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  127674. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  127675. ], Node.prototype, "name", void 0);
  127676. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  127677. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  127678. ], Node.prototype, "id", void 0);
  127679. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  127680. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  127681. ], Node.prototype, "uniqueId", void 0);
  127682. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  127683. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  127684. ], Node.prototype, "state", void 0);
  127685. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  127686. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  127687. ], Node.prototype, "metadata", void 0);
  127688. return Node;
  127689. }());
  127690. /***/ }),
  127691. /***/ "./scene.ts":
  127692. /*!******************!*\
  127693. !*** ./scene.ts ***!
  127694. \******************/
  127695. /*! exports provided: Scene */
  127696. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127697. "use strict";
  127698. __webpack_require__.r(__webpack_exports__);
  127699. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return Scene; });
  127700. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  127701. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Misc/tools */ "./Misc/tools.ts");
  127702. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/precisionDate */ "./Misc/precisionDate.ts");
  127703. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  127704. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Misc/smartArray */ "./Misc/smartArray.ts");
  127705. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  127706. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Misc/tags */ "./Misc/tags.ts");
  127707. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  127708. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  127709. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Cameras/camera */ "./Cameras/camera.ts");
  127710. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  127711. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  127712. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  127713. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Lights/light */ "./Lights/light.ts");
  127714. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  127715. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Events/pointerEvents */ "./Events/pointerEvents.ts");
  127716. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  127717. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Actions/actionEvent */ "./Actions/actionEvent.ts");
  127718. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  127719. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  127720. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  127721. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Engines/constants */ "./Engines/constants.ts");
  127722. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Misc/domManagement */ "./Misc/domManagement.ts");
  127723. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Misc/logger */ "./Misc/logger.ts");
  127724. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  127725. /* harmony import */ var _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./Actions/abstractActionManager */ "./Actions/abstractActionManager.ts");
  127726. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  127727. /** @hidden */
  127728. var ClickInfo = /** @class */ (function () {
  127729. function ClickInfo() {
  127730. this._singleClick = false;
  127731. this._doubleClick = false;
  127732. this._hasSwiped = false;
  127733. this._ignore = false;
  127734. }
  127735. Object.defineProperty(ClickInfo.prototype, "singleClick", {
  127736. get: function () {
  127737. return this._singleClick;
  127738. },
  127739. set: function (b) {
  127740. this._singleClick = b;
  127741. },
  127742. enumerable: true,
  127743. configurable: true
  127744. });
  127745. Object.defineProperty(ClickInfo.prototype, "doubleClick", {
  127746. get: function () {
  127747. return this._doubleClick;
  127748. },
  127749. set: function (b) {
  127750. this._doubleClick = b;
  127751. },
  127752. enumerable: true,
  127753. configurable: true
  127754. });
  127755. Object.defineProperty(ClickInfo.prototype, "hasSwiped", {
  127756. get: function () {
  127757. return this._hasSwiped;
  127758. },
  127759. set: function (b) {
  127760. this._hasSwiped = b;
  127761. },
  127762. enumerable: true,
  127763. configurable: true
  127764. });
  127765. Object.defineProperty(ClickInfo.prototype, "ignore", {
  127766. get: function () {
  127767. return this._ignore;
  127768. },
  127769. set: function (b) {
  127770. this._ignore = b;
  127771. },
  127772. enumerable: true,
  127773. configurable: true
  127774. });
  127775. return ClickInfo;
  127776. }());
  127777. /**
  127778. * Represents a scene to be rendered by the engine.
  127779. * @see http://doc.babylonjs.com/features/scene
  127780. */
  127781. var Scene = /** @class */ (function (_super) {
  127782. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Scene, _super);
  127783. /**
  127784. * Creates a new Scene
  127785. * @param engine defines the engine to use to render this scene
  127786. * @param options defines the scene options
  127787. */
  127788. function Scene(engine, options) {
  127789. var _this = _super.call(this) || this;
  127790. // Members
  127791. /** @hidden */
  127792. _this._isScene = true;
  127793. /**
  127794. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  127795. */
  127796. _this.autoClear = true;
  127797. /**
  127798. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  127799. */
  127800. _this.autoClearDepthAndStencil = true;
  127801. /**
  127802. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  127803. */
  127804. _this.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color4"](0.2, 0.2, 0.3, 1.0);
  127805. /**
  127806. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  127807. */
  127808. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0, 0, 0);
  127809. _this._forceWireframe = false;
  127810. _this._forcePointsCloud = false;
  127811. /**
  127812. * Gets or sets a boolean indicating if animations are enabled
  127813. */
  127814. _this.animationsEnabled = true;
  127815. _this._animationPropertiesOverride = null;
  127816. /**
  127817. * Gets or sets a boolean indicating if a constant deltatime has to be used
  127818. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  127819. */
  127820. _this.useConstantAnimationDeltaTime = false;
  127821. /**
  127822. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  127823. * Please note that it requires to run a ray cast through the scene on every frame
  127824. */
  127825. _this.constantlyUpdateMeshUnderPointer = false;
  127826. /**
  127827. * Defines the HTML cursor to use when hovering over interactive elements
  127828. */
  127829. _this.hoverCursor = "pointer";
  127830. /**
  127831. * Defines the HTML default cursor to use (empty by default)
  127832. */
  127833. _this.defaultCursor = "";
  127834. /**
  127835. * This is used to call preventDefault() on pointer down
  127836. * in order to block unwanted artifacts like system double clicks
  127837. */
  127838. _this.preventDefaultOnPointerDown = true;
  127839. /**
  127840. * This is used to call preventDefault() on pointer up
  127841. * in order to block unwanted artifacts like system double clicks
  127842. */
  127843. _this.preventDefaultOnPointerUp = true;
  127844. // Metadata
  127845. /**
  127846. * Gets or sets user defined metadata
  127847. */
  127848. _this.metadata = null;
  127849. /**
  127850. * For internal use only. Please do not use.
  127851. */
  127852. _this.reservedDataStore = null;
  127853. /**
  127854. * Use this array to add regular expressions used to disable offline support for specific urls
  127855. */
  127856. _this.disableOfflineSupportExceptionRules = new Array();
  127857. /**
  127858. * An event triggered when the scene is disposed.
  127859. */
  127860. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127861. _this._onDisposeObserver = null;
  127862. /**
  127863. * An event triggered before rendering the scene (right after animations and physics)
  127864. */
  127865. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127866. _this._onBeforeRenderObserver = null;
  127867. /**
  127868. * An event triggered after rendering the scene
  127869. */
  127870. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127871. _this._onAfterRenderObserver = null;
  127872. /**
  127873. * An event triggered before animating the scene
  127874. */
  127875. _this.onBeforeAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127876. /**
  127877. * An event triggered after animations processing
  127878. */
  127879. _this.onAfterAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127880. /**
  127881. * An event triggered before draw calls are ready to be sent
  127882. */
  127883. _this.onBeforeDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127884. /**
  127885. * An event triggered after draw calls have been sent
  127886. */
  127887. _this.onAfterDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127888. /**
  127889. * An event triggered when the scene is ready
  127890. */
  127891. _this.onReadyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127892. /**
  127893. * An event triggered before rendering a camera
  127894. */
  127895. _this.onBeforeCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127896. _this._onBeforeCameraRenderObserver = null;
  127897. /**
  127898. * An event triggered after rendering a camera
  127899. */
  127900. _this.onAfterCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127901. _this._onAfterCameraRenderObserver = null;
  127902. /**
  127903. * An event triggered when active meshes evaluation is about to start
  127904. */
  127905. _this.onBeforeActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127906. /**
  127907. * An event triggered when active meshes evaluation is done
  127908. */
  127909. _this.onAfterActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127910. /**
  127911. * An event triggered when particles rendering is about to start
  127912. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  127913. */
  127914. _this.onBeforeParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127915. /**
  127916. * An event triggered when particles rendering is done
  127917. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  127918. */
  127919. _this.onAfterParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127920. /**
  127921. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  127922. */
  127923. _this.onDataLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127924. /**
  127925. * An event triggered when a camera is created
  127926. */
  127927. _this.onNewCameraAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127928. /**
  127929. * An event triggered when a camera is removed
  127930. */
  127931. _this.onCameraRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127932. /**
  127933. * An event triggered when a light is created
  127934. */
  127935. _this.onNewLightAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127936. /**
  127937. * An event triggered when a light is removed
  127938. */
  127939. _this.onLightRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127940. /**
  127941. * An event triggered when a geometry is created
  127942. */
  127943. _this.onNewGeometryAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127944. /**
  127945. * An event triggered when a geometry is removed
  127946. */
  127947. _this.onGeometryRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127948. /**
  127949. * An event triggered when a transform node is created
  127950. */
  127951. _this.onNewTransformNodeAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127952. /**
  127953. * An event triggered when a transform node is removed
  127954. */
  127955. _this.onTransformNodeRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127956. /**
  127957. * An event triggered when a mesh is created
  127958. */
  127959. _this.onNewMeshAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127960. /**
  127961. * An event triggered when a mesh is removed
  127962. */
  127963. _this.onMeshRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127964. /**
  127965. * An event triggered when a material is created
  127966. */
  127967. _this.onNewMaterialAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127968. /**
  127969. * An event triggered when a material is removed
  127970. */
  127971. _this.onMaterialRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127972. /**
  127973. * An event triggered when a texture is created
  127974. */
  127975. _this.onNewTextureAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127976. /**
  127977. * An event triggered when a texture is removed
  127978. */
  127979. _this.onTextureRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127980. /**
  127981. * An event triggered when render targets are about to be rendered
  127982. * Can happen multiple times per frame.
  127983. */
  127984. _this.onBeforeRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127985. /**
  127986. * An event triggered when render targets were rendered.
  127987. * Can happen multiple times per frame.
  127988. */
  127989. _this.onAfterRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127990. /**
  127991. * An event triggered before calculating deterministic simulation step
  127992. */
  127993. _this.onBeforeStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127994. /**
  127995. * An event triggered after calculating deterministic simulation step
  127996. */
  127997. _this.onAfterStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127998. /**
  127999. * An event triggered when the activeCamera property is updated
  128000. */
  128001. _this.onActiveCameraChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128002. /**
  128003. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  128004. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  128005. * 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)
  128006. */
  128007. _this.onBeforeRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128008. /**
  128009. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  128010. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  128011. * 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)
  128012. */
  128013. _this.onAfterRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128014. /**
  128015. * This Observable will when a mesh has been imported into the scene.
  128016. */
  128017. _this.onMeshImportedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128018. // Animations
  128019. /** @hidden */
  128020. _this._registeredForLateAnimationBindings = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  128021. /**
  128022. * 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).
  128023. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  128024. */
  128025. _this.onPrePointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128026. /**
  128027. * Observable event triggered each time an input event is received from the rendering canvas
  128028. */
  128029. _this.onPointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128030. _this._meshPickProceed = false;
  128031. _this._currentPickResult = null;
  128032. _this._previousPickResult = null;
  128033. _this._totalPointersPressed = 0;
  128034. _this._doubleClickOccured = false;
  128035. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  128036. _this.cameraToUseForPointers = null;
  128037. _this._pointerX = 0;
  128038. _this._pointerY = 0;
  128039. _this._startingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  128040. _this._previousStartingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  128041. _this._startingPointerTime = 0;
  128042. _this._previousStartingPointerTime = 0;
  128043. _this._pointerCaptures = {};
  128044. // Deterministic lockstep
  128045. _this._timeAccumulator = 0;
  128046. _this._currentStepId = 0;
  128047. _this._currentInternalStep = 0;
  128048. // Keyboard
  128049. /**
  128050. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  128051. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  128052. */
  128053. _this.onPreKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128054. /**
  128055. * Observable event triggered each time an keyboard event is received from the hosting window
  128056. */
  128057. _this.onKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128058. // Coordinates system
  128059. _this._useRightHandedSystem = false;
  128060. // Fog
  128061. _this._fogEnabled = true;
  128062. _this._fogMode = Scene.FOGMODE_NONE;
  128063. /**
  128064. * Gets or sets the fog color to use
  128065. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128066. * (Default is Color3(0.2, 0.2, 0.3))
  128067. */
  128068. _this.fogColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0.2, 0.2, 0.3);
  128069. /**
  128070. * Gets or sets the fog density to use
  128071. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128072. * (Default is 0.1)
  128073. */
  128074. _this.fogDensity = 0.1;
  128075. /**
  128076. * Gets or sets the fog start distance to use
  128077. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128078. * (Default is 0)
  128079. */
  128080. _this.fogStart = 0;
  128081. /**
  128082. * Gets or sets the fog end distance to use
  128083. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128084. * (Default is 1000)
  128085. */
  128086. _this.fogEnd = 1000.0;
  128087. // Lights
  128088. _this._shadowsEnabled = true;
  128089. _this._lightsEnabled = true;
  128090. /** All of the active cameras added to this scene. */
  128091. _this.activeCameras = new Array();
  128092. // Textures
  128093. _this._texturesEnabled = true;
  128094. // Particles
  128095. /**
  128096. * Gets or sets a boolean indicating if particles are enabled on this scene
  128097. */
  128098. _this.particlesEnabled = true;
  128099. // Sprites
  128100. /**
  128101. * Gets or sets a boolean indicating if sprites are enabled on this scene
  128102. */
  128103. _this.spritesEnabled = true;
  128104. // Skeletons
  128105. _this._skeletonsEnabled = true;
  128106. // Lens flares
  128107. /**
  128108. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  128109. */
  128110. _this.lensFlaresEnabled = true;
  128111. // Collisions
  128112. /**
  128113. * Gets or sets a boolean indicating if collisions are enabled on this scene
  128114. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  128115. */
  128116. _this.collisionsEnabled = true;
  128117. /**
  128118. * Defines the gravity applied to this scene (used only for collisions)
  128119. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  128120. */
  128121. _this.gravity = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](0, -9.807, 0);
  128122. // Postprocesses
  128123. /**
  128124. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  128125. */
  128126. _this.postProcessesEnabled = true;
  128127. /**
  128128. * The list of postprocesses added to the scene
  128129. */
  128130. _this.postProcesses = new Array();
  128131. // Customs render targets
  128132. /**
  128133. * Gets or sets a boolean indicating if render targets are enabled on this scene
  128134. */
  128135. _this.renderTargetsEnabled = true;
  128136. /**
  128137. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  128138. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  128139. */
  128140. _this.dumpNextRenderTargets = false;
  128141. /**
  128142. * The list of user defined render targets added to the scene
  128143. */
  128144. _this.customRenderTargets = new Array();
  128145. /**
  128146. * Gets the list of meshes imported to the scene through SceneLoader
  128147. */
  128148. _this.importedMeshesFiles = new Array();
  128149. // Probes
  128150. /**
  128151. * Gets or sets a boolean indicating if probes are enabled on this scene
  128152. */
  128153. _this.probesEnabled = true;
  128154. _this._meshesForIntersections = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  128155. // Procedural textures
  128156. /**
  128157. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  128158. */
  128159. _this.proceduralTexturesEnabled = true;
  128160. // Performance counters
  128161. _this._totalVertices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  128162. /** @hidden */
  128163. _this._activeIndices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  128164. /** @hidden */
  128165. _this._activeParticles = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  128166. /** @hidden */
  128167. _this._activeBones = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  128168. /** @hidden */
  128169. _this._animationTime = 0;
  128170. /**
  128171. * Gets or sets a general scale for animation speed
  128172. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  128173. */
  128174. _this.animationTimeScale = 1;
  128175. _this._renderId = 0;
  128176. _this._frameId = 0;
  128177. _this._executeWhenReadyTimeoutId = -1;
  128178. _this._intermediateRendering = false;
  128179. _this._viewUpdateFlag = -1;
  128180. _this._projectionUpdateFlag = -1;
  128181. _this._alternateViewUpdateFlag = -1;
  128182. _this._alternateProjectionUpdateFlag = -1;
  128183. /** @hidden */
  128184. _this._toBeDisposed = new Array(256);
  128185. _this._activeRequests = new Array();
  128186. /** @hidden */
  128187. _this._pendingData = new Array();
  128188. _this._isDisposed = false;
  128189. /**
  128190. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  128191. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  128192. */
  128193. _this.dispatchAllSubMeshesOfActiveMeshes = false;
  128194. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  128195. _this._processedMaterials = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  128196. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  128197. /** @hidden */
  128198. _this._activeParticleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  128199. _this._activeSkeletons = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  128200. _this._softwareSkinnedMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  128201. /** @hidden */
  128202. _this._activeAnimatables = new Array();
  128203. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  128204. _this._useAlternateCameraConfiguration = false;
  128205. _this._alternateRendering = false;
  128206. _this._wheelEventName = "";
  128207. /**
  128208. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  128209. * This is useful if there are more lights that the maximum simulteanous authorized
  128210. */
  128211. _this.requireLightSorting = false;
  128212. /**
  128213. * @hidden
  128214. * Backing store of defined scene components.
  128215. */
  128216. _this._components = [];
  128217. /**
  128218. * @hidden
  128219. * Backing store of defined scene components.
  128220. */
  128221. _this._serializableComponents = [];
  128222. /**
  128223. * List of components to register on the next registration step.
  128224. */
  128225. _this._transientComponents = [];
  128226. /**
  128227. * @hidden
  128228. * Defines the actions happening before camera updates.
  128229. */
  128230. _this._beforeCameraUpdateStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128231. /**
  128232. * @hidden
  128233. * Defines the actions happening before clear the canvas.
  128234. */
  128235. _this._beforeClearStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128236. /**
  128237. * @hidden
  128238. * Defines the actions when collecting render targets for the frame.
  128239. */
  128240. _this._gatherRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128241. /**
  128242. * @hidden
  128243. * Defines the actions happening for one camera in the frame.
  128244. */
  128245. _this._gatherActiveCameraRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128246. /**
  128247. * @hidden
  128248. * Defines the actions happening during the per mesh ready checks.
  128249. */
  128250. _this._isReadyForMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128251. /**
  128252. * @hidden
  128253. * Defines the actions happening before evaluate active mesh checks.
  128254. */
  128255. _this._beforeEvaluateActiveMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128256. /**
  128257. * @hidden
  128258. * Defines the actions happening during the evaluate sub mesh checks.
  128259. */
  128260. _this._evaluateSubMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128261. /**
  128262. * @hidden
  128263. * Defines the actions happening during the active mesh stage.
  128264. */
  128265. _this._activeMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128266. /**
  128267. * @hidden
  128268. * Defines the actions happening during the per camera render target step.
  128269. */
  128270. _this._cameraDrawRenderTargetStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128271. /**
  128272. * @hidden
  128273. * Defines the actions happening just before the active camera is drawing.
  128274. */
  128275. _this._beforeCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128276. /**
  128277. * @hidden
  128278. * Defines the actions happening just before a render target is drawing.
  128279. */
  128280. _this._beforeRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128281. /**
  128282. * @hidden
  128283. * Defines the actions happening just before a rendering group is drawing.
  128284. */
  128285. _this._beforeRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128286. /**
  128287. * @hidden
  128288. * Defines the actions happening just before a mesh is drawing.
  128289. */
  128290. _this._beforeRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128291. /**
  128292. * @hidden
  128293. * Defines the actions happening just after a mesh has been drawn.
  128294. */
  128295. _this._afterRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128296. /**
  128297. * @hidden
  128298. * Defines the actions happening just after a rendering group has been drawn.
  128299. */
  128300. _this._afterRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128301. /**
  128302. * @hidden
  128303. * Defines the actions happening just after the active camera has been drawn.
  128304. */
  128305. _this._afterCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128306. /**
  128307. * @hidden
  128308. * Defines the actions happening just after a render target has been drawn.
  128309. */
  128310. _this._afterRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128311. /**
  128312. * @hidden
  128313. * Defines the actions happening just after rendering all cameras and computing intersections.
  128314. */
  128315. _this._afterRenderStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128316. /**
  128317. * @hidden
  128318. * Defines the actions happening when a pointer move event happens.
  128319. */
  128320. _this._pointerMoveStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128321. /**
  128322. * @hidden
  128323. * Defines the actions happening when a pointer down event happens.
  128324. */
  128325. _this._pointerDownStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128326. /**
  128327. * @hidden
  128328. * Defines the actions happening when a pointer up event happens.
  128329. */
  128330. _this._pointerUpStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128331. /**
  128332. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  128333. */
  128334. _this.geometriesByUniqueId = null;
  128335. _this._defaultMeshCandidates = {
  128336. data: [],
  128337. length: 0
  128338. };
  128339. _this._defaultSubMeshCandidates = {
  128340. data: [],
  128341. length: 0
  128342. };
  128343. _this._preventFreeActiveMeshesAndRenderingGroups = false;
  128344. _this._activeMeshesFrozen = false;
  128345. /** @hidden */
  128346. _this._allowPostProcessClearColor = true;
  128347. /**
  128348. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  128349. */
  128350. _this.getDeterministicFrameTime = function () {
  128351. return 1000.0 / 60.0; // frame time in ms
  128352. };
  128353. _this._blockMaterialDirtyMechanism = false;
  128354. _this._engine = engine || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_24__["EngineStore"].LastCreatedEngine;
  128355. _this._engine.scenes.push(_this);
  128356. _this._uid = null;
  128357. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_19__["RenderingManager"](_this);
  128358. if (_PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__["PostProcessManager"]) {
  128359. _this.postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__["PostProcessManager"](_this);
  128360. }
  128361. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_22__["DomManagement"].IsWindowObjectExist()) {
  128362. _this.attachControl();
  128363. }
  128364. // Uniform Buffer
  128365. _this._createUbo();
  128366. // Default Image processing definition
  128367. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]) {
  128368. _this._imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]();
  128369. }
  128370. _this.setDefaultCandidateProviders();
  128371. if (options && options.useGeometryUniqueIdsMap === true) {
  128372. _this.geometriesByUniqueId = {};
  128373. }
  128374. _this.useMaterialMeshMap = options && options.useGeometryUniqueIdsMap || false;
  128375. _this.useClonedMeshhMap = options && options.useClonedMeshhMap || false;
  128376. _this._engine.onNewSceneAddedObservable.notifyObservers(_this);
  128377. return _this;
  128378. }
  128379. /**
  128380. * Factory used to create the default material.
  128381. * @param name The name of the material to create
  128382. * @param scene The scene to create the material for
  128383. * @returns The default material
  128384. */
  128385. Scene.DefaultMaterialFactory = function (scene) {
  128386. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("StandardMaterial");
  128387. };
  128388. /**
  128389. * Factory used to create the a collision coordinator.
  128390. * @returns The collision coordinator
  128391. */
  128392. Scene.CollisionCoordinatorFactory = function () {
  128393. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("DefaultCollisionCoordinator");
  128394. };
  128395. Object.defineProperty(Scene.prototype, "environmentTexture", {
  128396. /**
  128397. * Texture used in all pbr material as the reflection texture.
  128398. * As in the majority of the scene they are the same (exception for multi room and so on),
  128399. * this is easier to reference from here than from all the materials.
  128400. */
  128401. get: function () {
  128402. return this._environmentTexture;
  128403. },
  128404. /**
  128405. * Texture used in all pbr material as the reflection texture.
  128406. * As in the majority of the scene they are the same (exception for multi room and so on),
  128407. * this is easier to set here than in all the materials.
  128408. */
  128409. set: function (value) {
  128410. if (this._environmentTexture === value) {
  128411. return;
  128412. }
  128413. this._environmentTexture = value;
  128414. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  128415. },
  128416. enumerable: true,
  128417. configurable: true
  128418. });
  128419. Object.defineProperty(Scene.prototype, "imageProcessingConfiguration", {
  128420. /**
  128421. * Default image processing configuration used either in the rendering
  128422. * Forward main pass or through the imageProcessingPostProcess if present.
  128423. * As in the majority of the scene they are the same (exception for multi camera),
  128424. * this is easier to reference from here than from all the materials and post process.
  128425. *
  128426. * No setter as we it is a shared configuration, you can set the values instead.
  128427. */
  128428. get: function () {
  128429. return this._imageProcessingConfiguration;
  128430. },
  128431. enumerable: true,
  128432. configurable: true
  128433. });
  128434. Object.defineProperty(Scene.prototype, "forceWireframe", {
  128435. get: function () {
  128436. return this._forceWireframe;
  128437. },
  128438. /**
  128439. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  128440. */
  128441. set: function (value) {
  128442. if (this._forceWireframe === value) {
  128443. return;
  128444. }
  128445. this._forceWireframe = value;
  128446. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  128447. },
  128448. enumerable: true,
  128449. configurable: true
  128450. });
  128451. Object.defineProperty(Scene.prototype, "forcePointsCloud", {
  128452. get: function () {
  128453. return this._forcePointsCloud;
  128454. },
  128455. /**
  128456. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  128457. */
  128458. set: function (value) {
  128459. if (this._forcePointsCloud === value) {
  128460. return;
  128461. }
  128462. this._forcePointsCloud = value;
  128463. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  128464. },
  128465. enumerable: true,
  128466. configurable: true
  128467. });
  128468. Object.defineProperty(Scene.prototype, "animationPropertiesOverride", {
  128469. /**
  128470. * Gets or sets the animation properties override
  128471. */
  128472. get: function () {
  128473. return this._animationPropertiesOverride;
  128474. },
  128475. set: function (value) {
  128476. this._animationPropertiesOverride = value;
  128477. },
  128478. enumerable: true,
  128479. configurable: true
  128480. });
  128481. Object.defineProperty(Scene.prototype, "onDispose", {
  128482. /** Sets a function to be executed when this scene is disposed. */
  128483. set: function (callback) {
  128484. if (this._onDisposeObserver) {
  128485. this.onDisposeObservable.remove(this._onDisposeObserver);
  128486. }
  128487. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  128488. },
  128489. enumerable: true,
  128490. configurable: true
  128491. });
  128492. Object.defineProperty(Scene.prototype, "beforeRender", {
  128493. /** Sets a function to be executed before rendering this scene */
  128494. set: function (callback) {
  128495. if (this._onBeforeRenderObserver) {
  128496. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  128497. }
  128498. if (callback) {
  128499. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  128500. }
  128501. },
  128502. enumerable: true,
  128503. configurable: true
  128504. });
  128505. Object.defineProperty(Scene.prototype, "afterRender", {
  128506. /** Sets a function to be executed after rendering this scene */
  128507. set: function (callback) {
  128508. if (this._onAfterRenderObserver) {
  128509. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  128510. }
  128511. if (callback) {
  128512. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  128513. }
  128514. },
  128515. enumerable: true,
  128516. configurable: true
  128517. });
  128518. Object.defineProperty(Scene.prototype, "beforeCameraRender", {
  128519. /** Sets a function to be executed before rendering a camera*/
  128520. set: function (callback) {
  128521. if (this._onBeforeCameraRenderObserver) {
  128522. this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  128523. }
  128524. this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(callback);
  128525. },
  128526. enumerable: true,
  128527. configurable: true
  128528. });
  128529. Object.defineProperty(Scene.prototype, "afterCameraRender", {
  128530. /** Sets a function to be executed after rendering a camera*/
  128531. set: function (callback) {
  128532. if (this._onAfterCameraRenderObserver) {
  128533. this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  128534. }
  128535. this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(callback);
  128536. },
  128537. enumerable: true,
  128538. configurable: true
  128539. });
  128540. Object.defineProperty(Scene.prototype, "unTranslatedPointer", {
  128541. /**
  128542. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  128543. */
  128544. get: function () {
  128545. return new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](this._unTranslatedPointerX, this._unTranslatedPointerY);
  128546. },
  128547. enumerable: true,
  128548. configurable: true
  128549. });
  128550. Object.defineProperty(Scene.prototype, "useRightHandedSystem", {
  128551. get: function () {
  128552. return this._useRightHandedSystem;
  128553. },
  128554. /**
  128555. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  128556. */
  128557. set: function (value) {
  128558. if (this._useRightHandedSystem === value) {
  128559. return;
  128560. }
  128561. this._useRightHandedSystem = value;
  128562. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  128563. },
  128564. enumerable: true,
  128565. configurable: true
  128566. });
  128567. /**
  128568. * Sets the step Id used by deterministic lock step
  128569. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128570. * @param newStepId defines the step Id
  128571. */
  128572. Scene.prototype.setStepId = function (newStepId) {
  128573. this._currentStepId = newStepId;
  128574. };
  128575. /**
  128576. * Gets the step Id used by deterministic lock step
  128577. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128578. * @returns the step Id
  128579. */
  128580. Scene.prototype.getStepId = function () {
  128581. return this._currentStepId;
  128582. };
  128583. /**
  128584. * Gets the internal step used by deterministic lock step
  128585. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128586. * @returns the internal step
  128587. */
  128588. Scene.prototype.getInternalStep = function () {
  128589. return this._currentInternalStep;
  128590. };
  128591. Object.defineProperty(Scene.prototype, "fogEnabled", {
  128592. get: function () {
  128593. return this._fogEnabled;
  128594. },
  128595. /**
  128596. * Gets or sets a boolean indicating if fog is enabled on this scene
  128597. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128598. * (Default is true)
  128599. */
  128600. set: function (value) {
  128601. if (this._fogEnabled === value) {
  128602. return;
  128603. }
  128604. this._fogEnabled = value;
  128605. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  128606. },
  128607. enumerable: true,
  128608. configurable: true
  128609. });
  128610. Object.defineProperty(Scene.prototype, "fogMode", {
  128611. get: function () {
  128612. return this._fogMode;
  128613. },
  128614. /**
  128615. * Gets or sets the fog mode to use
  128616. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128617. * | mode | value |
  128618. * | --- | --- |
  128619. * | FOGMODE_NONE | 0 |
  128620. * | FOGMODE_EXP | 1 |
  128621. * | FOGMODE_EXP2 | 2 |
  128622. * | FOGMODE_LINEAR | 3 |
  128623. */
  128624. set: function (value) {
  128625. if (this._fogMode === value) {
  128626. return;
  128627. }
  128628. this._fogMode = value;
  128629. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  128630. },
  128631. enumerable: true,
  128632. configurable: true
  128633. });
  128634. Object.defineProperty(Scene.prototype, "shadowsEnabled", {
  128635. get: function () {
  128636. return this._shadowsEnabled;
  128637. },
  128638. /**
  128639. * Gets or sets a boolean indicating if shadows are enabled on this scene
  128640. */
  128641. set: function (value) {
  128642. if (this._shadowsEnabled === value) {
  128643. return;
  128644. }
  128645. this._shadowsEnabled = value;
  128646. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_LightDirtyFlag);
  128647. },
  128648. enumerable: true,
  128649. configurable: true
  128650. });
  128651. Object.defineProperty(Scene.prototype, "lightsEnabled", {
  128652. get: function () {
  128653. return this._lightsEnabled;
  128654. },
  128655. /**
  128656. * Gets or sets a boolean indicating if lights are enabled on this scene
  128657. */
  128658. set: function (value) {
  128659. if (this._lightsEnabled === value) {
  128660. return;
  128661. }
  128662. this._lightsEnabled = value;
  128663. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_LightDirtyFlag);
  128664. },
  128665. enumerable: true,
  128666. configurable: true
  128667. });
  128668. Object.defineProperty(Scene.prototype, "activeCamera", {
  128669. /** Gets or sets the current active camera */
  128670. get: function () {
  128671. return this._activeCamera;
  128672. },
  128673. set: function (value) {
  128674. if (value === this._activeCamera) {
  128675. return;
  128676. }
  128677. this._activeCamera = value;
  128678. this.onActiveCameraChanged.notifyObservers(this);
  128679. },
  128680. enumerable: true,
  128681. configurable: true
  128682. });
  128683. Object.defineProperty(Scene.prototype, "defaultMaterial", {
  128684. /** The default material used on meshes when no material is affected */
  128685. get: function () {
  128686. if (!this._defaultMaterial) {
  128687. this._defaultMaterial = Scene.DefaultMaterialFactory(this);
  128688. }
  128689. return this._defaultMaterial;
  128690. },
  128691. /** The default material used on meshes when no material is affected */
  128692. set: function (value) {
  128693. this._defaultMaterial = value;
  128694. },
  128695. enumerable: true,
  128696. configurable: true
  128697. });
  128698. Object.defineProperty(Scene.prototype, "texturesEnabled", {
  128699. get: function () {
  128700. return this._texturesEnabled;
  128701. },
  128702. /**
  128703. * Gets or sets a boolean indicating if textures are enabled on this scene
  128704. */
  128705. set: function (value) {
  128706. if (this._texturesEnabled === value) {
  128707. return;
  128708. }
  128709. this._texturesEnabled = value;
  128710. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  128711. },
  128712. enumerable: true,
  128713. configurable: true
  128714. });
  128715. Object.defineProperty(Scene.prototype, "skeletonsEnabled", {
  128716. get: function () {
  128717. return this._skeletonsEnabled;
  128718. },
  128719. /**
  128720. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  128721. */
  128722. set: function (value) {
  128723. if (this._skeletonsEnabled === value) {
  128724. return;
  128725. }
  128726. this._skeletonsEnabled = value;
  128727. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_AttributesDirtyFlag);
  128728. },
  128729. enumerable: true,
  128730. configurable: true
  128731. });
  128732. Object.defineProperty(Scene.prototype, "collisionCoordinator", {
  128733. /** @hidden */
  128734. get: function () {
  128735. if (!this._collisionCoordinator) {
  128736. this._collisionCoordinator = Scene.CollisionCoordinatorFactory();
  128737. this._collisionCoordinator.init(this);
  128738. }
  128739. return this._collisionCoordinator;
  128740. },
  128741. enumerable: true,
  128742. configurable: true
  128743. });
  128744. Object.defineProperty(Scene.prototype, "_isAlternateRenderingEnabled", {
  128745. /** @hidden */
  128746. get: function () {
  128747. return this._alternateRendering;
  128748. },
  128749. enumerable: true,
  128750. configurable: true
  128751. });
  128752. Object.defineProperty(Scene.prototype, "frustumPlanes", {
  128753. /**
  128754. * Gets the list of frustum planes (built from the active camera)
  128755. */
  128756. get: function () {
  128757. return this._frustumPlanes;
  128758. },
  128759. enumerable: true,
  128760. configurable: true
  128761. });
  128762. /**
  128763. * Registers the transient components if needed.
  128764. */
  128765. Scene.prototype._registerTransientComponents = function () {
  128766. // Register components that have been associated lately to the scene.
  128767. if (this._transientComponents.length > 0) {
  128768. for (var _i = 0, _a = this._transientComponents; _i < _a.length; _i++) {
  128769. var component = _a[_i];
  128770. component.register();
  128771. }
  128772. this._transientComponents = [];
  128773. }
  128774. };
  128775. /**
  128776. * @hidden
  128777. * Add a component to the scene.
  128778. * Note that the ccomponent could be registered on th next frame if this is called after
  128779. * the register component stage.
  128780. * @param component Defines the component to add to the scene
  128781. */
  128782. Scene.prototype._addComponent = function (component) {
  128783. this._components.push(component);
  128784. this._transientComponents.push(component);
  128785. var serializableComponent = component;
  128786. if (serializableComponent.addFromContainer) {
  128787. this._serializableComponents.push(serializableComponent);
  128788. }
  128789. };
  128790. /**
  128791. * @hidden
  128792. * Gets a component from the scene.
  128793. * @param name defines the name of the component to retrieve
  128794. * @returns the component or null if not present
  128795. */
  128796. Scene.prototype._getComponent = function (name) {
  128797. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  128798. var component = _a[_i];
  128799. if (component.name === name) {
  128800. return component;
  128801. }
  128802. }
  128803. return null;
  128804. };
  128805. /**
  128806. * @hidden
  128807. */
  128808. Scene.prototype._getDefaultMeshCandidates = function () {
  128809. this._defaultMeshCandidates.data = this.meshes;
  128810. this._defaultMeshCandidates.length = this.meshes.length;
  128811. return this._defaultMeshCandidates;
  128812. };
  128813. /**
  128814. * @hidden
  128815. */
  128816. Scene.prototype._getDefaultSubMeshCandidates = function (mesh) {
  128817. this._defaultSubMeshCandidates.data = mesh.subMeshes;
  128818. this._defaultSubMeshCandidates.length = mesh.subMeshes.length;
  128819. return this._defaultSubMeshCandidates;
  128820. };
  128821. /**
  128822. * Sets the default candidate providers for the scene.
  128823. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  128824. * and getCollidingSubMeshCandidates to their default function
  128825. */
  128826. Scene.prototype.setDefaultCandidateProviders = function () {
  128827. this.getActiveMeshCandidates = this._getDefaultMeshCandidates.bind(this);
  128828. this.getActiveSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  128829. this.getIntersectingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  128830. this.getCollidingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  128831. };
  128832. Object.defineProperty(Scene.prototype, "meshUnderPointer", {
  128833. /**
  128834. * Gets the mesh that is currently under the pointer
  128835. */
  128836. get: function () {
  128837. return this._pointerOverMesh;
  128838. },
  128839. enumerable: true,
  128840. configurable: true
  128841. });
  128842. Object.defineProperty(Scene.prototype, "pointerX", {
  128843. /**
  128844. * Gets or sets the current on-screen X position of the pointer
  128845. */
  128846. get: function () {
  128847. return this._pointerX;
  128848. },
  128849. set: function (value) {
  128850. this._pointerX = value;
  128851. },
  128852. enumerable: true,
  128853. configurable: true
  128854. });
  128855. Object.defineProperty(Scene.prototype, "pointerY", {
  128856. /**
  128857. * Gets or sets the current on-screen Y position of the pointer
  128858. */
  128859. get: function () {
  128860. return this._pointerY;
  128861. },
  128862. set: function (value) {
  128863. this._pointerY = value;
  128864. },
  128865. enumerable: true,
  128866. configurable: true
  128867. });
  128868. /**
  128869. * Gets the cached material (ie. the latest rendered one)
  128870. * @returns the cached material
  128871. */
  128872. Scene.prototype.getCachedMaterial = function () {
  128873. return this._cachedMaterial;
  128874. };
  128875. /**
  128876. * Gets the cached effect (ie. the latest rendered one)
  128877. * @returns the cached effect
  128878. */
  128879. Scene.prototype.getCachedEffect = function () {
  128880. return this._cachedEffect;
  128881. };
  128882. /**
  128883. * Gets the cached visibility state (ie. the latest rendered one)
  128884. * @returns the cached visibility state
  128885. */
  128886. Scene.prototype.getCachedVisibility = function () {
  128887. return this._cachedVisibility;
  128888. };
  128889. /**
  128890. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  128891. * @param material defines the current material
  128892. * @param effect defines the current effect
  128893. * @param visibility defines the current visibility state
  128894. * @returns true if one parameter is not cached
  128895. */
  128896. Scene.prototype.isCachedMaterialInvalid = function (material, effect, visibility) {
  128897. if (visibility === void 0) { visibility = 1; }
  128898. return this._cachedEffect !== effect || this._cachedMaterial !== material || this._cachedVisibility !== visibility;
  128899. };
  128900. /**
  128901. * Gets the engine associated with the scene
  128902. * @returns an Engine
  128903. */
  128904. Scene.prototype.getEngine = function () {
  128905. return this._engine;
  128906. };
  128907. /**
  128908. * Gets the total number of vertices rendered per frame
  128909. * @returns the total number of vertices rendered per frame
  128910. */
  128911. Scene.prototype.getTotalVertices = function () {
  128912. return this._totalVertices.current;
  128913. };
  128914. Object.defineProperty(Scene.prototype, "totalVerticesPerfCounter", {
  128915. /**
  128916. * Gets the performance counter for total vertices
  128917. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  128918. */
  128919. get: function () {
  128920. return this._totalVertices;
  128921. },
  128922. enumerable: true,
  128923. configurable: true
  128924. });
  128925. /**
  128926. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  128927. * @returns the total number of active indices rendered per frame
  128928. */
  128929. Scene.prototype.getActiveIndices = function () {
  128930. return this._activeIndices.current;
  128931. };
  128932. Object.defineProperty(Scene.prototype, "totalActiveIndicesPerfCounter", {
  128933. /**
  128934. * Gets the performance counter for active indices
  128935. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  128936. */
  128937. get: function () {
  128938. return this._activeIndices;
  128939. },
  128940. enumerable: true,
  128941. configurable: true
  128942. });
  128943. /**
  128944. * Gets the total number of active particles rendered per frame
  128945. * @returns the total number of active particles rendered per frame
  128946. */
  128947. Scene.prototype.getActiveParticles = function () {
  128948. return this._activeParticles.current;
  128949. };
  128950. Object.defineProperty(Scene.prototype, "activeParticlesPerfCounter", {
  128951. /**
  128952. * Gets the performance counter for active particles
  128953. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  128954. */
  128955. get: function () {
  128956. return this._activeParticles;
  128957. },
  128958. enumerable: true,
  128959. configurable: true
  128960. });
  128961. /**
  128962. * Gets the total number of active bones rendered per frame
  128963. * @returns the total number of active bones rendered per frame
  128964. */
  128965. Scene.prototype.getActiveBones = function () {
  128966. return this._activeBones.current;
  128967. };
  128968. Object.defineProperty(Scene.prototype, "activeBonesPerfCounter", {
  128969. /**
  128970. * Gets the performance counter for active bones
  128971. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  128972. */
  128973. get: function () {
  128974. return this._activeBones;
  128975. },
  128976. enumerable: true,
  128977. configurable: true
  128978. });
  128979. /**
  128980. * Gets the array of active meshes
  128981. * @returns an array of AbstractMesh
  128982. */
  128983. Scene.prototype.getActiveMeshes = function () {
  128984. return this._activeMeshes;
  128985. };
  128986. /**
  128987. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  128988. * @returns a number
  128989. */
  128990. Scene.prototype.getAnimationRatio = function () {
  128991. return this._animationRatio !== undefined ? this._animationRatio : 1;
  128992. };
  128993. /**
  128994. * Gets an unique Id for the current render phase
  128995. * @returns a number
  128996. */
  128997. Scene.prototype.getRenderId = function () {
  128998. return this._renderId;
  128999. };
  129000. /**
  129001. * Gets an unique Id for the current frame
  129002. * @returns a number
  129003. */
  129004. Scene.prototype.getFrameId = function () {
  129005. return this._frameId;
  129006. };
  129007. /** Call this function if you want to manually increment the render Id*/
  129008. Scene.prototype.incrementRenderId = function () {
  129009. this._renderId++;
  129010. };
  129011. Scene.prototype._updatePointerPosition = function (evt) {
  129012. var canvasRect = this._engine.getRenderingCanvasClientRect();
  129013. if (!canvasRect) {
  129014. return;
  129015. }
  129016. this._pointerX = evt.clientX - canvasRect.left;
  129017. this._pointerY = evt.clientY - canvasRect.top;
  129018. this._unTranslatedPointerX = this._pointerX;
  129019. this._unTranslatedPointerY = this._pointerY;
  129020. };
  129021. Scene.prototype._createUbo = function () {
  129022. this._sceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  129023. this._sceneUbo.addUniform("viewProjection", 16);
  129024. this._sceneUbo.addUniform("view", 16);
  129025. };
  129026. Scene.prototype._createAlternateUbo = function () {
  129027. this._alternateSceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  129028. this._alternateSceneUbo.addUniform("viewProjection", 16);
  129029. this._alternateSceneUbo.addUniform("view", 16);
  129030. };
  129031. // Pointers handling
  129032. Scene.prototype._setRayOnPointerInfo = function (pointerInfo) {
  129033. if (pointerInfo.pickInfo && !pointerInfo.pickInfo._pickingUnavailable) {
  129034. if (!pointerInfo.pickInfo.ray) {
  129035. pointerInfo.pickInfo.ray = this.createPickingRay(pointerInfo.event.offsetX, pointerInfo.event.offsetY, _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity(), this.activeCamera);
  129036. }
  129037. }
  129038. };
  129039. /**
  129040. * Use this method to simulate a pointer move on a mesh
  129041. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  129042. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  129043. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  129044. * @returns the current scene
  129045. */
  129046. Scene.prototype.simulatePointerMove = function (pickResult, pointerEventInit) {
  129047. var evt = new PointerEvent("pointermove", pointerEventInit);
  129048. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE)) {
  129049. return this;
  129050. }
  129051. return this._processPointerMove(pickResult, evt);
  129052. };
  129053. Scene.prototype._processPointerMove = function (pickResult, evt) {
  129054. var canvas = this._engine.getRenderingCanvas();
  129055. if (!canvas) {
  129056. return this;
  129057. }
  129058. // Restore pointer
  129059. canvas.style.cursor = this.defaultCursor;
  129060. var isMeshPicked = (pickResult && pickResult.hit && pickResult.pickedMesh) ? true : false;
  129061. if (isMeshPicked) {
  129062. this.setPointerOverMesh(pickResult.pickedMesh);
  129063. if (this._pointerOverMesh && this._pointerOverMesh.actionManager && this._pointerOverMesh.actionManager.hasPointerTriggers) {
  129064. if (this._pointerOverMesh.actionManager.hoverCursor) {
  129065. canvas.style.cursor = this._pointerOverMesh.actionManager.hoverCursor;
  129066. }
  129067. else {
  129068. canvas.style.cursor = this.hoverCursor;
  129069. }
  129070. }
  129071. }
  129072. else {
  129073. this.setPointerOverMesh(null);
  129074. }
  129075. for (var _i = 0, _a = this._pointerMoveStage; _i < _a.length; _i++) {
  129076. var step = _a[_i];
  129077. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, isMeshPicked, canvas);
  129078. }
  129079. if (pickResult) {
  129080. var type = evt.type === this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE;
  129081. if (this.onPointerMove) {
  129082. this.onPointerMove(evt, pickResult, type);
  129083. }
  129084. if (this.onPointerObservable.hasObservers()) {
  129085. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  129086. this._setRayOnPointerInfo(pi);
  129087. this.onPointerObservable.notifyObservers(pi, type);
  129088. }
  129089. }
  129090. return this;
  129091. };
  129092. Scene.prototype._checkPrePointerObservable = function (pickResult, evt, type) {
  129093. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfoPre"](type, evt, this._unTranslatedPointerX, this._unTranslatedPointerY);
  129094. if (pickResult) {
  129095. pi.ray = pickResult.ray;
  129096. }
  129097. this.onPrePointerObservable.notifyObservers(pi, type);
  129098. if (pi.skipOnPointerObservable) {
  129099. return true;
  129100. }
  129101. else {
  129102. return false;
  129103. }
  129104. };
  129105. /**
  129106. * Use this method to simulate a pointer down on a mesh
  129107. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  129108. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  129109. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  129110. * @returns the current scene
  129111. */
  129112. Scene.prototype.simulatePointerDown = function (pickResult, pointerEventInit) {
  129113. var evt = new PointerEvent("pointerdown", pointerEventInit);
  129114. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN)) {
  129115. return this;
  129116. }
  129117. return this._processPointerDown(pickResult, evt);
  129118. };
  129119. Scene.prototype._processPointerDown = function (pickResult, evt) {
  129120. var _this = this;
  129121. if (pickResult && pickResult.hit && pickResult.pickedMesh) {
  129122. this._pickedDownMesh = pickResult.pickedMesh;
  129123. var actionManager = pickResult.pickedMesh.actionManager;
  129124. if (actionManager) {
  129125. if (actionManager.hasPickTriggers) {
  129126. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129127. switch (evt.button) {
  129128. case 0:
  129129. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLeftPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129130. break;
  129131. case 1:
  129132. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnCenterPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129133. break;
  129134. case 2:
  129135. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnRightPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129136. break;
  129137. }
  129138. }
  129139. if (actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLongPressTrigger)) {
  129140. window.setTimeout(function () {
  129141. 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);
  129142. if (pickResult && pickResult.hit && pickResult.pickedMesh && actionManager) {
  129143. if (_this._totalPointersPressed !== 0 &&
  129144. ((Date.now() - _this._startingPointerTime) > Scene.LongPressDelay) &&
  129145. !_this._isPointerSwiping()) {
  129146. _this._startingPointerTime = 0;
  129147. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLongPressTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129148. }
  129149. }
  129150. }, Scene.LongPressDelay);
  129151. }
  129152. }
  129153. }
  129154. else {
  129155. for (var _i = 0, _a = this._pointerDownStage; _i < _a.length; _i++) {
  129156. var step = _a[_i];
  129157. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  129158. }
  129159. }
  129160. if (pickResult) {
  129161. var type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN;
  129162. if (this.onPointerDown) {
  129163. this.onPointerDown(evt, pickResult, type);
  129164. }
  129165. if (this.onPointerObservable.hasObservers()) {
  129166. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  129167. this._setRayOnPointerInfo(pi);
  129168. this.onPointerObservable.notifyObservers(pi, type);
  129169. }
  129170. }
  129171. return this;
  129172. };
  129173. /**
  129174. * Use this method to simulate a pointer up on a mesh
  129175. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  129176. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  129177. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  129178. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  129179. * @returns the current scene
  129180. */
  129181. Scene.prototype.simulatePointerUp = function (pickResult, pointerEventInit, doubleTap) {
  129182. var evt = new PointerEvent("pointerup", pointerEventInit);
  129183. var clickInfo = new ClickInfo();
  129184. if (doubleTap) {
  129185. clickInfo.doubleClick = true;
  129186. }
  129187. else {
  129188. clickInfo.singleClick = true;
  129189. }
  129190. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP)) {
  129191. return this;
  129192. }
  129193. return this._processPointerUp(pickResult, evt, clickInfo);
  129194. };
  129195. Scene.prototype._processPointerUp = function (pickResult, evt, clickInfo) {
  129196. if (pickResult && pickResult && pickResult.pickedMesh) {
  129197. this._pickedUpMesh = pickResult.pickedMesh;
  129198. if (this._pickedDownMesh === this._pickedUpMesh) {
  129199. if (this.onPointerPick) {
  129200. this.onPointerPick(evt, pickResult);
  129201. }
  129202. if (clickInfo.singleClick && !clickInfo.ignore && this.onPointerObservable.hasObservers()) {
  129203. var type_1 = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK;
  129204. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type_1, evt, pickResult);
  129205. this._setRayOnPointerInfo(pi);
  129206. this.onPointerObservable.notifyObservers(pi, type_1);
  129207. }
  129208. }
  129209. if (pickResult.pickedMesh.actionManager && !clickInfo.ignore) {
  129210. pickResult.pickedMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129211. if (!clickInfo.hasSwiped && clickInfo.singleClick) {
  129212. pickResult.pickedMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129213. }
  129214. if (clickInfo.doubleClick && pickResult.pickedMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger)) {
  129215. pickResult.pickedMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129216. }
  129217. }
  129218. }
  129219. else {
  129220. if (!clickInfo.ignore) {
  129221. for (var _i = 0, _a = this._pointerUpStage; _i < _a.length; _i++) {
  129222. var step = _a[_i];
  129223. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  129224. }
  129225. }
  129226. }
  129227. if (this._pickedDownMesh &&
  129228. this._pickedDownMesh.actionManager &&
  129229. this._pickedDownMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickOutTrigger) &&
  129230. this._pickedDownMesh !== this._pickedUpMesh) {
  129231. this._pickedDownMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pickedDownMesh, evt));
  129232. }
  129233. var type = 0;
  129234. if (this.onPointerObservable.hasObservers()) {
  129235. if (!clickInfo.ignore && !clickInfo.hasSwiped) {
  129236. if (clickInfo.singleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  129237. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP;
  129238. }
  129239. else if (clickInfo.doubleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  129240. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP;
  129241. }
  129242. if (type) {
  129243. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  129244. this._setRayOnPointerInfo(pi);
  129245. this.onPointerObservable.notifyObservers(pi, type);
  129246. }
  129247. }
  129248. if (!clickInfo.ignore) {
  129249. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP;
  129250. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  129251. this._setRayOnPointerInfo(pi);
  129252. this.onPointerObservable.notifyObservers(pi, type);
  129253. }
  129254. }
  129255. if (this.onPointerUp && !clickInfo.ignore) {
  129256. this.onPointerUp(evt, pickResult, type);
  129257. }
  129258. return this;
  129259. };
  129260. /**
  129261. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  129262. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  129263. * @returns true if the pointer was captured
  129264. */
  129265. Scene.prototype.isPointerCaptured = function (pointerId) {
  129266. if (pointerId === void 0) { pointerId = 0; }
  129267. return this._pointerCaptures[pointerId];
  129268. };
  129269. /** @hidden */
  129270. Scene.prototype._isPointerSwiping = function () {
  129271. return Math.abs(this._startingPointerPosition.x - this._pointerX) > Scene.DragMovementThreshold ||
  129272. Math.abs(this._startingPointerPosition.y - this._pointerY) > Scene.DragMovementThreshold;
  129273. };
  129274. /**
  129275. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  129276. * @param attachUp defines if you want to attach events to pointerup
  129277. * @param attachDown defines if you want to attach events to pointerdown
  129278. * @param attachMove defines if you want to attach events to pointermove
  129279. */
  129280. Scene.prototype.attachControl = function (attachUp, attachDown, attachMove) {
  129281. var _this = this;
  129282. if (attachUp === void 0) { attachUp = true; }
  129283. if (attachDown === void 0) { attachDown = true; }
  129284. if (attachMove === void 0) { attachMove = true; }
  129285. this._initActionManager = function (act, clickInfo) {
  129286. if (!_this._meshPickProceed) {
  129287. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  129288. _this._currentPickResult = pickResult;
  129289. if (pickResult) {
  129290. act = (pickResult.hit && pickResult.pickedMesh) ? pickResult.pickedMesh.actionManager : null;
  129291. }
  129292. _this._meshPickProceed = true;
  129293. }
  129294. return act;
  129295. };
  129296. this._delayedSimpleClick = function (btn, clickInfo, cb) {
  129297. // double click delay is over and that no double click has been raised since, or the 2 consecutive keys pressed are different
  129298. if ((Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay && !_this._doubleClickOccured) ||
  129299. btn !== _this._previousButtonPressed) {
  129300. _this._doubleClickOccured = false;
  129301. clickInfo.singleClick = true;
  129302. clickInfo.ignore = false;
  129303. cb(clickInfo, _this._currentPickResult);
  129304. }
  129305. };
  129306. this._initClickEvent = function (obs1, obs2, evt, cb) {
  129307. var clickInfo = new ClickInfo();
  129308. _this._currentPickResult = null;
  129309. var act = null;
  129310. var checkPicking = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK)
  129311. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)
  129312. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  129313. if (!checkPicking && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"]) {
  129314. act = _this._initActionManager(act, clickInfo);
  129315. if (act) {
  129316. checkPicking = act.hasPickTriggers;
  129317. }
  129318. }
  129319. var needToIgnoreNext = false;
  129320. if (checkPicking) {
  129321. var btn = evt.button;
  129322. clickInfo.hasSwiped = _this._isPointerSwiping();
  129323. if (!clickInfo.hasSwiped) {
  129324. var checkSingleClickImmediately = !Scene.ExclusiveDoubleClickMode;
  129325. if (!checkSingleClickImmediately) {
  129326. checkSingleClickImmediately = !obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) &&
  129327. !obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  129328. if (checkSingleClickImmediately && !_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger)) {
  129329. act = _this._initActionManager(act, clickInfo);
  129330. if (act) {
  129331. checkSingleClickImmediately = !act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  129332. }
  129333. }
  129334. }
  129335. if (checkSingleClickImmediately) {
  129336. // single click detected if double click delay is over or two different successive keys pressed without exclusive double click or no double click required
  129337. if (Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay ||
  129338. btn !== _this._previousButtonPressed) {
  129339. clickInfo.singleClick = true;
  129340. cb(clickInfo, _this._currentPickResult);
  129341. needToIgnoreNext = true;
  129342. }
  129343. }
  129344. // at least one double click is required to be check and exclusive double click is enabled
  129345. else {
  129346. // wait that no double click has been raised during the double click delay
  129347. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  129348. _this._delayedSimpleClickTimeout = window.setTimeout(_this._delayedSimpleClick.bind(_this, btn, clickInfo, cb), Scene.DoubleClickDelay);
  129349. }
  129350. var checkDoubleClick = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) ||
  129351. obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  129352. if (!checkDoubleClick && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger)) {
  129353. act = _this._initActionManager(act, clickInfo);
  129354. if (act) {
  129355. checkDoubleClick = act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  129356. }
  129357. }
  129358. if (checkDoubleClick) {
  129359. // two successive keys pressed are equal, double click delay is not over and double click has not just occurred
  129360. if (btn === _this._previousButtonPressed &&
  129361. Date.now() - _this._previousStartingPointerTime < Scene.DoubleClickDelay &&
  129362. !_this._doubleClickOccured) {
  129363. // pointer has not moved for 2 clicks, it's a double click
  129364. if (!clickInfo.hasSwiped &&
  129365. !_this._isPointerSwiping()) {
  129366. _this._previousStartingPointerTime = 0;
  129367. _this._doubleClickOccured = true;
  129368. clickInfo.doubleClick = true;
  129369. clickInfo.ignore = false;
  129370. if (Scene.ExclusiveDoubleClickMode && _this._previousDelayedSimpleClickTimeout) {
  129371. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  129372. }
  129373. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  129374. cb(clickInfo, _this._currentPickResult);
  129375. }
  129376. // if the two successive clicks are too far, it's just two simple clicks
  129377. else {
  129378. _this._doubleClickOccured = false;
  129379. _this._previousStartingPointerTime = _this._startingPointerTime;
  129380. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  129381. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  129382. _this._previousButtonPressed = btn;
  129383. if (Scene.ExclusiveDoubleClickMode) {
  129384. if (_this._previousDelayedSimpleClickTimeout) {
  129385. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  129386. }
  129387. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  129388. cb(clickInfo, _this._previousPickResult);
  129389. }
  129390. else {
  129391. cb(clickInfo, _this._currentPickResult);
  129392. }
  129393. }
  129394. needToIgnoreNext = true;
  129395. }
  129396. // just the first click of the double has been raised
  129397. else {
  129398. _this._doubleClickOccured = false;
  129399. _this._previousStartingPointerTime = _this._startingPointerTime;
  129400. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  129401. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  129402. _this._previousButtonPressed = btn;
  129403. }
  129404. }
  129405. }
  129406. }
  129407. if (!needToIgnoreNext) {
  129408. cb(clickInfo, _this._currentPickResult);
  129409. }
  129410. };
  129411. this._onPointerMove = function (evt) {
  129412. _this._updatePointerPosition(evt);
  129413. // PreObservable support
  129414. 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)) {
  129415. return;
  129416. }
  129417. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  129418. return;
  129419. }
  129420. if (!_this.pointerMovePredicate) {
  129421. _this.pointerMovePredicate = function (mesh) { return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (mesh.enablePointerMoveEvents || _this.constantlyUpdateMeshUnderPointer || (mesh.actionManager !== null && mesh.actionManager !== undefined)); };
  129422. }
  129423. // Meshes
  129424. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerMovePredicate, false, _this.cameraToUseForPointers);
  129425. _this._processPointerMove(pickResult, evt);
  129426. };
  129427. this._onPointerDown = function (evt) {
  129428. _this._totalPointersPressed++;
  129429. _this._pickedDownMesh = null;
  129430. _this._meshPickProceed = false;
  129431. _this._updatePointerPosition(evt);
  129432. if (_this.preventDefaultOnPointerDown && canvas) {
  129433. evt.preventDefault();
  129434. canvas.focus();
  129435. }
  129436. _this._startingPointerPosition.x = _this._pointerX;
  129437. _this._startingPointerPosition.y = _this._pointerY;
  129438. _this._startingPointerTime = Date.now();
  129439. // PreObservable support
  129440. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN)) {
  129441. return;
  129442. }
  129443. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  129444. return;
  129445. }
  129446. _this._pointerCaptures[evt.pointerId] = true;
  129447. if (!_this.pointerDownPredicate) {
  129448. _this.pointerDownPredicate = function (mesh) {
  129449. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled();
  129450. };
  129451. }
  129452. // Meshes
  129453. _this._pickedDownMesh = null;
  129454. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  129455. _this._processPointerDown(pickResult, evt);
  129456. };
  129457. this._onPointerUp = function (evt) {
  129458. if (_this._totalPointersPressed === 0) { // We are attaching the pointer up to windows because of a bug in FF
  129459. return; // So we need to test it the pointer down was pressed before.
  129460. }
  129461. _this._totalPointersPressed--;
  129462. _this._pickedUpMesh = null;
  129463. _this._meshPickProceed = false;
  129464. _this._updatePointerPosition(evt);
  129465. if (_this.preventDefaultOnPointerUp && canvas) {
  129466. evt.preventDefault();
  129467. canvas.focus();
  129468. }
  129469. _this._initClickEvent(_this.onPrePointerObservable, _this.onPointerObservable, evt, function (clickInfo, pickResult) {
  129470. _this._pointerCaptures[evt.pointerId] = false;
  129471. // PreObservable support
  129472. if (_this.onPrePointerObservable.hasObservers()) {
  129473. if (!clickInfo.ignore) {
  129474. if (!clickInfo.hasSwiped) {
  129475. if (clickInfo.singleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  129476. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  129477. return;
  129478. }
  129479. }
  129480. if (clickInfo.doubleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  129481. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  129482. return;
  129483. }
  129484. }
  129485. }
  129486. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP)) {
  129487. return;
  129488. }
  129489. }
  129490. }
  129491. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  129492. return;
  129493. }
  129494. if (!_this.pointerUpPredicate) {
  129495. _this.pointerUpPredicate = function (mesh) {
  129496. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled();
  129497. };
  129498. }
  129499. // Meshes
  129500. if (!_this._meshPickProceed && (_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"] && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasTriggers || _this.onPointerObservable.hasObservers())) {
  129501. _this._initActionManager(null, clickInfo);
  129502. }
  129503. if (!pickResult) {
  129504. pickResult = _this._currentPickResult;
  129505. }
  129506. _this._processPointerUp(pickResult, evt, clickInfo);
  129507. _this._previousPickResult = _this._currentPickResult;
  129508. });
  129509. };
  129510. this._onKeyDown = function (evt) {
  129511. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardEventTypes"].KEYDOWN;
  129512. if (_this.onPreKeyboardObservable.hasObservers()) {
  129513. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfoPre"](type, evt);
  129514. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  129515. if (pi.skipOnPointerObservable) {
  129516. return;
  129517. }
  129518. }
  129519. if (_this.onKeyboardObservable.hasObservers()) {
  129520. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfo"](type, evt);
  129521. _this.onKeyboardObservable.notifyObservers(pi, type);
  129522. }
  129523. if (_this.actionManager) {
  129524. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnKeyDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNewFromScene(_this, evt));
  129525. }
  129526. };
  129527. this._onKeyUp = function (evt) {
  129528. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardEventTypes"].KEYUP;
  129529. if (_this.onPreKeyboardObservable.hasObservers()) {
  129530. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfoPre"](type, evt);
  129531. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  129532. if (pi.skipOnPointerObservable) {
  129533. return;
  129534. }
  129535. }
  129536. if (_this.onKeyboardObservable.hasObservers()) {
  129537. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfo"](type, evt);
  129538. _this.onKeyboardObservable.notifyObservers(pi, type);
  129539. }
  129540. if (_this.actionManager) {
  129541. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnKeyUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNewFromScene(_this, evt));
  129542. }
  129543. };
  129544. var engine = this.getEngine();
  129545. this._onCanvasFocusObserver = engine.onCanvasFocusObservable.add(function () {
  129546. if (!canvas) {
  129547. return;
  129548. }
  129549. canvas.addEventListener("keydown", _this._onKeyDown, false);
  129550. canvas.addEventListener("keyup", _this._onKeyUp, false);
  129551. });
  129552. this._onCanvasBlurObserver = engine.onCanvasBlurObservable.add(function () {
  129553. if (!canvas) {
  129554. return;
  129555. }
  129556. canvas.removeEventListener("keydown", _this._onKeyDown);
  129557. canvas.removeEventListener("keyup", _this._onKeyUp);
  129558. });
  129559. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  129560. var canvas = this._engine.getRenderingCanvas();
  129561. if (!canvas) {
  129562. return;
  129563. }
  129564. if (attachMove) {
  129565. canvas.addEventListener(eventPrefix + "move", this._onPointerMove, false);
  129566. // Wheel
  129567. this._wheelEventName = "onwheel" in document.createElement("div") ? "wheel" : // Modern browsers support "wheel"
  129568. document.onmousewheel !== undefined ? "mousewheel" : // Webkit and IE support at least "mousewheel"
  129569. "DOMMouseScroll"; // let's assume that remaining browsers are older Firefox
  129570. canvas.addEventListener(this._wheelEventName, this._onPointerMove, false);
  129571. }
  129572. if (attachDown) {
  129573. canvas.addEventListener(eventPrefix + "down", this._onPointerDown, false);
  129574. }
  129575. if (attachUp) {
  129576. window.addEventListener(eventPrefix + "up", this._onPointerUp, false);
  129577. }
  129578. canvas.tabIndex = 1;
  129579. };
  129580. /** Detaches all event handlers*/
  129581. Scene.prototype.detachControl = function () {
  129582. var engine = this.getEngine();
  129583. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  129584. var canvas = engine.getRenderingCanvas();
  129585. if (!canvas) {
  129586. return;
  129587. }
  129588. canvas.removeEventListener(eventPrefix + "move", this._onPointerMove);
  129589. canvas.removeEventListener(eventPrefix + "down", this._onPointerDown);
  129590. window.removeEventListener(eventPrefix + "up", this._onPointerUp);
  129591. if (this._onCanvasBlurObserver) {
  129592. engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  129593. }
  129594. if (this._onCanvasFocusObserver) {
  129595. engine.onCanvasFocusObservable.remove(this._onCanvasFocusObserver);
  129596. }
  129597. // Wheel
  129598. canvas.removeEventListener(this._wheelEventName, this._onPointerMove);
  129599. // Keyboard
  129600. canvas.removeEventListener("keydown", this._onKeyDown);
  129601. canvas.removeEventListener("keyup", this._onKeyUp);
  129602. // Observables
  129603. this.onKeyboardObservable.clear();
  129604. this.onPreKeyboardObservable.clear();
  129605. this.onPointerObservable.clear();
  129606. this.onPrePointerObservable.clear();
  129607. };
  129608. /**
  129609. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  129610. * Delay loaded resources are not taking in account
  129611. * @return true if all required resources are ready
  129612. */
  129613. Scene.prototype.isReady = function () {
  129614. if (this._isDisposed) {
  129615. return false;
  129616. }
  129617. var index;
  129618. var engine = this.getEngine();
  129619. // Effects
  129620. if (!engine.areAllEffectsReady()) {
  129621. return false;
  129622. }
  129623. // Pending data
  129624. if (this._pendingData.length > 0) {
  129625. return false;
  129626. }
  129627. // Meshes
  129628. for (index = 0; index < this.meshes.length; index++) {
  129629. var mesh = this.meshes[index];
  129630. if (!mesh.isEnabled()) {
  129631. continue;
  129632. }
  129633. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  129634. continue;
  129635. }
  129636. if (!mesh.isReady(true)) {
  129637. return false;
  129638. }
  129639. var hardwareInstancedRendering = mesh.getClassName() === "InstancedMesh" || mesh.getClassName() === "InstancedLinesMesh" || engine.getCaps().instancedArrays && mesh.instances.length > 0;
  129640. // Is Ready For Mesh
  129641. for (var _i = 0, _a = this._isReadyForMeshStage; _i < _a.length; _i++) {
  129642. var step = _a[_i];
  129643. if (!step.action(mesh, hardwareInstancedRendering)) {
  129644. return false;
  129645. }
  129646. }
  129647. }
  129648. // Geometries
  129649. for (index = 0; index < this.geometries.length; index++) {
  129650. var geometry = this.geometries[index];
  129651. if (geometry.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].DELAYLOADSTATE_LOADING) {
  129652. return false;
  129653. }
  129654. }
  129655. // Post-processes
  129656. if (this.activeCameras && this.activeCameras.length > 0) {
  129657. for (var _b = 0, _c = this.activeCameras; _b < _c.length; _b++) {
  129658. var camera = _c[_b];
  129659. if (!camera.isReady(true)) {
  129660. return false;
  129661. }
  129662. }
  129663. }
  129664. else if (this.activeCamera) {
  129665. if (!this.activeCamera.isReady(true)) {
  129666. return false;
  129667. }
  129668. }
  129669. // Particles
  129670. for (var _d = 0, _e = this.particleSystems; _d < _e.length; _d++) {
  129671. var particleSystem = _e[_d];
  129672. if (!particleSystem.isReady()) {
  129673. return false;
  129674. }
  129675. }
  129676. return true;
  129677. };
  129678. /** Resets all cached information relative to material (including effect and visibility) */
  129679. Scene.prototype.resetCachedMaterial = function () {
  129680. this._cachedMaterial = null;
  129681. this._cachedEffect = null;
  129682. this._cachedVisibility = null;
  129683. };
  129684. /**
  129685. * Registers a function to be called before every frame render
  129686. * @param func defines the function to register
  129687. */
  129688. Scene.prototype.registerBeforeRender = function (func) {
  129689. this.onBeforeRenderObservable.add(func);
  129690. };
  129691. /**
  129692. * Unregisters a function called before every frame render
  129693. * @param func defines the function to unregister
  129694. */
  129695. Scene.prototype.unregisterBeforeRender = function (func) {
  129696. this.onBeforeRenderObservable.removeCallback(func);
  129697. };
  129698. /**
  129699. * Registers a function to be called after every frame render
  129700. * @param func defines the function to register
  129701. */
  129702. Scene.prototype.registerAfterRender = function (func) {
  129703. this.onAfterRenderObservable.add(func);
  129704. };
  129705. /**
  129706. * Unregisters a function called after every frame render
  129707. * @param func defines the function to unregister
  129708. */
  129709. Scene.prototype.unregisterAfterRender = function (func) {
  129710. this.onAfterRenderObservable.removeCallback(func);
  129711. };
  129712. Scene.prototype._executeOnceBeforeRender = function (func) {
  129713. var _this = this;
  129714. var execFunc = function () {
  129715. func();
  129716. setTimeout(function () {
  129717. _this.unregisterBeforeRender(execFunc);
  129718. });
  129719. };
  129720. this.registerBeforeRender(execFunc);
  129721. };
  129722. /**
  129723. * The provided function will run before render once and will be disposed afterwards.
  129724. * A timeout delay can be provided so that the function will be executed in N ms.
  129725. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  129726. * @param func The function to be executed.
  129727. * @param timeout optional delay in ms
  129728. */
  129729. Scene.prototype.executeOnceBeforeRender = function (func, timeout) {
  129730. var _this = this;
  129731. if (timeout !== undefined) {
  129732. setTimeout(function () {
  129733. _this._executeOnceBeforeRender(func);
  129734. }, timeout);
  129735. }
  129736. else {
  129737. this._executeOnceBeforeRender(func);
  129738. }
  129739. };
  129740. /** @hidden */
  129741. Scene.prototype._addPendingData = function (data) {
  129742. this._pendingData.push(data);
  129743. };
  129744. /** @hidden */
  129745. Scene.prototype._removePendingData = function (data) {
  129746. var wasLoading = this.isLoading;
  129747. var index = this._pendingData.indexOf(data);
  129748. if (index !== -1) {
  129749. this._pendingData.splice(index, 1);
  129750. }
  129751. if (wasLoading && !this.isLoading) {
  129752. this.onDataLoadedObservable.notifyObservers(this);
  129753. }
  129754. };
  129755. /**
  129756. * Returns the number of items waiting to be loaded
  129757. * @returns the number of items waiting to be loaded
  129758. */
  129759. Scene.prototype.getWaitingItemsCount = function () {
  129760. return this._pendingData.length;
  129761. };
  129762. Object.defineProperty(Scene.prototype, "isLoading", {
  129763. /**
  129764. * Returns a boolean indicating if the scene is still loading data
  129765. */
  129766. get: function () {
  129767. return this._pendingData.length > 0;
  129768. },
  129769. enumerable: true,
  129770. configurable: true
  129771. });
  129772. /**
  129773. * Registers a function to be executed when the scene is ready
  129774. * @param {Function} func - the function to be executed
  129775. */
  129776. Scene.prototype.executeWhenReady = function (func) {
  129777. var _this = this;
  129778. this.onReadyObservable.add(func);
  129779. if (this._executeWhenReadyTimeoutId !== -1) {
  129780. return;
  129781. }
  129782. this._executeWhenReadyTimeoutId = setTimeout(function () {
  129783. _this._checkIsReady();
  129784. }, 150);
  129785. };
  129786. /**
  129787. * Returns a promise that resolves when the scene is ready
  129788. * @returns A promise that resolves when the scene is ready
  129789. */
  129790. Scene.prototype.whenReadyAsync = function () {
  129791. var _this = this;
  129792. return new Promise(function (resolve) {
  129793. _this.executeWhenReady(function () {
  129794. resolve();
  129795. });
  129796. });
  129797. };
  129798. /** @hidden */
  129799. Scene.prototype._checkIsReady = function () {
  129800. var _this = this;
  129801. this._registerTransientComponents();
  129802. if (this.isReady()) {
  129803. this.onReadyObservable.notifyObservers(this);
  129804. this.onReadyObservable.clear();
  129805. this._executeWhenReadyTimeoutId = -1;
  129806. return;
  129807. }
  129808. this._executeWhenReadyTimeoutId = setTimeout(function () {
  129809. _this._checkIsReady();
  129810. }, 150);
  129811. };
  129812. Object.defineProperty(Scene.prototype, "animatables", {
  129813. /**
  129814. * Gets all animatable attached to the scene
  129815. */
  129816. get: function () {
  129817. return this._activeAnimatables;
  129818. },
  129819. enumerable: true,
  129820. configurable: true
  129821. });
  129822. /**
  129823. * Resets the last animation time frame.
  129824. * Useful to override when animations start running when loading a scene for the first time.
  129825. */
  129826. Scene.prototype.resetLastAnimationTimeFrame = function () {
  129827. this._animationTimeLast = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__["PrecisionDate"].Now;
  129828. };
  129829. // Matrix
  129830. /** @hidden */
  129831. Scene.prototype._switchToAlternateCameraConfiguration = function (active) {
  129832. this._useAlternateCameraConfiguration = active;
  129833. };
  129834. /**
  129835. * Gets the current view matrix
  129836. * @returns a Matrix
  129837. */
  129838. Scene.prototype.getViewMatrix = function () {
  129839. return this._useAlternateCameraConfiguration ? this._alternateViewMatrix : this._viewMatrix;
  129840. };
  129841. /**
  129842. * Gets the current projection matrix
  129843. * @returns a Matrix
  129844. */
  129845. Scene.prototype.getProjectionMatrix = function () {
  129846. return this._useAlternateCameraConfiguration ? this._alternateProjectionMatrix : this._projectionMatrix;
  129847. };
  129848. /**
  129849. * Gets the current transform matrix
  129850. * @returns a Matrix made of View * Projection
  129851. */
  129852. Scene.prototype.getTransformMatrix = function () {
  129853. return this._useAlternateCameraConfiguration ? this._alternateTransformMatrix : this._transformMatrix;
  129854. };
  129855. /**
  129856. * Sets the current transform matrix
  129857. * @param view defines the View matrix to use
  129858. * @param projection defines the Projection matrix to use
  129859. */
  129860. Scene.prototype.setTransformMatrix = function (view, projection) {
  129861. if (this._viewUpdateFlag === view.updateFlag && this._projectionUpdateFlag === projection.updateFlag) {
  129862. return;
  129863. }
  129864. this._viewUpdateFlag = view.updateFlag;
  129865. this._projectionUpdateFlag = projection.updateFlag;
  129866. this._viewMatrix = view;
  129867. this._projectionMatrix = projection;
  129868. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  129869. // Update frustum
  129870. if (!this._frustumPlanes) {
  129871. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanes(this._transformMatrix);
  129872. }
  129873. else {
  129874. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  129875. }
  129876. if (this.activeCamera && this.activeCamera._alternateCamera) {
  129877. var otherCamera = this.activeCamera._alternateCamera;
  129878. otherCamera.getViewMatrix().multiplyToRef(otherCamera.getProjectionMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Matrix[0]);
  129879. _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
  129880. }
  129881. if (this._sceneUbo.useUbo) {
  129882. this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix);
  129883. this._sceneUbo.updateMatrix("view", this._viewMatrix);
  129884. this._sceneUbo.update();
  129885. }
  129886. };
  129887. /** @hidden */
  129888. Scene.prototype._setAlternateTransformMatrix = function (view, projection) {
  129889. if (this._alternateViewUpdateFlag === view.updateFlag && this._alternateProjectionUpdateFlag === projection.updateFlag) {
  129890. return;
  129891. }
  129892. this._alternateViewUpdateFlag = view.updateFlag;
  129893. this._alternateProjectionUpdateFlag = projection.updateFlag;
  129894. this._alternateViewMatrix = view;
  129895. this._alternateProjectionMatrix = projection;
  129896. if (!this._alternateTransformMatrix) {
  129897. this._alternateTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  129898. }
  129899. this._alternateViewMatrix.multiplyToRef(this._alternateProjectionMatrix, this._alternateTransformMatrix);
  129900. if (!this._alternateSceneUbo) {
  129901. this._createAlternateUbo();
  129902. }
  129903. if (this._alternateSceneUbo.useUbo) {
  129904. this._alternateSceneUbo.updateMatrix("viewProjection", this._alternateTransformMatrix);
  129905. this._alternateSceneUbo.updateMatrix("view", this._alternateViewMatrix);
  129906. this._alternateSceneUbo.update();
  129907. }
  129908. };
  129909. /**
  129910. * Gets the uniform buffer used to store scene data
  129911. * @returns a UniformBuffer
  129912. */
  129913. Scene.prototype.getSceneUniformBuffer = function () {
  129914. return this._useAlternateCameraConfiguration ? this._alternateSceneUbo : this._sceneUbo;
  129915. };
  129916. /**
  129917. * Gets an unique (relatively to the current scene) Id
  129918. * @returns an unique number for the scene
  129919. */
  129920. Scene.prototype.getUniqueId = function () {
  129921. var result = Scene._uniqueIdCounter;
  129922. Scene._uniqueIdCounter++;
  129923. return result;
  129924. };
  129925. /**
  129926. * Add a mesh to the list of scene's meshes
  129927. * @param newMesh defines the mesh to add
  129928. * @param recursive if all child meshes should also be added to the scene
  129929. */
  129930. Scene.prototype.addMesh = function (newMesh, recursive) {
  129931. var _this = this;
  129932. if (recursive === void 0) { recursive = false; }
  129933. this.meshes.push(newMesh);
  129934. newMesh._resyncLightSources();
  129935. this.onNewMeshAddedObservable.notifyObservers(newMesh);
  129936. if (recursive) {
  129937. newMesh.getChildMeshes().forEach(function (m) {
  129938. _this.addMesh(m);
  129939. });
  129940. }
  129941. };
  129942. /**
  129943. * Remove a mesh for the list of scene's meshes
  129944. * @param toRemove defines the mesh to remove
  129945. * @param recursive if all child meshes should also be removed from the scene
  129946. * @returns the index where the mesh was in the mesh list
  129947. */
  129948. Scene.prototype.removeMesh = function (toRemove, recursive) {
  129949. var _this = this;
  129950. if (recursive === void 0) { recursive = false; }
  129951. var index = this.meshes.indexOf(toRemove);
  129952. if (index !== -1) {
  129953. // Remove from the scene if mesh found
  129954. this.meshes[index] = this.meshes[this.meshes.length - 1];
  129955. this.meshes.pop();
  129956. }
  129957. this.onMeshRemovedObservable.notifyObservers(toRemove);
  129958. if (recursive) {
  129959. toRemove.getChildMeshes().forEach(function (m) {
  129960. _this.removeMesh(m);
  129961. });
  129962. }
  129963. return index;
  129964. };
  129965. /**
  129966. * Add a transform node to the list of scene's transform nodes
  129967. * @param newTransformNode defines the transform node to add
  129968. */
  129969. Scene.prototype.addTransformNode = function (newTransformNode) {
  129970. newTransformNode._indexInSceneTransformNodesArray = this.transformNodes.length;
  129971. this.transformNodes.push(newTransformNode);
  129972. this.onNewTransformNodeAddedObservable.notifyObservers(newTransformNode);
  129973. };
  129974. /**
  129975. * Remove a transform node for the list of scene's transform nodes
  129976. * @param toRemove defines the transform node to remove
  129977. * @returns the index where the transform node was in the transform node list
  129978. */
  129979. Scene.prototype.removeTransformNode = function (toRemove) {
  129980. var index = toRemove._indexInSceneTransformNodesArray;
  129981. if (index !== -1) {
  129982. if (index !== this.transformNodes.length - 1) {
  129983. var lastNode = this.transformNodes[this.transformNodes.length - 1];
  129984. this.transformNodes[index] = lastNode;
  129985. lastNode._indexInSceneTransformNodesArray = index;
  129986. }
  129987. toRemove._indexInSceneTransformNodesArray = -1;
  129988. this.transformNodes.pop();
  129989. }
  129990. this.onTransformNodeRemovedObservable.notifyObservers(toRemove);
  129991. return index;
  129992. };
  129993. /**
  129994. * Remove a skeleton for the list of scene's skeletons
  129995. * @param toRemove defines the skeleton to remove
  129996. * @returns the index where the skeleton was in the skeleton list
  129997. */
  129998. Scene.prototype.removeSkeleton = function (toRemove) {
  129999. var index = this.skeletons.indexOf(toRemove);
  130000. if (index !== -1) {
  130001. // Remove from the scene if found
  130002. this.skeletons.splice(index, 1);
  130003. }
  130004. return index;
  130005. };
  130006. /**
  130007. * Remove a morph target for the list of scene's morph targets
  130008. * @param toRemove defines the morph target to remove
  130009. * @returns the index where the morph target was in the morph target list
  130010. */
  130011. Scene.prototype.removeMorphTargetManager = function (toRemove) {
  130012. var index = this.morphTargetManagers.indexOf(toRemove);
  130013. if (index !== -1) {
  130014. // Remove from the scene if found
  130015. this.morphTargetManagers.splice(index, 1);
  130016. }
  130017. return index;
  130018. };
  130019. /**
  130020. * Remove a light for the list of scene's lights
  130021. * @param toRemove defines the light to remove
  130022. * @returns the index where the light was in the light list
  130023. */
  130024. Scene.prototype.removeLight = function (toRemove) {
  130025. var index = this.lights.indexOf(toRemove);
  130026. if (index !== -1) {
  130027. // Remove from meshes
  130028. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  130029. var mesh = _a[_i];
  130030. mesh._removeLightSource(toRemove);
  130031. }
  130032. // Remove from the scene if mesh found
  130033. this.lights.splice(index, 1);
  130034. this.sortLightsByPriority();
  130035. }
  130036. this.onLightRemovedObservable.notifyObservers(toRemove);
  130037. return index;
  130038. };
  130039. /**
  130040. * Remove a camera for the list of scene's cameras
  130041. * @param toRemove defines the camera to remove
  130042. * @returns the index where the camera was in the camera list
  130043. */
  130044. Scene.prototype.removeCamera = function (toRemove) {
  130045. var index = this.cameras.indexOf(toRemove);
  130046. if (index !== -1) {
  130047. // Remove from the scene if mesh found
  130048. this.cameras.splice(index, 1);
  130049. }
  130050. // Remove from activeCameras
  130051. var index2 = this.activeCameras.indexOf(toRemove);
  130052. if (index2 !== -1) {
  130053. // Remove from the scene if mesh found
  130054. this.activeCameras.splice(index2, 1);
  130055. }
  130056. // Reset the activeCamera
  130057. if (this.activeCamera === toRemove) {
  130058. if (this.cameras.length > 0) {
  130059. this.activeCamera = this.cameras[0];
  130060. }
  130061. else {
  130062. this.activeCamera = null;
  130063. }
  130064. }
  130065. this.onCameraRemovedObservable.notifyObservers(toRemove);
  130066. return index;
  130067. };
  130068. /**
  130069. * Remove a particle system for the list of scene's particle systems
  130070. * @param toRemove defines the particle system to remove
  130071. * @returns the index where the particle system was in the particle system list
  130072. */
  130073. Scene.prototype.removeParticleSystem = function (toRemove) {
  130074. var index = this.particleSystems.indexOf(toRemove);
  130075. if (index !== -1) {
  130076. this.particleSystems.splice(index, 1);
  130077. }
  130078. return index;
  130079. };
  130080. /**
  130081. * Remove a animation for the list of scene's animations
  130082. * @param toRemove defines the animation to remove
  130083. * @returns the index where the animation was in the animation list
  130084. */
  130085. Scene.prototype.removeAnimation = function (toRemove) {
  130086. var index = this.animations.indexOf(toRemove);
  130087. if (index !== -1) {
  130088. this.animations.splice(index, 1);
  130089. }
  130090. return index;
  130091. };
  130092. /**
  130093. * Removes the given animation group from this scene.
  130094. * @param toRemove The animation group to remove
  130095. * @returns The index of the removed animation group
  130096. */
  130097. Scene.prototype.removeAnimationGroup = function (toRemove) {
  130098. var index = this.animationGroups.indexOf(toRemove);
  130099. if (index !== -1) {
  130100. this.animationGroups.splice(index, 1);
  130101. }
  130102. return index;
  130103. };
  130104. /**
  130105. * Removes the given multi-material from this scene.
  130106. * @param toRemove The multi-material to remove
  130107. * @returns The index of the removed multi-material
  130108. */
  130109. Scene.prototype.removeMultiMaterial = function (toRemove) {
  130110. var index = this.multiMaterials.indexOf(toRemove);
  130111. if (index !== -1) {
  130112. this.multiMaterials.splice(index, 1);
  130113. }
  130114. return index;
  130115. };
  130116. /**
  130117. * Removes the given material from this scene.
  130118. * @param toRemove The material to remove
  130119. * @returns The index of the removed material
  130120. */
  130121. Scene.prototype.removeMaterial = function (toRemove) {
  130122. var index = toRemove._indexInSceneMaterialArray;
  130123. if (index !== -1 && index < this.materials.length) {
  130124. if (index !== this.materials.length - 1) {
  130125. var lastMaterial = this.materials[this.materials.length - 1];
  130126. this.materials[index] = lastMaterial;
  130127. lastMaterial._indexInSceneMaterialArray = index;
  130128. }
  130129. toRemove._indexInSceneMaterialArray = -1;
  130130. this.materials.pop();
  130131. }
  130132. this.onMaterialRemovedObservable.notifyObservers(toRemove);
  130133. return index;
  130134. };
  130135. /**
  130136. * Removes the given action manager from this scene.
  130137. * @param toRemove The action manager to remove
  130138. * @returns The index of the removed action manager
  130139. */
  130140. Scene.prototype.removeActionManager = function (toRemove) {
  130141. var index = this.actionManagers.indexOf(toRemove);
  130142. if (index !== -1) {
  130143. this.actionManagers.splice(index, 1);
  130144. }
  130145. return index;
  130146. };
  130147. /**
  130148. * Removes the given texture from this scene.
  130149. * @param toRemove The texture to remove
  130150. * @returns The index of the removed texture
  130151. */
  130152. Scene.prototype.removeTexture = function (toRemove) {
  130153. var index = this.textures.indexOf(toRemove);
  130154. if (index !== -1) {
  130155. this.textures.splice(index, 1);
  130156. }
  130157. this.onTextureRemovedObservable.notifyObservers(toRemove);
  130158. return index;
  130159. };
  130160. /**
  130161. * Adds the given light to this scene
  130162. * @param newLight The light to add
  130163. */
  130164. Scene.prototype.addLight = function (newLight) {
  130165. this.lights.push(newLight);
  130166. this.sortLightsByPriority();
  130167. // Add light to all meshes (To support if the light is removed and then readded)
  130168. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  130169. var mesh = _a[_i];
  130170. if (mesh._lightSources.indexOf(newLight) === -1) {
  130171. mesh._lightSources.push(newLight);
  130172. mesh._resyncLightSources();
  130173. }
  130174. }
  130175. this.onNewLightAddedObservable.notifyObservers(newLight);
  130176. };
  130177. /**
  130178. * Sorts the list list based on light priorities
  130179. */
  130180. Scene.prototype.sortLightsByPriority = function () {
  130181. if (this.requireLightSorting) {
  130182. this.lights.sort(_Lights_light__WEBPACK_IMPORTED_MODULE_13__["Light"].CompareLightsPriority);
  130183. }
  130184. };
  130185. /**
  130186. * Adds the given camera to this scene
  130187. * @param newCamera The camera to add
  130188. */
  130189. Scene.prototype.addCamera = function (newCamera) {
  130190. this.cameras.push(newCamera);
  130191. this.onNewCameraAddedObservable.notifyObservers(newCamera);
  130192. };
  130193. /**
  130194. * Adds the given skeleton to this scene
  130195. * @param newSkeleton The skeleton to add
  130196. */
  130197. Scene.prototype.addSkeleton = function (newSkeleton) {
  130198. this.skeletons.push(newSkeleton);
  130199. };
  130200. /**
  130201. * Adds the given particle system to this scene
  130202. * @param newParticleSystem The particle system to add
  130203. */
  130204. Scene.prototype.addParticleSystem = function (newParticleSystem) {
  130205. this.particleSystems.push(newParticleSystem);
  130206. };
  130207. /**
  130208. * Adds the given animation to this scene
  130209. * @param newAnimation The animation to add
  130210. */
  130211. Scene.prototype.addAnimation = function (newAnimation) {
  130212. this.animations.push(newAnimation);
  130213. };
  130214. /**
  130215. * Adds the given animation group to this scene.
  130216. * @param newAnimationGroup The animation group to add
  130217. */
  130218. Scene.prototype.addAnimationGroup = function (newAnimationGroup) {
  130219. this.animationGroups.push(newAnimationGroup);
  130220. };
  130221. /**
  130222. * Adds the given multi-material to this scene
  130223. * @param newMultiMaterial The multi-material to add
  130224. */
  130225. Scene.prototype.addMultiMaterial = function (newMultiMaterial) {
  130226. this.multiMaterials.push(newMultiMaterial);
  130227. };
  130228. /**
  130229. * Adds the given material to this scene
  130230. * @param newMaterial The material to add
  130231. */
  130232. Scene.prototype.addMaterial = function (newMaterial) {
  130233. newMaterial._indexInSceneMaterialArray = this.materials.length;
  130234. this.materials.push(newMaterial);
  130235. this.onNewMaterialAddedObservable.notifyObservers(newMaterial);
  130236. };
  130237. /**
  130238. * Adds the given morph target to this scene
  130239. * @param newMorphTargetManager The morph target to add
  130240. */
  130241. Scene.prototype.addMorphTargetManager = function (newMorphTargetManager) {
  130242. this.morphTargetManagers.push(newMorphTargetManager);
  130243. };
  130244. /**
  130245. * Adds the given geometry to this scene
  130246. * @param newGeometry The geometry to add
  130247. */
  130248. Scene.prototype.addGeometry = function (newGeometry) {
  130249. if (this.geometriesByUniqueId) {
  130250. this.geometriesByUniqueId[newGeometry.uniqueId] = this.geometries.length;
  130251. }
  130252. this.geometries.push(newGeometry);
  130253. };
  130254. /**
  130255. * Adds the given action manager to this scene
  130256. * @param newActionManager The action manager to add
  130257. */
  130258. Scene.prototype.addActionManager = function (newActionManager) {
  130259. this.actionManagers.push(newActionManager);
  130260. };
  130261. /**
  130262. * Adds the given texture to this scene.
  130263. * @param newTexture The texture to add
  130264. */
  130265. Scene.prototype.addTexture = function (newTexture) {
  130266. this.textures.push(newTexture);
  130267. this.onNewTextureAddedObservable.notifyObservers(newTexture);
  130268. };
  130269. /**
  130270. * Switch active camera
  130271. * @param newCamera defines the new active camera
  130272. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  130273. */
  130274. Scene.prototype.switchActiveCamera = function (newCamera, attachControl) {
  130275. if (attachControl === void 0) { attachControl = true; }
  130276. var canvas = this._engine.getRenderingCanvas();
  130277. if (!canvas) {
  130278. return;
  130279. }
  130280. if (this.activeCamera) {
  130281. this.activeCamera.detachControl(canvas);
  130282. }
  130283. this.activeCamera = newCamera;
  130284. if (attachControl) {
  130285. newCamera.attachControl(canvas);
  130286. }
  130287. };
  130288. /**
  130289. * sets the active camera of the scene using its ID
  130290. * @param id defines the camera's ID
  130291. * @return the new active camera or null if none found.
  130292. */
  130293. Scene.prototype.setActiveCameraByID = function (id) {
  130294. var camera = this.getCameraByID(id);
  130295. if (camera) {
  130296. this.activeCamera = camera;
  130297. return camera;
  130298. }
  130299. return null;
  130300. };
  130301. /**
  130302. * sets the active camera of the scene using its name
  130303. * @param name defines the camera's name
  130304. * @returns the new active camera or null if none found.
  130305. */
  130306. Scene.prototype.setActiveCameraByName = function (name) {
  130307. var camera = this.getCameraByName(name);
  130308. if (camera) {
  130309. this.activeCamera = camera;
  130310. return camera;
  130311. }
  130312. return null;
  130313. };
  130314. /**
  130315. * get an animation group using its name
  130316. * @param name defines the material's name
  130317. * @return the animation group or null if none found.
  130318. */
  130319. Scene.prototype.getAnimationGroupByName = function (name) {
  130320. for (var index = 0; index < this.animationGroups.length; index++) {
  130321. if (this.animationGroups[index].name === name) {
  130322. return this.animationGroups[index];
  130323. }
  130324. }
  130325. return null;
  130326. };
  130327. /**
  130328. * get a material using its id
  130329. * @param id defines the material's ID
  130330. * @return the material or null if none found.
  130331. */
  130332. Scene.prototype.getMaterialByID = function (id) {
  130333. for (var index = 0; index < this.materials.length; index++) {
  130334. if (this.materials[index].id === id) {
  130335. return this.materials[index];
  130336. }
  130337. }
  130338. return null;
  130339. };
  130340. /**
  130341. * Gets a material using its name
  130342. * @param name defines the material's name
  130343. * @return the material or null if none found.
  130344. */
  130345. Scene.prototype.getMaterialByName = function (name) {
  130346. for (var index = 0; index < this.materials.length; index++) {
  130347. if (this.materials[index].name === name) {
  130348. return this.materials[index];
  130349. }
  130350. }
  130351. return null;
  130352. };
  130353. /**
  130354. * Gets a camera using its id
  130355. * @param id defines the id to look for
  130356. * @returns the camera or null if not found
  130357. */
  130358. Scene.prototype.getCameraByID = function (id) {
  130359. for (var index = 0; index < this.cameras.length; index++) {
  130360. if (this.cameras[index].id === id) {
  130361. return this.cameras[index];
  130362. }
  130363. }
  130364. return null;
  130365. };
  130366. /**
  130367. * Gets a camera using its unique id
  130368. * @param uniqueId defines the unique id to look for
  130369. * @returns the camera or null if not found
  130370. */
  130371. Scene.prototype.getCameraByUniqueID = function (uniqueId) {
  130372. for (var index = 0; index < this.cameras.length; index++) {
  130373. if (this.cameras[index].uniqueId === uniqueId) {
  130374. return this.cameras[index];
  130375. }
  130376. }
  130377. return null;
  130378. };
  130379. /**
  130380. * Gets a camera using its name
  130381. * @param name defines the camera's name
  130382. * @return the camera or null if none found.
  130383. */
  130384. Scene.prototype.getCameraByName = function (name) {
  130385. for (var index = 0; index < this.cameras.length; index++) {
  130386. if (this.cameras[index].name === name) {
  130387. return this.cameras[index];
  130388. }
  130389. }
  130390. return null;
  130391. };
  130392. /**
  130393. * Gets a bone using its id
  130394. * @param id defines the bone's id
  130395. * @return the bone or null if not found
  130396. */
  130397. Scene.prototype.getBoneByID = function (id) {
  130398. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  130399. var skeleton = this.skeletons[skeletonIndex];
  130400. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  130401. if (skeleton.bones[boneIndex].id === id) {
  130402. return skeleton.bones[boneIndex];
  130403. }
  130404. }
  130405. }
  130406. return null;
  130407. };
  130408. /**
  130409. * Gets a bone using its id
  130410. * @param name defines the bone's name
  130411. * @return the bone or null if not found
  130412. */
  130413. Scene.prototype.getBoneByName = function (name) {
  130414. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  130415. var skeleton = this.skeletons[skeletonIndex];
  130416. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  130417. if (skeleton.bones[boneIndex].name === name) {
  130418. return skeleton.bones[boneIndex];
  130419. }
  130420. }
  130421. }
  130422. return null;
  130423. };
  130424. /**
  130425. * Gets a light node using its name
  130426. * @param name defines the the light's name
  130427. * @return the light or null if none found.
  130428. */
  130429. Scene.prototype.getLightByName = function (name) {
  130430. for (var index = 0; index < this.lights.length; index++) {
  130431. if (this.lights[index].name === name) {
  130432. return this.lights[index];
  130433. }
  130434. }
  130435. return null;
  130436. };
  130437. /**
  130438. * Gets a light node using its id
  130439. * @param id defines the light's id
  130440. * @return the light or null if none found.
  130441. */
  130442. Scene.prototype.getLightByID = function (id) {
  130443. for (var index = 0; index < this.lights.length; index++) {
  130444. if (this.lights[index].id === id) {
  130445. return this.lights[index];
  130446. }
  130447. }
  130448. return null;
  130449. };
  130450. /**
  130451. * Gets a light node using its scene-generated unique ID
  130452. * @param uniqueId defines the light's unique id
  130453. * @return the light or null if none found.
  130454. */
  130455. Scene.prototype.getLightByUniqueID = function (uniqueId) {
  130456. for (var index = 0; index < this.lights.length; index++) {
  130457. if (this.lights[index].uniqueId === uniqueId) {
  130458. return this.lights[index];
  130459. }
  130460. }
  130461. return null;
  130462. };
  130463. /**
  130464. * Gets a particle system by id
  130465. * @param id defines the particle system id
  130466. * @return the corresponding system or null if none found
  130467. */
  130468. Scene.prototype.getParticleSystemByID = function (id) {
  130469. for (var index = 0; index < this.particleSystems.length; index++) {
  130470. if (this.particleSystems[index].id === id) {
  130471. return this.particleSystems[index];
  130472. }
  130473. }
  130474. return null;
  130475. };
  130476. /**
  130477. * Gets a geometry using its ID
  130478. * @param id defines the geometry's id
  130479. * @return the geometry or null if none found.
  130480. */
  130481. Scene.prototype.getGeometryByID = function (id) {
  130482. for (var index = 0; index < this.geometries.length; index++) {
  130483. if (this.geometries[index].id === id) {
  130484. return this.geometries[index];
  130485. }
  130486. }
  130487. return null;
  130488. };
  130489. Scene.prototype._getGeometryByUniqueID = function (uniqueId) {
  130490. if (this.geometriesByUniqueId) {
  130491. var index_1 = this.geometriesByUniqueId[uniqueId];
  130492. if (index_1 !== undefined) {
  130493. return this.geometries[index_1];
  130494. }
  130495. }
  130496. else {
  130497. for (var index = 0; index < this.geometries.length; index++) {
  130498. if (this.geometries[index].uniqueId === uniqueId) {
  130499. return this.geometries[index];
  130500. }
  130501. }
  130502. }
  130503. return null;
  130504. };
  130505. /**
  130506. * Add a new geometry to this scene
  130507. * @param geometry defines the geometry to be added to the scene.
  130508. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  130509. * @return a boolean defining if the geometry was added or not
  130510. */
  130511. Scene.prototype.pushGeometry = function (geometry, force) {
  130512. if (!force && this._getGeometryByUniqueID(geometry.uniqueId)) {
  130513. return false;
  130514. }
  130515. this.addGeometry(geometry);
  130516. this.onNewGeometryAddedObservable.notifyObservers(geometry);
  130517. return true;
  130518. };
  130519. /**
  130520. * Removes an existing geometry
  130521. * @param geometry defines the geometry to be removed from the scene
  130522. * @return a boolean defining if the geometry was removed or not
  130523. */
  130524. Scene.prototype.removeGeometry = function (geometry) {
  130525. var index;
  130526. if (this.geometriesByUniqueId) {
  130527. index = this.geometriesByUniqueId[geometry.uniqueId];
  130528. if (index === undefined) {
  130529. return false;
  130530. }
  130531. }
  130532. else {
  130533. index = this.geometries.indexOf(geometry);
  130534. if (index < 0) {
  130535. return false;
  130536. }
  130537. }
  130538. if (index !== this.geometries.length - 1) {
  130539. var lastGeometry = this.geometries[this.geometries.length - 1];
  130540. this.geometries[index] = lastGeometry;
  130541. if (this.geometriesByUniqueId) {
  130542. this.geometriesByUniqueId[lastGeometry.uniqueId] = index;
  130543. this.geometriesByUniqueId[geometry.uniqueId] = undefined;
  130544. }
  130545. }
  130546. this.geometries.pop();
  130547. this.onGeometryRemovedObservable.notifyObservers(geometry);
  130548. return true;
  130549. };
  130550. /**
  130551. * Gets the list of geometries attached to the scene
  130552. * @returns an array of Geometry
  130553. */
  130554. Scene.prototype.getGeometries = function () {
  130555. return this.geometries;
  130556. };
  130557. /**
  130558. * Gets the first added mesh found of a given ID
  130559. * @param id defines the id to search for
  130560. * @return the mesh found or null if not found at all
  130561. */
  130562. Scene.prototype.getMeshByID = function (id) {
  130563. for (var index = 0; index < this.meshes.length; index++) {
  130564. if (this.meshes[index].id === id) {
  130565. return this.meshes[index];
  130566. }
  130567. }
  130568. return null;
  130569. };
  130570. /**
  130571. * Gets a list of meshes using their id
  130572. * @param id defines the id to search for
  130573. * @returns a list of meshes
  130574. */
  130575. Scene.prototype.getMeshesByID = function (id) {
  130576. return this.meshes.filter(function (m) {
  130577. return m.id === id;
  130578. });
  130579. };
  130580. /**
  130581. * Gets the first added transform node found of a given ID
  130582. * @param id defines the id to search for
  130583. * @return the found transform node or null if not found at all.
  130584. */
  130585. Scene.prototype.getTransformNodeByID = function (id) {
  130586. for (var index = 0; index < this.transformNodes.length; index++) {
  130587. if (this.transformNodes[index].id === id) {
  130588. return this.transformNodes[index];
  130589. }
  130590. }
  130591. return null;
  130592. };
  130593. /**
  130594. * Gets a list of transform nodes using their id
  130595. * @param id defines the id to search for
  130596. * @returns a list of transform nodes
  130597. */
  130598. Scene.prototype.getTransformNodesByID = function (id) {
  130599. return this.transformNodes.filter(function (m) {
  130600. return m.id === id;
  130601. });
  130602. };
  130603. /**
  130604. * Gets a mesh with its auto-generated unique id
  130605. * @param uniqueId defines the unique id to search for
  130606. * @return the found mesh or null if not found at all.
  130607. */
  130608. Scene.prototype.getMeshByUniqueID = function (uniqueId) {
  130609. for (var index = 0; index < this.meshes.length; index++) {
  130610. if (this.meshes[index].uniqueId === uniqueId) {
  130611. return this.meshes[index];
  130612. }
  130613. }
  130614. return null;
  130615. };
  130616. /**
  130617. * Gets a the last added mesh using a given id
  130618. * @param id defines the id to search for
  130619. * @return the found mesh or null if not found at all.
  130620. */
  130621. Scene.prototype.getLastMeshByID = function (id) {
  130622. for (var index = this.meshes.length - 1; index >= 0; index--) {
  130623. if (this.meshes[index].id === id) {
  130624. return this.meshes[index];
  130625. }
  130626. }
  130627. return null;
  130628. };
  130629. /**
  130630. * Gets a the last added node (Mesh, Camera, Light) using a given id
  130631. * @param id defines the id to search for
  130632. * @return the found node or null if not found at all
  130633. */
  130634. Scene.prototype.getLastEntryByID = function (id) {
  130635. var index;
  130636. for (index = this.meshes.length - 1; index >= 0; index--) {
  130637. if (this.meshes[index].id === id) {
  130638. return this.meshes[index];
  130639. }
  130640. }
  130641. for (index = this.transformNodes.length - 1; index >= 0; index--) {
  130642. if (this.transformNodes[index].id === id) {
  130643. return this.transformNodes[index];
  130644. }
  130645. }
  130646. for (index = this.cameras.length - 1; index >= 0; index--) {
  130647. if (this.cameras[index].id === id) {
  130648. return this.cameras[index];
  130649. }
  130650. }
  130651. for (index = this.lights.length - 1; index >= 0; index--) {
  130652. if (this.lights[index].id === id) {
  130653. return this.lights[index];
  130654. }
  130655. }
  130656. return null;
  130657. };
  130658. /**
  130659. * Gets a node (Mesh, Camera, Light) using a given id
  130660. * @param id defines the id to search for
  130661. * @return the found node or null if not found at all
  130662. */
  130663. Scene.prototype.getNodeByID = function (id) {
  130664. var mesh = this.getMeshByID(id);
  130665. if (mesh) {
  130666. return mesh;
  130667. }
  130668. var transformNode = this.getTransformNodeByID(id);
  130669. if (transformNode) {
  130670. return transformNode;
  130671. }
  130672. var light = this.getLightByID(id);
  130673. if (light) {
  130674. return light;
  130675. }
  130676. var camera = this.getCameraByID(id);
  130677. if (camera) {
  130678. return camera;
  130679. }
  130680. var bone = this.getBoneByID(id);
  130681. if (bone) {
  130682. return bone;
  130683. }
  130684. return null;
  130685. };
  130686. /**
  130687. * Gets a node (Mesh, Camera, Light) using a given name
  130688. * @param name defines the name to search for
  130689. * @return the found node or null if not found at all.
  130690. */
  130691. Scene.prototype.getNodeByName = function (name) {
  130692. var mesh = this.getMeshByName(name);
  130693. if (mesh) {
  130694. return mesh;
  130695. }
  130696. var transformNode = this.getTransformNodeByName(name);
  130697. if (transformNode) {
  130698. return transformNode;
  130699. }
  130700. var light = this.getLightByName(name);
  130701. if (light) {
  130702. return light;
  130703. }
  130704. var camera = this.getCameraByName(name);
  130705. if (camera) {
  130706. return camera;
  130707. }
  130708. var bone = this.getBoneByName(name);
  130709. if (bone) {
  130710. return bone;
  130711. }
  130712. return null;
  130713. };
  130714. /**
  130715. * Gets a mesh using a given name
  130716. * @param name defines the name to search for
  130717. * @return the found mesh or null if not found at all.
  130718. */
  130719. Scene.prototype.getMeshByName = function (name) {
  130720. for (var index = 0; index < this.meshes.length; index++) {
  130721. if (this.meshes[index].name === name) {
  130722. return this.meshes[index];
  130723. }
  130724. }
  130725. return null;
  130726. };
  130727. /**
  130728. * Gets a transform node using a given name
  130729. * @param name defines the name to search for
  130730. * @return the found transform node or null if not found at all.
  130731. */
  130732. Scene.prototype.getTransformNodeByName = function (name) {
  130733. for (var index = 0; index < this.transformNodes.length; index++) {
  130734. if (this.transformNodes[index].name === name) {
  130735. return this.transformNodes[index];
  130736. }
  130737. }
  130738. return null;
  130739. };
  130740. /**
  130741. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  130742. * @param id defines the id to search for
  130743. * @return the found skeleton or null if not found at all.
  130744. */
  130745. Scene.prototype.getLastSkeletonByID = function (id) {
  130746. for (var index = this.skeletons.length - 1; index >= 0; index--) {
  130747. if (this.skeletons[index].id === id) {
  130748. return this.skeletons[index];
  130749. }
  130750. }
  130751. return null;
  130752. };
  130753. /**
  130754. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  130755. * @param id defines the id to search for
  130756. * @return the found skeleton or null if not found at all.
  130757. */
  130758. Scene.prototype.getSkeletonById = function (id) {
  130759. for (var index = 0; index < this.skeletons.length; index++) {
  130760. if (this.skeletons[index].id === id) {
  130761. return this.skeletons[index];
  130762. }
  130763. }
  130764. return null;
  130765. };
  130766. /**
  130767. * Gets a skeleton using a given name
  130768. * @param name defines the name to search for
  130769. * @return the found skeleton or null if not found at all.
  130770. */
  130771. Scene.prototype.getSkeletonByName = function (name) {
  130772. for (var index = 0; index < this.skeletons.length; index++) {
  130773. if (this.skeletons[index].name === name) {
  130774. return this.skeletons[index];
  130775. }
  130776. }
  130777. return null;
  130778. };
  130779. /**
  130780. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  130781. * @param id defines the id to search for
  130782. * @return the found morph target manager or null if not found at all.
  130783. */
  130784. Scene.prototype.getMorphTargetManagerById = function (id) {
  130785. for (var index = 0; index < this.morphTargetManagers.length; index++) {
  130786. if (this.morphTargetManagers[index].uniqueId === id) {
  130787. return this.morphTargetManagers[index];
  130788. }
  130789. }
  130790. return null;
  130791. };
  130792. /**
  130793. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  130794. * @param id defines the id to search for
  130795. * @return the found morph target or null if not found at all.
  130796. */
  130797. Scene.prototype.getMorphTargetById = function (id) {
  130798. for (var managerIndex = 0; managerIndex < this.morphTargetManagers.length; ++managerIndex) {
  130799. var morphTargetManager = this.morphTargetManagers[managerIndex];
  130800. for (var index = 0; index < morphTargetManager.numTargets; ++index) {
  130801. var target = morphTargetManager.getTarget(index);
  130802. if (target.id === id) {
  130803. return target;
  130804. }
  130805. }
  130806. }
  130807. return null;
  130808. };
  130809. /**
  130810. * Gets a boolean indicating if the given mesh is active
  130811. * @param mesh defines the mesh to look for
  130812. * @returns true if the mesh is in the active list
  130813. */
  130814. Scene.prototype.isActiveMesh = function (mesh) {
  130815. return (this._activeMeshes.indexOf(mesh) !== -1);
  130816. };
  130817. Object.defineProperty(Scene.prototype, "uid", {
  130818. /**
  130819. * Return a unique id as a string which can serve as an identifier for the scene
  130820. */
  130821. get: function () {
  130822. if (!this._uid) {
  130823. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].RandomId();
  130824. }
  130825. return this._uid;
  130826. },
  130827. enumerable: true,
  130828. configurable: true
  130829. });
  130830. /**
  130831. * Add an externaly attached data from its key.
  130832. * This method call will fail and return false, if such key already exists.
  130833. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  130834. * @param key the unique key that identifies the data
  130835. * @param data the data object to associate to the key for this Engine instance
  130836. * @return true if no such key were already present and the data was added successfully, false otherwise
  130837. */
  130838. Scene.prototype.addExternalData = function (key, data) {
  130839. if (!this._externalData) {
  130840. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  130841. }
  130842. return this._externalData.add(key, data);
  130843. };
  130844. /**
  130845. * Get an externaly attached data from its key
  130846. * @param key the unique key that identifies the data
  130847. * @return the associated data, if present (can be null), or undefined if not present
  130848. */
  130849. Scene.prototype.getExternalData = function (key) {
  130850. if (!this._externalData) {
  130851. return null;
  130852. }
  130853. return this._externalData.get(key);
  130854. };
  130855. /**
  130856. * Get an externaly attached data from its key, create it using a factory if it's not already present
  130857. * @param key the unique key that identifies the data
  130858. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  130859. * @return the associated data, can be null if the factory returned null.
  130860. */
  130861. Scene.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  130862. if (!this._externalData) {
  130863. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  130864. }
  130865. return this._externalData.getOrAddWithFactory(key, factory);
  130866. };
  130867. /**
  130868. * Remove an externaly attached data from the Engine instance
  130869. * @param key the unique key that identifies the data
  130870. * @return true if the data was successfully removed, false if it doesn't exist
  130871. */
  130872. Scene.prototype.removeExternalData = function (key) {
  130873. return this._externalData.remove(key);
  130874. };
  130875. Scene.prototype._evaluateSubMesh = function (subMesh, mesh) {
  130876. if (this.dispatchAllSubMeshesOfActiveMeshes || mesh.alwaysSelectAsActiveMesh || mesh.subMeshes.length === 1 || subMesh.isInFrustum(this._frustumPlanes)) {
  130877. for (var _i = 0, _a = this._evaluateSubMeshStage; _i < _a.length; _i++) {
  130878. var step = _a[_i];
  130879. step.action(mesh, subMesh);
  130880. }
  130881. var material = subMesh.getMaterial();
  130882. if (material !== null && material !== undefined) {
  130883. // Render targets
  130884. if (material.hasRenderTargetTextures && material.getRenderTargetTextures !== undefined) {
  130885. if (this._processedMaterials.indexOf(material) === -1) {
  130886. this._processedMaterials.push(material);
  130887. this._renderTargets.concatWithNoDuplicate(material.getRenderTargetTextures());
  130888. }
  130889. }
  130890. // Dispatch
  130891. this._activeIndices.addCount(subMesh.indexCount, false);
  130892. this._renderingManager.dispatch(subMesh, mesh, material);
  130893. }
  130894. }
  130895. };
  130896. /**
  130897. * Clear the processed materials smart array preventing retention point in material dispose.
  130898. */
  130899. Scene.prototype.freeProcessedMaterials = function () {
  130900. this._processedMaterials.dispose();
  130901. };
  130902. Object.defineProperty(Scene.prototype, "blockfreeActiveMeshesAndRenderingGroups", {
  130903. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  130904. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  130905. * when disposing several meshes in a row or a hierarchy of meshes.
  130906. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  130907. */
  130908. get: function () {
  130909. return this._preventFreeActiveMeshesAndRenderingGroups;
  130910. },
  130911. set: function (value) {
  130912. if (this._preventFreeActiveMeshesAndRenderingGroups === value) {
  130913. return;
  130914. }
  130915. if (value) {
  130916. this.freeActiveMeshes();
  130917. this.freeRenderingGroups();
  130918. }
  130919. this._preventFreeActiveMeshesAndRenderingGroups = value;
  130920. },
  130921. enumerable: true,
  130922. configurable: true
  130923. });
  130924. /**
  130925. * Clear the active meshes smart array preventing retention point in mesh dispose.
  130926. */
  130927. Scene.prototype.freeActiveMeshes = function () {
  130928. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  130929. return;
  130930. }
  130931. this._activeMeshes.dispose();
  130932. if (this.activeCamera && this.activeCamera._activeMeshes) {
  130933. this.activeCamera._activeMeshes.dispose();
  130934. }
  130935. if (this.activeCameras) {
  130936. for (var i = 0; i < this.activeCameras.length; i++) {
  130937. var activeCamera = this.activeCameras[i];
  130938. if (activeCamera && activeCamera._activeMeshes) {
  130939. activeCamera._activeMeshes.dispose();
  130940. }
  130941. }
  130942. }
  130943. };
  130944. /**
  130945. * Clear the info related to rendering groups preventing retention points during dispose.
  130946. */
  130947. Scene.prototype.freeRenderingGroups = function () {
  130948. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  130949. return;
  130950. }
  130951. if (this._renderingManager) {
  130952. this._renderingManager.freeRenderingGroups();
  130953. }
  130954. if (this.textures) {
  130955. for (var i = 0; i < this.textures.length; i++) {
  130956. var texture = this.textures[i];
  130957. if (texture && texture.renderList) {
  130958. texture.freeRenderingGroups();
  130959. }
  130960. }
  130961. }
  130962. };
  130963. /** @hidden */
  130964. Scene.prototype._isInIntermediateRendering = function () {
  130965. return this._intermediateRendering;
  130966. };
  130967. /**
  130968. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  130969. * @returns the current scene
  130970. */
  130971. Scene.prototype.freezeActiveMeshes = function () {
  130972. if (!this.activeCamera) {
  130973. return this;
  130974. }
  130975. if (!this._frustumPlanes) {
  130976. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  130977. }
  130978. this._evaluateActiveMeshes();
  130979. this._activeMeshesFrozen = true;
  130980. return this;
  130981. };
  130982. /**
  130983. * Use this function to restart evaluating active meshes on every frame
  130984. * @returns the current scene
  130985. */
  130986. Scene.prototype.unfreezeActiveMeshes = function () {
  130987. this._activeMeshesFrozen = false;
  130988. return this;
  130989. };
  130990. Scene.prototype._evaluateActiveMeshes = function () {
  130991. if (this._activeMeshesFrozen && this._activeMeshes.length) {
  130992. return;
  130993. }
  130994. if (!this.activeCamera) {
  130995. return;
  130996. }
  130997. this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this);
  130998. this.activeCamera._activeMeshes.reset();
  130999. this._activeMeshes.reset();
  131000. this._renderingManager.reset();
  131001. this._processedMaterials.reset();
  131002. this._activeParticleSystems.reset();
  131003. this._activeSkeletons.reset();
  131004. this._softwareSkinnedMeshes.reset();
  131005. for (var _i = 0, _a = this._beforeEvaluateActiveMeshStage; _i < _a.length; _i++) {
  131006. var step = _a[_i];
  131007. step.action();
  131008. }
  131009. // Determine mesh candidates
  131010. var meshes = this.getActiveMeshCandidates();
  131011. // Check each mesh
  131012. var len = meshes.length;
  131013. for (var i = 0; i < len; i++) {
  131014. var mesh = meshes.data[i];
  131015. if (mesh.isBlocked) {
  131016. continue;
  131017. }
  131018. this._totalVertices.addCount(mesh.getTotalVertices(), false);
  131019. if (!mesh.isReady() || !mesh.isEnabled()) {
  131020. continue;
  131021. }
  131022. mesh.computeWorldMatrix();
  131023. // Intersections
  131024. if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers2(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger, _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger)) {
  131025. this._meshesForIntersections.pushNoDuplicate(mesh);
  131026. }
  131027. // Switch to current LOD
  131028. var meshLOD = mesh.getLOD(this.activeCamera);
  131029. if (meshLOD === undefined || meshLOD === null) {
  131030. continue;
  131031. }
  131032. mesh._preActivate();
  131033. if (mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && (mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(this._frustumPlanes))) {
  131034. this._activeMeshes.push(mesh);
  131035. this.activeCamera._activeMeshes.push(mesh);
  131036. mesh._activate(this._renderId);
  131037. if (meshLOD !== mesh) {
  131038. meshLOD._activate(this._renderId);
  131039. }
  131040. this._activeMesh(mesh, meshLOD);
  131041. }
  131042. }
  131043. this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this);
  131044. // Particle systems
  131045. if (this.particlesEnabled) {
  131046. this.onBeforeParticlesRenderingObservable.notifyObservers(this);
  131047. for (var particleIndex = 0; particleIndex < this.particleSystems.length; particleIndex++) {
  131048. var particleSystem = this.particleSystems[particleIndex];
  131049. if (!particleSystem.isStarted() || !particleSystem.emitter) {
  131050. continue;
  131051. }
  131052. var emitter = particleSystem.emitter;
  131053. if (!emitter.position || emitter.isEnabled()) {
  131054. this._activeParticleSystems.push(particleSystem);
  131055. particleSystem.animate();
  131056. this._renderingManager.dispatchParticles(particleSystem);
  131057. }
  131058. }
  131059. this.onAfterParticlesRenderingObservable.notifyObservers(this);
  131060. }
  131061. };
  131062. Scene.prototype._activeMesh = function (sourceMesh, mesh) {
  131063. if (this._skeletonsEnabled && mesh.skeleton !== null && mesh.skeleton !== undefined) {
  131064. if (this._activeSkeletons.pushNoDuplicate(mesh.skeleton)) {
  131065. mesh.skeleton.prepare();
  131066. }
  131067. if (!mesh.computeBonesUsingShaders) {
  131068. this._softwareSkinnedMeshes.pushNoDuplicate(mesh);
  131069. }
  131070. }
  131071. for (var _i = 0, _a = this._activeMeshStage; _i < _a.length; _i++) {
  131072. var step = _a[_i];
  131073. step.action(sourceMesh, mesh);
  131074. }
  131075. if (mesh !== undefined && mesh !== null
  131076. && mesh.subMeshes !== undefined && mesh.subMeshes !== null && mesh.subMeshes.length > 0) {
  131077. var subMeshes = this.getActiveSubMeshCandidates(mesh);
  131078. var len = subMeshes.length;
  131079. for (var i = 0; i < len; i++) {
  131080. var subMesh = subMeshes.data[i];
  131081. this._evaluateSubMesh(subMesh, mesh);
  131082. }
  131083. }
  131084. };
  131085. /**
  131086. * Update the transform matrix to update from the current active camera
  131087. * @param force defines a boolean used to force the update even if cache is up to date
  131088. */
  131089. Scene.prototype.updateTransformMatrix = function (force) {
  131090. if (!this.activeCamera) {
  131091. return;
  131092. }
  131093. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(force));
  131094. };
  131095. /**
  131096. * 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)
  131097. * @param alternateCamera defines the camera to use
  131098. */
  131099. Scene.prototype.updateAlternateTransformMatrix = function (alternateCamera) {
  131100. this._setAlternateTransformMatrix(alternateCamera.getViewMatrix(), alternateCamera.getProjectionMatrix());
  131101. };
  131102. Scene.prototype._renderForCamera = function (camera, rigParent) {
  131103. if (camera && camera._skipRendering) {
  131104. return;
  131105. }
  131106. var engine = this._engine;
  131107. this.activeCamera = camera;
  131108. if (!this.activeCamera) {
  131109. throw new Error("Active camera not set");
  131110. }
  131111. // Viewport
  131112. engine.setViewport(this.activeCamera.viewport);
  131113. // Camera
  131114. this.resetCachedMaterial();
  131115. this._renderId++;
  131116. this.updateTransformMatrix();
  131117. if (camera._alternateCamera) {
  131118. this.updateAlternateTransformMatrix(camera._alternateCamera);
  131119. this._alternateRendering = true;
  131120. }
  131121. this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera);
  131122. // Meshes
  131123. this._evaluateActiveMeshes();
  131124. // Software skinning
  131125. for (var softwareSkinnedMeshIndex = 0; softwareSkinnedMeshIndex < this._softwareSkinnedMeshes.length; softwareSkinnedMeshIndex++) {
  131126. var mesh = this._softwareSkinnedMeshes.data[softwareSkinnedMeshIndex];
  131127. mesh.applySkeleton(mesh.skeleton);
  131128. }
  131129. // Render targets
  131130. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  131131. if (camera.customRenderTargets && camera.customRenderTargets.length > 0) {
  131132. this._renderTargets.concatWithNoDuplicate(camera.customRenderTargets);
  131133. }
  131134. if (rigParent && rigParent.customRenderTargets && rigParent.customRenderTargets.length > 0) {
  131135. this._renderTargets.concatWithNoDuplicate(rigParent.customRenderTargets);
  131136. }
  131137. // Collects render targets from external components.
  131138. for (var _i = 0, _a = this._gatherActiveCameraRenderTargetsStage; _i < _a.length; _i++) {
  131139. var step = _a[_i];
  131140. step.action(this._renderTargets);
  131141. }
  131142. if (this.renderTargetsEnabled) {
  131143. this._intermediateRendering = true;
  131144. if (this._renderTargets.length > 0) {
  131145. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
  131146. for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
  131147. var renderTarget = this._renderTargets.data[renderIndex];
  131148. if (renderTarget._shouldRender()) {
  131149. this._renderId++;
  131150. var hasSpecialRenderTargetCamera = renderTarget.activeCamera && renderTarget.activeCamera !== this.activeCamera;
  131151. renderTarget.render(hasSpecialRenderTargetCamera, this.dumpNextRenderTargets);
  131152. }
  131153. }
  131154. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Render targets", this._renderTargets.length > 0);
  131155. this._renderId++;
  131156. }
  131157. for (var _b = 0, _c = this._cameraDrawRenderTargetStage; _b < _c.length; _b++) {
  131158. var step = _c[_b];
  131159. step.action(this.activeCamera);
  131160. }
  131161. this._intermediateRendering = false;
  131162. if (this.activeCamera.outputRenderTarget) {
  131163. var internalTexture = this.activeCamera.outputRenderTarget.getInternalTexture();
  131164. if (internalTexture) {
  131165. engine.bindFramebuffer(internalTexture);
  131166. }
  131167. else {
  131168. _Misc_logger__WEBPACK_IMPORTED_MODULE_23__["Logger"].Error("Camera contains invalid customDefaultRenderTarget");
  131169. }
  131170. }
  131171. else {
  131172. engine.restoreDefaultFramebuffer(); // Restore back buffer if needed
  131173. }
  131174. }
  131175. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  131176. // Prepare Frame
  131177. if (this.postProcessManager) {
  131178. this.postProcessManager._prepareFrame();
  131179. }
  131180. // Before Camera Draw
  131181. for (var _d = 0, _e = this._beforeCameraDrawStage; _d < _e.length; _d++) {
  131182. var step = _e[_d];
  131183. step.action(this.activeCamera);
  131184. }
  131185. // Render
  131186. this.onBeforeDrawPhaseObservable.notifyObservers(this);
  131187. this._renderingManager.render(null, null, true, true);
  131188. this.onAfterDrawPhaseObservable.notifyObservers(this);
  131189. // After Camera Draw
  131190. for (var _f = 0, _g = this._afterCameraDrawStage; _f < _g.length; _f++) {
  131191. var step = _g[_f];
  131192. step.action(this.activeCamera);
  131193. }
  131194. // Finalize frame
  131195. if (this.postProcessManager) {
  131196. this.postProcessManager._finalizeFrame(camera.isIntermediate);
  131197. }
  131198. // Reset some special arrays
  131199. this._renderTargets.reset();
  131200. this._alternateRendering = false;
  131201. this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera);
  131202. };
  131203. Scene.prototype._processSubCameras = function (camera) {
  131204. if (camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  131205. this._renderForCamera(camera);
  131206. return;
  131207. }
  131208. // rig cameras
  131209. for (var index = 0; index < camera._rigCameras.length; index++) {
  131210. this._renderForCamera(camera._rigCameras[index], camera);
  131211. }
  131212. this.activeCamera = camera;
  131213. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  131214. };
  131215. Scene.prototype._checkIntersections = function () {
  131216. for (var index = 0; index < this._meshesForIntersections.length; index++) {
  131217. var sourceMesh = this._meshesForIntersections.data[index];
  131218. if (!sourceMesh.actionManager) {
  131219. continue;
  131220. }
  131221. for (var actionIndex = 0; actionIndex < sourceMesh.actionManager.actions.length; actionIndex++) {
  131222. var action = sourceMesh.actionManager.actions[actionIndex];
  131223. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  131224. var parameters = action.getTriggerParameter();
  131225. var otherMesh = parameters instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameters : parameters.mesh;
  131226. var areIntersecting = otherMesh.intersectsMesh(sourceMesh, parameters.usePreciseIntersection);
  131227. var currentIntersectionInProgress = sourceMesh._intersectionsInProgress.indexOf(otherMesh);
  131228. if (areIntersecting && currentIntersectionInProgress === -1) {
  131229. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger) {
  131230. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  131231. sourceMesh._intersectionsInProgress.push(otherMesh);
  131232. }
  131233. else if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  131234. sourceMesh._intersectionsInProgress.push(otherMesh);
  131235. }
  131236. }
  131237. else if (!areIntersecting && currentIntersectionInProgress > -1) {
  131238. //They intersected, and now they don't.
  131239. //is this trigger an exit trigger? execute an event.
  131240. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  131241. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  131242. }
  131243. //if this is an exit trigger, or no exit trigger exists, remove the id from the intersection in progress array.
  131244. if (!sourceMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger, function (parameter) {
  131245. var parameterMesh = parameter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameter : parameter.mesh;
  131246. return otherMesh === parameterMesh;
  131247. }) || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  131248. sourceMesh._intersectionsInProgress.splice(currentIntersectionInProgress, 1);
  131249. }
  131250. }
  131251. }
  131252. }
  131253. }
  131254. };
  131255. /** @hidden */
  131256. Scene.prototype._advancePhysicsEngineStep = function (step) {
  131257. // Do nothing. Code will be replaced if physics engine component is referenced
  131258. };
  131259. /** @hidden */
  131260. Scene.prototype._animate = function () {
  131261. // Nothing to do as long as Animatable have not been imported.
  131262. };
  131263. /**
  131264. * Render the scene
  131265. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  131266. */
  131267. Scene.prototype.render = function (updateCameras) {
  131268. if (updateCameras === void 0) { updateCameras = true; }
  131269. if (this.isDisposed) {
  131270. return;
  131271. }
  131272. this._frameId++;
  131273. // Register components that have been associated lately to the scene.
  131274. this._registerTransientComponents();
  131275. this._activeParticles.fetchNewFrame();
  131276. this._totalVertices.fetchNewFrame();
  131277. this._activeIndices.fetchNewFrame();
  131278. this._activeBones.fetchNewFrame();
  131279. this._meshesForIntersections.reset();
  131280. this.resetCachedMaterial();
  131281. this.onBeforeAnimationsObservable.notifyObservers(this);
  131282. // Actions
  131283. if (this.actionManager) {
  131284. this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnEveryFrameTrigger);
  131285. }
  131286. if (this._engine.isDeterministicLockStep()) {
  131287. var deltaTime = Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime)) + this._timeAccumulator;
  131288. var defaultFPS = (60.0 / 1000.0);
  131289. var defaultFrameTime = this.getDeterministicFrameTime();
  131290. var stepsTaken = 0;
  131291. var maxSubSteps = this._engine.getLockstepMaxSteps();
  131292. var internalSteps = Math.floor(deltaTime / (1000 * defaultFPS));
  131293. internalSteps = Math.min(internalSteps, maxSubSteps);
  131294. do {
  131295. this.onBeforeStepObservable.notifyObservers(this);
  131296. // Animations
  131297. this._animationRatio = defaultFrameTime * defaultFPS;
  131298. this._animate();
  131299. this.onAfterAnimationsObservable.notifyObservers(this);
  131300. // Physics
  131301. this._advancePhysicsEngineStep(defaultFrameTime);
  131302. this.onAfterStepObservable.notifyObservers(this);
  131303. this._currentStepId++;
  131304. stepsTaken++;
  131305. deltaTime -= defaultFrameTime;
  131306. } while (deltaTime > 0 && stepsTaken < internalSteps);
  131307. this._timeAccumulator = deltaTime < 0 ? 0 : deltaTime;
  131308. }
  131309. else {
  131310. // Animations
  131311. var deltaTime = this.useConstantAnimationDeltaTime ? 16 : Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime));
  131312. this._animationRatio = deltaTime * (60.0 / 1000.0);
  131313. this._animate();
  131314. this.onAfterAnimationsObservable.notifyObservers(this);
  131315. // Physics
  131316. this._advancePhysicsEngineStep(deltaTime);
  131317. }
  131318. // Before camera update steps
  131319. for (var _i = 0, _a = this._beforeCameraUpdateStage; _i < _a.length; _i++) {
  131320. var step = _a[_i];
  131321. step.action();
  131322. }
  131323. // Update Cameras
  131324. if (updateCameras) {
  131325. if (this.activeCameras.length > 0) {
  131326. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  131327. var camera = this.activeCameras[cameraIndex];
  131328. camera.update();
  131329. if (camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  131330. // rig cameras
  131331. for (var index = 0; index < camera._rigCameras.length; index++) {
  131332. camera._rigCameras[index].update();
  131333. }
  131334. }
  131335. }
  131336. }
  131337. else if (this.activeCamera) {
  131338. this.activeCamera.update();
  131339. if (this.activeCamera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  131340. // rig cameras
  131341. for (var index = 0; index < this.activeCamera._rigCameras.length; index++) {
  131342. this.activeCamera._rigCameras[index].update();
  131343. }
  131344. }
  131345. }
  131346. }
  131347. // Before render
  131348. this.onBeforeRenderObservable.notifyObservers(this);
  131349. // Customs render targets
  131350. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  131351. var engine = this.getEngine();
  131352. var currentActiveCamera = this.activeCamera;
  131353. if (this.renderTargetsEnabled) {
  131354. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  131355. this._intermediateRendering = true;
  131356. for (var customIndex = 0; customIndex < this.customRenderTargets.length; customIndex++) {
  131357. var renderTarget = this.customRenderTargets[customIndex];
  131358. if (renderTarget._shouldRender()) {
  131359. this._renderId++;
  131360. this.activeCamera = renderTarget.activeCamera || this.activeCamera;
  131361. if (!this.activeCamera) {
  131362. throw new Error("Active camera not set");
  131363. }
  131364. // Viewport
  131365. engine.setViewport(this.activeCamera.viewport);
  131366. // Camera
  131367. this.updateTransformMatrix();
  131368. renderTarget.render(currentActiveCamera !== this.activeCamera, this.dumpNextRenderTargets);
  131369. }
  131370. }
  131371. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  131372. this._intermediateRendering = false;
  131373. this._renderId++;
  131374. }
  131375. // Restore back buffer
  131376. if (this.customRenderTargets.length > 0) {
  131377. engine.restoreDefaultFramebuffer();
  131378. }
  131379. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  131380. this.activeCamera = currentActiveCamera;
  131381. for (var _b = 0, _c = this._beforeClearStage; _b < _c.length; _b++) {
  131382. var step = _c[_b];
  131383. step.action();
  131384. }
  131385. // Clear
  131386. if (this.autoClearDepthAndStencil || this.autoClear) {
  131387. this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil);
  131388. }
  131389. // Collects render targets from external components.
  131390. for (var _d = 0, _e = this._gatherRenderTargetsStage; _d < _e.length; _d++) {
  131391. var step = _e[_d];
  131392. step.action(this._renderTargets);
  131393. }
  131394. // Multi-cameras?
  131395. if (this.activeCameras.length > 0) {
  131396. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  131397. if (cameraIndex > 0) {
  131398. this._engine.clear(null, false, true, true);
  131399. }
  131400. this._processSubCameras(this.activeCameras[cameraIndex]);
  131401. }
  131402. }
  131403. else {
  131404. if (!this.activeCamera) {
  131405. throw new Error("No camera defined");
  131406. }
  131407. this._processSubCameras(this.activeCamera);
  131408. }
  131409. // Intersection checks
  131410. this._checkIntersections();
  131411. // Executes the after render stage actions.
  131412. for (var _f = 0, _g = this._afterRenderStage; _f < _g.length; _f++) {
  131413. var step = _g[_f];
  131414. step.action();
  131415. }
  131416. // After render
  131417. if (this.afterRender) {
  131418. this.afterRender();
  131419. }
  131420. this.onAfterRenderObservable.notifyObservers(this);
  131421. // Cleaning
  131422. if (this._toBeDisposed.length) {
  131423. for (var index = 0; index < this._toBeDisposed.length; index++) {
  131424. var data = this._toBeDisposed[index];
  131425. if (data) {
  131426. data.dispose();
  131427. }
  131428. }
  131429. this._toBeDisposed = [];
  131430. }
  131431. if (this.dumpNextRenderTargets) {
  131432. this.dumpNextRenderTargets = false;
  131433. }
  131434. this._activeBones.addCount(0, true);
  131435. this._activeIndices.addCount(0, true);
  131436. this._activeParticles.addCount(0, true);
  131437. };
  131438. /**
  131439. * Freeze all materials
  131440. * A frozen material will not be updatable but should be faster to render
  131441. */
  131442. Scene.prototype.freezeMaterials = function () {
  131443. for (var i = 0; i < this.materials.length; i++) {
  131444. this.materials[i].freeze();
  131445. }
  131446. };
  131447. /**
  131448. * Unfreeze all materials
  131449. * A frozen material will not be updatable but should be faster to render
  131450. */
  131451. Scene.prototype.unfreezeMaterials = function () {
  131452. for (var i = 0; i < this.materials.length; i++) {
  131453. this.materials[i].unfreeze();
  131454. }
  131455. };
  131456. /**
  131457. * Releases all held ressources
  131458. */
  131459. Scene.prototype.dispose = function () {
  131460. this.beforeRender = null;
  131461. this.afterRender = null;
  131462. this.skeletons = [];
  131463. this.morphTargetManagers = [];
  131464. this._transientComponents = [];
  131465. this._isReadyForMeshStage.clear();
  131466. this._beforeEvaluateActiveMeshStage.clear();
  131467. this._evaluateSubMeshStage.clear();
  131468. this._activeMeshStage.clear();
  131469. this._cameraDrawRenderTargetStage.clear();
  131470. this._beforeCameraDrawStage.clear();
  131471. this._beforeRenderTargetDrawStage.clear();
  131472. this._beforeRenderingGroupDrawStage.clear();
  131473. this._beforeRenderingMeshStage.clear();
  131474. this._afterRenderingMeshStage.clear();
  131475. this._afterRenderingGroupDrawStage.clear();
  131476. this._afterCameraDrawStage.clear();
  131477. this._afterRenderTargetDrawStage.clear();
  131478. this._afterRenderStage.clear();
  131479. this._beforeCameraUpdateStage.clear();
  131480. this._beforeClearStage.clear();
  131481. this._gatherRenderTargetsStage.clear();
  131482. this._gatherActiveCameraRenderTargetsStage.clear();
  131483. this._pointerMoveStage.clear();
  131484. this._pointerDownStage.clear();
  131485. this._pointerUpStage.clear();
  131486. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  131487. var component = _a[_i];
  131488. component.dispose();
  131489. }
  131490. this.importedMeshesFiles = new Array();
  131491. this.stopAllAnimations();
  131492. this.resetCachedMaterial();
  131493. // Smart arrays
  131494. if (this.activeCamera) {
  131495. this.activeCamera._activeMeshes.dispose();
  131496. this.activeCamera = null;
  131497. }
  131498. this._activeMeshes.dispose();
  131499. this._renderingManager.dispose();
  131500. this._processedMaterials.dispose();
  131501. this._activeParticleSystems.dispose();
  131502. this._activeSkeletons.dispose();
  131503. this._softwareSkinnedMeshes.dispose();
  131504. this._renderTargets.dispose();
  131505. this._registeredForLateAnimationBindings.dispose();
  131506. this._meshesForIntersections.dispose();
  131507. this._toBeDisposed = [];
  131508. // Abort active requests
  131509. for (var _b = 0, _c = this._activeRequests; _b < _c.length; _b++) {
  131510. var request = _c[_b];
  131511. request.abort();
  131512. }
  131513. // Events
  131514. this.onDisposeObservable.notifyObservers(this);
  131515. this.onDisposeObservable.clear();
  131516. this.onBeforeRenderObservable.clear();
  131517. this.onAfterRenderObservable.clear();
  131518. this.onBeforeRenderTargetsRenderObservable.clear();
  131519. this.onAfterRenderTargetsRenderObservable.clear();
  131520. this.onAfterStepObservable.clear();
  131521. this.onBeforeStepObservable.clear();
  131522. this.onBeforeActiveMeshesEvaluationObservable.clear();
  131523. this.onAfterActiveMeshesEvaluationObservable.clear();
  131524. this.onBeforeParticlesRenderingObservable.clear();
  131525. this.onAfterParticlesRenderingObservable.clear();
  131526. this.onBeforeDrawPhaseObservable.clear();
  131527. this.onAfterDrawPhaseObservable.clear();
  131528. this.onBeforeAnimationsObservable.clear();
  131529. this.onAfterAnimationsObservable.clear();
  131530. this.onDataLoadedObservable.clear();
  131531. this.onBeforeRenderingGroupObservable.clear();
  131532. this.onAfterRenderingGroupObservable.clear();
  131533. this.onMeshImportedObservable.clear();
  131534. this.onBeforeCameraRenderObservable.clear();
  131535. this.onAfterCameraRenderObservable.clear();
  131536. this.onReadyObservable.clear();
  131537. this.onNewCameraAddedObservable.clear();
  131538. this.onCameraRemovedObservable.clear();
  131539. this.onNewLightAddedObservable.clear();
  131540. this.onLightRemovedObservable.clear();
  131541. this.onNewGeometryAddedObservable.clear();
  131542. this.onGeometryRemovedObservable.clear();
  131543. this.onNewTransformNodeAddedObservable.clear();
  131544. this.onTransformNodeRemovedObservable.clear();
  131545. this.onNewMeshAddedObservable.clear();
  131546. this.onMeshRemovedObservable.clear();
  131547. this.onNewMaterialAddedObservable.clear();
  131548. this.onMaterialRemovedObservable.clear();
  131549. this.onNewTextureAddedObservable.clear();
  131550. this.onTextureRemovedObservable.clear();
  131551. this.onPrePointerObservable.clear();
  131552. this.onPointerObservable.clear();
  131553. this.onPreKeyboardObservable.clear();
  131554. this.onKeyboardObservable.clear();
  131555. this.onActiveCameraChanged.clear();
  131556. this.detachControl();
  131557. // Detach cameras
  131558. var canvas = this._engine.getRenderingCanvas();
  131559. if (canvas) {
  131560. var index;
  131561. for (index = 0; index < this.cameras.length; index++) {
  131562. this.cameras[index].detachControl(canvas);
  131563. }
  131564. }
  131565. // Release animation groups
  131566. while (this.animationGroups.length) {
  131567. this.animationGroups[0].dispose();
  131568. }
  131569. // Release lights
  131570. while (this.lights.length) {
  131571. this.lights[0].dispose();
  131572. }
  131573. // Release meshes
  131574. while (this.meshes.length) {
  131575. this.meshes[0].dispose(true);
  131576. }
  131577. while (this.transformNodes.length) {
  131578. this.removeTransformNode(this.transformNodes[0]);
  131579. }
  131580. // Release cameras
  131581. while (this.cameras.length) {
  131582. this.cameras[0].dispose();
  131583. }
  131584. // Release materials
  131585. if (this.defaultMaterial) {
  131586. this.defaultMaterial.dispose();
  131587. }
  131588. while (this.multiMaterials.length) {
  131589. this.multiMaterials[0].dispose();
  131590. }
  131591. while (this.materials.length) {
  131592. this.materials[0].dispose();
  131593. }
  131594. // Release particles
  131595. while (this.particleSystems.length) {
  131596. this.particleSystems[0].dispose();
  131597. }
  131598. // Release postProcesses
  131599. while (this.postProcesses.length) {
  131600. this.postProcesses[0].dispose();
  131601. }
  131602. // Release textures
  131603. while (this.textures.length) {
  131604. this.textures[0].dispose();
  131605. }
  131606. // Release UBO
  131607. this._sceneUbo.dispose();
  131608. if (this._alternateSceneUbo) {
  131609. this._alternateSceneUbo.dispose();
  131610. }
  131611. // Post-processes
  131612. this.postProcessManager.dispose();
  131613. // Remove from engine
  131614. index = this._engine.scenes.indexOf(this);
  131615. if (index > -1) {
  131616. this._engine.scenes.splice(index, 1);
  131617. }
  131618. this._engine.wipeCaches(true);
  131619. this._isDisposed = true;
  131620. };
  131621. Object.defineProperty(Scene.prototype, "isDisposed", {
  131622. /**
  131623. * Gets if the scene is already disposed
  131624. */
  131625. get: function () {
  131626. return this._isDisposed;
  131627. },
  131628. enumerable: true,
  131629. configurable: true
  131630. });
  131631. /**
  131632. * Call this function to reduce memory footprint of the scene.
  131633. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  131634. */
  131635. Scene.prototype.clearCachedVertexData = function () {
  131636. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  131637. var mesh = this.meshes[meshIndex];
  131638. var geometry = mesh.geometry;
  131639. if (geometry) {
  131640. geometry._indices = [];
  131641. for (var vbName in geometry._vertexBuffers) {
  131642. if (!geometry._vertexBuffers.hasOwnProperty(vbName)) {
  131643. continue;
  131644. }
  131645. geometry._vertexBuffers[vbName]._buffer._data = null;
  131646. }
  131647. }
  131648. }
  131649. };
  131650. /**
  131651. * This function will remove the local cached buffer data from texture.
  131652. * It will save memory but will prevent the texture from being rebuilt
  131653. */
  131654. Scene.prototype.cleanCachedTextureBuffer = function () {
  131655. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  131656. var baseTexture = _a[_i];
  131657. var buffer = baseTexture._buffer;
  131658. if (buffer) {
  131659. baseTexture._buffer = null;
  131660. }
  131661. }
  131662. };
  131663. /**
  131664. * Get the world extend vectors with an optional filter
  131665. *
  131666. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  131667. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  131668. */
  131669. Scene.prototype.getWorldExtends = function (filterPredicate) {
  131670. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  131671. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  131672. filterPredicate = filterPredicate || (function () { return true; });
  131673. this.meshes.filter(filterPredicate).forEach(function (mesh) {
  131674. mesh.computeWorldMatrix(true);
  131675. if (!mesh.subMeshes || mesh.subMeshes.length === 0 || mesh.infiniteDistance) {
  131676. return;
  131677. }
  131678. var boundingInfo = mesh.getBoundingInfo();
  131679. var minBox = boundingInfo.boundingBox.minimumWorld;
  131680. var maxBox = boundingInfo.boundingBox.maximumWorld;
  131681. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  131682. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  131683. });
  131684. return {
  131685. min: min,
  131686. max: max
  131687. };
  131688. };
  131689. // Picking
  131690. /**
  131691. * Creates a ray that can be used to pick in the scene
  131692. * @param x defines the x coordinate of the origin (on-screen)
  131693. * @param y defines the y coordinate of the origin (on-screen)
  131694. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  131695. * @param camera defines the camera to use for the picking
  131696. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  131697. * @returns a Ray
  131698. */
  131699. Scene.prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  131700. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  131701. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131702. };
  131703. /**
  131704. * Creates a ray that can be used to pick in the scene
  131705. * @param x defines the x coordinate of the origin (on-screen)
  131706. * @param y defines the y coordinate of the origin (on-screen)
  131707. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  131708. * @param result defines the ray where to store the picking ray
  131709. * @param camera defines the camera to use for the picking
  131710. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  131711. * @returns the current scene
  131712. */
  131713. Scene.prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  131714. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  131715. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131716. };
  131717. /**
  131718. * Creates a ray that can be used to pick in the scene
  131719. * @param x defines the x coordinate of the origin (on-screen)
  131720. * @param y defines the y coordinate of the origin (on-screen)
  131721. * @param camera defines the camera to use for the picking
  131722. * @returns a Ray
  131723. */
  131724. Scene.prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  131725. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131726. };
  131727. /**
  131728. * Creates a ray that can be used to pick in the scene
  131729. * @param x defines the x coordinate of the origin (on-screen)
  131730. * @param y defines the y coordinate of the origin (on-screen)
  131731. * @param result defines the ray where to store the picking ray
  131732. * @param camera defines the camera to use for the picking
  131733. * @returns the current scene
  131734. */
  131735. Scene.prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  131736. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131737. };
  131738. /** Launch a ray to try to pick a mesh in the scene
  131739. * @param x position on screen
  131740. * @param y position on screen
  131741. * @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
  131742. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  131743. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  131744. * @returns a PickingInfo
  131745. */
  131746. Scene.prototype.pick = function (x, y, predicate, fastCheck, camera) {
  131747. // Dummy info if picking as not been imported
  131748. var pi = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__["PickingInfo"]();
  131749. pi._pickingUnavailable = true;
  131750. return pi;
  131751. };
  131752. /** Use the given ray to pick a mesh in the scene
  131753. * @param ray The ray to use to pick meshes
  131754. * @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
  131755. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  131756. * @returns a PickingInfo
  131757. */
  131758. Scene.prototype.pickWithRay = function (ray, predicate, fastCheck) {
  131759. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131760. };
  131761. /**
  131762. * Launch a ray to try to pick a mesh in the scene
  131763. * @param x X position on screen
  131764. * @param y Y position on screen
  131765. * @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
  131766. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  131767. * @returns an array of PickingInfo
  131768. */
  131769. Scene.prototype.multiPick = function (x, y, predicate, camera) {
  131770. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131771. };
  131772. /**
  131773. * Launch a ray to try to pick a mesh in the scene
  131774. * @param ray Ray to use
  131775. * @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
  131776. * @returns an array of PickingInfo
  131777. */
  131778. Scene.prototype.multiPickWithRay = function (ray, predicate) {
  131779. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131780. };
  131781. /**
  131782. * Force the value of meshUnderPointer
  131783. * @param mesh defines the mesh to use
  131784. */
  131785. Scene.prototype.setPointerOverMesh = function (mesh) {
  131786. if (this._pointerOverMesh === mesh) {
  131787. return;
  131788. }
  131789. if (this._pointerOverMesh && this._pointerOverMesh.actionManager) {
  131790. this._pointerOverMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pointerOverMesh));
  131791. }
  131792. this._pointerOverMesh = mesh;
  131793. if (this._pointerOverMesh && this._pointerOverMesh.actionManager) {
  131794. this._pointerOverMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pointerOverMesh));
  131795. }
  131796. };
  131797. /**
  131798. * Gets the mesh under the pointer
  131799. * @returns a Mesh or null if no mesh is under the pointer
  131800. */
  131801. Scene.prototype.getPointerOverMesh = function () {
  131802. return this._pointerOverMesh;
  131803. };
  131804. // Misc.
  131805. /** @hidden */
  131806. Scene.prototype._rebuildGeometries = function () {
  131807. for (var _i = 0, _a = this.geometries; _i < _a.length; _i++) {
  131808. var geometry = _a[_i];
  131809. geometry._rebuild();
  131810. }
  131811. for (var _b = 0, _c = this.meshes; _b < _c.length; _b++) {
  131812. var mesh = _c[_b];
  131813. mesh._rebuild();
  131814. }
  131815. if (this.postProcessManager) {
  131816. this.postProcessManager._rebuild();
  131817. }
  131818. for (var _d = 0, _e = this._components; _d < _e.length; _d++) {
  131819. var component = _e[_d];
  131820. component.rebuild();
  131821. }
  131822. for (var _f = 0, _g = this.particleSystems; _f < _g.length; _f++) {
  131823. var system = _g[_f];
  131824. system.rebuild();
  131825. }
  131826. };
  131827. /** @hidden */
  131828. Scene.prototype._rebuildTextures = function () {
  131829. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  131830. var texture = _a[_i];
  131831. texture._rebuild();
  131832. }
  131833. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  131834. };
  131835. // Tags
  131836. Scene.prototype._getByTags = function (list, tagsQuery, forEach) {
  131837. if (tagsQuery === undefined) {
  131838. // returns the complete list (could be done with Tags.MatchesQuery but no need to have a for-loop here)
  131839. return list;
  131840. }
  131841. var listByTags = [];
  131842. forEach = forEach || (function (item) { return; });
  131843. for (var i in list) {
  131844. var item = list[i];
  131845. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"].MatchesQuery(item, tagsQuery)) {
  131846. listByTags.push(item);
  131847. forEach(item);
  131848. }
  131849. }
  131850. return listByTags;
  131851. };
  131852. /**
  131853. * Get a list of meshes by tags
  131854. * @param tagsQuery defines the tags query to use
  131855. * @param forEach defines a predicate used to filter results
  131856. * @returns an array of Mesh
  131857. */
  131858. Scene.prototype.getMeshesByTags = function (tagsQuery, forEach) {
  131859. return this._getByTags(this.meshes, tagsQuery, forEach);
  131860. };
  131861. /**
  131862. * Get a list of cameras by tags
  131863. * @param tagsQuery defines the tags query to use
  131864. * @param forEach defines a predicate used to filter results
  131865. * @returns an array of Camera
  131866. */
  131867. Scene.prototype.getCamerasByTags = function (tagsQuery, forEach) {
  131868. return this._getByTags(this.cameras, tagsQuery, forEach);
  131869. };
  131870. /**
  131871. * Get a list of lights by tags
  131872. * @param tagsQuery defines the tags query to use
  131873. * @param forEach defines a predicate used to filter results
  131874. * @returns an array of Light
  131875. */
  131876. Scene.prototype.getLightsByTags = function (tagsQuery, forEach) {
  131877. return this._getByTags(this.lights, tagsQuery, forEach);
  131878. };
  131879. /**
  131880. * Get a list of materials by tags
  131881. * @param tagsQuery defines the tags query to use
  131882. * @param forEach defines a predicate used to filter results
  131883. * @returns an array of Material
  131884. */
  131885. Scene.prototype.getMaterialByTags = function (tagsQuery, forEach) {
  131886. return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
  131887. };
  131888. /**
  131889. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  131890. * This allowed control for front to back rendering or reversly depending of the special needs.
  131891. *
  131892. * @param renderingGroupId The rendering group id corresponding to its index
  131893. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  131894. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  131895. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  131896. */
  131897. Scene.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  131898. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  131899. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  131900. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  131901. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  131902. };
  131903. /**
  131904. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  131905. *
  131906. * @param renderingGroupId The rendering group id corresponding to its index
  131907. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  131908. * @param depth Automatically clears depth between groups if true and autoClear is true.
  131909. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  131910. */
  131911. Scene.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  131912. if (depth === void 0) { depth = true; }
  131913. if (stencil === void 0) { stencil = true; }
  131914. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil, depth, stencil);
  131915. };
  131916. /**
  131917. * Gets the current auto clear configuration for one rendering group of the rendering
  131918. * manager.
  131919. * @param index the rendering group index to get the information for
  131920. * @returns The auto clear setup for the requested rendering group
  131921. */
  131922. Scene.prototype.getAutoClearDepthStencilSetup = function (index) {
  131923. return this._renderingManager.getAutoClearDepthStencilSetup(index);
  131924. };
  131925. Object.defineProperty(Scene.prototype, "blockMaterialDirtyMechanism", {
  131926. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  131927. get: function () {
  131928. return this._blockMaterialDirtyMechanism;
  131929. },
  131930. set: function (value) {
  131931. if (this._blockMaterialDirtyMechanism === value) {
  131932. return;
  131933. }
  131934. this._blockMaterialDirtyMechanism = value;
  131935. if (!value) { // Do a complete update
  131936. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_AllDirtyFlag);
  131937. }
  131938. },
  131939. enumerable: true,
  131940. configurable: true
  131941. });
  131942. /**
  131943. * Will flag all materials as dirty to trigger new shader compilation
  131944. * @param flag defines the flag used to specify which material part must be marked as dirty
  131945. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  131946. */
  131947. Scene.prototype.markAllMaterialsAsDirty = function (flag, predicate) {
  131948. if (this._blockMaterialDirtyMechanism) {
  131949. return;
  131950. }
  131951. for (var _i = 0, _a = this.materials; _i < _a.length; _i++) {
  131952. var material = _a[_i];
  131953. if (predicate && !predicate(material)) {
  131954. continue;
  131955. }
  131956. material.markAsDirty(flag);
  131957. }
  131958. };
  131959. /** @hidden */
  131960. Scene.prototype._loadFile = function (url, onSuccess, onProgress, useOfflineSupport, useArrayBuffer, onError) {
  131961. var _this = this;
  131962. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadFile(url, onSuccess, onProgress, useOfflineSupport ? this.offlineProvider : undefined, useArrayBuffer, onError);
  131963. this._activeRequests.push(request);
  131964. request.onCompleteObservable.add(function (request) {
  131965. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  131966. });
  131967. return request;
  131968. };
  131969. /** @hidden */
  131970. Scene.prototype._loadFileAsync = function (url, useOfflineSupport, useArrayBuffer) {
  131971. var _this = this;
  131972. return new Promise(function (resolve, reject) {
  131973. _this._loadFile(url, function (data) {
  131974. resolve(data);
  131975. }, undefined, useOfflineSupport, useArrayBuffer, function (request, exception) {
  131976. reject(exception);
  131977. });
  131978. });
  131979. };
  131980. // Statics
  131981. Scene._uniqueIdCounter = 0;
  131982. /** The fog is deactivated */
  131983. Scene.FOGMODE_NONE = 0;
  131984. /** The fog density is following an exponential function */
  131985. Scene.FOGMODE_EXP = 1;
  131986. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  131987. Scene.FOGMODE_EXP2 = 2;
  131988. /** The fog density is following a linear function. */
  131989. Scene.FOGMODE_LINEAR = 3;
  131990. /**
  131991. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  131992. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131993. */
  131994. Scene.MinDeltaTime = 1.0;
  131995. /**
  131996. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  131997. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131998. */
  131999. Scene.MaxDeltaTime = 1000.0;
  132000. /** The distance in pixel that you have to move to prevent some events */
  132001. Scene.DragMovementThreshold = 10; // in pixels
  132002. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  132003. Scene.LongPressDelay = 500; // in milliseconds
  132004. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  132005. Scene.DoubleClickDelay = 300; // in milliseconds
  132006. /** If you need to check double click without raising a single click at first click, enable this flag */
  132007. Scene.ExclusiveDoubleClickMode = false;
  132008. return Scene;
  132009. }(_abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"]));
  132010. /***/ }),
  132011. /***/ "./sceneComponent.ts":
  132012. /*!***************************!*\
  132013. !*** ./sceneComponent.ts ***!
  132014. \***************************/
  132015. /*! exports provided: SceneComponentConstants, Stage */
  132016. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132017. "use strict";
  132018. __webpack_require__.r(__webpack_exports__);
  132019. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return SceneComponentConstants; });
  132020. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return Stage; });
  132021. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  132022. /**
  132023. * Groups all the scene component constants in one place to ease maintenance.
  132024. * @hidden
  132025. */
  132026. var SceneComponentConstants = /** @class */ (function () {
  132027. function SceneComponentConstants() {
  132028. }
  132029. SceneComponentConstants.NAME_EFFECTLAYER = "EffectLayer";
  132030. SceneComponentConstants.NAME_LAYER = "Layer";
  132031. SceneComponentConstants.NAME_LENSFLARESYSTEM = "LensFlareSystem";
  132032. SceneComponentConstants.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer";
  132033. SceneComponentConstants.NAME_PARTICLESYSTEM = "ParticleSystem";
  132034. SceneComponentConstants.NAME_GAMEPAD = "Gamepad";
  132035. SceneComponentConstants.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue";
  132036. SceneComponentConstants.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer";
  132037. SceneComponentConstants.NAME_DEPTHRENDERER = "DepthRenderer";
  132038. SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager";
  132039. SceneComponentConstants.NAME_SPRITE = "Sprite";
  132040. SceneComponentConstants.NAME_OUTLINERENDERER = "Outline";
  132041. SceneComponentConstants.NAME_PROCEDURALTEXTURE = "ProceduralTexture";
  132042. SceneComponentConstants.NAME_SHADOWGENERATOR = "ShadowGenerator";
  132043. SceneComponentConstants.NAME_OCTREE = "Octree";
  132044. SceneComponentConstants.NAME_PHYSICSENGINE = "PhysicsEngine";
  132045. SceneComponentConstants.NAME_AUDIO = "Audio";
  132046. SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER = 0;
  132047. SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  132048. SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;
  132049. SceneComponentConstants.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  132050. SceneComponentConstants.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1;
  132051. SceneComponentConstants.STEP_BEFORECAMERADRAW_EFFECTLAYER = 0;
  132052. SceneComponentConstants.STEP_BEFORECAMERADRAW_LAYER = 1;
  132053. SceneComponentConstants.STEP_BEFORERENDERTARGETDRAW_LAYER = 0;
  132054. SceneComponentConstants.STEP_BEFORERENDERINGMESH_OUTLINE = 0;
  132055. SceneComponentConstants.STEP_AFTERRENDERINGMESH_OUTLINE = 0;
  132056. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0;
  132057. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1;
  132058. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0;
  132059. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1;
  132060. SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0;
  132061. SceneComponentConstants.STEP_AFTERRENDERTARGETDRAW_LAYER = 0;
  132062. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER = 0;
  132063. SceneComponentConstants.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 1;
  132064. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 2;
  132065. SceneComponentConstants.STEP_AFTERCAMERADRAW_LAYER = 3;
  132066. SceneComponentConstants.STEP_AFTERRENDER_AUDIO = 0;
  132067. SceneComponentConstants.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 0;
  132068. SceneComponentConstants.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1;
  132069. SceneComponentConstants.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 2;
  132070. SceneComponentConstants.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3;
  132071. SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0;
  132072. SceneComponentConstants.STEP_POINTERMOVE_SPRITE = 0;
  132073. SceneComponentConstants.STEP_POINTERDOWN_SPRITE = 0;
  132074. SceneComponentConstants.STEP_POINTERUP_SPRITE = 0;
  132075. return SceneComponentConstants;
  132076. }());
  132077. /**
  132078. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  132079. * @hidden
  132080. */
  132081. var Stage = /** @class */ (function (_super) {
  132082. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Stage, _super);
  132083. /**
  132084. * Hide ctor from the rest of the world.
  132085. * @param items The items to add.
  132086. */
  132087. function Stage(items) {
  132088. return _super.apply(this, items) || this;
  132089. }
  132090. /**
  132091. * Creates a new Stage.
  132092. * @returns A new instance of a Stage
  132093. */
  132094. Stage.Create = function () {
  132095. return Object.create(Stage.prototype);
  132096. };
  132097. /**
  132098. * Registers a step in an ordered way in the targeted stage.
  132099. * @param index Defines the position to register the step in
  132100. * @param component Defines the component attached to the step
  132101. * @param action Defines the action to launch during the step
  132102. */
  132103. Stage.prototype.registerStep = function (index, component, action) {
  132104. var i = 0;
  132105. var maxIndex = Number.MAX_VALUE;
  132106. for (; i < this.length; i++) {
  132107. var step = this[i];
  132108. maxIndex = step.index;
  132109. if (index < maxIndex) {
  132110. break;
  132111. }
  132112. }
  132113. this.splice(i, 0, { index: index, component: component, action: action.bind(component) });
  132114. };
  132115. /**
  132116. * Clears all the steps from the stage.
  132117. */
  132118. Stage.prototype.clear = function () {
  132119. this.length = 0;
  132120. };
  132121. return Stage;
  132122. }(Array));
  132123. /***/ })
  132124. /******/ });
  132125. });
  132126. //# sourceMappingURL=babylon.max.js.map